@planningcenter/tapestry-migration-cli 2.7.1-qa-513.0 → 2.7.1-qa-522.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.
Files changed (28) hide show
  1. package/dist/tapestry-react-shim.cjs +1 -1
  2. package/package.json +3 -2
  3. package/src/components/button/transforms/themeVariantToKind.test.ts +1 -1
  4. package/src/components/checkbox/index.ts +2 -0
  5. package/src/components/checkbox/transforms/auditSpreadProps.test.ts +356 -0
  6. package/src/components/checkbox/transforms/auditSpreadProps.ts +10 -0
  7. package/src/components/checkbox/transforms/sizeMapping.test.ts +88 -9
  8. package/src/components/checkbox/transforms/sizeMapping.ts +6 -3
  9. package/src/components/checkbox/transforms/unsupportedProps.ts +6 -11
  10. package/src/components/radio/index.ts +38 -0
  11. package/src/components/radio/transforms/auditSpreadProps.test.ts +356 -0
  12. package/src/components/radio/transforms/auditSpreadProps.ts +10 -0
  13. package/src/components/radio/transforms/convertStyleProps.test.ts +161 -0
  14. package/src/components/radio/transforms/convertStyleProps.ts +10 -0
  15. package/src/components/radio/transforms/moveRadioImport.test.ts +152 -0
  16. package/src/components/radio/transforms/moveRadioImport.ts +13 -0
  17. package/src/components/radio/transforms/setDefaultSize.test.ts +287 -0
  18. package/src/components/radio/transforms/setDefaultSize.ts +28 -0
  19. package/src/components/radio/transforms/sizeMapping.test.ts +201 -0
  20. package/src/components/radio/transforms/sizeMapping.ts +49 -0
  21. package/src/components/radio/transforms/unsupportedProps.test.ts +241 -0
  22. package/src/components/radio/transforms/unsupportedProps.ts +35 -0
  23. package/src/components/shared/actions/getAttributeValue.test.ts +18 -0
  24. package/src/components/shared/actions/getAttributeValue.ts +18 -5
  25. package/src/components/shared/helpers/unsupportedPropsHelpers.ts +24 -9
  26. package/src/components/shared/transformFactories/commentOnSpreadPropsFactory.test.ts +84 -0
  27. package/src/components/shared/transformFactories/commentOnSpreadPropsFactory.ts +26 -0
  28. package/src/reportGenerator.ts +2 -0
@@ -2925,8 +2925,8 @@ const tokens = {
2925
2925
  "--t-fill-color-control-neutral-off": "hsl(0, 0%, 58%)",
2926
2926
  "--t-fill-color-control-neutral-on": "hsl(0, 0%, 24%)",
2927
2927
  "--t-fill-color-control": "hsl(204, 100%, 40%)",
2928
- "--t-fill-color-control-secondary": "hsl(97, 57%, 40%)",
2929
2928
  "--t-fill-color-control-error": "hsl(8, 60%, 47%)",
2929
+ "--t-fill-color-control-secondary": "hsl(97, 57%, 40%)",
2930
2930
  "--t-fill-color-control-disabled": "hsl(0, 0%, 81%)",
2931
2931
  "--t-fill-color-status-neutral": "hsl(0, 0%, 42%)",
2932
2932
  "--t-fill-color-status-neutral-ghost": "hsl(0, 0%, 93%)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/tapestry-migration-cli",
3
- "version": "2.7.1-qa-513.0",
3
+ "version": "2.7.1-qa-522.0",
4
4
  "description": "CLI tool for Tapestry migrations",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,6 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@emotion/react": "^11.14.0",
35
+ "@planningcenter/tapestry": "^2.7.1-qa-522.0",
35
36
  "@planningcenter/tapestry-react": "^4.11.5",
36
37
  "@types/jscodeshift": "^17.3.0",
37
38
  "@types/node": "^20.0.0",
@@ -51,5 +52,5 @@
51
52
  "publishConfig": {
52
53
  "access": "public"
53
54
  },
54
- "gitHead": "99523ff01a0b24f7ecaf6a22b9da40e2594880ef"
55
+ "gitHead": "98685175a4b14601fd9a6c0b5974a9a91161fe2c"
55
56
  }
