@planningcenter/tapestry-migration-cli 2.4.0 → 2.4.1-rc.1

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.
@@ -0,0 +1,47 @@
1
+ import { JSXAttribute, Transform } from "jscodeshift"
2
+
3
+ import { addCommentToUnsupportedProps } from "../../shared/actions/addCommentToUnsupportedProps"
4
+ import { SUPPORTED_PROPS_BASE } from "../../shared/helpers/unsupportedPropsHelpers"
5
+ import { attributeTransformFactory } from "../../shared/transformFactories/attributeTransformFactory"
6
+
7
+ const CHECKBOX_SPECIFIC_PROPS = [
8
+ "checked",
9
+ "disabled",
10
+ "indeterminate",
11
+ "label",
12
+ "name",
13
+ "onChange",
14
+ "value",
15
+ ]
16
+
17
+ const SUPPORTED_PROPS = [...SUPPORTED_PROPS_BASE, ...CHECKBOX_SPECIFIC_PROPS]
18
+
19
+ const transform: Transform = attributeTransformFactory({
20
+ targetComponent: "Checkbox",
21
+ targetPackage: "@planningcenter/tapestry-react",
22
+ transform: (element, { j }) => {
23
+ const UNSUPPORTED_PROPS = (element.openingElement.attributes || [])
24
+ .filter(
25
+ (attr) =>
26
+ attr.type === "JSXAttribute" &&
27
+ !SUPPORTED_PROPS.includes(attr.name.name as string) &&
28
+ !(attr.name.name as string).startsWith("aria-") &&
29
+ !(attr.name.name as string).startsWith("data-")
30
+ )
31
+ .map((attr) => (attr as JSXAttribute).name.name as string)
32
+
33
+ return addCommentToUnsupportedProps({
34
+ element,
35
+ j,
36
+ messageSuffix: (prop) => {
37
+ if (prop === "css") {
38
+ return "\n * CSS prop is not supported. Use className or style prop instead.\n"
39
+ }
40
+ return ""
41
+ },
42
+ props: UNSUPPORTED_PROPS,
43
+ })
44
+ },
45
+ })
46
+
47
+ export default transform
@@ -3,7 +3,11 @@ import { existsSync } from "fs"
3
3
  import { dirname, resolve } from "path"
4
4
  import { fileURLToPath } from "url"
5
5
 
6
- import { generateMigrationReport, WEIGHT_CONFIGS } from "./reportGenerator"
6
+ import {
7
+ generateMigrationReport,
8
+ GLOBAL_MESSAGES,
9
+ WEIGHT_CONFIGS,
10
+ } from "./reportGenerator"
7
11
  import { Options } from "./shared/types"
8
12
 
9
13
  const __filename = fileURLToPath(import.meta.url)
@@ -45,7 +49,11 @@ export function runTransforms(key: string, options: Options): void {
45
49
  stdio: "inherit",
46
50
  })
47
51
 
52
+ const message = GLOBAL_MESSAGES[key as keyof typeof GLOBAL_MESSAGES]
53
+ if (message) console.log(`\nšŸ“¢ Note: ${message}\n`)
54
+
48
55
  generateMigrationReport({
56
+ globalMessage: message,
49
57
  outputPath: options.reportPath,
50
58
  targetPath,
51
59
  weightConfig: WEIGHT_CONFIGS[key] || { default: 1 },
@@ -23,6 +23,11 @@ interface CommentStats {
23
23
  weight: number
24
24
  }
25
25
 
26
+ export const GLOBAL_MESSAGES = {
27
+ checkbox:
28
+ "Checkbox sizes have adjusted. Verify visual appearance as sizes may differ slightly.",
29
+ }
30
+
26
31
  export const WEIGHT_CONFIGS: { [key: string]: WeightConfig } = {
27
32
  button: {
28
33
  default: 1,
@@ -36,6 +41,13 @@ export const WEIGHT_CONFIGS: { [key: string]: WeightConfig } = {
36
41
  tooltip: 2,
37
42
  unsupported: 3,
38
43
  },
44
+ checkbox: {
45
+ children: 2,
46
+ css: 3,
47
+ default: 1,
48
+ label: 2,
49
+ size: 2,
50
+ },
39
51
  }
40
52
 
41
53
  /**
@@ -258,7 +270,8 @@ function aggregateComments(
258
270
  function generateMarkdownReport(
259
271
  stats: CommentStats[],
260
272
  allComments: CommentData[],
261
- basePath: string
273
+ basePath: string,
274
+ globalMessage?: string
262
275
  ): string {
263
276
  const totalComments = allComments.length
264
277
  const uniqueCommentTypes = stats.length
@@ -280,6 +293,7 @@ function generateMarkdownReport(
280
293
  "",
281
294
  `**Generated:** ${new Date().toISOString()}`,
282
295
  "",
296
+ ...(globalMessage ? [`> šŸ“¢ Note: ${globalMessage}`, ""] : []),
283
297
  "## Overview",
284
298
  "",
285
299
  ]
@@ -403,7 +417,9 @@ export function generateMigrationReport({
403
417
  targetPath,
404
418
  outputPath,
405
419
  weightConfig,
420
+ globalMessage,
406
421
  }: {
422
+ globalMessage?: string
407
423
  outputPath?: string
408
424
  targetPath: string
409
425
  weightConfig: WeightConfig
@@ -430,7 +446,12 @@ export function generateMigrationReport({
430
446
  const stats = aggregateComments(allComments, weightConfig)
431
447
 
432
448
  // Generate markdown report
433
- const report = generateMarkdownReport(stats, allComments, targetPath)
449
+ const report = generateMarkdownReport(
450
+ stats,
451
+ allComments,
452
+ targetPath,
453
+ globalMessage
454
+ )
434
455
 
435
456
  // Determine output path
436
457
  const finalOutputPath =