@kaizen/components 1.80.3 → 1.80.5
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/codemods/README.md +12 -0
- package/codemods/migrateV2NextToCurrent/index.ts +40 -0
- package/codemods/migrateV2NextToCurrent/migrateV2NextToCurrent.spec.ts +555 -0
- package/codemods/migrateV2NextToCurrent/migrateV2NextToCurrent.ts +104 -0
- package/codemods/renameV2ComponentImportsAndUsages/index.ts +12 -1
- package/codemods/renameV2ComponentImportsAndUsages/renameV2ComponentImportsAndUsages.ts +57 -136
- package/codemods/utils/createModulePathTransformer.spec.ts +209 -0
- package/codemods/utils/createModulePathTransformer.ts +59 -0
- package/codemods/utils/createRenameMapFromGroups.ts +31 -0
- package/codemods/utils/index.ts +2 -0
- package/dist/cjs/src/Tile/subcomponents/GenericTile/GenericTile.cjs +1 -1
- package/dist/esm/src/Tile/subcomponents/GenericTile/GenericTile.mjs +1 -1
- package/dist/styles.css +22 -22
- package/package.json +1 -1
- package/src/Tile/subcomponents/GenericTile/GenericTile.spec.stories.tsx +8 -3
- package/src/Tile/subcomponents/GenericTile/GenericTile.tsx +1 -4
package/codemods/README.md
CHANGED
|
@@ -25,6 +25,18 @@ pnpm kaizen-codemod src migrateWellVariantToColor
|
|
|
25
25
|
|
|
26
26
|
## Available codemods
|
|
27
27
|
|
|
28
|
+
### `migrateV2NextToCurrent`
|
|
29
|
+
|
|
30
|
+
Released in `1.80.4`
|
|
31
|
+
|
|
32
|
+
Migrates Menu, Tabs, and Tooltip to current import path
|
|
33
|
+
|
|
34
|
+
- `Menu` from `/v3/actions` and `/next` to current
|
|
35
|
+
- `Tabs` from `/future` and `/next` to current
|
|
36
|
+
- `Tooltip` from `/v3/overlays`, `/future` and `/next` to current
|
|
37
|
+
|
|
38
|
+
This also captures `MenuItem`, `MenuHeader`, `MenuPopover`, `MenuSection`, `MenuTrugger`, `Tab`, `TabList`, `TabPanel` and `TooltipTrigger`.
|
|
39
|
+
|
|
28
40
|
### `renameV2ComponentImportsAndUsages`
|
|
29
41
|
|
|
30
42
|
Released in `1.80.3`
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { transformComponentsInDir } from '../utils'
|
|
2
|
+
import { migrateV2NextToCurrent } from './migrateV2NextToCurrent'
|
|
3
|
+
|
|
4
|
+
const run = (): void => {
|
|
5
|
+
console.log('~(-_- ~) Running V2 component renaming (~ -_-)~')
|
|
6
|
+
|
|
7
|
+
const targetDir = process.argv[2]
|
|
8
|
+
if (!targetDir) {
|
|
9
|
+
process.exit(1)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
transformComponentsInDir(
|
|
13
|
+
targetDir,
|
|
14
|
+
[
|
|
15
|
+
'Menu',
|
|
16
|
+
'MenuHeader',
|
|
17
|
+
'MenuItem',
|
|
18
|
+
'MenuPopover',
|
|
19
|
+
'MenuSection',
|
|
20
|
+
'MenuTrigger',
|
|
21
|
+
'Tabs',
|
|
22
|
+
'Tab',
|
|
23
|
+
'TabList',
|
|
24
|
+
'TabPanel',
|
|
25
|
+
'Icon',
|
|
26
|
+
'Focusable',
|
|
27
|
+
'Key',
|
|
28
|
+
'Tooltip',
|
|
29
|
+
'TooltipTrigger',
|
|
30
|
+
'ReversedColors',
|
|
31
|
+
'Button',
|
|
32
|
+
'ButtonProps',
|
|
33
|
+
'ButtonsSizes',
|
|
34
|
+
'ButtonVariants',
|
|
35
|
+
],
|
|
36
|
+
(tagNames) => [migrateV2NextToCurrent(tagNames)],
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
run()
|
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { parseJsx } from '../__tests__/utils'
|
|
2
|
+
import {
|
|
3
|
+
getKaioTagNamesMapByComponentName,
|
|
4
|
+
printAst,
|
|
5
|
+
transformSource,
|
|
6
|
+
type TransformSourceArgs,
|
|
7
|
+
} from '../utils'
|
|
8
|
+
import { migrateV2NextToCurrent } from './migrateV2NextToCurrent'
|
|
9
|
+
|
|
10
|
+
const transformComponents = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
11
|
+
const kaioTagNamesMap = getKaioTagNamesMapByComponentName(sourceFile, [
|
|
12
|
+
'Menu',
|
|
13
|
+
'MenuHeader',
|
|
14
|
+
'MenuItem',
|
|
15
|
+
'MenuPopover',
|
|
16
|
+
'MenuSection',
|
|
17
|
+
'MenuTrigger',
|
|
18
|
+
'Tabs',
|
|
19
|
+
'Tab',
|
|
20
|
+
'TabList',
|
|
21
|
+
'TabPanel',
|
|
22
|
+
'Tooltip',
|
|
23
|
+
'TooltipTrigger',
|
|
24
|
+
'ReversedColors',
|
|
25
|
+
'Focusable',
|
|
26
|
+
'Key',
|
|
27
|
+
'Button',
|
|
28
|
+
'ButtonProps',
|
|
29
|
+
'ButtonsSizes',
|
|
30
|
+
'ButtonVariants',
|
|
31
|
+
'Icon',
|
|
32
|
+
])
|
|
33
|
+
return transformSource({
|
|
34
|
+
sourceFile,
|
|
35
|
+
transformers: [migrateV2NextToCurrent(kaioTagNamesMap!)],
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe('migrateV2NextToCurrent', () => {
|
|
40
|
+
describe('Menu import statements', () => {
|
|
41
|
+
it('should update Menu next import', () => {
|
|
42
|
+
const inputAst = parseJsx(`import { Menu } from "@kaizen/components/next"`)
|
|
43
|
+
const expectedAst = parseJsx(`import { Menu } from "@kaizen/components"`)
|
|
44
|
+
|
|
45
|
+
const result = transformComponents(inputAst)
|
|
46
|
+
expect(result).toBe(printAst(expectedAst))
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should update Menu v3/actions import', () => {
|
|
50
|
+
const inputAst = parseJsx(`import { Menu } from "@kaizen/components/v3/actions"`)
|
|
51
|
+
const expectedAst = parseJsx(`import { Menu } from "@kaizen/components"`)
|
|
52
|
+
|
|
53
|
+
const result = transformComponents(inputAst)
|
|
54
|
+
expect(result).toBe(printAst(expectedAst))
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
describe('MenuHeader import statements', () => {
|
|
59
|
+
it('should update MenuHeader next import', () => {
|
|
60
|
+
const inputAst = parseJsx(`import { MenuHeader } from "@kaizen/components/next"`)
|
|
61
|
+
const expectedAst = parseJsx(`import { MenuHeader } from "@kaizen/components"`)
|
|
62
|
+
|
|
63
|
+
const result = transformComponents(inputAst)
|
|
64
|
+
expect(result).toBe(printAst(expectedAst))
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('should update MenuHeader v3/actions import', () => {
|
|
68
|
+
const inputAst = parseJsx(`import { MenuHeader } from "@kaizen/components/v3/actions"`)
|
|
69
|
+
const expectedAst = parseJsx(`import { MenuHeader } from "@kaizen/components"`)
|
|
70
|
+
|
|
71
|
+
const result = transformComponents(inputAst)
|
|
72
|
+
expect(result).toBe(printAst(expectedAst))
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
describe('MenuItem import statements', () => {
|
|
77
|
+
it('should update MenuItem next import', () => {
|
|
78
|
+
const inputAst = parseJsx(`import { MenuItem } from "@kaizen/components/next"`)
|
|
79
|
+
const expectedAst = parseJsx(`import { MenuItem } from "@kaizen/components"`)
|
|
80
|
+
|
|
81
|
+
const result = transformComponents(inputAst)
|
|
82
|
+
expect(result).toBe(printAst(expectedAst))
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('should update MenuItem v3/actions import', () => {
|
|
86
|
+
const inputAst = parseJsx(`import { MenuItem } from "@kaizen/components/v3/actions"`)
|
|
87
|
+
const expectedAst = parseJsx(`import { MenuItem } from "@kaizen/components"`)
|
|
88
|
+
|
|
89
|
+
const result = transformComponents(inputAst)
|
|
90
|
+
expect(result).toBe(printAst(expectedAst))
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
describe('MenuPopover import statements', () => {
|
|
95
|
+
it('should update MenuPopover next import', () => {
|
|
96
|
+
const inputAst = parseJsx(`import { MenuPopover } from "@kaizen/components/next"`)
|
|
97
|
+
const expectedAst = parseJsx(`import { MenuPopover } from "@kaizen/components"`)
|
|
98
|
+
|
|
99
|
+
const result = transformComponents(inputAst)
|
|
100
|
+
expect(result).toBe(printAst(expectedAst))
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('should update MenuPopover v3/actions import', () => {
|
|
104
|
+
const inputAst = parseJsx(`import { MenuPopover } from "@kaizen/components/v3/actions"`)
|
|
105
|
+
const expectedAst = parseJsx(`import { MenuPopover } from "@kaizen/components"`)
|
|
106
|
+
|
|
107
|
+
const result = transformComponents(inputAst)
|
|
108
|
+
expect(result).toBe(printAst(expectedAst))
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
describe('MenuSection import statements', () => {
|
|
113
|
+
it('should update MenuSection next import', () => {
|
|
114
|
+
const inputAst = parseJsx(`import { MenuSection } from "@kaizen/components/next"`)
|
|
115
|
+
const expectedAst = parseJsx(`import { MenuSection } from "@kaizen/components"`)
|
|
116
|
+
|
|
117
|
+
const result = transformComponents(inputAst)
|
|
118
|
+
expect(result).toBe(printAst(expectedAst))
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should update MenuSection v3/actions import', () => {
|
|
122
|
+
const inputAst = parseJsx(`import { MenuSection } from "@kaizen/components/v3/actions"`)
|
|
123
|
+
const expectedAst = parseJsx(`import { MenuSection } from "@kaizen/components"`)
|
|
124
|
+
|
|
125
|
+
const result = transformComponents(inputAst)
|
|
126
|
+
expect(result).toBe(printAst(expectedAst))
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
describe('MenuTrigger import statements', () => {
|
|
131
|
+
it('should update MenuTrigger next import', () => {
|
|
132
|
+
const inputAst = parseJsx(`import { MenuTrigger } from "@kaizen/components/next"`)
|
|
133
|
+
const expectedAst = parseJsx(`import { MenuTrigger } from "@kaizen/components"`)
|
|
134
|
+
|
|
135
|
+
const result = transformComponents(inputAst)
|
|
136
|
+
expect(result).toBe(printAst(expectedAst))
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('should update MenuTrigger v3/actions import', () => {
|
|
140
|
+
const inputAst = parseJsx(`import { MenuTrigger } from "@kaizen/components/v3/actions"`)
|
|
141
|
+
const expectedAst = parseJsx(`import { MenuTrigger } from "@kaizen/components"`)
|
|
142
|
+
|
|
143
|
+
const result = transformComponents(inputAst)
|
|
144
|
+
expect(result).toBe(printAst(expectedAst))
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
describe('Tabs import statements', () => {
|
|
149
|
+
it('should update Tabs next import', () => {
|
|
150
|
+
const inputAst = parseJsx(`import { Tabs } from "@kaizen/components/next"`)
|
|
151
|
+
const expectedAst = parseJsx(`import { Tabs } from "@kaizen/components"`)
|
|
152
|
+
|
|
153
|
+
const result = transformComponents(inputAst)
|
|
154
|
+
expect(result).toBe(printAst(expectedAst))
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('should update Tabs future import', () => {
|
|
158
|
+
const inputAst = parseJsx(`import { Tabs } from "@kaizen/components/future"`)
|
|
159
|
+
const expectedAst = parseJsx(`import { Tabs } from "@kaizen/components"`)
|
|
160
|
+
|
|
161
|
+
const result = transformComponents(inputAst)
|
|
162
|
+
expect(result).toBe(printAst(expectedAst))
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
describe('Tab import statements', () => {
|
|
167
|
+
it('should update Tab next import', () => {
|
|
168
|
+
const inputAst = parseJsx(`import { Tab } from "@kaizen/components/next"`)
|
|
169
|
+
const expectedAst = parseJsx(`import { Tab } from "@kaizen/components"`)
|
|
170
|
+
|
|
171
|
+
const result = transformComponents(inputAst)
|
|
172
|
+
expect(result).toBe(printAst(expectedAst))
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('should update Tab future import', () => {
|
|
176
|
+
const inputAst = parseJsx(`import { Tab } from "@kaizen/components/future"`)
|
|
177
|
+
const expectedAst = parseJsx(`import { Tab } from "@kaizen/components"`)
|
|
178
|
+
|
|
179
|
+
const result = transformComponents(inputAst)
|
|
180
|
+
expect(result).toBe(printAst(expectedAst))
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
describe('TabList import statements', () => {
|
|
185
|
+
it('should update TabList next import', () => {
|
|
186
|
+
const inputAst = parseJsx(`import { TabList } from "@kaizen/components/next"`)
|
|
187
|
+
const expectedAst = parseJsx(`import { TabList } from "@kaizen/components"`)
|
|
188
|
+
|
|
189
|
+
const result = transformComponents(inputAst)
|
|
190
|
+
expect(result).toBe(printAst(expectedAst))
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('should update TabList future import', () => {
|
|
194
|
+
const inputAst = parseJsx(`import { TabList } from "@kaizen/components/future"`)
|
|
195
|
+
const expectedAst = parseJsx(`import { TabList } from "@kaizen/components"`)
|
|
196
|
+
|
|
197
|
+
const result = transformComponents(inputAst)
|
|
198
|
+
expect(result).toBe(printAst(expectedAst))
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
describe('TabPanel import statements', () => {
|
|
203
|
+
it('should update TabPanel next import', () => {
|
|
204
|
+
const inputAst = parseJsx(`import { TabPanel } from "@kaizen/components/next"`)
|
|
205
|
+
const expectedAst = parseJsx(`import { TabPanel } from "@kaizen/components"`)
|
|
206
|
+
|
|
207
|
+
const result = transformComponents(inputAst)
|
|
208
|
+
expect(result).toBe(printAst(expectedAst))
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it('should update TabPanel future import', () => {
|
|
212
|
+
const inputAst = parseJsx(`import { TabPanel } from "@kaizen/components/future"`)
|
|
213
|
+
const expectedAst = parseJsx(`import { TabPanel } from "@kaizen/components"`)
|
|
214
|
+
|
|
215
|
+
const result = transformComponents(inputAst)
|
|
216
|
+
expect(result).toBe(printAst(expectedAst))
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
describe('Tooltip import statements', () => {
|
|
221
|
+
it('should update Tooltip next import', () => {
|
|
222
|
+
const inputAst = parseJsx(`import { Tooltip } from "@kaizen/components/next"`)
|
|
223
|
+
const expectedAst = parseJsx(`import { Tooltip } from "@kaizen/components"`)
|
|
224
|
+
|
|
225
|
+
const result = transformComponents(inputAst)
|
|
226
|
+
expect(result).toBe(printAst(expectedAst))
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
it('should update Tooltip future import', () => {
|
|
230
|
+
const inputAst = parseJsx(`import { Tooltip } from "@kaizen/components/future"`)
|
|
231
|
+
const expectedAst = parseJsx(`import { Tooltip } from "@kaizen/components"`)
|
|
232
|
+
|
|
233
|
+
const result = transformComponents(inputAst)
|
|
234
|
+
expect(result).toBe(printAst(expectedAst))
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it('should update Tooltip v3/overlays import', () => {
|
|
238
|
+
const inputAst = parseJsx(`import { Tooltip } from "@kaizen/components/v3/overlays"`)
|
|
239
|
+
const expectedAst = parseJsx(`import { Tooltip } from "@kaizen/components"`)
|
|
240
|
+
|
|
241
|
+
const result = transformComponents(inputAst)
|
|
242
|
+
expect(result).toBe(printAst(expectedAst))
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
describe('TooltipTrigger import statements', () => {
|
|
247
|
+
it('should update TooltipTrigger next import', () => {
|
|
248
|
+
const inputAst = parseJsx(`import { TooltipTrigger } from "@kaizen/components/next"`)
|
|
249
|
+
const expectedAst = parseJsx(`import { TooltipTrigger } from "@kaizen/components"`)
|
|
250
|
+
|
|
251
|
+
const result = transformComponents(inputAst)
|
|
252
|
+
expect(result).toBe(printAst(expectedAst))
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
it('should update TooltipTrigger future import', () => {
|
|
256
|
+
const inputAst = parseJsx(`import { TooltipTrigger } from "@kaizen/components/future"`)
|
|
257
|
+
const expectedAst = parseJsx(`import { TooltipTrigger } from "@kaizen/components"`)
|
|
258
|
+
|
|
259
|
+
const result = transformComponents(inputAst)
|
|
260
|
+
expect(result).toBe(printAst(expectedAst))
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
it('should update TooltipTrigger v3/overlays import', () => {
|
|
264
|
+
const inputAst = parseJsx(`import { TooltipTrigger } from "@kaizen/components/v3/overlays"`)
|
|
265
|
+
const expectedAst = parseJsx(`import { TooltipTrigger } from "@kaizen/components"`)
|
|
266
|
+
|
|
267
|
+
const result = transformComponents(inputAst)
|
|
268
|
+
expect(result).toBe(printAst(expectedAst))
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
describe('ReversedColors import statements', () => {
|
|
273
|
+
it('should update ReversedColors v3/utilities import', () => {
|
|
274
|
+
const inputAst = parseJsx(`import { ReversedColors } from "@kaizen/components/v3/utilities"`)
|
|
275
|
+
const expectedAst = parseJsx(`import { ReversedColors } from "@kaizen/components"`)
|
|
276
|
+
|
|
277
|
+
const result = transformComponents(inputAst)
|
|
278
|
+
expect(result).toBe(printAst(expectedAst))
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
describe('Focusable import statements', () => {
|
|
283
|
+
it('should update Focusable next import', () => {
|
|
284
|
+
const inputAst = parseJsx(`import { Focusable } from "@kaizen/components/next"`)
|
|
285
|
+
const expectedAst = parseJsx(`import { Focusable } from "@kaizen/components"`)
|
|
286
|
+
|
|
287
|
+
const result = transformComponents(inputAst)
|
|
288
|
+
expect(result).toBe(printAst(expectedAst))
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('should update Focusable future import', () => {
|
|
292
|
+
const inputAst = parseJsx(`import { Focusable } from "@kaizen/components/future"`)
|
|
293
|
+
const expectedAst = parseJsx(`import { Focusable } from "@kaizen/components"`)
|
|
294
|
+
|
|
295
|
+
const result = transformComponents(inputAst)
|
|
296
|
+
expect(result).toBe(printAst(expectedAst))
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
describe('Key import statements', () => {
|
|
301
|
+
it('should update Key next import', () => {
|
|
302
|
+
const inputAst = parseJsx(`import { Key } from "@kaizen/components/next"`)
|
|
303
|
+
const expectedAst = parseJsx(`import { Key } from "@kaizen/components"`)
|
|
304
|
+
|
|
305
|
+
const result = transformComponents(inputAst)
|
|
306
|
+
expect(result).toBe(printAst(expectedAst))
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
it('should update Key future import', () => {
|
|
310
|
+
const inputAst = parseJsx(`import { Key } from "@kaizen/components/future"`)
|
|
311
|
+
const expectedAst = parseJsx(`import { Key } from "@kaizen/components"`)
|
|
312
|
+
|
|
313
|
+
const result = transformComponents(inputAst)
|
|
314
|
+
expect(result).toBe(printAst(expectedAst))
|
|
315
|
+
})
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
describe('Icon import statements', () => {
|
|
319
|
+
it('should update Icon next import', () => {
|
|
320
|
+
const inputAst = parseJsx(`import { Icon } from "@kaizen/components/next"`)
|
|
321
|
+
const expectedAst = parseJsx(`import { Icon } from "@kaizen/components"`)
|
|
322
|
+
|
|
323
|
+
const result = transformComponents(inputAst)
|
|
324
|
+
expect(result).toBe(printAst(expectedAst))
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
it('should update Icon future import', () => {
|
|
328
|
+
const inputAst = parseJsx(`import { Icon } from "@kaizen/components/future"`)
|
|
329
|
+
const expectedAst = parseJsx(`import { Icon } from "@kaizen/components"`)
|
|
330
|
+
|
|
331
|
+
const result = transformComponents(inputAst)
|
|
332
|
+
expect(result).toBe(printAst(expectedAst))
|
|
333
|
+
})
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
describe('Button import statements', () => {
|
|
337
|
+
it('should update Button next import', () => {
|
|
338
|
+
const inputAst = parseJsx(`import { Button } from "@kaizen/components/next"`)
|
|
339
|
+
const expectedAst = parseJsx(`import { Button } from "@kaizen/components"`)
|
|
340
|
+
|
|
341
|
+
const result = transformComponents(inputAst)
|
|
342
|
+
expect(result).toBe(printAst(expectedAst))
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
it('should update Button future import', () => {
|
|
346
|
+
const inputAst = parseJsx(`import { Button } from "@kaizen/components/future"`)
|
|
347
|
+
const expectedAst = parseJsx(`import { Button } from "@kaizen/components"`)
|
|
348
|
+
|
|
349
|
+
const result = transformComponents(inputAst)
|
|
350
|
+
expect(result).toBe(printAst(expectedAst))
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
it('should update Button v3/actions import', () => {
|
|
354
|
+
const inputAst = parseJsx(`import { Button } from "@kaizen/components/v3/actions"`)
|
|
355
|
+
const expectedAst = parseJsx(`import { Button } from "@kaizen/components"`)
|
|
356
|
+
|
|
357
|
+
const result = transformComponents(inputAst)
|
|
358
|
+
expect(result).toBe(printAst(expectedAst))
|
|
359
|
+
})
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
describe('ButtonProps import statements', () => {
|
|
363
|
+
it('should update ButtonProps next import', () => {
|
|
364
|
+
const inputAst = parseJsx(`import { ButtonProps } from "@kaizen/components/next"`)
|
|
365
|
+
const expectedAst = parseJsx(`import { ButtonProps } from "@kaizen/components"`)
|
|
366
|
+
|
|
367
|
+
const result = transformComponents(inputAst)
|
|
368
|
+
expect(result).toBe(printAst(expectedAst))
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
it('should update ButtonProps future import', () => {
|
|
372
|
+
const inputAst = parseJsx(`import { ButtonProps } from "@kaizen/components/future"`)
|
|
373
|
+
const expectedAst = parseJsx(`import { ButtonProps } from "@kaizen/components"`)
|
|
374
|
+
|
|
375
|
+
const result = transformComponents(inputAst)
|
|
376
|
+
expect(result).toBe(printAst(expectedAst))
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
it('should update ButtonProps v3/actions import', () => {
|
|
380
|
+
const inputAst = parseJsx(`import { ButtonProps } from "@kaizen/components/v3/actions"`)
|
|
381
|
+
const expectedAst = parseJsx(`import { ButtonProps } from "@kaizen/components"`)
|
|
382
|
+
|
|
383
|
+
const result = transformComponents(inputAst)
|
|
384
|
+
expect(result).toBe(printAst(expectedAst))
|
|
385
|
+
})
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
describe('ButtonsSizes import statements', () => {
|
|
389
|
+
it('should update ButtonsSizes next import', () => {
|
|
390
|
+
const inputAst = parseJsx(`import { ButtonsSizes } from "@kaizen/components/next"`)
|
|
391
|
+
const expectedAst = parseJsx(`import { ButtonsSizes } from "@kaizen/components"`)
|
|
392
|
+
|
|
393
|
+
const result = transformComponents(inputAst)
|
|
394
|
+
expect(result).toBe(printAst(expectedAst))
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
it('should update ButtonsSizes future import', () => {
|
|
398
|
+
const inputAst = parseJsx(`import { ButtonsSizes } from "@kaizen/components/future"`)
|
|
399
|
+
const expectedAst = parseJsx(`import { ButtonsSizes } from "@kaizen/components"`)
|
|
400
|
+
|
|
401
|
+
const result = transformComponents(inputAst)
|
|
402
|
+
expect(result).toBe(printAst(expectedAst))
|
|
403
|
+
})
|
|
404
|
+
|
|
405
|
+
it('should update ButtonsSizes v3/actions import', () => {
|
|
406
|
+
const inputAst = parseJsx(`import { ButtonsSizes } from "@kaizen/components/v3/actions"`)
|
|
407
|
+
const expectedAst = parseJsx(`import { ButtonsSizes } from "@kaizen/components"`)
|
|
408
|
+
|
|
409
|
+
const result = transformComponents(inputAst)
|
|
410
|
+
expect(result).toBe(printAst(expectedAst))
|
|
411
|
+
})
|
|
412
|
+
})
|
|
413
|
+
|
|
414
|
+
describe('ButtonVariants import statements', () => {
|
|
415
|
+
it('should update ButtonVariants next import', () => {
|
|
416
|
+
const inputAst = parseJsx(`import { ButtonVariants } from "@kaizen/components/next"`)
|
|
417
|
+
const expectedAst = parseJsx(`import { ButtonVariants } from "@kaizen/components"`)
|
|
418
|
+
|
|
419
|
+
const result = transformComponents(inputAst)
|
|
420
|
+
expect(result).toBe(printAst(expectedAst))
|
|
421
|
+
})
|
|
422
|
+
|
|
423
|
+
it('should update ButtonVariants future import', () => {
|
|
424
|
+
const inputAst = parseJsx(`import { ButtonVariants } from "@kaizen/components/future"`)
|
|
425
|
+
const expectedAst = parseJsx(`import { ButtonVariants } from "@kaizen/components"`)
|
|
426
|
+
|
|
427
|
+
const result = transformComponents(inputAst)
|
|
428
|
+
expect(result).toBe(printAst(expectedAst))
|
|
429
|
+
})
|
|
430
|
+
|
|
431
|
+
it('should update ButtonVariants v3/actions import', () => {
|
|
432
|
+
const inputAst = parseJsx(`import { ButtonVariants } from "@kaizen/components/v3/actions"`)
|
|
433
|
+
const expectedAst = parseJsx(`import { ButtonVariants } from "@kaizen/components"`)
|
|
434
|
+
|
|
435
|
+
const result = transformComponents(inputAst)
|
|
436
|
+
expect(result).toBe(printAst(expectedAst))
|
|
437
|
+
})
|
|
438
|
+
})
|
|
439
|
+
|
|
440
|
+
describe('Mixed scenarios', () => {
|
|
441
|
+
it('should merge imports', () => {
|
|
442
|
+
const inputAst = parseJsx(
|
|
443
|
+
`
|
|
444
|
+
import { Foobar, Menu, MenuItem, MenuPopover, MenuSection, MenuTrigger, } from "@kaizen/components/v3/actions"
|
|
445
|
+
import { Card } from "@kaizen/components"
|
|
446
|
+
`,
|
|
447
|
+
)
|
|
448
|
+
const expectedAst = parseJsx(`
|
|
449
|
+
import { Foobar } from "@kaizen/components/v3/actions"
|
|
450
|
+
import { Card, Menu, MenuItem, MenuPopover, MenuSection, MenuTrigger } from "@kaizen/components"
|
|
451
|
+
`)
|
|
452
|
+
const result = transformComponents(inputAst)
|
|
453
|
+
expect(result).toBe(printAst(expectedAst))
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
it('should handle handle merging type imports', () => {
|
|
457
|
+
const inputAst = parseJsx(
|
|
458
|
+
`
|
|
459
|
+
import { Foobar, Menu, MenuItem, MenuPopover, MenuSection, MenuTrigger, } from "@kaizen/components/next"
|
|
460
|
+
import { type CardProps, FooBar } from "@kaizen/components"
|
|
461
|
+
`,
|
|
462
|
+
)
|
|
463
|
+
const expectedAst = parseJsx(`
|
|
464
|
+
import { Foobar } from "@kaizen/components/next"
|
|
465
|
+
import { type CardProps, FooBar, Menu, MenuItem, MenuPopover, MenuSection, MenuTrigger } from "@kaizen/components"
|
|
466
|
+
`)
|
|
467
|
+
const result = transformComponents(inputAst)
|
|
468
|
+
expect(result).toBe(printAst(expectedAst))
|
|
469
|
+
})
|
|
470
|
+
|
|
471
|
+
it('should preserve alaised imports', () => {
|
|
472
|
+
const inputAst = parseJsx(
|
|
473
|
+
`
|
|
474
|
+
import { Foobar, Menu as KZMenu, MenuItem, MenuPopover, MenuSection, MenuTrigger, } from "@kaizen/components/next"
|
|
475
|
+
`,
|
|
476
|
+
)
|
|
477
|
+
const expectedAst = parseJsx(`
|
|
478
|
+
import { Foobar } from "@kaizen/components/next"
|
|
479
|
+
import { Menu as KZMenu, MenuItem, MenuPopover, MenuSection, MenuTrigger } from "@kaizen/components"
|
|
480
|
+
`)
|
|
481
|
+
const result = transformComponents(inputAst)
|
|
482
|
+
expect(result).toBe(printAst(expectedAst))
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
it('should preserve aliased type imports', () => {
|
|
486
|
+
const inputAst = parseJsx(
|
|
487
|
+
`
|
|
488
|
+
import { Foobar, type Menu as KZMenu, type MenuItem as KZMenuItem } from "@kaizen/components/next"
|
|
489
|
+
`,
|
|
490
|
+
)
|
|
491
|
+
const expectedAst = parseJsx(`
|
|
492
|
+
import { Foobar } from "@kaizen/components/next"
|
|
493
|
+
import type { Menu as KZMenu, MenuItem as KZMenuItem } from "@kaizen/components"
|
|
494
|
+
`)
|
|
495
|
+
const result = transformComponents(inputAst)
|
|
496
|
+
expect(result).toBe(printAst(expectedAst))
|
|
497
|
+
})
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
describe('Module path transformations', () => {
|
|
501
|
+
it('should transform react-aria module path', () => {
|
|
502
|
+
const inputAst = parseJsx(`import { Button } from "@kaizen/components/v3/react-aria"`)
|
|
503
|
+
const expectedAst = parseJsx(`import { Button } from "@kaizen/components/react-aria"`)
|
|
504
|
+
|
|
505
|
+
const result = transformComponents(inputAst)
|
|
506
|
+
expect(result).toBe(printAst(expectedAst))
|
|
507
|
+
})
|
|
508
|
+
|
|
509
|
+
it('should transform react-aria-components module path', () => {
|
|
510
|
+
const inputAst = parseJsx(
|
|
511
|
+
`import { TextField } from "@kaizen/components/v3/react-aria-components"`,
|
|
512
|
+
)
|
|
513
|
+
const expectedAst = parseJsx(
|
|
514
|
+
`import { TextField } from "@kaizen/components/react-aria-components"`,
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
const result = transformComponents(inputAst)
|
|
518
|
+
expect(result).toBe(printAst(expectedAst))
|
|
519
|
+
})
|
|
520
|
+
|
|
521
|
+
it('should handle multiple imports from react-aria modules', () => {
|
|
522
|
+
const inputAst = parseJsx(`import { Button, Link } from "@kaizen/components/v3/react-aria"`)
|
|
523
|
+
const expectedAst = parseJsx(`import { Button, Link } from "@kaizen/components/react-aria"`)
|
|
524
|
+
|
|
525
|
+
const result = transformComponents(inputAst)
|
|
526
|
+
expect(result).toBe(printAst(expectedAst))
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
it('should handle aliased imports from react-aria modules', () => {
|
|
530
|
+
const inputAst = parseJsx(
|
|
531
|
+
`import { Button as AriaButton } from "@kaizen/components/v3/react-aria"`,
|
|
532
|
+
)
|
|
533
|
+
const expectedAst = parseJsx(
|
|
534
|
+
`import { Button as AriaButton } from "@kaizen/components/react-aria"`,
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
const result = transformComponents(inputAst)
|
|
538
|
+
expect(result).toBe(printAst(expectedAst))
|
|
539
|
+
})
|
|
540
|
+
|
|
541
|
+
it('should not interfere with regular component renaming', () => {
|
|
542
|
+
const inputAst = parseJsx(`
|
|
543
|
+
import { Menu } from "@kaizen/components/next"
|
|
544
|
+
import { Button } from "@kaizen/components/v3/react-aria"
|
|
545
|
+
`)
|
|
546
|
+
const expectedAst = parseJsx(`
|
|
547
|
+
import { Menu } from "@kaizen/components"
|
|
548
|
+
import { Button } from "@kaizen/components/react-aria"
|
|
549
|
+
`)
|
|
550
|
+
|
|
551
|
+
const result = transformComponents(inputAst)
|
|
552
|
+
expect(result).toBe(printAst(expectedAst))
|
|
553
|
+
})
|
|
554
|
+
})
|
|
555
|
+
})
|