@planningcenter/tapestry-migration-cli 3.4.1-rc.2 → 3.4.1-rc.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/tapestry-migration-cli",
3
- "version": "3.4.1-rc.2",
3
+ "version": "3.4.1-rc.3",
4
4
  "description": "CLI tool for Tapestry migrations",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@emotion/react": "^11.14.0",
33
- "@planningcenter/tapestry": "^3.4.1-rc.2",
33
+ "@planningcenter/tapestry": "^3.4.1-rc.3",
34
34
  "@planningcenter/tapestry-react": "^4.11.5",
35
35
  "@types/jscodeshift": "^17.3.0",
36
36
  "@types/node": "^20.0.0",
@@ -50,5 +50,5 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "a03b5528947440b2a5daff47a308e91de4c6727e"
53
+ "gitHead": "51487ee80b4a2012c20b9666d74c8251e45b0efc"
54
54
  }
@@ -0,0 +1,48 @@
1
+ import jscodeshift from "jscodeshift"
2
+ import { describe, expect, it } from "vitest"
3
+
4
+ import transform from "./index"
5
+
6
+ const j = jscodeshift.withParser("tsx")
7
+
8
+ function applyTransform(source: string): string | null {
9
+ const fileInfo = { path: "test.tsx", source }
10
+ return transform(
11
+ fileInfo,
12
+ { j, jscodeshift: j, report: () => {}, stats: () => {} },
13
+ {}
14
+ ) as string | null
15
+ }
16
+
17
+ describe("dropdown orchestrator", () => {
18
+ it("returns null for a legacy Dropdown source (no-op until rules are added)", () => {
19
+ const input = `
20
+ import { Dropdown } from "@planningcenter/tapestry-react"
21
+
22
+ export default function Test() {
23
+ return (
24
+ <Dropdown title="Actions" variant="outline">
25
+ <Dropdown.Item onSelect={() => {}}>Edit</Dropdown.Item>
26
+ <Dropdown.Link to="/docs">Docs</Dropdown.Link>
27
+ </Dropdown>
28
+ )
29
+ }
30
+ `.trim()
31
+
32
+ const result = applyTransform(input)
33
+ expect(result).toBe(null)
34
+ })
35
+
36
+ it("returns null for an empty file", () => {
37
+ const result = applyTransform("")
38
+ expect(result).toBe(null)
39
+ })
40
+
41
+ it("does not throw for arbitrary source", () => {
42
+ expect(() =>
43
+ applyTransform(
44
+ `import React from "react"\nexport default function Noop() { return <div /> }`
45
+ )
46
+ ).not.toThrow()
47
+ })
48
+ })
@@ -0,0 +1,26 @@
1
+ import { Transform } from "jscodeshift"
2
+
3
+ // Transforms are added one per commit as rules are built out.
4
+ // moveDropdownImport MUST remain last in the chain.
5
+ const transform: Transform = (fileInfo, api, options) => {
6
+ let currentSource = fileInfo.source
7
+ let hasAnyChanges = false
8
+
9
+ const transforms: Transform[] = []
10
+
11
+ for (const individualTransform of transforms) {
12
+ const result = individualTransform(
13
+ { ...fileInfo, source: currentSource },
14
+ api,
15
+ options
16
+ )
17
+ if (result && result !== currentSource) {
18
+ currentSource = result as string
19
+ hasAnyChanges = true
20
+ }
21
+ }
22
+
23
+ return hasAnyChanges ? currentSource : null
24
+ }
25
+
26
+ export default transform
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ const COMPONENTS_SET = new Set([
15
15
  "button",
16
16
  "checkbox",
17
17
  "date-picker",
18
+ "dropdown",
18
19
  "input",
19
20
  "link",
20
21
  "radio",