@planningcenter/tapestry-migration-cli 3.5.0 → 3.6.1-qa-1035.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.
- package/README.md +37 -0
- package/dist/tapestry-react-shim.cjs +195 -11
- package/package.json +3 -3
- package/src/availableComponents.ts +1 -0
- package/src/components/button/transforms/tooltipToWrapper.test.ts +50 -3
- package/src/components/button/transforms/tooltipToWrapper.ts +18 -0
- package/src/components/flex/index.test.ts +291 -0
- package/src/components/flex/index.ts +54 -0
- package/src/components/flex/transforms/alignmentToAlign.test.ts +185 -0
- package/src/components/flex/transforms/alignmentToAlign.ts +73 -0
- package/src/components/flex/transforms/auditSpreadProps.test.ts +93 -0
- package/src/components/flex/transforms/auditSpreadProps.ts +6 -0
- package/src/components/flex/transforms/axisToDirection.test.ts +155 -0
- package/src/components/flex/transforms/axisToDirection.ts +77 -0
- package/src/components/flex/transforms/convertStyleProps.test.ts +147 -0
- package/src/components/flex/transforms/convertStyleProps.ts +23 -0
- package/src/components/flex/transforms/cssFlexAliasesToProps.test.ts +202 -0
- package/src/components/flex/transforms/cssFlexAliasesToProps.ts +110 -0
- package/src/components/flex/transforms/distributionToJustify.test.ts +214 -0
- package/src/components/flex/transforms/distributionToJustify.ts +76 -0
- package/src/components/flex/transforms/flexPropToExpand.test.ts +156 -0
- package/src/components/flex/transforms/flexPropToExpand.ts +100 -0
- package/src/components/flex/transforms/innerRefToRef.test.ts +100 -0
- package/src/components/flex/transforms/innerRefToRef.ts +14 -0
- package/src/components/flex/transforms/mediaQueriesToResponsive.test.ts +714 -0
- package/src/components/flex/transforms/mediaQueriesToResponsive.ts +523 -0
- package/src/components/flex/transforms/moveFlexImport.test.ts +202 -0
- package/src/components/flex/transforms/moveFlexImport.ts +14 -0
- package/src/components/flex/transforms/paddingPropsToFlex.test.ts +252 -0
- package/src/components/flex/transforms/paddingPropsToFlex.ts +150 -0
- package/src/components/flex/transforms/setDefaultAxis.test.ts +126 -0
- package/src/components/flex/transforms/setDefaultAxis.ts +30 -0
- package/src/components/flex/transforms/spacingToGap.test.ts +176 -0
- package/src/components/flex/transforms/spacingToGap.ts +49 -0
- package/src/components/flex/transforms/unsupportedProps.test.ts +141 -0
- package/src/components/flex/transforms/unsupportedProps.ts +17 -0
- package/src/components/select/index.ts +2 -0
- package/src/components/select/transforms/onChangeSignature.test.ts +224 -0
- package/src/components/select/transforms/onChangeSignature.ts +172 -0
- package/src/components/shared/actions/resolveConstantAttributeValue.test.ts +122 -0
- package/src/components/shared/actions/resolveConstantAttributeValue.ts +31 -0
- package/src/components/shared/helpers/unsupportedPropsHelpers.ts +41 -0
- package/src/components/shared/transformFactories/stylePropTransformFactory.test.ts +47 -0
- package/src/components/shared/transformFactories/stylePropTransformFactory.ts +16 -0
- package/src/components/toggle-switch/index.ts +2 -0
- package/src/components/toggle-switch/transforms/onClickToOnChange.test.ts +210 -0
- package/src/components/toggle-switch/transforms/onClickToOnChange.ts +71 -0
- package/src/index.test.ts +79 -0
- package/src/index.ts +29 -0
- package/src/migrationList.ts +22 -0
- package/src/utils/componentLabel.test.ts +61 -0
- package/src/utils/componentLabel.ts +15 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import jscodeshift from "jscodeshift"
|
|
2
|
+
import { describe, expect, it } from "vitest"
|
|
3
|
+
|
|
4
|
+
import transform from "./innerRefToRef"
|
|
5
|
+
|
|
6
|
+
const j = jscodeshift.withParser("tsx")
|
|
7
|
+
|
|
8
|
+
function applyTransform(source: string, verbose = false): string | null {
|
|
9
|
+
const fileInfo = { path: "test.tsx", source }
|
|
10
|
+
return transform(
|
|
11
|
+
fileInfo,
|
|
12
|
+
{ j, jscodeshift: j, report: () => {}, stats: () => {} },
|
|
13
|
+
{ verbose }
|
|
14
|
+
) as string | null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe("innerRefToRef transform", () => {
|
|
18
|
+
it("renames innerRef to ref", () => {
|
|
19
|
+
const input = `
|
|
20
|
+
import { StackView } from "@planningcenter/tapestry-react"
|
|
21
|
+
|
|
22
|
+
export default function Test() {
|
|
23
|
+
const ref = React.useRef()
|
|
24
|
+
return <StackView innerRef={ref}>Test</StackView>
|
|
25
|
+
}
|
|
26
|
+
`.trim()
|
|
27
|
+
|
|
28
|
+
const result = applyTransform(input)
|
|
29
|
+
expect(result).toContain("ref={ref}")
|
|
30
|
+
expect(result).not.toContain("innerRef=")
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it("renames innerRef with a callback ref", () => {
|
|
34
|
+
const input = `
|
|
35
|
+
import { StackView } from "@planningcenter/tapestry-react"
|
|
36
|
+
|
|
37
|
+
export default function Test() {
|
|
38
|
+
return <StackView innerRef={(el) => console.log(el)}>Test</StackView>
|
|
39
|
+
}
|
|
40
|
+
`.trim()
|
|
41
|
+
|
|
42
|
+
const result = applyTransform(input)
|
|
43
|
+
expect(result).toContain("ref={(el) => console.log(el)}")
|
|
44
|
+
expect(result).not.toContain("innerRef=")
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it("respects an aliased StackView import", () => {
|
|
48
|
+
const input = `
|
|
49
|
+
import { StackView as Stack } from "@planningcenter/tapestry-react"
|
|
50
|
+
|
|
51
|
+
export default function Test() {
|
|
52
|
+
return <Stack innerRef={myRef}>Test</Stack>
|
|
53
|
+
}
|
|
54
|
+
`.trim()
|
|
55
|
+
|
|
56
|
+
const result = applyTransform(input)
|
|
57
|
+
expect(result).toContain("ref={myRef}")
|
|
58
|
+
expect(result).not.toContain("innerRef=")
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it("adds a CHANGED comment when verbose is enabled", () => {
|
|
62
|
+
const input = `
|
|
63
|
+
import { StackView } from "@planningcenter/tapestry-react"
|
|
64
|
+
|
|
65
|
+
export default function Test() {
|
|
66
|
+
return <StackView innerRef={myRef}>Test</StackView>
|
|
67
|
+
}
|
|
68
|
+
`.trim()
|
|
69
|
+
|
|
70
|
+
const result = applyTransform(input, true)
|
|
71
|
+
expect(result).toContain("ref={myRef}")
|
|
72
|
+
expect(result).toContain(
|
|
73
|
+
"CHANGED: tapestry-migration (ref): renamed from innerRef"
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it("returns null when there is no innerRef to migrate", () => {
|
|
78
|
+
const input = `
|
|
79
|
+
import { StackView } from "@planningcenter/tapestry-react"
|
|
80
|
+
|
|
81
|
+
export default function Test() {
|
|
82
|
+
return <StackView>Test</StackView>
|
|
83
|
+
}
|
|
84
|
+
`.trim()
|
|
85
|
+
|
|
86
|
+
expect(applyTransform(input)).toBe(null)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it("returns null when StackView is not imported from tapestry-react", () => {
|
|
90
|
+
const input = `
|
|
91
|
+
import { StackView } from "some-other-package"
|
|
92
|
+
|
|
93
|
+
export default function Test() {
|
|
94
|
+
return <StackView innerRef={myRef}>Test</StackView>
|
|
95
|
+
}
|
|
96
|
+
`.trim()
|
|
97
|
+
|
|
98
|
+
expect(applyTransform(input)).toBe(null)
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { transformAttributeName } from "../../shared/actions/transformAttributeName"
|
|
2
|
+
import { hasAttribute } from "../../shared/conditions/hasAttribute"
|
|
3
|
+
import { attributeTransformFactory } from "../../shared/transformFactories/attributeTransformFactory"
|
|
4
|
+
|
|
5
|
+
const transform = attributeTransformFactory({
|
|
6
|
+
condition: hasAttribute("innerRef"),
|
|
7
|
+
targetComponent: "StackView",
|
|
8
|
+
targetPackage: "@planningcenter/tapestry-react",
|
|
9
|
+
transform: (element, { j, options }) => {
|
|
10
|
+
return transformAttributeName("innerRef", "ref", { element, j, options })
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export default transform
|