@elliemae/ds-codemods 3.55.1 → 3.57.0-next.1
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/index.mjs +1 -10
- package/bin/cli/code-mods/command-logics/check-missing-packages/index.mjs +1 -1
- package/bin/cli/code-mods/command-logics/components-usage-report/utils.mjs +46 -16
- package/bin/cli/code-mods/command-logics/deprecated-components-usage-report/index.mjs +9 -5
- package/bin/cli/code-mods/command-logics/deprecated-components-usage-report/utils.mjs +23 -17
- package/bin/cli/constants/deprecatedPackages.mjs +6 -1
- package/bin/cli/utils/getEmDsPackagesFromNPMLS.mjs +79 -0
- package/bin/cli/utils/index.mjs +4 -3
- package/bin/cli/utils/npmLs.mjs +78 -0
- package/package.json +4 -4
- package/bin/cli/code-mods/command-logics/check-deprecated-packages/getEmDsPackagesFromNPMLS.mjs +0 -18
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { exec } from 'child_process';
|
|
2
|
-
import { getEmDsPackagesFromNPMLS } from './getEmDsPackagesFromNPMLS.mjs';
|
|
3
1
|
import { logResults, logCyanQuestion } from './logResults.mjs';
|
|
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
|
-
};
|
|
2
|
+
import { npmLs } from '../../../utils/npmLs.mjs';
|
|
12
3
|
|
|
13
4
|
export const checkDeprecatedPackages = async (options) => {
|
|
14
5
|
const installedPackages = await npmLs(options);
|
|
@@ -93,7 +93,7 @@ export const checkMissingPackages = async (options) => {
|
|
|
93
93
|
depcheck.special.tslint,
|
|
94
94
|
depcheck.special.webpack,
|
|
95
95
|
],
|
|
96
|
-
ignorePatterns,
|
|
96
|
+
ignorePatterns: [...ignorePatterns, '.cache', 'src/tests'],
|
|
97
97
|
ignoreMatches,
|
|
98
98
|
};
|
|
99
99
|
const pathToRoot = generatePathFromCurrentFolder(projectFolderPath);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-params, max-lines, max-statements, max-len */
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { filePathsWithGitIgnore } from '../../../utils/filepathsMatchers.mjs';
|
|
4
|
+
import { npmLsSyncMultipleFormatsSync } from '../../../utils/npmLs.mjs';
|
|
4
5
|
import { dimsumImportStatementsRegExp } from './dimsumImportStatementsRegExp.mjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -19,7 +20,7 @@ import { dimsumImportStatementsRegExp } from './dimsumImportStatementsRegExp.mjs
|
|
|
19
20
|
*
|
|
20
21
|
* @typedef {PartialNamedImport[]} NamedImportResults
|
|
21
22
|
*
|
|
22
|
-
* @typedef {
|
|
23
|
+
* @typedef {Object} ImportsFlags
|
|
23
24
|
* @property {boolean} hasRelationWithDimsum
|
|
24
25
|
*
|
|
25
26
|
*
|
|
@@ -29,8 +30,23 @@ import { dimsumImportStatementsRegExp } from './dimsumImportStatementsRegExp.mjs
|
|
|
29
30
|
* @property {namedImportWithoutRename[]} importedNamedComponentsWithoutRename
|
|
30
31
|
* @property {namedImportWithRename[]} importedNamedComponentsWithRename
|
|
31
32
|
*
|
|
32
|
-
* @typedef {ImportsFlags & fileImportsInfos
|
|
33
|
+
* @typedef {ImportsFlags & fileImportsInfos} FileReport
|
|
33
34
|
* @property {string} filePath
|
|
35
|
+
*
|
|
36
|
+
* @typedef {Object} ScriptOptions
|
|
37
|
+
* @property {string} options.outputPath - path to the .csv file to write the report to
|
|
38
|
+
* @property {string} options.startingDirPath - path to the project root directory (where node_modules folder lives)
|
|
39
|
+
* @property {string} options.gitIgnorePath - path to the .gitignore file
|
|
40
|
+
* @property {string} options.org - optional org, if present an extra column will be added to the report
|
|
41
|
+
* @property {string} options.repo - optional repo, if present an extra column will be added to the report
|
|
42
|
+
* @property {boolean} options.debug - debug flag
|
|
43
|
+
* @property {boolean} options.append - whether to append to the file or override it
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
* @typedef {import('../../../utils/getEmDsPackagesFromNPMLS.mjs').MatchWithMultipleVersionsArrayObj} MatchWithMultipleVersionsArrayObj
|
|
47
|
+
* @typedef {Object.<string, MatchWithMultipleVersionsArrayObj>} MapOfMatchesBasedOnPackageName
|
|
48
|
+
*
|
|
49
|
+
* @typedef {ScriptOptions & {packagesVersions: MapOfMatchesBasedOnPackageName}} CSVGenerationOptions
|
|
34
50
|
*/
|
|
35
51
|
|
|
36
52
|
// specific regexp to distinguish 'import * as X from "Y"'
|
|
@@ -190,18 +206,29 @@ export const getFileReport = (filePath) => {
|
|
|
190
206
|
};
|
|
191
207
|
/**
|
|
192
208
|
* given a datum and a file path and options, generates a csv row
|
|
209
|
+
* @param {Object} datum - the datum to generate the csv row from
|
|
210
|
+
* @param {string} datum.importedComponent - the imported component name
|
|
211
|
+
* @param {string} datum.packageName - the package name
|
|
212
|
+
* @param {string} datum.renamedAs - the renamed alias
|
|
213
|
+
* @param {string} filePath - the file path where the datum was found
|
|
214
|
+
* @param {CSVGenerationOptions} options - options for the csv generation
|
|
215
|
+
* @returns {string} - the csv row
|
|
193
216
|
*/
|
|
194
217
|
const generateCSVRow = (datum, filePath, options) => {
|
|
195
|
-
|
|
218
|
+
const { packagesVersions = {} } = options;
|
|
219
|
+
// "Org(?),Imported Component,Repository(?),Package Name,Renamed Alias,File Path,Version(s)"
|
|
196
220
|
const { importedComponent, packageName, renamedAs } = datum;
|
|
221
|
+
const packageFound = packagesVersions[packageName];
|
|
222
|
+
const packageVersion = packageFound?.versions?.join?.('; ') || '';
|
|
197
223
|
return `${options.org ? `${options.org},` : ''}${importedComponent},${
|
|
198
224
|
options.repo ? `${options.repo},` : ''
|
|
199
|
-
}${packageName},${renamedAs},${filePath}`;
|
|
225
|
+
}${packageName},${renamedAs},${filePath},${packageVersion}`;
|
|
200
226
|
};
|
|
201
227
|
|
|
202
228
|
/**
|
|
203
229
|
* given a file report, generates related csv rows (one or more)
|
|
204
230
|
* @param {FileReport} fileReport - the file report to generate the csv rows from
|
|
231
|
+
* @param {CSVGenerationOptions} options - options for the csv generation
|
|
205
232
|
* @returns {string[]} - the csv rows flattened per relevant columns distinguishers
|
|
206
233
|
*
|
|
207
234
|
*/
|
|
@@ -288,14 +315,7 @@ const generateCSVRows = (fileReport, options) => {
|
|
|
288
315
|
};
|
|
289
316
|
/**
|
|
290
317
|
* generates a report of components usage
|
|
291
|
-
* @param {
|
|
292
|
-
* @param {string} options.outputPath - path to the .csv file to write the report to
|
|
293
|
-
* @param {string} options.startingDirPath - path to the project root directory (where node_modules folder lives)
|
|
294
|
-
* @param {string} options.gitIgnorePath - path to the .gitignore file
|
|
295
|
-
* @param {string} options.org - optional org, if present an extra column will be added to the report
|
|
296
|
-
* @param {string} options.repo - optional repo, if present an extra column will be added to the report
|
|
297
|
-
* @param {boolean} options.debug - debug flag
|
|
298
|
-
* @param {boolean} options.append - whether to append to the file or override it
|
|
318
|
+
* @param {ScriptOptions} options - options for the report generation directly from the command line
|
|
299
319
|
*
|
|
300
320
|
* @returns {string[]} - the csv rows, always starting with the header
|
|
301
321
|
*/
|
|
@@ -303,16 +323,26 @@ export const createCSVReport = (options) => {
|
|
|
303
323
|
const filesToParse = filePathsWithGitIgnore(options);
|
|
304
324
|
|
|
305
325
|
let csvRows = [
|
|
306
|
-
generateCSVRow(
|
|
326
|
+
`${generateCSVRow(
|
|
307
327
|
{ importedComponent: 'Imported Component', packageName: 'Package Name', renamedAs: 'Renamed Alias' },
|
|
308
328
|
'File Path',
|
|
309
|
-
{
|
|
310
|
-
|
|
329
|
+
{
|
|
330
|
+
...options,
|
|
331
|
+
org: options.org ? 'Org' : undefined,
|
|
332
|
+
repo: options.repo ? 'Repository' : undefined,
|
|
333
|
+
packagesVersions: {}, // the title row does not need versions
|
|
334
|
+
},
|
|
335
|
+
)}Version(s)`, // the title row has no related "datum" versions, we hardcode the last column title
|
|
311
336
|
];
|
|
312
337
|
|
|
338
|
+
const packagesVersions =
|
|
339
|
+
npmLsSyncMultipleFormatsSync({
|
|
340
|
+
cwd: options.startingDirPath,
|
|
341
|
+
})?.packageAsKeyVersionMatchedAsArrayOfStrings || {};
|
|
342
|
+
|
|
313
343
|
filesToParse.forEach((filePath) => {
|
|
314
344
|
const fileReport = getFileReport(filePath);
|
|
315
|
-
const fileCSVRows = generateCSVRows(fileReport, options);
|
|
345
|
+
const fileCSVRows = generateCSVRows(fileReport, { ...options, packagesVersions });
|
|
316
346
|
csvRows.push(...fileCSVRows);
|
|
317
347
|
});
|
|
318
348
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { filePathsWithGitIgnore } from '../../../utils/filepathsMatchers.mjs';
|
|
3
|
+
import { npmLsSyncMultipleFormatsSync } from '../../../utils/npmLs.mjs';
|
|
3
4
|
import { generateCsvRows, checkFileForDeprecatedComponents } from './utils.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -26,19 +27,22 @@ export const deprecatedComponentsUsageReport = (options) => {
|
|
|
26
27
|
// "Org(?),Legacy Component,Repository(?),Legacy Package,Filename,File Path,Effort Size,Story Points"
|
|
27
28
|
let csvRows = [
|
|
28
29
|
// eslint-disable-next-line prettier/prettier
|
|
29
|
-
`Legacy Component,${
|
|
30
|
-
options.org ? 'Org,' : ''
|
|
31
|
-
}${
|
|
30
|
+
`Legacy Component,${options.org ? 'Org,' : ''}${
|
|
32
31
|
options.repo ? 'Repository,' : ''
|
|
33
|
-
}Legacy Package,Filename,File Path,Effort Size,Story Points`,
|
|
32
|
+
}Legacy Package,Filename,File Path,Effort Size,Story Points,Version(s)`,
|
|
34
33
|
];
|
|
34
|
+
|
|
35
|
+
const packagesVersions =
|
|
36
|
+
npmLsSyncMultipleFormatsSync({
|
|
37
|
+
cwd: options.startingDirPath,
|
|
38
|
+
})?.packageAsKeyVersionMatchedAsArrayOfStrings || {};
|
|
35
39
|
filesToParse.forEach((filePath) => {
|
|
36
40
|
const fileReport = checkFileForDeprecatedComponents(filePath);
|
|
37
41
|
if (fileReport.isFileProblematic) {
|
|
38
42
|
// we have a lot more info than the one we use in the csv,
|
|
39
43
|
// in case we want to expand it in the future we can store it in the map...
|
|
40
44
|
// problematicFiles.set(filePath, fileReport);
|
|
41
|
-
csvRows.push(...generateCsvRows(fileReport, filePath, options.org, options.repo));
|
|
45
|
+
csvRows.push(...generateCsvRows(fileReport, filePath, options.org, options.repo, packagesVersions));
|
|
42
46
|
}
|
|
43
47
|
});
|
|
44
48
|
if (!append) {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/* eslint-disable max-params, max-lines, max-statements, max-len */
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { dimsumImportStatementsRegExp } from './regexp.mjs';
|
|
4
3
|
import {
|
|
5
|
-
|
|
6
|
-
LEGACY_WITH_NEW_MEDIUM_MIGRATION_EFFORT,
|
|
7
|
-
LEGACY_WITH_NEW_LARGE_MIGRATION_EFFORT,
|
|
4
|
+
DISMISSED_BEFORE_DEPRECATION_FLOWS_EXISTED,
|
|
8
5
|
DISMISSED_WITH_EXAMPLE,
|
|
6
|
+
LEGACY_WITH_NEW_LARGE_MIGRATION_EFFORT,
|
|
7
|
+
LEGACY_WITH_NEW_MEDIUM_MIGRATION_EFFORT,
|
|
8
|
+
LEGACY_WITH_NEW_SMALL_MIGRATION_EFFORT,
|
|
9
9
|
NEVER_INTENDED_FOR_EXTERNAL_USAGE,
|
|
10
|
-
DISMISSED_BEFORE_DEPRECATION_FLOWS_EXISTED,
|
|
11
10
|
STORYPOINTS_TO_EFFORT,
|
|
12
11
|
} from '../../../constants/index.mjs';
|
|
13
|
-
|
|
12
|
+
import { dimsumImportStatementsRegExp } from './regexp.mjs';
|
|
14
13
|
/**
|
|
14
|
+
* @typedef {import('../../../utils/getEmDsPackagesFromNPMLS.mjs').MatchWithMultipleVersionsArrayObj} MatchWithMultipleVersionsArrayObj
|
|
15
|
+
* @typedef {Object.<string, MatchWithMultipleVersionsArrayObj>} MapOfMatchesBasedOnPackageName
|
|
16
|
+
*
|
|
15
17
|
* @typedef {typeof LEGACY_WITH_NEW_SMALL_MIGRATION_EFFORT
|
|
16
18
|
* | typeof LEGACY_WITH_NEW_MEDIUM_MIGRATION_EFFORT
|
|
17
19
|
* | typeof LEGACY_WITH_NEW_LARGE_MIGRATION_EFFORT} deprecatedEffortMap
|
|
@@ -315,10 +317,11 @@ export const checkFileForDeprecatedComponents = (filePath) => {
|
|
|
315
317
|
* @param {string} filePath
|
|
316
318
|
* @param {string} org - optional, if present an extra column will be added to the report
|
|
317
319
|
* @param {string} repo - optional, if present an extra column will be added to the report
|
|
320
|
+
* @param {MapOfMatchesBasedOnPackageName} packagesVersions - a map of package names to their versions
|
|
318
321
|
* @returns {string} - csv row
|
|
319
322
|
*/
|
|
320
|
-
const generateCsvRowFromMatchedEffort = (matchingEffortMetainfo, filePath, org, repo) => {
|
|
321
|
-
// "Legacy Component,Org(?),Repository(?),Legacy Package,Filename,File Path,Effort Size,Story Points"
|
|
323
|
+
const generateCsvRowFromMatchedEffort = (matchingEffortMetainfo, filePath, org, repo, packagesVersions) => {
|
|
324
|
+
// "Legacy Component,Org(?),Repository(?),Legacy Package,Filename,File Path,Effort Size,Story Points,Version(s)"
|
|
322
325
|
|
|
323
326
|
// matchingEffortMetainfo type is deprecatedEffortMapEntry | dismissedWithExampleEntry
|
|
324
327
|
// they share 'component' and 'oldPackage' properties and for the current use case we only care about those
|
|
@@ -331,9 +334,11 @@ const generateCsvRowFromMatchedEffort = (matchingEffortMetainfo, filePath, org,
|
|
|
331
334
|
const latestMatchingFolderIndx = pathFolders.findIndex((folder, indx) => folder !== cwdFolders[indx]);
|
|
332
335
|
const filePathFolders = pathFolders.slice(latestMatchingFolderIndx);
|
|
333
336
|
const reducedFilePath = filePathFolders.join('/');
|
|
337
|
+
const packageFound = packagesVersions[oldPackage];
|
|
338
|
+
const packageVersion = packageFound?.versions?.join?.('; ') || '';
|
|
334
339
|
return `${component},${org ? `${org},` : ''}${
|
|
335
340
|
repo ? `${repo},` : ''
|
|
336
|
-
}${oldPackage},${filename},${reducedFilePath},${tshirt},${storyPoints}`;
|
|
341
|
+
}${oldPackage},${filename},${reducedFilePath},${tshirt},${storyPoints},${packageVersion}`;
|
|
337
342
|
};
|
|
338
343
|
/**
|
|
339
344
|
* Helper function to generate a list of csv rows from a given file report
|
|
@@ -341,9 +346,10 @@ const generateCsvRowFromMatchedEffort = (matchingEffortMetainfo, filePath, org,
|
|
|
341
346
|
* @param {string} filePath
|
|
342
347
|
* @param {string} org - optional, if present an extra column will be added to the report
|
|
343
348
|
* @param {string} repo - optional, if present an extra column will be added to the report
|
|
349
|
+
* @param {MapOfMatchesBasedOnPackageName} packagesVersions - a map of package names to their versions
|
|
344
350
|
* @returns {string[]} - list of csv rows
|
|
345
351
|
*/
|
|
346
|
-
export const generateCsvRows = (fileReport, filePath, org, repo) => {
|
|
352
|
+
export const generateCsvRows = (fileReport, filePath, org, repo, packagesVersions) => {
|
|
347
353
|
const {
|
|
348
354
|
deprecatedSmallEffort,
|
|
349
355
|
deprecatedMediumEffort,
|
|
@@ -352,7 +358,7 @@ export const generateCsvRows = (fileReport, filePath, org, repo) => {
|
|
|
352
358
|
reportingUsageOfInternalOnly,
|
|
353
359
|
deprecatedBeforeDeprecationFlowsExisted,
|
|
354
360
|
} = fileReport;
|
|
355
|
-
// csv structure = `Legacy Component,${options.org ? 'Org,' : ''}${options.repo ? 'Repository,' : ''}Legacy Package,Filename,File Path,Effort Size,Story Points
|
|
361
|
+
// csv structure = `Legacy Component,${options.org ? 'Org,' : ''}${options.repo ? 'Repository,' : ''}Legacy Package,Filename,File Path,Effort Size,Story Points,Version(s)`;
|
|
356
362
|
// Legacy Component -> matchingEffortMetainfo.component
|
|
357
363
|
// Legacy Package -> matchingEffortMetainfo.oldPackage
|
|
358
364
|
// Filename -> filePath last part
|
|
@@ -363,40 +369,40 @@ export const generateCsvRows = (fileReport, filePath, org, repo) => {
|
|
|
363
369
|
deprecatedSmallEffort.forEach((effort) => {
|
|
364
370
|
const { matchingEffortsMetainfo } = effort;
|
|
365
371
|
matchingEffortsMetainfo.forEach((effort) => {
|
|
366
|
-
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
372
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo, packagesVersions));
|
|
367
373
|
});
|
|
368
374
|
});
|
|
369
375
|
deprecatedMediumEffort.forEach((effort) => {
|
|
370
376
|
const { matchingEffortsMetainfo } = effort;
|
|
371
377
|
matchingEffortsMetainfo.forEach((effort) => {
|
|
372
|
-
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
378
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo, packagesVersions));
|
|
373
379
|
});
|
|
374
380
|
});
|
|
375
381
|
deprecatedLargeEffort.forEach((effort) => {
|
|
376
382
|
const { matchingEffortsMetainfo } = effort;
|
|
377
383
|
matchingEffortsMetainfo.forEach((effort) => {
|
|
378
|
-
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
384
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo, packagesVersions));
|
|
379
385
|
});
|
|
380
386
|
});
|
|
381
387
|
|
|
382
388
|
deprecatedWithExample.forEach((effort) => {
|
|
383
389
|
const { matchingEffortsMetainfo } = effort;
|
|
384
390
|
matchingEffortsMetainfo.forEach((effort) => {
|
|
385
|
-
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
391
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo, packagesVersions));
|
|
386
392
|
});
|
|
387
393
|
});
|
|
388
394
|
|
|
389
395
|
reportingUsageOfInternalOnly.forEach((effort) => {
|
|
390
396
|
const { matchingEffortsMetainfo } = effort;
|
|
391
397
|
matchingEffortsMetainfo.forEach((effort) => {
|
|
392
|
-
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
398
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo, packagesVersions));
|
|
393
399
|
});
|
|
394
400
|
});
|
|
395
401
|
|
|
396
402
|
deprecatedBeforeDeprecationFlowsExisted.forEach((effort) => {
|
|
397
403
|
const { matchingEffortsMetainfo } = effort;
|
|
398
404
|
matchingEffortsMetainfo.forEach((effort) => {
|
|
399
|
-
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
405
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo, packagesVersions));
|
|
400
406
|
});
|
|
401
407
|
});
|
|
402
408
|
|
|
@@ -246,6 +246,11 @@ export const LEGACY_WITH_NEW_SMALL_MIGRATION_EFFORT = [
|
|
|
246
246
|
newComponent: 'DSControlledRadio', newPackage: '@elliemae/ds-controlled-form',
|
|
247
247
|
tags:[ SEVERITY_TAGS.A11Y_LIMITATIONS ], storyPoints: "150",
|
|
248
248
|
},
|
|
249
|
+
|
|
250
|
+
{ component: 'DSRadioGroup', oldPackage: '@elliemae/ds-form',
|
|
251
|
+
newComponent: 'DSFormLayoutRadioGroup', newPackage: '@elliemae/ds-form-layout-blocks',
|
|
252
|
+
tags:[ SEVERITY_TAGS.A11Y_LIMITATIONS ], storyPoints: "150",
|
|
253
|
+
},
|
|
249
254
|
|
|
250
255
|
{ component: 'DSTextBox', oldPackage: '@elliemae/ds-form',
|
|
251
256
|
newComponent: 'DSInputText', newPackage: '@elliemae/ds-controlled-form',
|
|
@@ -345,7 +350,7 @@ export const LEGACY_WITH_NEW_LARGE_MIGRATION_EFFORT = [
|
|
|
345
350
|
tags:[ SEVERITY_TAGS.A11Y_LIMITATIONS ], storyPoints: "500",
|
|
346
351
|
},
|
|
347
352
|
|
|
348
|
-
{ component: '
|
|
353
|
+
{ component: 'DSDataGrid', oldPackage: '@elliemae/ds-datagrids',
|
|
349
354
|
newComponent: 'DataTable', newPackage: '@elliemae/ds-data-table',
|
|
350
355
|
tags:[ SEVERITY_TAGS.A11Y_LIMITATIONS ], storyPoints: "500",
|
|
351
356
|
},
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable max-statements */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} MatchObj
|
|
5
|
+
* @property {string} fullMatch - the full match string from npm ls
|
|
6
|
+
* @property {string} version - the version string from npm ls
|
|
7
|
+
* @property {string} package - the package name string from npm ls
|
|
8
|
+
*
|
|
9
|
+
* @typedef {Object} MatchWithMultipleVersionsArrayObj
|
|
10
|
+
* @property {Array<{string}>} versions - all the versions found for this package
|
|
11
|
+
* @property {Array<MatchObj>} matchObjs
|
|
12
|
+
* - all the match objects found for this package
|
|
13
|
+
*
|
|
14
|
+
* @typedef {Object.<string, MatchWithMultipleVersionsArrayObj>} MapOfMatchesBasedOnPackageName
|
|
15
|
+
*
|
|
16
|
+
* @typedef {Object} getEmDsPackagesFromNPMLSOptions
|
|
17
|
+
* @property {Function} [perMatchCallback] - a callback function that is called for each match found
|
|
18
|
+
*
|
|
19
|
+
* @typedef {Object} getEmDsPackagesFromNPMLsMultipleFormatsReturn
|
|
20
|
+
* @property {MapOfMatchesBasedOnPackageName} packageAsKeyVersionMatchedAsArrayOfStrings
|
|
21
|
+
* - an object with package names as keys and their versions and match objects as values
|
|
22
|
+
* @property {Array<MatchObj>} arrayOfMatches
|
|
23
|
+
* - an array of match objects
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const dsPackageRegExpFromNpmLs = /@elliemae\/ds-.*?@(.*)/gm;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Given the npm ls stdout, parse it to find @elliemae/ds-* packages and return the matches
|
|
30
|
+
* @param {string} npmLsStdout
|
|
31
|
+
* @param {getEmDsPackagesFromNPMLSOptions} opts
|
|
32
|
+
* @returns {Array<MatchObj>}
|
|
33
|
+
*/
|
|
34
|
+
export function getEmDsPackagesFromNPMLS(npmLsStdout = '', { perMatchCallback = () => {} } = {}) {
|
|
35
|
+
const matches = new Map();
|
|
36
|
+
if (npmLsStdout && typeof npmLsStdout === 'string') {
|
|
37
|
+
const npmLsMatches = [...npmLsStdout.matchAll(dsPackageRegExpFromNpmLs)];
|
|
38
|
+
npmLsMatches.forEach(([fullMatch, version], index) => {
|
|
39
|
+
// in case there are extraneous things after the version, like "deduped" or "extraneous"
|
|
40
|
+
const cleanedFullMatch = fullMatch.split(' ')[0];
|
|
41
|
+
const cleanedVersion = version.split(' ')[0];
|
|
42
|
+
const cleanedPackage = cleanedFullMatch.split(cleanedVersion)[0].slice(0, -1);
|
|
43
|
+
const matchObj = {
|
|
44
|
+
fullMatch: cleanedFullMatch,
|
|
45
|
+
version: cleanedVersion,
|
|
46
|
+
package: cleanedPackage,
|
|
47
|
+
};
|
|
48
|
+
matches.set(cleanedFullMatch, matchObj);
|
|
49
|
+
perMatchCallback({ matchObj, cleanedFullMatch, cleanedVersion, cleanedPackage, fullMatch, version, index });
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return Array.from(matches.values());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// like getEmDsPackagesFromNPMLS and based on it, but we organize the output format differently
|
|
57
|
+
/**
|
|
58
|
+
* given the npm ls stdout, parse it to find @elliemae/ds-* packages and return the matches in different formats
|
|
59
|
+
*
|
|
60
|
+
* @param {string} npmLsStdout - the stdout from running `npm ls`
|
|
61
|
+
* @returns {getEmDsPackagesFromNPMLsMultipleFormatsReturn}
|
|
62
|
+
* - object with the different formats of the parsed output
|
|
63
|
+
*/
|
|
64
|
+
export function getEmDsPackagesFromNPMLsMultipleFormats(npmLsStdout = '') {
|
|
65
|
+
const packageAsKeyVersionMatchedAsArrayOfStrings = {};
|
|
66
|
+
const opts = {
|
|
67
|
+
perMatchCallback: ({ matchObj, cleanedPackage, cleanedVersion }) => {
|
|
68
|
+
if (!packageAsKeyVersionMatchedAsArrayOfStrings[cleanedPackage]) {
|
|
69
|
+
packageAsKeyVersionMatchedAsArrayOfStrings[cleanedPackage] = { versions: [], matchObjs: [] };
|
|
70
|
+
}
|
|
71
|
+
packageAsKeyVersionMatchedAsArrayOfStrings[cleanedPackage].versions.push(cleanedVersion);
|
|
72
|
+
packageAsKeyVersionMatchedAsArrayOfStrings[cleanedPackage].matchObjs.push(matchObj);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const arrayOfMatches = getEmDsPackagesFromNPMLS(npmLsStdout, opts);
|
|
77
|
+
|
|
78
|
+
return { packageAsKeyVersionMatchedAsArrayOfStrings, arrayOfMatches };
|
|
79
|
+
}
|
package/bin/cli/utils/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { fullFilesPaths, generatePathFromCurrentFolder } from './filepathsMatchers.mjs';
|
|
2
|
+
export { getLatestDimsumVersion } from './getLatestDimsumVersion.mjs';
|
|
2
3
|
export { globArray } from './globArray.mjs';
|
|
4
|
+
export { getHighestMatchVersion, getMatchVersions, getVersions } from './matchHelpers.mjs';
|
|
5
|
+
export { npmLs } from './npmLs.mjs';
|
|
3
6
|
export { replaceFromMap } from './replaceFromMap.mjs';
|
|
4
|
-
export { getVersions, getMatchVersions, getHighestMatchVersion } from './matchHelpers.mjs';
|
|
5
|
-
export { getLatestDimsumVersion } from './getLatestDimsumVersion.mjs';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { exec, execSync } from 'child_process';
|
|
2
|
+
import { getEmDsPackagesFromNPMLS, getEmDsPackagesFromNPMLsMultipleFormats } from './getEmDsPackagesFromNPMLS.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('./getEmDsPackagesFromNPMLS.mjs').MatchObj} MatchObj
|
|
6
|
+
* @typedef {import('./getEmDsPackagesFromNPMLS.mjs').PackageNameAsKeyObject} PackageNameAsKeyObject
|
|
7
|
+
* @typedef {import('./getEmDsPackagesFromNPMLS.mjs').getEmDsPackagesFromNPMLsMultipleFormatsReturn}
|
|
8
|
+
* getEmDsPackagesFromNPMLsMultipleFormatsReturn
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** run `npm ls` in the specified directory and parse the output to find @elliemae/ds-* packages
|
|
12
|
+
* @param {object} runningOptions
|
|
13
|
+
* @param {string} runningOptions.cwd - the working directory to run npm ls in
|
|
14
|
+
* @returns {Promise<Array<MatchObj>>}
|
|
15
|
+
* - array of objects with fullMatch, version, and package keys
|
|
16
|
+
*/
|
|
17
|
+
export const npmLs = async ({ cwd }) => {
|
|
18
|
+
const [, stdout] = await new Promise((resolve) => {
|
|
19
|
+
exec('npm ls', { cwd }, (...cbRes) => resolve(cbRes));
|
|
20
|
+
});
|
|
21
|
+
if (stdout) return getEmDsPackagesFromNPMLS(stdout);
|
|
22
|
+
return [];
|
|
23
|
+
};
|
|
24
|
+
/** run `npm ls` in the specified directory and parse the output to find @elliemae/ds-* packages in a synchronous way
|
|
25
|
+
* @param {object} runningOptions
|
|
26
|
+
* @param {string} runningOptions.cwd - the working directory to run npm ls in
|
|
27
|
+
* @returns {Array<MatchObj>}
|
|
28
|
+
* - array of objects with fullMatch, version, and package keys
|
|
29
|
+
*/
|
|
30
|
+
export const npmLsSync = ({ cwd }) => {
|
|
31
|
+
let stdout = '';
|
|
32
|
+
try {
|
|
33
|
+
stdout = execSync('npm ls', { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error.stdout) {
|
|
36
|
+
// we expect errors due to the fragility of npm ls and how it errors on malformed but functional package.json
|
|
37
|
+
// but we want to continue with the stdout if it exists
|
|
38
|
+
stdout = error.stdout;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (stdout) return getEmDsPackagesFromNPMLS(stdout);
|
|
42
|
+
return [];
|
|
43
|
+
};
|
|
44
|
+
/** run `npm ls` in the specified directory and parse the output to find @elliemae/ds-* packages
|
|
45
|
+
*
|
|
46
|
+
* @param {object} runningOptions
|
|
47
|
+
* @param {string} runningOptions.cwd - the working directory to run npm ls in
|
|
48
|
+
* @returns {Promise<getEmDsPackagesFromNPMLsMultipleFormatsReturn>}
|
|
49
|
+
* - object with the different formats of the parsed output
|
|
50
|
+
*/
|
|
51
|
+
export const npmLsMultipleFormats = async ({ cwd }) => {
|
|
52
|
+
const [, stdout] = await new Promise((resolve) => {
|
|
53
|
+
exec('npm ls', { cwd }, (...cbRes) => resolve(cbRes));
|
|
54
|
+
});
|
|
55
|
+
if (stdout) return getEmDsPackagesFromNPMLsMultipleFormats(stdout);
|
|
56
|
+
return [];
|
|
57
|
+
};
|
|
58
|
+
/** run `npm ls` in the specified directory and parse the output to find @elliemae/ds-* packages
|
|
59
|
+
*
|
|
60
|
+
* @param {object} runningOptions
|
|
61
|
+
* @param {string} runningOptions.cwd - the working directory to run npm ls in
|
|
62
|
+
* @returns {getEmDsPackagesFromNPMLsMultipleFormatsReturn}
|
|
63
|
+
* - object with the different formats of the parsed output
|
|
64
|
+
*/
|
|
65
|
+
export const npmLsSyncMultipleFormatsSync = ({ cwd }) => {
|
|
66
|
+
let stdout = '';
|
|
67
|
+
try {
|
|
68
|
+
stdout = execSync('npm ls', { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error.stdout) {
|
|
71
|
+
// we expect errors due to the fragility of npm ls and how it errors on malformed but functional package.json
|
|
72
|
+
// but we want to continue with the stdout if it exists
|
|
73
|
+
stdout = error.stdout;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (stdout) return getEmDsPackagesFromNPMLsMultipleFormats(stdout);
|
|
77
|
+
return [];
|
|
78
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-codemods",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.57.0-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Code Mods",
|
|
6
6
|
"files": [
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"test-check-packages-inconsistencies": "npx ./ check-packages-inconsistencies --globPattern='./test-ables/check-packages-inconsistencies/package.mock' --globPatternIgnore='**/node_modules/**/*'",
|
|
51
51
|
"test-check-deprecated-packages": "npx ./ check-deprecated-packages --cwd=\"test-ables/check-deprecated-packages/with-deprecated\"",
|
|
52
52
|
"test-check-deprecated-packages-no-dimsum": "npx ./ check-deprecated-packages --cwd=\"test-ables/check-deprecated-packages/without-dimsum-packages\"",
|
|
53
|
-
"test-components-usage-report-deprecated": "npx ./ deprecated-components-usage-report --outputPath=\"./test.csv\" --startingDirPath=\"../../../environments\" --gitIgnorePath=\"../../../.gitignore\"",
|
|
53
|
+
"test-components-usage-report-deprecated": "npx ./ deprecated-components-usage-report --outputPath=\"./test-deprecated.csv\" --startingDirPath=\"../../../environments\" --gitIgnorePath=\"../../../.gitignore\"",
|
|
54
54
|
"test-components-usage-report": "npx ./ components-usage-report --outputPath=\"./test.csv\" --startingDirPath=\"../../../environments\" --gitIgnorePath=\"../../../.gitignore\"",
|
|
55
|
-
"test-components-usage-report-complete": "npx ./ components-usage-report --outputPath=\"./test.csv\" --startingDirPath=\"../../../environments\" --gitIgnorePath=\"../../../.gitignore\" --repo=\"Dimsum\" --org=\"ICE\"",
|
|
56
|
-
"test-components-usage-report-complete-append": "npx ./ components-usage-report --outputPath=\"./test.csv\" --startingDirPath=\"../../../environments\" --gitIgnorePath=\"../../../.gitignore\" --repo=\"Dimsum2\" --org=\"ICE2\"",
|
|
55
|
+
"test-components-usage-report-complete": "npx ./ components-usage-report --outputPath=\"./test-with-org.csv\" --startingDirPath=\"../../../environments\" --gitIgnorePath=\"../../../.gitignore\" --repo=\"Dimsum\" --org=\"ICE\"",
|
|
56
|
+
"test-components-usage-report-complete-append": "npx ./ components-usage-report --outputPath=\"./test-with-org.csv\" --startingDirPath=\"../../../environments\" --gitIgnorePath=\"../../../.gitignore\" --repo=\"Dimsum2\" --org=\"ICE2\"",
|
|
57
57
|
"test-help-migrate-to-v3": "npx ./ help-migrate-to-v3 --globPattern=\"test-ables/help-migrate-to-v3/**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx\" --globPatternIgnore=\"**/node_modules/**/*\"",
|
|
58
58
|
"checkDeps": "exit 0 | echo"
|
|
59
59
|
}
|
package/bin/cli/code-mods/command-logics/check-deprecated-packages/getEmDsPackagesFromNPMLS.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|