@@ -253,7 +253,7 @@ describe("themeVariantToKind", () => {
253
253
  expect(result).toContain(
254
254
  "TODO: tapestry-migration (theme/variant): cannot be converted"
255
255
  )
256
- expect(result).toContain('{"primary"}')
256
+ expect(result).toContain('theme="primary"')
257
257
  })
258
258
  })
259
259
 
@@ -1,5 +1,6 @@
1
1
  import { Transform } from "jscodeshift"
2
2
 
3
+ import auditSpreadProps from "./transforms/auditSpreadProps"
3
4
  import childrenToLabel from "./transforms/childrenToLabel"
4
5
  import convertStyleProps from "./transforms/convertStyleProps"
5
6
  import innerRefToRef from "./transforms/innerRefToRef"
@@ -12,6 +13,7 @@ const transform: Transform = (fileInfo, api, options) => {
12
13
  let hasAnyChanges = false
13
14
 
14
15
  const transforms = [
16
+ auditSpreadProps,
15
17
  childrenToLabel,
16
18
  sizeMapping,
17
19
  innerRefToRef,
@@ -0,0 +1,356 @@
1
+ import jscodeshift from "jscodeshift"
2
+ import { describe, expect, it } from "vitest"
3
+
4
+ import transform from "./auditSpreadProps"
5
+
6
+ const j = jscodeshift.withParser("tsx")
7
+
8
+ const AUDIT_COMMENT =
9
+ "TODO: tapestry-migration (spreadAttribute): Spread props can contain unsupported props, please explore usages and migrate as needed."
10
+
11
+ function applyTransform(source: string) {
12
+ const fileInfo = { path: "test.tsx", source }
13
+ return transform(
14
+ fileInfo,
15
+ { j, jscodeshift: j, report: () => {}, stats: () => {} },
16
+ {}
17
+ ) as string | null
18
+ }
19
+
20
+ describe("auditSpreadProps transform", () => {
21
+ describe("basic transformations", () => {
22
+ it("should add comment to Checkbox with single spread prop", () => {
23
+ const input = `
24
+ import { Checkbox } from "@planningcenter/tapestry-react"
25
+
26
+ export default function Test() {
27
+ const props = { onChange: handleChange }
28
+ return <Checkbox {...props} label="Save" name="choice" />
29
+ }
30
+ `.trim()
31
+
32
+ const result = applyTransform(input)
33
+ expect(result).toContain(AUDIT_COMMENT)
34
+ expect(result).toContain("{...props}")
35
+ })
36
+
37
+ it("should add comment to Checkbox with multiple spread props", () => {
38
+ const input = `
39
+ import { Checkbox } from "@planningcenter/tapestry-react"
40
+
41
+ export default function Test() {
42
+ const baseProps = { onChange: handleChange }
43
+ const styleProps = { className: "checkbox" }
44
+ return <Checkbox {...baseProps} {...styleProps} label="Save" name="choice" />
45
+ }
46
+ `.trim()
47
+
48
+ const result = applyTransform(input)
49
+ expect(result).toContain(AUDIT_COMMENT)
50
+ expect(result).toContain("{...baseProps}")
51
+ expect(result).toContain("{...styleProps}")
52
+ })
53
+
54
+ it("should handle Checkbox with spread props and regular attributes", () => {
55
+ const input = `
56
+ import { Checkbox } from "@planningcenter/tapestry-react"
57
+
58
+ export default function Test() {
59
+ const props = { onChange: handleChange }
60
+ return <Checkbox label="Save" name="choice" {...props} disabled />
61
+ }
62
+ `.trim()
63
+
64
+ const result = applyTransform(input)
65
+ expect(result).toContain(AUDIT_COMMENT)
66
+ expect(result).toContain('label="Save"')
67
+ expect(result).toContain('name="choice"')
68
+ expect(result).toContain("{...props}")
69
+ expect(result).toContain("disabled")
70
+ })
71
+
72
+ it("should handle multiple Checkbox components with spread props", () => {
73
+ const input = `
74
+ import { Checkbox } from "@planningcenter/tapestry-react"
75
+
76
+ export default function Test() {
77
+ const props1 = { onChange: handleChange1 }
78
+ const props2 = { onChange: handleChange2 }
79
+ return (
80
+ <div>
81
+ <Checkbox {...props1} label="Save" name="choice" />
82
+ <Checkbox {...props2} label="Cancel" name="choice" />
83
+ </div>
84
+ )
85
+ }
86
+ `.trim()
87
+
88
+ const result = applyTransform(input)
89
+ expect(result).toContain(AUDIT_COMMENT)
90
+ expect(result).toContain("{...props1}")
91
+ expect(result).toContain("{...props2}")
92
+ })
93
+ })
94
+
95
+ describe("edge cases", () => {
96
+ it("should not transform Checkbox without spread props", () => {
97
+ const input = `
98
+ import { Checkbox } from "@planningcenter/tapestry-react"
99
+
100
+ export default function Test() {
101
+ return <Checkbox onChange={handleChange} label="Save" name="choice" />
102
+ }
103
+ `.trim()
104
+
105
+ const result = applyTransform(input)
106
+ expect(result).toBe(null)
107
+ })
108
+
109
+ it("should not transform if Checkbox is not imported from @planningcenter/tapestry-react", () => {
110
+ const input = `
111
+ import { Checkbox } from "other-library"
112
+
113
+ export default function Test() {
114
+ const props = { onChange: handleChange }
115
+ return <Checkbox {...props} label="Save" name="choice" />
116
+ }
117
+ `.trim()
118
+
119
+ const result = applyTransform(input)
120
+ expect(result).toBe(null)
121
+ })
122
+
123
+ it("should handle Checkbox with alias import", () => {
124
+ const input = `
125
+ import { Checkbox as TapestryCheckbox } from "@planningcenter/tapestry-react"
126
+
127
+ export default function Test() {
128
+ const props = { onChange: handleChange }
129
+ return <TapestryCheckbox {...props} label="Save" name="choice" />
130
+ }
131
+ `.trim()
132
+
133
+ const result = applyTransform(input)
134
+ expect(result).toContain(AUDIT_COMMENT)
135
+ expect(result).toContain("{...props}")
136
+ })
137
+
138
+ it("should handle mixed Checkbox components (with and without spread props)", () => {
139
+ const input = `
140
+ import { Checkbox } from "@planningcenter/tapestry-react"
141
+
142
+ export default function Test() {
143
+ const props = { onChange: handleSave }
144
+ return (
145
+ <div>
146
+ <Checkbox {...props} label="Save" name="choice" />
147
+ <Checkbox label="Cancel" name="choice" />
148
+ <Checkbox onChange={handleDelete} label="Delete" name="choice" />
149
+ </div>
150
+ )
151
+ }
152
+ `.trim()
153
+
154
+ const result = applyTransform(input)
155
+ expect(result).toContain(AUDIT_COMMENT)
156
+ expect(result).toContain("{...props}")
157
+ expect(result).toContain('<Checkbox label="Cancel" name="choice" />')
158
+ expect(result).toContain("onChange={handleDelete}")
159
+ })
160
+ })
161
+
162
+ describe("complex spread prop scenarios", () => {
163
+ it("should handle Checkbox with complex spread expression", () => {
164
+ const input = `
165
+ import { Checkbox } from "@planningcenter/tapestry-react"
166
+
167
+ export default function Test() {
168
+ const baseProps = { className: "checkbox" }
169
+ const additionalProps = isDisabled ? { disabled: true } : {}
170
+ return <Checkbox {...baseProps} {...additionalProps} label="Save" name="choice" />
171
+ }
172
+ `.trim()
173
+
174
+ const result = applyTransform(input)
175
+ expect(result).toContain(AUDIT_COMMENT)
176
+ expect(result).toContain("{...baseProps}")
177
+ expect(result).toContain("{...additionalProps}")
178
+ })
179
+
180
+ it("should handle Checkbox with spread props in different positions", () => {
181
+ const input = `
182
+ import { Checkbox } from "@planningcenter/tapestry-react"
183
+
184
+ export default function Test() {
185
+ const props = { className: "checkbox" }
186
+ return (
187
+ <Checkbox
188
+ label="Save"
189
+ name="choice"
190
+ {...props}
191
+ disabled={false}
192
+ onChange={handleSave}
193
+ />
194
+ )
195
+ }
196
+ `.trim()
197
+
198
+ const result = applyTransform(input)
199
+ expect(result).toContain(AUDIT_COMMENT)
200
+ expect(result).toContain('label="Save"')
201
+ expect(result).toContain('name="choice"')
202
+ expect(result).toContain("{...props}")
203
+ expect(result).toContain("disabled={false}")
204
+ expect(result).toContain("onChange={handleSave}")
205
+ })
206
+
207
+ it("should handle spread props with object expressions", () => {
208
+ const input = `
209
+ import { Checkbox } from "@planningcenter/tapestry-react"
210
+
211
+ export default function Test() {
212
+ return <Checkbox {...{ onChange: handleChange, className: "checkbox" }} label="Save" name="choice" />
213
+ }
214
+ `.trim()
215
+
216
+ const result = applyTransform(input)
217
+ expect(result).toContain(AUDIT_COMMENT)
218
+ expect(result).toContain(
219
+ '{...{ onChange: handleChange, className: "checkbox" }}'
220
+ )
221
+ })
222
+
223
+ it("should handle spread props with function calls", () => {
224
+ const input = `
225
+ import { Checkbox } from "@planningcenter/tapestry-react"
226
+
227
+ export default function Test() {
228
+ return <Checkbox {...getCheckboxProps()} {...getStyleProps()} label="Save" name="choice" />
229
+ }
230
+ `.trim()
231
+
232
+ const result = applyTransform(input)
233
+ expect(result).toContain(AUDIT_COMMENT)
234
+ expect(result).toContain("{...getCheckboxProps()}")
235
+ expect(result).toContain("{...getStyleProps()}")
236
+ })
237
+ })
238
+
239
+ describe("self-closing Checkbox components", () => {
240
+ it("should handle self-closing Checkbox with spread props", () => {
241
+ const input = `
242
+ import { Checkbox } from "@planningcenter/tapestry-react"
243
+
244
+ export default function Test() {
245
+ const props = { label: "Close", name: "choice", onChange: handleClose }
246
+ return <Checkbox {...props} />
247
+ }
248
+ `.trim()
249
+
250
+ const result = applyTransform(input)
251
+ expect(result).toContain(AUDIT_COMMENT)
252
+ expect(result).toContain("{...props}")
253
+ })
254
+
255
+ it("should handle self-closing Checkbox with multiple spread props and attributes", () => {
256
+ const input = `
257
+ import { Checkbox } from "@planningcenter/tapestry-react"
258
+
259
+ export default function Test() {
260
+ const baseProps = { onChange: handleChange }
261
+ const styleProps = { className: "checkbox" }
262
+ return <Checkbox label="Action" name="choice" {...baseProps} {...styleProps} disabled />
263
+ }
264
+ `.trim()
265
+
266
+ const result = applyTransform(input)
267
+ expect(result).toContain(AUDIT_COMMENT)
268
+ expect(result).toContain('label="Action"')
269
+ expect(result).toContain('name="choice"')
270
+ expect(result).toContain("{...baseProps}")
271
+ expect(result).toContain("{...styleProps}")
272
+ expect(result).toContain("disabled")
273
+ })
274
+ })
275
+
276
+ describe("no changes scenarios", () => {
277
+ it("should return null when no Checkbox components have spread props", () => {
278
+ const input = `
279
+ import { Checkbox } from "@planningcenter/tapestry-react"
280
+
281
+ export default function Test() {
282
+ return (
283
+ <div>
284
+ <Checkbox label="Save" name="choice" />
285
+ <Checkbox label="Delete" name="choice" />
286
+ <Checkbox onChange={handleChange} label="Cancel" name="choice" />
287
+ </div>
288
+ )
289
+ }
290
+ `.trim()
291
+
292
+ const result = applyTransform(input)
293
+ expect(result).toBe(null)
294
+ })
295
+
296
+ it("should return null when no Checkbox imports exist", () => {
297
+ const input = `
298
+ import { Button } from "@planningcenter/tapestry-react"
299
+
300
+ export default function Test() {
301
+ const props = { onClick: handleClick }
302
+ return <Button {...props}>Save</Button>
303
+ }
304
+ `.trim()
305
+
306
+ const result = applyTransform(input)
307
+ expect(result).toBe(null)
308
+ })
309
+
310
+ it("should return null for empty file", () => {
311
+ const result = applyTransform("")
312
+ expect(result).toBe(null)
313
+ })
314
+
315
+ it("should return null when file has no JSX", () => {
316
+ const input = `
317
+ export function handleChange() {
318
+ console.log("changed")
319
+ }
320
+ `.trim()
321
+
322
+ const result = applyTransform(input)
323
+ expect(result).toBe(null)
324
+ })
325
+ })
326
+
327
+ describe("different import scenarios", () => {
328
+ it("should handle default import with spread props", () => {
329
+ const input = `
330
+ import Checkbox from "@planningcenter/tapestry-react"
331
+
332
+ export default function Test() {
333
+ const props = { onChange: handleChange }
334
+ return <Checkbox {...props} label="Save" name="choice" />
335
+ }
336
+ `.trim()
337
+
338
+ const result = applyTransform(input)
339
+ expect(result).toBe(null)
340
+ })
341
+
342
+ it("should handle namespace import", () => {
343
+ const input = `
344
+ import * as Tapestry from "@planningcenter/tapestry-react"
345
+
346
+ export default function Test() {
347
+ const props = { onChange: handleChange }
348
+ return <Tapestry.Checkbox {...props} label="Save" name="choice" />
349
+ }
350
+ `.trim()
351
+
352
+ const result = applyTransform(input)
353
+ expect(result).toBe(null)
354
+ })
355
+ })
356
+ })
@@ -0,0 +1,10 @@
1
+ import { Transform } from "jscodeshift"
2
+
3
+ import { commentOnSpreadPropsFactory } from "../../shared/transformFactories/commentOnSpreadPropsFactory"
4
+
5
+ const transform: Transform = commentOnSpreadPropsFactory({
6
+ targetComponent: "Checkbox",
7
+ targetPackage: "@planningcenter/tapestry-react",
8
+ })
9
+
10
+ export default transform
@@ -34,6 +34,23 @@ function Test() {
34
34
  )
35
35
  })
