@planningcenter/tapestry-migration-cli 3.2.3-rc.4 → 3.2.3-rc.6

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 (46) hide show
  1. package/package.json +3 -3
  2. package/src/components/button/transforms/unsupportedProps.ts +3 -31
  3. package/src/components/checkbox/transforms/unsupportedProps.ts +3 -28
  4. package/src/components/date-picker/index.ts +56 -0
  5. package/src/components/date-picker/transforms/auditSpreadProps.test.ts +97 -0
  6. package/src/components/date-picker/transforms/auditSpreadProps.ts +10 -0
  7. package/src/components/date-picker/transforms/convertStyleProps.test.ts +58 -0
  8. package/src/components/date-picker/transforms/convertStyleProps.ts +10 -0
  9. package/src/components/date-picker/transforms/maxDateToMax.test.ts +87 -0
  10. package/src/components/date-picker/transforms/maxDateToMax.ts +16 -0
  11. package/src/components/date-picker/transforms/mergeFieldIntoDateField.test.ts +240 -0
  12. package/src/components/date-picker/transforms/mergeFieldIntoDateField.ts +5 -0
  13. package/src/components/date-picker/transforms/minDateToMin.test.ts +87 -0
  14. package/src/components/date-picker/transforms/minDateToMin.ts +16 -0
  15. package/src/components/date-picker/transforms/momentToDateString.test.ts +240 -0
  16. package/src/components/date-picker/transforms/momentToDateString.ts +87 -0
  17. package/src/components/date-picker/transforms/moveDatePickerImport.test.ts +157 -0
  18. package/src/components/date-picker/transforms/moveDatePickerImport.ts +14 -0
  19. package/src/components/date-picker/transforms/nativeDateToString.test.ts +220 -0
  20. package/src/components/date-picker/transforms/nativeDateToString.ts +59 -0
  21. package/src/components/date-picker/transforms/removeDuplicateKeys.test.ts +120 -0
  22. package/src/components/date-picker/transforms/removeDuplicateKeys.ts +8 -0
  23. package/src/components/date-picker/transforms/removeFormatValue.test.ts +119 -0
  24. package/src/components/date-picker/transforms/removeFormatValue.ts +22 -0
  25. package/src/components/date-picker/transforms/removePlaceholder.test.ts +117 -0
  26. package/src/components/date-picker/transforms/removePlaceholder.ts +22 -0
  27. package/src/components/date-picker/transforms/sizeMapping.test.ts +173 -0
  28. package/src/components/date-picker/transforms/sizeMapping.ts +15 -0
  29. package/src/components/date-picker/transforms/stateToInvalid.test.ts +109 -0
  30. package/src/components/date-picker/transforms/stateToInvalid.ts +57 -0
  31. package/src/components/date-picker/transforms/stateToInvalidTernary.test.ts +72 -0
  32. package/src/components/date-picker/transforms/stateToInvalidTernary.ts +11 -0
  33. package/src/components/date-picker/transforms/unsupportedProps.test.ts +170 -0
  34. package/src/components/date-picker/transforms/unsupportedProps.ts +10 -0
  35. package/src/components/input/transforms/unsupportedProps.ts +2 -2
  36. package/src/components/link/transforms/unsupportedProps.test.ts +3 -1
  37. package/src/components/link/transforms/unsupportedProps.ts +9 -37
  38. package/src/components/radio/transforms/unsupportedProps.ts +3 -28
  39. package/src/components/select/transforms/unsupportedProps.ts +9 -35
  40. package/src/components/shared/helpers/unsupportedPropsHelpers.ts +22 -0
  41. package/src/components/shared/transformFactories/unsupportedPropsFactory.test.ts +162 -0
  42. package/src/components/shared/transformFactories/unsupportedPropsFactory.ts +60 -0
  43. package/src/components/text-area/transforms/unsupportedProps.ts +3 -28
  44. package/src/components/time-field/transforms/unsupportedProps.ts +3 -30
  45. package/src/components/toggle-switch/transforms/unsupportedProps.ts +3 -28
  46. package/src/index.ts +7 -1
@@ -1,37 +1,10 @@
1
- import { JSXAttribute, Transform } from "jscodeshift"
2
-
3
- import { addCommentToUnsupportedProps } from "../../shared/actions/addCommentToUnsupportedProps"
4
1
  import { TIME_FIELD_SUPPORTED_PROPS } from "../../shared/helpers/unsupportedPropsHelpers"
5
- import { attributeTransformFactory } from "../../shared/transformFactories/attributeTransformFactory"
2
+ import { unsupportedPropsFactory } from "../../shared/transformFactories/unsupportedPropsFactory"
6
3
 
