@elliemae/ds-codemods 3.38.0-rc.2 → 3.38.0-rc.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.
|
@@ -25,10 +25,10 @@ import {
|
|
|
25
25
|
* @property {regexpInfo} matchSharedPropieties.regexpInfo
|
|
26
26
|
*
|
|
27
27
|
* @typedef { object } matchWithEffortEntryPropeties
|
|
28
|
-
* @property { deprecatedEffortMapEntry } matchWithEffortEntryPropeties.
|
|
28
|
+
* @property { deprecatedEffortMapEntry[] } matchWithEffortEntryPropeties.matchingEffortsMetainfo
|
|
29
29
|
*
|
|
30
30
|
* @typedef { object } matchDeprecatedEntryPropeties
|
|
31
|
-
* @property { dismissedWithExampleEntry } matchDeprecatedEntryPropeties.
|
|
31
|
+
* @property { dismissedWithExampleEntry[] } matchDeprecatedEntryPropeties.matchingEffortsMetainfo
|
|
32
32
|
*
|
|
33
33
|
* @typedef {matchSharedPropieties & matchWithEffortEntryPropeties} matchWithEffortMetaInfo
|
|
34
34
|
* @typedef {matchSharedPropieties & matchDeprecatedEntryPropeties} matchDeprecatedWithExample
|
|
@@ -75,11 +75,33 @@ const getSupportingDataStructures = (deprecatedEffortMap, effortCacheUID) => {
|
|
|
75
75
|
if (!effortsDifferentPackageList.includes(oldPackage)) effortsDifferentPackageList.push(oldPackage);
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
+
const packagesOnlyAppearingAsOldAndNeverAsNew = [];
|
|
79
|
+
const oldPackages = new Map();
|
|
80
|
+
const newPackages = new Map();
|
|
81
|
+
LEGACY_WITH_NEW_SMALL_MIGRATION_EFFORT.forEach((effort) => {
|
|
82
|
+
const { oldPackage, newPackage } = effort;
|
|
83
|
+
oldPackages.set(oldPackage, true);
|
|
84
|
+
newPackages.set(newPackage, true);
|
|
85
|
+
});
|
|
86
|
+
LEGACY_WITH_NEW_MEDIUM_MIGRATION_EFFORT.forEach((effort) => {
|
|
87
|
+
const { oldPackage, newPackage } = effort;
|
|
88
|
+
oldPackages.set(oldPackage, true);
|
|
89
|
+
newPackages.set(newPackage, true);
|
|
90
|
+
});
|
|
91
|
+
LEGACY_WITH_NEW_LARGE_MIGRATION_EFFORT.forEach((effort) => {
|
|
92
|
+
const { oldPackage, newPackage } = effort;
|
|
93
|
+
oldPackages.set(oldPackage, true);
|
|
94
|
+
newPackages.set(newPackage, true);
|
|
95
|
+
});
|
|
96
|
+
oldPackages.forEach((_, oldPackage) => {
|
|
97
|
+
if (!newPackages.has(oldPackage)) packagesOnlyAppearingAsOldAndNeverAsNew.push(oldPackage);
|
|
98
|
+
});
|
|
78
99
|
|
|
79
100
|
runtimeDeprecatedDSReportCache.set(effortCacheUID, {
|
|
80
101
|
effortsSamePackageList,
|
|
81
102
|
effortsSamePackageOldComponentsList,
|
|
82
103
|
effortsDifferentPackageList,
|
|
104
|
+
packagesOnlyAppearingAsOldAndNeverAsNew,
|
|
83
105
|
});
|
|
84
106
|
|
|
85
107
|
return runtimeDeprecatedDSReportCache.get(effortCacheUID);
|
|
@@ -93,8 +115,12 @@ const getSupportingDataStructures = (deprecatedEffortMap, effortCacheUID) => {
|
|
|
93
115
|
* @returns {Map<string, matchWithEffortMetaInfo>} - a map of matched statements
|
|
94
116
|
*/
|
|
95
117
|
const checkDeprecatedEffort = (importStatements, deprecatedEffortMap, effortCacheUID = '') => {
|
|
96
|
-
const {
|
|
97
|
-
|
|
118
|
+
const {
|
|
119
|
+
effortsSamePackageList,
|
|
120
|
+
effortsSamePackageOldComponentsList,
|
|
121
|
+
effortsDifferentPackageList,
|
|
122
|
+
packagesOnlyAppearingAsOldAndNeverAsNew,
|
|
123
|
+
} = getSupportingDataStructures(deprecatedEffortMap, effortCacheUID);
|
|
98
124
|
|
|
99
125
|
const matchedEfforts = new Map();
|
|
100
126
|
|
|
@@ -104,11 +130,13 @@ const checkDeprecatedEffort = (importStatements, deprecatedEffortMap, effortCach
|
|
|
104
130
|
// we do not care if the package is not in the list of packages that are deprecated
|
|
105
131
|
// when the deprecated component and live components lives in different packages we know for sure that the statement is deprecated
|
|
106
132
|
const statementIsDeprecatedForSure =
|
|
133
|
+
packagesOnlyAppearingAsOldAndNeverAsNew.findIndex((pck) => subStringAdhocDSMatcher(pck, packageName)) !== -1 ||
|
|
107
134
|
effortsDifferentPackageList.findIndex((pck) => subStringAdhocDSMatcher(pck, packageName)) !== -1;
|
|
108
135
|
// when the new and old lives under the same package (E.G. tooltip -> tooltipv3 from ds-tooltip, buttonv2 -> buttonv3 from ds-button-v2 ...)
|
|
109
136
|
// we need to check if the component itself is deprecated or not, just the "from ..." part is not enough
|
|
110
137
|
const statementIsPotentiallyDeprecated =
|
|
111
138
|
effortsSamePackageList.findIndex((pck) => subStringAdhocDSMatcher(pck, packageName)) !== -1;
|
|
139
|
+
|
|
112
140
|
let isStatementActuallyDeprecated = false;
|
|
113
141
|
if (!statementIsDeprecatedForSure && statementIsPotentiallyDeprecated) {
|
|
114
142
|
effortsSamePackageOldComponentsList.forEach((deprecatedComponent) => {
|
|
@@ -120,13 +148,17 @@ const checkDeprecatedEffort = (importStatements, deprecatedEffortMap, effortCach
|
|
|
120
148
|
// we iterate the deprecatedEffortMap again now that we know the statement is deprecated,
|
|
121
149
|
// we do this so we can reach the constant meta-informations (like the new package name, severityTags, etc...)
|
|
122
150
|
// technically this is O(n * m) where n is ~<10 and m is ~<50 so even the worst case is not that bad...
|
|
123
|
-
const matchingEffortMetainfoIndx = deprecatedEffortMap.findIndex((effortMetainfo) =>
|
|
151
|
+
// const matchingEffortMetainfoIndx = deprecatedEffortMap.findIndex((effortMetainfo) =>
|
|
152
|
+
// subStringAdhocDSMatcher(importedComponent, effortMetainfo.component),
|
|
153
|
+
// );
|
|
154
|
+
const matchingDeprecations = deprecatedEffortMap.filter((effortMetainfo) =>
|
|
124
155
|
subStringAdhocDSMatcher(importedComponent, effortMetainfo.component),
|
|
125
156
|
);
|
|
126
|
-
if (
|
|
157
|
+
if (matchingDeprecations.length < 1) return;
|
|
158
|
+
// if (matchingEffortMetainfoIndx === -1) return;
|
|
127
159
|
matchedEfforts.set(fullMatch, {
|
|
128
160
|
regexpInfo: { fullMatch, importedComponent, packageName },
|
|
129
|
-
|
|
161
|
+
matchingEffortsMetainfo: matchingDeprecations,
|
|
130
162
|
});
|
|
131
163
|
}
|
|
132
164
|
});
|
|
@@ -165,16 +197,16 @@ export const checkDeprecatedDismissed = (importStatements) => {
|
|
|
165
197
|
const matchedEfforts = new Map();
|
|
166
198
|
importStatements.forEach((importStatement) => {
|
|
167
199
|
const [fullMatch, importedComponent, packageName] = importStatement;
|
|
168
|
-
const
|
|
200
|
+
const matchingDeprecations = DISMISSED_WITH_EXAMPLE.filter(
|
|
169
201
|
(effortMetainfo) =>
|
|
170
202
|
subStringAdhocDSMatcher(importedComponent, effortMetainfo.component) &&
|
|
171
203
|
// {DSGroupBox} from 'ds-mobile' is not (yet) deprecated, DSGroupBox is a repeated component name, we need the extra package check
|
|
172
204
|
subStringAdhocDSMatcher(packageName, effortMetainfo.oldPackage),
|
|
173
205
|
);
|
|
174
|
-
if (
|
|
206
|
+
if (matchingDeprecations.length < 1) return;
|
|
175
207
|
matchedEfforts.set(fullMatch, {
|
|
176
208
|
regexpInfo: { fullMatch, importedComponent, packageName },
|
|
177
|
-
|
|
209
|
+
matchingEffortsMetainfo: matchingDeprecations,
|
|
178
210
|
});
|
|
179
211
|
});
|
|
180
212
|
return matchedEfforts;
|
|
@@ -211,15 +243,15 @@ export const checkFileForDeprecatedComponents = (filePath) => {
|
|
|
211
243
|
|
|
212
244
|
/**
|
|
213
245
|
* Helper function to generate a csv row from a "matched effort" object
|
|
214
|
-
* @param {
|
|
246
|
+
* @param {deprecatedEffortMapEntry | dismissedWithExampleEntry} matchedEffort
|
|
215
247
|
* @param {string} filePath
|
|
216
248
|
* @param {string} org - optional, if present an extra column will be added to the report
|
|
217
249
|
* @param {string} repo - optional, if present an extra column will be added to the report
|
|
218
250
|
* @returns {string} - csv row
|
|
219
251
|
*/
|
|
220
|
-
const generateCsvRowFromMatchedEffort = (
|
|
252
|
+
const generateCsvRowFromMatchedEffort = (matchingEffortMetainfo, filePath, org, repo) => {
|
|
221
253
|
// "Legacy Component,Org(?),Repository(?),Legacy Package,Filename,File Path,Effort Size,Story Points"
|
|
222
|
-
|
|
254
|
+
|
|
223
255
|
// matchingEffortMetainfo type is deprecatedEffortMapEntry | dismissedWithExampleEntry
|
|
224
256
|
// they share 'component' and 'oldPackage' properties and for the current use case we only care about those
|
|
225
257
|
// if we want to expand the csv in the future we have to take care of this difference in the types
|
|
@@ -254,17 +286,29 @@ export const generateCsvRows = (fileReport, filePath, org, repo) => {
|
|
|
254
286
|
// this is not a perfect "detect the root" solution, but should work in our CI/CD pipeline
|
|
255
287
|
const csvRows = [];
|
|
256
288
|
deprecatedSmallEffort.forEach((effort) => {
|
|
257
|
-
|
|
289
|
+
const { matchingEffortsMetainfo } = effort;
|
|
290
|
+
matchingEffortsMetainfo.forEach((effort) => {
|
|
291
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
292
|
+
});
|
|
258
293
|
});
|
|
259
294
|
deprecatedMediumEffort.forEach((effort) => {
|
|
260
|
-
|
|
295
|
+
const { matchingEffortsMetainfo } = effort;
|
|
296
|
+
matchingEffortsMetainfo.forEach((effort) => {
|
|
297
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
298
|
+
});
|
|
261
299
|
});
|
|
262
300
|
deprecatedLargeEffort.forEach((effort) => {
|
|
263
|
-
|
|
301
|
+
const { matchingEffortsMetainfo } = effort;
|
|
302
|
+
matchingEffortsMetainfo.forEach((effort) => {
|
|
303
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
304
|
+
});
|
|
264
305
|
});
|
|
265
306
|
|
|
266
307
|
deprecatedDismissed.forEach((effort) => {
|
|
267
|
-
|
|
308
|
+
const { matchingEffortsMetainfo } = effort;
|
|
309
|
+
matchingEffortsMetainfo.forEach((effort) => {
|
|
310
|
+
csvRows.push(generateCsvRowFromMatchedEffort(effort, filePath, org, repo));
|
|
311
|
+
});
|
|
268
312
|
});
|
|
269
313
|
|
|
270
314
|
return csvRows;
|