@elliemae/ds-codemods 2.3.2-next.0 → 2.4.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/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.4.0-next.0](https://git.elliemae.io/platform-ui/dimsum/compare/v2.3.2-next.0...v2.4.0-next.0) (2022-02-03)
7
+
8
+
9
+ ### Features
10
+
11
+ * ds-codemods:: check dimsum deprecated packages command via npm ls + husky commit validator ([#4180](https://git.elliemae.io/platform-ui/dimsum/issues/4180)) ([82c03fe](https://git.elliemae.io/platform-ui/dimsum/commit/82c03feec7eaa1333b08b3fe5f31e0105d870e54))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * dimsum:: fixed unused/missing dependencies ([#4150](https://git.elliemae.io/platform-ui/dimsum/issues/4150)) ([51dddfb](https://git.elliemae.io/platform-ui/dimsum/commit/51dddfb51e76ba4a7407a28ac1c34b81f8f4d095))
17
+
18
+
19
+
6
20
  ### [2.3.2-next.0](https://git.elliemae.io/platform-ui/dimsum/compare/v2.3.0-next.19...v2.3.2-next.0) (2022-02-01)
7
21
 
8
22
  **Note:** Version bump only for package @elliemae/ds-codemods
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-codemods",
3
- "version": "2.3.2-next.0",
3
+ "version": "2.4.0-next.0",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Code Mods",
6
6
  "module": "./esm/index.js",
@@ -27,23 +27,23 @@
27
27
  "prebuild": "exit 0",
28
28
  "predev": "exit 0",
29
29
  "build": "exit 0",
30
- "test": "echo \"Error: no test specified\" && exit 1"
30
+ "test": "echo \"Error: no test specified\" && exit 1",
31
+ "try-codemods": "npx ./",
32
+ "try-check-deprecated-packages": "npx ./ check-deprecated-packages --cwd=\"test-ables/check-deprecated-packages/with-deprecated\"",
33
+ "try-check-deprecated-packages-no-dimsum": "npx ./ check-deprecated-packages --cwd=\"test-ables/check-deprecated-packages/without-dimsum-packages\""
31
34
  },
32
35
  "dependencies": {
33
36
  "arg": "^5.0.1",
34
- "chalk": "5.0.0",
35
- "depcheck": "1.4.3",
37
+ "chalk": "4.1.2",
38
+ "depcheck": "1.4.2",
36
39
  "esm": "^3.2.25",
37
40
  "fs": "0.0.1-security",
38
41
  "fs-extra": "^10.0.0",
39
42
  "glob": "^7.2.0",
40
43
  "inquirer": "^8.2.0",
41
- "pacote": "12.0.3",
44
+ "pacote": "12.0.2",
42
45
  "path": "^0.12.7"
43
46
  },
44
- "resolutions": {
45
- "depcheck/@babel/parser": "7.16.4"
46
- },
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
@@ -5,6 +5,7 @@ import { executeCommandsMap } from './command-logics/execute-commands-map';
5
5
  function parseArgumentsIntoOptions(rawArgs) {
6
6
  const args = arg(
7
7
  {
8
+ '--cwd': String,
8
9
  '--globPattern': String,
9
10
  '--globPatternIgnore': String,
10
11
  '--projectFolderPath': String,
@@ -16,6 +17,7 @@ function parseArgumentsIntoOptions(rawArgs) {
16
17
  },
17
18
  );
18
19
  return {
20
+ cwd: args['--cwd'],
19
21
  globPattern: args['--globPattern'],
20
22
  globPatternIgnore: args['--globPatternIgnore'],
21
23
  projectFolderPath: args['--projectFolderPath'],
@@ -0,0 +1,13 @@
1
+ export const getDeprecatedPackagesQuestions = (originalOptions) => {
2
+ const extraOptions = [];
3
+ const { cwd } = originalOptions;
4
+ if (!cwd && cwd !== '') {
5
+ extraOptions.push({
6
+ type: 'input',
7
+ name: 'globPatternIgnore',
8
+ message: 'Please provide the project root directory (where node_modules folder lives)',
9
+ default: './',
10
+ });
11
+ }
12
+ return extraOptions;
13
+ };
@@ -0,0 +1,87 @@
1
+ export const SEVERITY = {
2
+ NON_STARTER: ['Failing to upgrade will make the project impossible to start/use', 1],
3
+ KNOWN_ISSUES: [
4
+ 'The component has unfixable known issues. Failing to upgrade means APP will have to live with those',
5
+ 2,
6
+ ],
7
+ FRAGILE_AND_UNMANTAINED: [
8
+ 'Failing to upgrade will make the project fragile and any error will have to be addressed by the APP team',
9
+ 3,
10
+ ],
11
+ UNMANTAINED: ['Failing to upgrade will mean that any error will have to be addressed by the APP team', 4],
12
+ };
13
+
14
+ export const SOLUTIONS = {
15
+ REMOVED: 'the component has been regarded as supreflous and has hencheforth been removed in favor of examples',
16
+ NEW_VERSION_BREAKING: 'the component impedes further enhancments/bugfixes, a new version ex-novo has been created.',
17
+ };
18
+
19
+ export const DEPRECATED_PACKAGES = {
20
+ '@elliemae/ds-datagrids': {
21
+ name: 'data-grid',
22
+ solution: SOLUTIONS.NEW_VERSION_BREAKING,
23
+ severity: SEVERITY.KNOWN_ISSUES,
24
+ // TODO create relative confluence
25
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Breaking+changes+-+Migration+steps+and+rationale',
26
+ },
27
+ '@elliemae/ds-date-picker': {
28
+ name: 'date-picker',
29
+ solution: SOLUTIONS.NEW_VERSION_BREAKING,
30
+ severity: SEVERITY.KNOWN_ISSUES,
31
+ // TODO create relative confluence
32
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Breaking+changes+-+Migration+steps+and+rationale',
33
+ },
34
+ '@elliemae/ds-date-range-picker': {
35
+ name: 'date-range-picker',
36
+ solution: SOLUTIONS.NEW_VERSION_BREAKING,
37
+ severity: SEVERITY.KNOWN_ISSUES,
38
+ // TODO create relative confluence
39
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Breaking+changes+-+Migration+steps+and+rationale',
40
+ },
41
+ '@elliemae/ds-date-time-picker': {
42
+ name: 'date-time-picker',
43
+ solution: SOLUTIONS.NEW_VERSION_BREAKING,
44
+ severity: SEVERITY.KNOWN_ISSUES,
45
+ // TODO create relative confluence
46
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Breaking+changes+-+Migration+steps+and+rationale',
47
+ },
48
+ '@elliemae/ds-time-picker': {
49
+ name: 'time-picker',
50
+ solution: SOLUTIONS.NEW_VERSION_BREAKING,
51
+ severity: SEVERITY.KNOWN_ISSUES,
52
+ // TODO create relative confluence
53
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Breaking+changes+-+Migration+steps+and+rationale',
54
+ },
55
+ '@elliemae/ds-button-group': {
56
+ name: 'button-group',
57
+ solution: SOLUTIONS.REMOVED,
58
+ severity: SEVERITY.NON_STARTER,
59
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Button+Group+-+Dimsum+2.x',
60
+ },
61
+ '@elliemae/ds-card-array': {
62
+ name: 'card-array',
63
+ solution: SOLUTIONS.REMOVED,
64
+ severity: SEVERITY.NON_STARTER,
65
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Card+Array+-+Dimsum+2.x',
66
+ },
67
+ '@elliemae/ds-form': {
68
+ subComponents: [
69
+ {
70
+ name: 'combobox',
71
+ solution: SOLUTIONS.NEW_VERSION_BREAKING,
72
+ severity: SEVERITY.FRAGILE_AND_UNMANTAINED,
73
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Combo-box+-+Dimsum+2.x',
74
+ },
75
+ ],
76
+ },
77
+ '@elliemae/ds-combox-v1': {
78
+ subComponents: [
79
+ {
80
+ name: 'combobox',
81
+ solution: SOLUTIONS.NEW_VERSION_BREAKING,
82
+ severity: SEVERITY.FRAGILE_AND_UNMANTAINED,
83
+ confluence: 'https://confluence.elliemae.io/display/FEAE/Combo-box+-+Dimsum+2.x',
84
+ },
85
+ ],
86
+ },
87
+ };
@@ -0,0 +1,18 @@
1
+ /* eslint-disable max-statements */
2
+ export function getEmDsPackagesFromNPMLS(npmLsStdout = '') {
3
+ const dsPackageRegExp = /@elliemae\/ds-.*?@(.*)/gm;
4
+ const matches = [];
5
+ if (npmLsStdout) {
6
+ const npmLsMatches = [...npmLsStdout.matchAll(dsPackageRegExp)];
7
+ npmLsMatches.forEach(([fullMatch, version]) => {
8
+ const matchObj = {
9
+ fullMatch,
10
+ version,
11
+ package: fullMatch.split(version)[0].slice(0, -1),
12
+ };
13
+ matches.push(matchObj);
14
+ });
15
+ }
16
+
17
+ return matches;
18
+ }
@@ -0,0 +1,19 @@
1
+ import { exec } from 'child_process';
2
+ import { getEmDsPackagesFromNPMLS } from './getEmDsPackagesFromNPMLS';
3
+ import { logResults, logCyanQuestion } from './logResults';
4
+
5
+ const npmLs = async ({ cwd }) => {
6
+ const [, stdout] = await new Promise((resolve) => {
7
+ exec('npm ls', { cwd }, (...cbRes) => resolve(cbRes));
8
+ });
9
+ if (stdout) return getEmDsPackagesFromNPMLS(stdout);
10
+ return [];
11
+ };
12
+
13
+ export const checkDeprecatedPackages = async (options) => {
14
+ const installedPackages = await npmLs(options);
15
+ if (installedPackages.length === 0) logCyanQuestion('no dimsum packages found... did you specify the correct cwd?');
16
+ logResults(installedPackages);
17
+ };
18
+
19
+ export default checkDeprecatedPackages;
@@ -0,0 +1,70 @@
1
+ import chalk from 'chalk';
2
+ 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
+
46
+ const logDeprecatedComponent = ({ name, solution, severity, confluence }) => {
47
+ const [sevDesc, sevLevel] = severity;
48
+ const chalkLog = chalkMap[sevLevel];
49
+ console.log(chalk.yellow('--------------------------------'));
50
+ console.log(chalk.bold.cyan(`${name} deprecation!`));
51
+ console.log(chalkLog(sevDesc));
52
+ console.log(chalk.bold.green(solution));
53
+ console.log(chalk.white(confluence));
54
+ console.log(chalk.yellow('--------------------------------'));
55
+ };
56
+
57
+ export function logCyanQuestion(question) {
58
+ console.log(chalk.cyanBright(question));
59
+ }
60
+
61
+ export function logResults(detectedPackages) {
62
+ detectedPackages.forEach((pack) => {
63
+ const deprecatedMetaInfo = DEPRECATED_PACKAGES[pack.package];
64
+ if (deprecatedMetaInfo) {
65
+ const { subComponents, ...metainfo } = deprecatedMetaInfo;
66
+ if (JSON.stringify(metainfo) !== '{}') logDeprecatedComponent(metainfo);
67
+ if (subComponents) subComponents.forEach(logDeprecatedComponent);
68
+ }
69
+ });
70
+ }
@@ -1,6 +1,7 @@
1
1
  import { fixLegacyImports } from './fix-legacy-imports';
2
2
  import { checkPackagesInconsistencies } from './check-packages-inconsistencies';
3
3
  import { checkMissingPackages } from './check-missing-packages';
4
+ import { checkDeprecatedPackages } from './check-deprecated-packages';
4
5
  import { COMMANDS } from '../commands';
5
6
 
6
7
  export async function executeCommandsMap(args, options) {
@@ -17,6 +18,9 @@ export async function executeCommandsMap(args, options) {
17
18
  case COMMANDS.CHECK_MISSING_PACKAGES:
18
19
  checkMissingPackages(options);
19
20
  break;
21
+ case COMMANDS.CHECK_DEPRECATED_PACKAGES:
22
+ checkDeprecatedPackages(options);
23
+ break;
20
24
  default:
21
25
  break;
22
26
  }
@@ -1,6 +1,7 @@
1
1
  export const COMMANDS = {
2
2
  FIX_LEGACY_IMPORTS: 'fix-legacy-imports',
3
3
  FIX_LEGACY_IMPORTS_REVERT: 'fix-legacy-imports:revert',
4
+ CHECK_DEPRECATED_PACKAGES: 'check-deprecated-packages',
4
5
  CHECK_PACKAGES_INCONSISTENCIES: 'check-packages-inconsistencies',
5
6
  CHECK_MISSING_PACKAGES: 'check-missing-packages',
6
7
  EXIT: 'exit',
@@ -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 { getDeprecatedPackagesQuestions } from './command-arguments/promptDeprecatedPackages';
5
6
  import { getMissingPackagesQuestions } from './command-arguments/promptMissingPackages';
6
7
 
7
8
  async function promptForMissingScriptSpecificOptions({ originalOptions, promptOptions }) {
@@ -18,6 +19,9 @@ async function promptForMissingScriptSpecificOptions({ originalOptions, promptOp
18
19
  case COMMANDS.CHECK_MISSING_PACKAGES:
19
20
  scriptQuestions.push(...getMissingPackagesQuestions(originalOptions));
20
21
  break;
22
+ case COMMANDS.CHECK_DEPRECATED_PACKAGES:
23
+ scriptQuestions.push(...getDeprecatedPackagesQuestions(originalOptions));
24
+ break;
21
25
  default:
22
26
  break;
23
27
  }
@@ -1,5 +1,11 @@
1
1
  import path from 'path';
2
-
3
- export const generatePathFromCurrentFolder = (...patterns) => path.join(process.cwd(), ...patterns);
2
+ /**
3
+ * prepend process.cwd() to a string and convert to POSIX (glob compatible) slashes ( \ -- to --> /).
4
+ *
5
+ * @param {string} stringToPrependTo the string to prepend the CWD and make glob compatible
6
+ * @returns {string} paths with prepent CWD and glob compatible POSIX slashes ( \ -- to --> /).
7
+ */
8
+ export const generatePathFromCurrentFolder = (...stringToPrependTo) =>
9
+ path.join(process.cwd(), ...stringToPrependTo).replace(/\\/g, '/');
4
10
 
5
11
  export default generatePathFromCurrentFolder;
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "some-project",
3
+ "version": "2.3.0-next.19",
4
+ "license": "MIT",
5
+ "description": "Ellie Mae - Dim Sum - Date Time Picker",
6
+ "main": "cjs/index.js",
7
+ "module": "esm/index.js",
8
+ "sideEffects": [
9
+ "*.css",
10
+ "*.scss"
11
+ ],
12
+ "scripts": {
13
+ "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
14
+ "prebuild": "exit 0",
15
+ "predev": "exit 0",
16
+ "build": "node ../../scripts/build/build.js"
17
+ },
18
+ "dependencies": {
19
+ "@elliemae/ds-basic": "2.3.0-next.19",
20
+ "@elliemae/ds-classnames": "2.3.0-next.19",
21
+ "@elliemae/ds-date-picker": "2.3.0-next.19",
22
+ "@elliemae/ds-form": "2.3.0-next.19",
23
+ "@elliemae/ds-utilities": "2.3.0-next.19",
24
+ "lodash": "~4.17.19",
25
+ "moment": "~2.29.1",
26
+ "prop-types": "~15.7.2",
27
+ "react-dates": "~21.8.0",
28
+ "react-text-mask": "~5.4.3"
29
+ },
30
+ "peerDependencies": {
31
+ "@elliemae/ds-basic": "2.3.0-next.19",
32
+ "@elliemae/ds-classnames": "2.3.0-next.19",
33
+ "@elliemae/ds-date-picker": "2.3.0-next.19",
34
+ "@elliemae/ds-form": "2.3.0-next.19",
35
+ "@elliemae/ds-utilities": "2.3.0-next.19",
36
+ "lodash": "^4.17.20",
37
+ "react": "~17.0.1",
38
+ "react-dom": "^17.0.1"
39
+ },
40
+ "devDependencies": {
41
+ "@elliemae/ds-basic": "2.3.0-next.19",
42
+ "@elliemae/ds-classnames": "2.3.0-next.19",
43
+ "@elliemae/ds-date-picker": "2.3.0-next.19",
44
+ "@elliemae/ds-form": "2.3.0-next.19",
45
+ "@elliemae/ds-utilities": "2.3.0-next.19",
46
+ "lodash": "^4.17.20",
47
+ "react": "~17.0.1",
48
+ "react-dom": "^17.0.1"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public",
52
+ "directory": "dist"
53
+ }
54
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "some-project",
3
+ "version": "2.3.0-next.19",
4
+ "license": "MIT",
5
+ "description": "Ellie Mae - Dim Sum - Date Time Picker",
6
+ "main": "cjs/index.js",
7
+ "module": "esm/index.js",
8
+ "sideEffects": [
9
+ "*.css",
10
+ "*.scss"
11
+ ],
12
+ "scripts": {
13
+ "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
14
+ "prebuild": "exit 0",
15
+ "predev": "exit 0",
16
+ "build": "node ../../scripts/build/build.js"
17
+ },
18
+ "dependencies": {
19
+ "lodash": "~4.17.19",
20
+ "moment": "~2.29.1",
21
+ "prop-types": "~15.7.2",
22
+ "react-dates": "~21.8.0",
23
+ "react-text-mask": "~5.4.3"
24
+ },
25
+ "peerDependencies": {
26
+ "lodash": "^4.17.20",
27
+ "react": "~17.0.1",
28
+ "react-dom": "^17.0.1"
29
+ },
30
+ "devDependencies": {
31
+ "lodash": "^4.17.20",
32
+ "react": "~17.0.1",
33
+ "react-dom": "^17.0.1"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public",
37
+ "directory": "dist"
38
+ }
39
+ }