7
- const transform: Transform = attributeTransformFactory({
4
+ const transform = unsupportedPropsFactory({
5
+ supportedProps: TIME_FIELD_SUPPORTED_PROPS,
8
6
  targetComponent: "TimeField",
9
7
  targetPackage: "@planningcenter/tapestry-react",
10
- transform: (element, { j }) => {
11
- const attrs = element.openingElement.attributes || []
12
-
13
- const UNSUPPORTED_PROPS = attrs
14
- .filter(
15
- (attr) =>
16
- attr.type === "JSXAttribute" &&
17
- !TIME_FIELD_SUPPORTED_PROPS.includes(attr.name.name as string) &&
18
- !(attr.name.name as string).startsWith("aria-") &&
19
- !(attr.name.name as string).startsWith("data-")
20
- )
21
- .map((attr) => (attr as JSXAttribute).name.name as string)
22
-
23
- return addCommentToUnsupportedProps({
24
- element,
25
- j,
26
- messageSuffix: (prop) => {
27
- if (prop === "css") {
28
- return "\n * CSS prop is not supported. Use className or style prop instead.\n"
29
- }
30
- return ""
31
- },
32
- props: UNSUPPORTED_PROPS,
33
- })
34
- },
35
8
  })
36
9
 
37
10
  export default transform
@@ -1,8 +1,5 @@
1
- import { JSXAttribute, Transform } from "jscodeshift"
2
-
3
- import { addCommentToUnsupportedProps } from "../../shared/actions/addCommentToUnsupportedProps"
4
1
  import { CHECKBOX_RADIO_SUPPORTED_PROPS } from "../../shared/helpers/unsupportedPropsHelpers"
5
- import { attributeTransformFactory } from "../../shared/transformFactories/attributeTransformFactory"
2
+ import { unsupportedPropsFactory } from "../../shared/transformFactories/unsupportedPropsFactory"
6
3
 
7
4
  const TOGGLE_SWITCH_SPECIFIC_PROPS = ["hideLabel"]
8
5
 
@@ -11,32 +8,10 @@ const SUPPORTED_PROPS = [
11
8
  ...TOGGLE_SWITCH_SPECIFIC_PROPS,
12
9
  ]
13
10
 
14
- const transform: Transform = attributeTransformFactory({
11
+ const transform = unsupportedPropsFactory({
12
+ supportedProps: SUPPORTED_PROPS,
15
13
  targetComponent: "ToggleSwitch",
16
14
  targetPackage: "@planningcenter/tapestry-react",
17
- transform: (element, { j }) => {
18
- const UNSUPPORTED_PROPS = (element.openingElement.attributes || [])
19
- .filter(
20
- (attr) =>
21
- attr.type === "JSXAttribute" &&
22
- !SUPPORTED_PROPS.includes(attr.name.name as string) &&
23
- !(attr.name.name as string).startsWith("aria-") &&
24
- !(attr.name.name as string).startsWith("data-")
25
- )
26
- .map((attr) => (attr as JSXAttribute).name.name as string)
27
-
28
- return addCommentToUnsupportedProps({
29
- element,
30
- j,
31
- messageSuffix: (prop) => {
32
- if (prop === "css") {
33
- return "\n * CSS prop is not supported. Use className or style prop instead.\n"
34
- }
35
- return ""
36
- },
37
- props: UNSUPPORTED_PROPS,
38
- })
39
- },
40
15
  })
41
16
 
42
17
  export default transform
package/src/index.ts CHANGED
@@ -14,6 +14,7 @@ program
14
14
  const COMPONENTS_SET = new Set([
15
15
  "button",
16
16
  "checkbox",
17
+ "date-picker",
17
18
  "input",
18
19
  "link",
19
20
  "radio",
@@ -23,12 +24,17 @@ const COMPONENTS_SET = new Set([
23
24
  "toggle-switch",
24
25
  ])
25
26
 
27
+ const COMPONENTS_SENTENCE = new Intl.ListFormat("en", {
28
+ style: "long",
29
+ type: "conjunction",
30
+ }).format([...COMPONENTS_SET])
31
+
26
32
  program
27
33
  .command("run")
28
34
  .description("Run a migration of a component from Tapestry React to Tapestry")
29
35
  .argument(
30
36
  "<component-name>",
31
- "The name of the component to migrate (button, checkbox, input, link, radio, select, text-area, time-field, toggle-switch)"
37
+ `The name of the component to migrate (${COMPONENTS_SENTENCE})`
32
38
  )
33
39
  .requiredOption(
34
40
  "-p, --path <path>",