36
36
 
37
+ it('should transform size={"lg"} to md', () => {
38
+ const input = `
39
+ import { Checkbox } from "@planningcenter/tapestry-react"
40
+
41
+ function Test() {
42
+ return <Checkbox size={"lg"} label="Large checkbox" />
43
+ }
44
+ `.trim()
45
+
46
+ const result = applyTransform(input)
47
+ expect(result).toContain('size="md"')
48
+ expect(result).not.toContain('size={"lg"}')
49
+ expect(result).toContain(
50
+ 'TODO: tapestry-migration (size): Size "lg" was mapped to "md"'
51
+ )
52
+ })
53
+
37
54
  it("should transform xl to md", () => {
38
55
  const input = `
39
56
  import { Checkbox } from "@planningcenter/tapestry-react"
@@ -51,7 +68,24 @@ function Test() {
51
68
  )
52
69
  })
53
70
 
54
- it("should not transform xs size", () => {
71
+ it('should transform size={"xl"} to md', () => {
72
+ const input = `
73
+ import { Checkbox } from "@planningcenter/tapestry-react"
74
+
75
+ function Test() {
76
+ return <Checkbox size={"xl"} label="Extra large checkbox" />
77
+ }
78
+ `.trim()
79
+
80
+ const result = applyTransform(input)
81
+ expect(result).toContain('size="md"')
82
+ expect(result).not.toContain('size={"xl"}')
83
+ expect(result).toContain(
84
+ 'TODO: tapestry-migration (size): Size "xl" was mapped to "md"'
85
+ )
86
+ })
87
+
88
+ it("should transform xs to sm", () => {
55
89
  const input = `
56
90
  import { Checkbox } from "@planningcenter/tapestry-react"
57
91
 
@@ -61,8 +95,28 @@ function Test() {
61
95
  `.trim()
62
96
 
63
97
  const result = applyTransform(input)
64
- expect(result).toContain('size="xs"')
65
- expect(result).not.toContain("TODO: tapestry-migration")
98
+ expect(result).toContain('size="sm"')
99
+ expect(result).not.toContain('size="xs"')
100
+ expect(result).toContain(
101
+ 'TODO: tapestry-migration (size): Size "xs" was mapped to "sm"'
102
+ )
103
+ })
104
+
105
+ it('should transform size={"xs"} to sm', () => {
106
+ const input = `
107
+ import { Checkbox } from "@planningcenter/tapestry-react"
108
+
109
+ function Test() {
110
+ return <Checkbox size={"xs"} label="Extra small checkbox" />
111
+ }
112
+ `.trim()
113
+
114
+ const result = applyTransform(input)
115
+ expect(result).toContain('size="sm"')
116
+ expect(result).not.toContain('size={"xs"}')
117
+ expect(result).toContain(
118
+ 'TODO: tapestry-migration (size): Size "xs" was mapped to "sm"'
119
+ )
66
120
  })
67
121
 
68
122
  it("should not transform supported sizes", () => {
@@ -74,7 +128,6 @@ function Test() {
74
128
  <div>
75
129
  <Checkbox size="md" label="Medium checkbox" />
76
130
  <Checkbox size="sm" label="Small checkbox" />
77
- <Checkbox size="xs" label="Extra small checkbox" />
78
131
  </div>
79
132
  )
80
133
  }
@@ -83,7 +136,6 @@ function Test() {
83
136
  const result = applyTransform(input)
84
137
  expect(result).toContain('size="md"')
85
138
  expect(result).toContain('size="sm"')
86
- expect(result).toContain('size="xs"')
87
139
  expect(result).not.toContain("TODO: tapestry-migration")
88
140
  })
89
141
  })
@@ -139,12 +191,13 @@ function Test() {
139
191
 
140
192
  const result = applyTransform(input)
141
193
  expect(result).toContain('size="md"')
142
- expect(result).toContain('size="xs"')
194
+ expect(result).toContain('size="sm"')
143
195
  expect(result).not.toContain('size="lg"')
144
196
  expect(result).not.toContain('size="xl"')
145
- // Should have 2 TODO comments (one for lg->md, one for xl->md)
197
+ expect(result).not.toContain('size="xs"')
198
+ // Should have 3 TODO comments (one for lg->md, one for xl->md, one for xs->sm)
146
199
  const todoMatches = result.match(/TODO: tapestry-migration \(size\)/g)
147
- expect(todoMatches).toHaveLength(2)
200
+ expect(todoMatches).toHaveLength(3)
148
201
  })
149
202
 
150
203
  it("should preserve other props", () => {
@@ -175,7 +228,33 @@ function Test() {
175
228
  )
176
229
  })
177
230
 
178
- it("should not transform expression values", () => {
231
+ it("should handle mixed string literals and JSXExpressionContainers", () => {
232
+ const input = `
233
+ import { Checkbox } from "@planningcenter/tapestry-react"
234
+
235
+ function Test() {
236
+ return (
237
+ <div>
238
+ <Checkbox size="lg" label="String literal" />
239
+ <Checkbox size={"xl"} label="JSXExpressionContainer" />
240
+ <Checkbox size="xs" label="Another string literal" />
241
+ </div>
242
+ )
243
+ }
244
+ `.trim()
245
+
246
+ const result = applyTransform(input)
247
+ expect(result).toContain('size="md"')
248
+ expect(result).toContain('size="sm"')
249
+ expect(result).not.toContain('size="lg"')
250
+ expect(result).not.toContain('size={"xl"}')
251
+ expect(result).not.toContain('size="xs"')
252
+ // Should have 3 TODO comments (one for lg->md, one for xl->md, one for xs->sm)
253
+ const todoMatches = result.match(/TODO: tapestry-migration \(size\)/g)
254
+ expect(todoMatches).toHaveLength(3)
255
+ })
256
+
257
+ it("should not transform variable expression values", () => {
179
258
  const input = `
180
259
  import { Checkbox } from "@planningcenter/tapestry-react"
181
260
 
@@ -1,12 +1,14 @@
1
1
  import { Transform } from "jscodeshift"
2
2
 
3
3
  import { addCommentToAttribute } from "../../shared/actions/addCommentToAttribute"
4
+ import { getAttributeValue } from "../../shared/actions/getAttributeValue"
4
5
  import { hasAttribute } from "../../shared/conditions/hasAttribute"
5
6
  import { attributeTransformFactory } from "../../shared/transformFactories/attributeTransformFactory"
6
7
 
7
8
  const SIZE_MAPPING = {
8
9
  lg: "md",
9
10
  xl: "md",
11
+ xs: "sm",
10
12
  }
11
13
 
12
14
  const transform: Transform = attributeTransformFactory({
@@ -21,12 +23,13 @@ const transform: Transform = attributeTransformFactory({
21
23
  )
22
24
 
23
25
  if (sizeAttr && sizeAttr.type === "JSXAttribute") {
24
- if (sizeAttr.value?.type === "StringLiteral") {
25
- const sizeValue = sizeAttr.value.value as string
26
+ const sizeValue = getAttributeValue({ attribute: sizeAttr, j })
27
+
28
+ if (sizeValue) {
26
29
  const mappedSize = SIZE_MAPPING[sizeValue as keyof typeof SIZE_MAPPING]
27
30
 
28
31
  if (mappedSize && mappedSize !== sizeValue) {
29
- sizeAttr.value.value = mappedSize
32
+ sizeAttr.value = j.stringLiteral(mappedSize)
30
33
  hasChanges = true
31
34
 
32
35
  addCommentToAttribute({
@@ -1,20 +1,15 @@
1
1
  import { JSXAttribute, Transform } from "jscodeshift"
2
2
 
3
3
  import { addCommentToUnsupportedProps } from "../../shared/actions/addCommentToUnsupportedProps"
4
- import { SUPPORTED_PROPS_BASE } from "../../shared/helpers/unsupportedPropsHelpers"
4
+ import { CHECKBOX_RADIO_SUPPORTED_PROPS } from "../../shared/helpers/unsupportedPropsHelpers"
5
5
  import { attributeTransformFactory } from "../../shared/transformFactories/attributeTransformFactory"
6
6
 
7
- const CHECKBOX_SPECIFIC_PROPS = [
8
- "checked",
9
- "disabled",
10
- "indeterminate",
11
- "label",
12
- "name",
13
- "onChange",
14
- "value",
15
- ]
7
+ const CHECKBOX_SPECIFIC_PROPS = ["indeterminate"]
16
8
 
17
- const SUPPORTED_PROPS = [...SUPPORTED_PROPS_BASE, ...CHECKBOX_SPECIFIC_PROPS]
9
+ const SUPPORTED_PROPS = [
10
+ ...CHECKBOX_RADIO_SUPPORTED_PROPS,
11
+ ...CHECKBOX_SPECIFIC_PROPS,
12
+ ]
18
13
 
19
14
  const transform: Transform = attributeTransformFactory({
20
15
  targetComponent: "Checkbox",
@@ -0,0 +1,38 @@
1
+ import { Transform } from "jscodeshift"
2
+
3
+ import auditSpreadProps from "./transforms/auditSpreadProps"
4
+ import convertStyleProps from "./transforms/convertStyleProps"
5
+ import moveRadioImport from "./transforms/moveRadioImport"
6
+ import setDefaultSize from "./transforms/setDefaultSize"
7
+ import sizeMapping from "./transforms/sizeMapping"
8
+ import unsupportedProps from "./transforms/unsupportedProps"
9
+
10
+ const transform: Transform = (fileInfo, api, options) => {
11
+ let currentSource = fileInfo.source
12
+ let hasAnyChanges = false
13
+
14
+ const transforms = [
15
+ auditSpreadProps,
16
+ setDefaultSize,
17
+ sizeMapping,
18
+ convertStyleProps,
19
+ unsupportedProps,
20
+ moveRadioImport,
21
+ ]
22
+
23
+ for (const individualTransform of transforms) {
24
+ const result = individualTransform(
25
+ { ...fileInfo, source: currentSource },
26
+ api,
27
+ options
28
+ )
29
+ if (result && result !== currentSource) {
30
+ currentSource = result as string
31
+ hasAnyChanges = true
32
+ }
33
+ }
34
+
35
+ return hasAnyChanges ? currentSource : null
36
+ }
37
+
38
+ export default transform