@planningcenter/tapestry-migration-cli 2.4.0-rc.19 → 2.4.0-rc.20
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/package.json +2 -2
- package/src/components/link/index.ts +4 -4
- package/src/components/link/transforms/{inlineMemberToKind.test.ts → removeInlineMember.test.ts} +13 -28
- package/src/components/link/transforms/removeInlineMember.ts +11 -0
- package/src/components/link/transforms/{inlinePropToKind.test.ts → removeInlineProp.test.ts} +12 -29
- package/src/components/link/transforms/{inlinePropToKind.ts → removeInlineProp.ts} +0 -9
- package/src/components/link/transforms/inlineMemberToKind.ts +0 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-migration-cli",
|
|
3
|
-
"version": "2.4.0-rc.
|
|
3
|
+
"version": "2.4.0-rc.20",
|
|
4
4
|
"description": "CLI tool for Tapestry migrations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "bcad7a2b3f0b5f30db8cf3675f6089dbc91d0148"
|
|
55
55
|
}
|
|
@@ -3,11 +3,11 @@ import { Transform } from "jscodeshift"
|
|
|
3
3
|
import auditSpreadProps from "./transforms/auditSpreadProps"
|
|
4
4
|
import childrenToLabel from "./transforms/childrenToLabel"
|
|
5
5
|
import convertStyleProps from "./transforms/convertStyleProps"
|
|
6
|
-
import inlineMemberToKind from "./transforms/inlineMemberToKind"
|
|
7
|
-
import inlinePropToKind from "./transforms/inlinePropToKind"
|
|
8
6
|
import innerRefToRef from "./transforms/innerRefToRef"
|
|
9
7
|
import moveLinkImport from "./transforms/moveLinkImport"
|
|
10
8
|
import removeAs from "./transforms/removeAs"
|
|
9
|
+
import removeInlineMember from "./transforms/removeInlineMember"
|
|
10
|
+
import removeInlineProp from "./transforms/removeInlineProp"
|
|
11
11
|
import reviewStyles from "./transforms/reviewStyles"
|
|
12
12
|
import targetBlankToExternal from "./transforms/targetBlankToExternal"
|
|
13
13
|
import tooltipToWrapper from "./transforms/tooltipToWrapper"
|
|
@@ -19,8 +19,8 @@ const transform: Transform = (fileInfo, api, options) => {
|
|
|
19
19
|
let hasAnyChanges = false
|
|
20
20
|
|
|
21
21
|
const transforms: Transform[] = [
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
removeInlineMember,
|
|
23
|
+
removeInlineProp,
|
|
24
24
|
tooltipToWrapper,
|
|
25
25
|
toToHref,
|
|
26
26
|
targetBlankToExternal,
|
package/src/components/link/transforms/{inlineMemberToKind.test.ts → removeInlineMember.test.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import jscodeshift from "jscodeshift"
|
|
2
2
|
import { describe, expect, it } from "vitest"
|
|
3
3
|
|
|
4
|
-
import transform from "./
|
|
4
|
+
import transform from "./removeInlineMember"
|
|
5
5
|
|
|
6
6
|
const j = jscodeshift.withParser("tsx")
|
|
7
7
|
|
|
@@ -14,9 +14,9 @@ function applyTransform(source: string): string | null {
|
|
|
14
14
|
) as string | null
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
describe("
|
|
17
|
+
describe("removeInlineMember transform", () => {
|
|
18
18
|
describe("basic transformations", () => {
|
|
19
|
-
it("should transform Link.Inline to Link
|
|
19
|
+
it("should transform Link.Inline to Link", () => {
|
|
20
20
|
const input = `
|
|
21
21
|
import { Link } from "@planningcenter/tapestry-react"
|
|
22
22
|
|
|
@@ -29,7 +29,7 @@ export default function Test() {
|
|
|
29
29
|
import { Link } from "@planningcenter/tapestry-react"
|
|
30
30
|
|
|
31
31
|
export default function Test() {
|
|
32
|
-
return <Link href="/profile"
|
|
32
|
+
return <Link href="/profile">Profile</Link>;
|
|
33
33
|
}
|
|
34
34
|
`.trim()
|
|
35
35
|
|
|
@@ -57,13 +57,11 @@ export default function Test() {
|
|
|
57
57
|
`.trim()
|
|
58
58
|
|
|
59
59
|
const result = applyTransform(input)
|
|
60
|
-
expect(result).toContain('kind="inline-text"')
|
|
61
60
|
expect(result).toContain('href="/dashboard"')
|
|
62
61
|
expect(result).toContain('className="nav-link"')
|
|
63
62
|
expect(result).toContain('target="_blank"')
|
|
64
63
|
expect(result).toContain('rel="noopener"')
|
|
65
64
|
expect(result).toContain('data-testid="profile-link"')
|
|
66
|
-
expect(result).toContain('kind="inline-text"')
|
|
67
65
|
expect(result).toContain("<Link")
|
|
68
66
|
expect(result).not.toContain("Link.Inline")
|
|
69
67
|
})
|
|
@@ -81,7 +79,7 @@ export default function Test() {
|
|
|
81
79
|
import { Link } from "@planningcenter/tapestry-react"
|
|
82
80
|
|
|
83
81
|
export default function Test() {
|
|
84
|
-
return <Link href="/dashboard"
|
|
82
|
+
return <Link href="/dashboard" />;
|
|
85
83
|
}
|
|
86
84
|
`.trim()
|
|
87
85
|
|
|
@@ -104,12 +102,8 @@ export default function Test() {
|
|
|
104
102
|
`.trim()
|
|
105
103
|
|
|
106
104
|
const result = applyTransform(input)
|
|
107
|
-
expect(result).toContain(
|
|
108
|
-
|
|
109
|
-
)
|
|
110
|
-
expect(result).toContain(
|
|
111
|
-
'<Link href="/about" kind="inline-text">About</Link>'
|
|
112
|
-
)
|
|
105
|
+
expect(result).toContain('<Link href="/home">Home</Link>')
|
|
106
|
+
expect(result).toContain('<Link href="/about">About</Link>')
|
|
113
107
|
expect(result).not.toContain("Link.Inline")
|
|
114
108
|
})
|
|
115
109
|
})
|
|
@@ -132,9 +126,7 @@ export default function Test() {
|
|
|
132
126
|
|
|
133
127
|
const result = applyTransform(input)
|
|
134
128
|
expect(result).toContain('<Link href="/home">Home</Link>')
|
|
135
|
-
expect(result).toContain(
|
|
136
|
-
'<Link href="/profile" kind="inline-text">Profile</Link>'
|
|
137
|
-
)
|
|
129
|
+
expect(result).toContain('<Link href="/profile">Profile</Link>')
|
|
138
130
|
expect(result).toContain(
|
|
139
131
|
'<Link as="button" href="/dashboard">Dashboard</Link>'
|
|
140
132
|
)
|
|
@@ -152,7 +144,7 @@ export default function Test() {
|
|
|
152
144
|
|
|
153
145
|
const result = applyTransform(input)
|
|
154
146
|
expect(result).toContain(
|
|
155
|
-
'<TapestryLink href="/profile"
|
|
147
|
+
'<TapestryLink href="/profile">Profile</TapestryLink>'
|
|
156
148
|
)
|
|
157
149
|
expect(result).not.toContain("TapestryLink.Inline")
|
|
158
150
|
})
|
|
@@ -175,11 +167,9 @@ export default function Test({ items, showInline }) {
|
|
|
175
167
|
|
|
176
168
|
const result = applyTransform(input)
|
|
177
169
|
expect(result).toContain(
|
|
178
|
-
|
|
179
|
-
)
|
|
180
|
-
expect(result).toContain(
|
|
181
|
-
'<Link href="/conditional" kind="inline-text">Conditional</Link>'
|
|
170
|
+
"<Link key={item.id} href={item.url}>{item.name}</Link>"
|
|
182
171
|
)
|
|
172
|
+
expect(result).toContain('<Link href="/conditional">Conditional</Link>')
|
|
183
173
|
expect(result).not.toContain("Link.Inline")
|
|
184
174
|
})
|
|
185
175
|
})
|
|
@@ -216,7 +206,6 @@ export default function Test({ url, isExternal }) {
|
|
|
216
206
|
`.trim()
|
|
217
207
|
|
|
218
208
|
const result = applyTransform(input)
|
|
219
|
-
expect(result).toContain('kind="inline-text"')
|
|
220
209
|
expect(result).toContain("<Link")
|
|
221
210
|
expect(result).toContain("href={url}")
|
|
222
211
|
expect(result).toContain('target={isExternal ? "_blank" : "_self"}')
|
|
@@ -245,12 +234,8 @@ export default function Test() {
|
|
|
245
234
|
`.trim()
|
|
246
235
|
|
|
247
236
|
const result = applyTransform(input)
|
|
248
|
-
expect(result).toContain(
|
|
249
|
-
|
|
250
|
-
)
|
|
251
|
-
expect(result).toContain(
|
|
252
|
-
'<Link href="/help" kind="inline-text">help section</Link>'
|
|
253
|
-
)
|
|
237
|
+
expect(result).toContain('<Link href="/about">about page</Link>')
|
|
238
|
+
expect(result).toContain('<Link href="/help">help section</Link>')
|
|
254
239
|
expect(result).not.toContain("Link.Inline")
|
|
255
240
|
})
|
|
256
241
|
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { componentTransformFactory } from "../../shared/transformFactories/componentTransformFactory"
|
|
2
|
+
|
|
3
|
+
const transform = componentTransformFactory({
|
|
4
|
+
condition: () => true, // Transform all Link.Inline elements
|
|
5
|
+
fromComponent: "Link.Inline",
|
|
6
|
+
fromPackage: "@planningcenter/tapestry-react",
|
|
7
|
+
toComponent: "Link",
|
|
8
|
+
toPackage: "@planningcenter/tapestry-react",
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export default transform
|
package/src/components/link/transforms/{inlinePropToKind.test.ts → removeInlineProp.test.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import jscodeshift from "jscodeshift"
|
|
2
2
|
import { describe, expect, it } from "vitest"
|
|
3
3
|
|
|
4
|
-
import transform from "./
|
|
4
|
+
import transform from "./removeInlineProp"
|
|
5
5
|
|
|
6
6
|
const j = jscodeshift.withParser("tsx")
|
|
7
7
|
|
|
@@ -14,9 +14,9 @@ function applyTransform(source: string): string | null {
|
|
|
14
14
|
) as string | null
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
describe("
|
|
17
|
+
describe("removeInlineProp transform", () => {
|
|
18
18
|
describe("basic transformations", () => {
|
|
19
|
-
it("should
|
|
19
|
+
it("should remove inline prop from Link", () => {
|
|
20
20
|
const input = `
|
|
21
21
|
import { Link } from "@planningcenter/tapestry-react"
|
|
22
22
|
|
|
@@ -26,14 +26,14 @@ export default function Test() {
|
|
|
26
26
|
`.trim()
|
|
27
27
|
|
|
28
28
|
const result = applyTransform(input)
|
|
29
|
-
expect(result).toContain('kind="inline-text"')
|
|
30
29
|
expect(result).not.toContain("inline>")
|
|
31
30
|
expect(result).not.toContain("inline />")
|
|
32
31
|
expect(result).not.toContain("inline=")
|
|
33
32
|
expect(result).toContain('href="/profile"')
|
|
33
|
+
expect(result).toContain('<Link href="/profile">Profile</Link>')
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
it("should
|
|
36
|
+
it("should remove inline={true} from Link", () => {
|
|
37
37
|
const input = `
|
|
38
38
|
import { Link } from "@planningcenter/tapestry-react"
|
|
39
39
|
|
|
@@ -43,7 +43,6 @@ export default function Test() {
|
|
|
43
43
|
`.trim()
|
|
44
44
|
|
|
45
45
|
const result = applyTransform(input)
|
|
46
|
-
expect(result).toContain('kind="inline-text"')
|
|
47
46
|
expect(result).not.toContain("inline>")
|
|
48
47
|
expect(result).not.toContain("inline />")
|
|
49
48
|
expect(result).not.toContain("inline=")
|
|
@@ -69,7 +68,6 @@ export default function Test() {
|
|
|
69
68
|
`.trim()
|
|
70
69
|
|
|
71
70
|
const result = applyTransform(input)
|
|
72
|
-
expect(result).toContain('kind="inline-text"')
|
|
73
71
|
expect(result).toContain('href="/dashboard"')
|
|
74
72
|
expect(result).toContain('className="nav-link"')
|
|
75
73
|
expect(result).toContain('data-testid="profile-link"')
|
|
@@ -88,7 +86,6 @@ export default function Test() {
|
|
|
88
86
|
`.trim()
|
|
89
87
|
|
|
90
88
|
const result = applyTransform(input)
|
|
91
|
-
expect(result).toContain('kind="inline-text"')
|
|
92
89
|
expect(result).toContain('href="/dashboard"')
|
|
93
90
|
expect(result).not.toContain("inline>")
|
|
94
91
|
expect(result).not.toContain("inline />")
|
|
@@ -110,12 +107,8 @@ export default function Test() {
|
|
|
110
107
|
`.trim()
|
|
111
108
|
|
|
112
109
|
const result = applyTransform(input)
|
|
113
|
-
expect(result).toContain(
|
|
114
|
-
|
|
115
|
-
)
|
|
116
|
-
expect(result).toContain(
|
|
117
|
-
'<Link href="/about" kind="inline-text">About</Link>'
|
|
118
|
-
)
|
|
110
|
+
expect(result).toContain('<Link href="/home">Home</Link>')
|
|
111
|
+
expect(result).toContain('<Link href="/about">About</Link>')
|
|
119
112
|
expect(result).not.toContain("inline>")
|
|
120
113
|
expect(result).not.toContain("inline />")
|
|
121
114
|
expect(result).not.toContain("inline=")
|
|
@@ -140,9 +133,7 @@ export default function Test() {
|
|
|
140
133
|
|
|
141
134
|
const result = applyTransform(input)
|
|
142
135
|
expect(result).toContain('<Link href="/home">Home</Link>')
|
|
143
|
-
expect(result).toContain(
|
|
144
|
-
'<Link href="/profile" kind="inline-text">Profile</Link>'
|
|
145
|
-
)
|
|
136
|
+
expect(result).toContain('<Link href="/profile">Profile</Link>')
|
|
146
137
|
expect(result).toContain(
|
|
147
138
|
'<Link href="/dashboard" kind="primary">Dashboard</Link>'
|
|
148
139
|
)
|
|
@@ -161,7 +152,6 @@ export default function Test() {
|
|
|
161
152
|
`.trim()
|
|
162
153
|
|
|
163
154
|
const result = applyTransform(input)
|
|
164
|
-
expect(result).toContain('kind="inline-text"')
|
|
165
155
|
expect(result).not.toContain("inline>")
|
|
166
156
|
expect(result).not.toContain("inline />")
|
|
167
157
|
expect(result).not.toContain("inline=")
|
|
@@ -193,7 +183,6 @@ export default function Test({ linkProps }) {
|
|
|
193
183
|
`.trim()
|
|
194
184
|
|
|
195
185
|
const result = applyTransform(input)
|
|
196
|
-
expect(result).toContain('kind="inline-text"')
|
|
197
186
|
expect(result).toContain("{...linkProps}")
|
|
198
187
|
expect(result).not.toContain("inline>")
|
|
199
188
|
expect(result).not.toContain("inline />")
|
|
@@ -218,11 +207,9 @@ export default function Test({ items, showInline }) {
|
|
|
218
207
|
|
|
219
208
|
const result = applyTransform(input)
|
|
220
209
|
expect(result).toContain(
|
|
221
|
-
|
|
222
|
-
)
|
|
223
|
-
expect(result).toContain(
|
|
224
|
-
'<Link href="/conditional" kind="inline-text">Conditional</Link>'
|
|
210
|
+
"<Link key={item.id} href={item.url}>{item.name}</Link>"
|
|
225
211
|
)
|
|
212
|
+
expect(result).toContain('<Link href="/conditional">Conditional</Link>')
|
|
226
213
|
expect(result).not.toContain("inline>")
|
|
227
214
|
expect(result).not.toContain("inline />")
|
|
228
215
|
expect(result).not.toContain("inline=")
|
|
@@ -247,12 +234,8 @@ export default function Test() {
|
|
|
247
234
|
`.trim()
|
|
248
235
|
|
|
249
236
|
const result = applyTransform(input)
|
|
250
|
-
expect(result).toContain(
|
|
251
|
-
|
|
252
|
-
)
|
|
253
|
-
expect(result).toContain(
|
|
254
|
-
'<Link href="/help" kind="inline-text">help section</Link>'
|
|
255
|
-
)
|
|
237
|
+
expect(result).toContain('<Link href="/about">about page</Link>')
|
|
238
|
+
expect(result).toContain('<Link href="/help">help section</Link>')
|
|
256
239
|
expect(result).not.toContain("inline>")
|
|
257
240
|
expect(result).not.toContain("inline />")
|
|
258
241
|
expect(result).not.toContain("inline=")
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { addAttribute } from "../../shared/actions/addAttribute"
|
|
2
1
|
import { removeAttribute } from "../../shared/actions/removeAttribute"
|
|
3
2
|
import { hasAttribute } from "../../shared/conditions/hasAttribute"
|
|
4
3
|
import { attributeTransformFactory } from "../../shared/transformFactories/attributeTransformFactory"
|
|
@@ -9,14 +8,6 @@ const transform = attributeTransformFactory({
|
|
|
9
8
|
targetPackage: "@planningcenter/tapestry-react",
|
|
10
9
|
transform: (element, { j, source }) => {
|
|
11
10
|
removeAttribute("inline", { element, j, source })
|
|
12
|
-
|
|
13
|
-
addAttribute({
|
|
14
|
-
element,
|
|
15
|
-
j,
|
|
16
|
-
name: "kind",
|
|
17
|
-
value: "inline-text",
|
|
18
|
-
})
|
|
19
|
-
|
|
20
11
|
return true
|
|
21
12
|
},
|
|
22
13
|
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Transform } from "jscodeshift"
|
|
2
|
-
|
|
3
|
-
import { addAttribute } from "../../shared/actions/addAttribute"
|
|
4
|
-
import { attributeTransformFactory } from "../../shared/transformFactories/attributeTransformFactory"
|
|
5
|
-
import { componentTransformFactory } from "../../shared/transformFactories/componentTransformFactory"
|
|
6
|
-
|
|
7
|
-
const addKindAttribute = attributeTransformFactory({
|
|
8
|
-
condition: () => true, // Add to all Link.Inline elements
|
|
9
|
-
targetComponent: "Link.Inline",
|
|
10
|
-
targetPackage: "@planningcenter/tapestry-react",
|
|
11
|
-
transform: (element, { j }) => {
|
|
12
|
-
addAttribute({
|
|
13
|
-
element,
|
|
14
|
-
j,
|
|
15
|
-
name: "kind",
|
|
16
|
-
value: "inline-text",
|
|
17
|
-
})
|
|
18
|
-
return true
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const transformComponent = componentTransformFactory({
|
|
23
|
-
condition: () => true, // Transform all Link.Inline elements
|
|
24
|
-
fromComponent: "Link.Inline",
|
|
25
|
-
fromPackage: "@planningcenter/tapestry-react",
|
|
26
|
-
toComponent: "Link",
|
|
27
|
-
toPackage: "@planningcenter/tapestry-react",
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
// Combined transform that runs both steps
|
|
31
|
-
const transform: Transform = (fileInfo, api, options) => {
|
|
32
|
-
// Step 1: Add kind attribute to Link.Inline elements
|
|
33
|
-
const result1 = addKindAttribute(fileInfo, api, options)
|
|
34
|
-
|
|
35
|
-
if (!result1) {
|
|
36
|
-
return null
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Step 2: Transform Link.Inline to Link
|
|
40
|
-
const result2 = transformComponent(
|
|
41
|
-
{ ...fileInfo, source: result1 as string },
|
|
42
|
-
api,
|
|
43
|
-
options
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
return result2 || result1
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default transform
|