@elliemae/ds-codemods 3.31.4 → 3.32.0-rc.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +374 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-codemods",
3
- "version": "3.31.4",
3
+ "version": "3.32.0-rc.2",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Code Mods",
6
6
  "files": [
package/readme.md ADDED
@@ -0,0 +1,374 @@
1
+ # `ds-codemods` API Documentation (up to version 3.31.X)
2
+
3
+ ## Migrating from `<1.37.X` to `>1.37.X`
4
+
5
+ This scripts will recursively check the files matching the `globPattern` and using an opinionated substitution map will "search and replace" some legacy imports
6
+
7
+ This was created for adressing dimsum 1.37.X legacy way of improting components and is only addressing the specific substitution map for moving from `< 1.37.X` to `> 1.37.X`
8
+
9
+ ### Command
10
+
11
+ `npx @elliemae/ds-codemods fix-legacy-imports`
12
+
13
+ ### Arguments
14
+
15
+ - `globPattern`
16
+
17
+ A comma separated list of globPatterns catching the file in which to fix the imports
18
+
19
+ default: `'./**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx'`
20
+
21
+ - `globPatternIgnore`
22
+
23
+ A comma separated list of ignored files that are matched by the globPattern and should not be "fixed"
24
+
25
+ default: `'**/node_modules/**/*'`
26
+
27
+ ### Usage
28
+
29
+ - **CLI**
30
+
31
+ ```
32
+ npx @elliemae/ds-codemods fix-legacy-imports --globPattern='./**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx' --globPatternIgnore='**/node_modules/**/*'
33
+ ```
34
+
35
+ - **Guided CLI**
36
+
37
+ ```
38
+ npx @elliemae/ds-codemods fix-legacy-imports
39
+ ```
40
+
41
+ ## Reverting `>1.37.X` Migration
42
+
43
+ This scripts will recursively check the files matching the `globPattern` and using an opinionated substitution map will undo the changes from the `fix-legacy-imports`.
44
+
45
+ This was created "for good measure" and "just in case", but in a `git` based project it would be much better to just undo pending changes if possible.
46
+
47
+ ### Command
48
+
49
+ `npx @elliemae/ds-codemods fix-legacy-imports:revert`
50
+
51
+ ### Arguments
52
+
53
+ - Same as migrating from `<1.37.X` to `>1.37.X`.
54
+
55
+ ### Usage
56
+
57
+ - **CLI**
58
+
59
+ ```
60
+ npx @elliemae/ds-codemods fix-legacy-imports:revert --globPattern='./**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx' --globPatternIgnore='**/node_modules/**/*'
61
+ ```
62
+
63
+ - **Guided CLI**
64
+
65
+ ```
66
+ npx @elliemae/ds-codemods fix-legacy-imports:revert
67
+ ```
68
+
69
+ ## Deprecated Components Check (Dismissed)
70
+
71
+ Based on the execution of `npm ls` command, analyse the output vs "deprecated dimsum packages",
72
+
73
+ Executing this script will result in a `markdown` compliant log in the terminal of the currently found deprecated components
74
+
75
+ This script is somewhate not mantained and is instead substituted by the much more powerful `deprecated-components-usage-report` script, information from this scripts WILL be partial
76
+
77
+ ### Command
78
+
79
+ `npx @elliemae/ds-codemods check-deprecated-packages`
80
+
81
+ ### Arguments
82
+
83
+ - `cwd`
84
+
85
+ The project root directory (where node_modules folder lives)
86
+
87
+ default: `'./'`
88
+
89
+ ### Usage
90
+
91
+ - **CLI**
92
+
93
+ ```
94
+ npx @elliemae/ds-codemods check-deprecated-packages --cwd='./'
95
+ ```
96
+
97
+ - **Guided CLI**
98
+
99
+ ```
100
+ npx @elliemae/ds-codemods check-deprecated-packages
101
+ ```
102
+
103
+ ## Ensuring `package.json` Compliance
104
+
105
+ A script meant to be used to ensure the dependencies listed in a given `package.json` file matches the `dimsum`'s versioning assumption to be considered "healthy"
106
+
107
+ The assumption are
108
+
109
+ - all the `@elliemae/ds-*` packages MUST point to the same version
110
+ - the "pointed" version should be within 6 `minor` version from highest release
111
+
112
+ uses third-party `pacote` to detect latest publish version.
113
+
114
+ ### Command
115
+
116
+ `npx @elliemae/ds-codemods check-packages-inconsistencies`
117
+
118
+ ### Arguments
119
+
120
+ - `globPattern`
121
+
122
+ A comma separated list of globPatterns catching the file in which to fix the imports
123
+
124
+ default: `'./package.json'`
125
+
126
+ - `globPatternIgnore`
127
+
128
+ A comma separated list of ignored files that are matched by the globPattern and should not be "fixed"
129
+
130
+ default: `'**/node_modules/**/*'`
131
+
132
+ ### Usage
133
+
134
+ - **CLI**
135
+
136
+ ```
137
+ npx @elliemae/ds-codemods check-packages-inconsistencies --globPattern='./package.json' --globPatternIgnore='**/node_modules/**/*'
138
+ ```
139
+
140
+ - **Guided CLI**
141
+
142
+ ```
143
+ npx @elliemae/ds-codemods check-packages-inconsistencies
144
+ ```
145
+
146
+ ## Missing Dependencies Detection
147
+
148
+ A script that using the third-party package `pacote` checks if the project `package.json` is not correctly depending on the "expected" packages.
149
+
150
+ This is a simple overloaded way to invoke pacote, so it's affected 1-1 with any limitation/problem the `pacote` package may have.
151
+
152
+ ### Command
153
+
154
+ `npx @elliemae/ds-codemods check-missing-packages`
155
+
156
+ ### Arguments
157
+
158
+ - `projectFolderPath`
159
+
160
+ path to the project folder containing the package.json file
161
+
162
+ default: `'./'`
163
+
164
+ - `ignorePackagesGlobPattern`
165
+
166
+ A comma separated list of "false positive" packages to be passed to pacote, if any.
167
+
168
+ default: `''`
169
+
170
+ - `ignoreFilesGlobPattern`
171
+
172
+ A comma separated list of globPatterns for ignored files, if any.
173
+
174
+ default: `'**/*.eslintrc.js'`
175
+
176
+ ### Usage
177
+
178
+ - **CLI**
179
+
180
+ ```
181
+ npx @elliemae/ds-codemods check-missing-packages --projectFolderPath='./' --ignorePackagesGlobPattern='' --ignoreFilesGlobPattern='**/*.eslintrc.js'
182
+ ```
183
+
184
+ - **Guided CLI**
185
+
186
+ ```
187
+ npx @elliemae/ds-codemods check-missing-packages
188
+ ```
189
+
190
+ ## Migrating from `<3.X.X` to `>3.X.X`
191
+
192
+ similar to `fix-legacy-imports` this script was created to facilitate projects transition from `dimsum < 3.x.x` to `> 3.x.x`.
193
+
194
+ This mainly search for imports from `@elliema/ds-basic/{something}` and switch the ESM module import syntax to the one that dimsum `3.x.x` requires ( which is usually pointing to the specific dedicated package, instead of the aggregated ds-basic package which in dimsum 3.x.x dropped all the components exports )
195
+
196
+ ### Command
197
+
198
+ `npx @elliemae/ds-codemods help-migrate-to-v3`
199
+
200
+ ### Arguments
201
+
202
+ - `globPattern`
203
+
204
+ A comma separated list of globPatterns catching the file in which to fix the imports
205
+
206
+ default: `'./**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx'`
207
+
208
+ - `globPatternIgnore`
209
+
210
+ A comma separated list of ignored files that are matched by the globPattern and should not be "fixed"
211
+
212
+ default: `'**/node_modules/**/*'`
213
+
214
+ ### Usage
215
+
216
+ - **CLI**
217
+
218
+ ```
219
+ npx @elliemae/ds-codemods help-migrate-to-v3 --globPattern='./**/*.js,./**/*.jsx,./**/*.ts,./**/*.tsx' --globPatternIgnore='**/node_modules/**/*'
220
+ ```
221
+
222
+ - **Guided CLI**
223
+
224
+ ```
225
+ npx @elliemae/ds-codemods help-migrate-to-v3
226
+ ```
227
+
228
+ ## Generating Reports on Deprecated Component Usage
229
+
230
+ The latest script attempting to tackle "housekeeping" with the dimsum deprecated packages,
231
+
232
+ Will create a file in the `outputPath` that will contain a report in a `csv` format,
233
+ The file that will be checked for will depend on sensible defaults and the opinionated sensible default is making use of `gitIgnore` if present, scan all js/ts jsx/tsx files.
234
+
235
+ This is manually mantained some minor miss-aligment MAY happen, but dimsum teams tries it's best to keep this up to date.
236
+
237
+ ### Command
238
+
239
+ `npx @elliemae/ds-codemods deprecated-components-usage-report`
240
+
241
+ ### Arguments
242
+
243
+ - `outputPath`
244
+
245
+ path to the .csv file to write the report to
246
+
247
+ default: `'./dimsum-deprecated-components-usage-report.csv'`
248
+
249
+ - `startingDirPath`
250
+
251
+ Please provide the project root directory (where node_modules folder lives)
252
+
253
+ default: `'./'`
254
+
255
+ - `gitIgnorePath`
256
+
257
+ Please provide the path to the .gitignore file (if a non-matching path is provided, node_modules, dist and build will be ignored)
258
+
259
+ default: `'./.gitignore'`
260
+
261
+ - `debug` (CLI Only)
262
+
263
+ A flag to display some debugging information in case an execution bug arises
264
+
265
+ default: `false`
266
+
267
+ - `append` (CLI Only)
268
+
269
+ A flag to specify that if the `outputPath` csv already exists, the script should try to append the `csv` rows to that file instead of overwriting the content
270
+
271
+ default: `false`
272
+
273
+ - `org` (CLI Only)
274
+
275
+ A `string` that when provided will add a dedicated column to the csv report. Mainly used to be able to analyze multiple code-base and being able to recognize them in the report
276
+
277
+ default: `undefined`
278
+
279
+ - `repo` (CLI Only)
280
+
281
+ A `string` that when provided will add a dedicated column to the csv report. Mainly used to be able to analyze multiple code-base and being able to recognize them in the report
282
+
283
+ default: `undefined`
284
+
285
+ ### Usage
286
+
287
+ - **CLI:**
288
+
289
+ ```
290
+ npx @elliemae/ds-codemods deprecated-components-usage-report --outputPath='./dimsum-deprecated-components-usage-report.csv' --startingDirPath='./' --gitIgnorePath='./.gitignore' --debug --append --org='ICE' --repo='Dimsum'
291
+ ```
292
+
293
+ - **Guided CLI:**
294
+
295
+ ```
296
+ npx @elliemae/ds-codemods deprecated-components-usage-report
297
+ ```
298
+
299
+ ```
300
+ npx @elliemae/ds-codemods deprecated-components-usage-report --append --org='ICE' --repo='Dimsum'
301
+ ```
302
+
303
+ ## Generating `.CSV` Reports on Component Usage
304
+
305
+ A script that will create a `csv` report as per defined in the output path and will fill it with a detailed report of every istance of ESM `import` statement that involves a `@elliemae/ds-*` package
306
+
307
+ This report also reports wheter "default" imports, "named import with alias" or "global import" pattern has been used.
308
+ `Dimsum` strongly suggest and kind-of would like t
309
+
310
+ ### Command
311
+
312
+ `npx @elliemae/ds-codemods components-usage-report`
313
+
314
+ ### Arguments
315
+
316
+ - `outputPath`
317
+
318
+ path to the .csv file to write the report to
319
+
320
+ default: `'./dimsum-components-usage-report.csv'`
321
+
322
+ - `startingDirPath`
323
+
324
+ Please provide the project root directory (where node_modules folder lives)
325
+
326
+ default: `'./'`
327
+
328
+ - `gitIgnorePath`
329
+
330
+ Please provide the path to the .gitignore file (if a non-matching path is provided, node_modules, dist and build will be ignored)
331
+
332
+ default: `'./.gitignore'`
333
+
334
+ - `debug` (CLI Only)
335
+
336
+ A flag to display some debugging information in case an execution bug arises
337
+
338
+ default: `false`
339
+
340
+ - `append` (CLI Only)
341
+
342
+ A flag to specify that if the `outputPath` csv already exists, the script should try to append the `csv` rows to that file instead of overwriting the content
343
+
344
+ default: `false`
345
+
346
+ - `org` (CLI Only)
347
+
348
+ A `string` that when provided will add a dedicated column to the csv report. Mainly used to be able to analyze multiple code-base and being able to recognize them in the report
349
+
350
+ default: `undefined`
351
+
352
+ - `repo` (CLI Only)
353
+
354
+ A `string` that when provided will add a dedicated column to the csv report. Mainly used to be able to analyze multiple code-base and being able to recognize them in the report
355
+
356
+ default: `undefined`
357
+
358
+ ### Usage
359
+
360
+ - **CLI:**
361
+
362
+ ```
363
+ npx @elliemae/ds-codemods components-usage-report --outputPath='./dimsum-components-usage-report.csv' --startingDirPath='./' --gitIgnorePath='./.gitignore' --debug --append --org='ICE' --repo='Dimsum'
364
+ ```
365
+
366
+ - **Guided CLI:**
367
+
368
+ ```
369
+ npx @elliemae/ds-codemods components-usage-report
370
+ ```
371
+
372
+ ```
373
+ npx @elliemae/ds-codemods components-usage-report --append --org='ICE' --repo='Dimsum'
374
+ ```