@atlaskit/codemod-cli 0.34.8 → 1.0.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.
Files changed (233) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/cli.js +4 -3
  3. package/dist/cjs/get-transform-module.js +14 -0
  4. package/dist/cjs/get-transform-path.js +11 -0
  5. package/dist/cjs/get-transform-version.js +16 -0
  6. package/dist/cjs/{transforms.js → get-transforms.js} +19 -45
  7. package/dist/cjs/has-transform.js +10 -0
  8. package/dist/cjs/index.js +1 -14
  9. package/dist/cjs/main.js +17 -12
  10. package/dist/cjs/no-transforms-exist-error.js +23 -0
  11. package/dist/cjs/parse-transform-path.js +11 -0
  12. package/dist/cjs/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +22 -0
  13. package/dist/cjs/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +1 -17
  14. package/dist/cjs/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +6 -4
  15. package/dist/cjs/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +12 -0
  16. package/dist/cjs/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +28 -0
  17. package/dist/cjs/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +13 -0
  18. package/dist/cjs/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +29 -0
  19. package/dist/cjs/presets/migrate-to-link/codemods/migrate-to-link.js +4 -2
  20. package/dist/cjs/presets/migrate-to-link/utils/comments.js +2 -13
  21. package/dist/cjs/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +11 -0
  22. package/dist/cjs/presets/migrate-to-link/utils/style-prop-comment.js +12 -0
  23. package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +2 -2
  24. package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +18 -16
  25. package/dist/cjs/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +11 -0
  26. package/dist/cjs/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +1 -5
  27. package/dist/cjs/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +3 -12
  28. package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-element.js +47 -0
  29. package/dist/cjs/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +15 -0
  30. package/dist/cjs/presets/migrate-to-new-buttons/utils/get-icon-element.js +13 -0
  31. package/dist/cjs/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +81 -0
  32. package/dist/cjs/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +4 -3
  33. package/dist/cjs/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +18 -0
  34. package/dist/cjs/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +16 -0
  35. package/dist/cjs/presets/remove-token-fallbacks/after-all.js +337 -0
  36. package/dist/cjs/presets/remove-token-fallbacks/before-all.js +33 -0
  37. package/dist/cjs/presets/remove-token-fallbacks/remove-token-fallbacks.js +4 -360
  38. package/dist/cjs/presets/remove-token-fallbacks/utils/clear-folder.js +68 -0
  39. package/dist/cjs/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -37
  40. package/dist/cjs/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +59 -182
  41. package/dist/cjs/presets/remove-token-fallbacks/utils/compare-hex.js +25 -0
  42. package/dist/cjs/presets/remove-token-fallbacks/utils/is-valid-color.js +41 -0
  43. package/dist/cjs/presets/remove-token-fallbacks/utils/normalize-values.js +8 -6
  44. package/dist/cjs/presets/remove-token-fallbacks/utils/write-reports.js +83 -0
  45. package/dist/cjs/sinceRef.js +2 -2
  46. package/dist/cjs/types.js +1 -31
  47. package/dist/cjs/validation-error.js +23 -0
  48. package/dist/es2019/cli.js +2 -1
  49. package/dist/es2019/get-transform-module.js +7 -0
  50. package/dist/es2019/get-transform-path.js +4 -0
  51. package/dist/es2019/get-transform-version.js +9 -0
  52. package/dist/es2019/{transforms.js → get-transforms.js} +10 -31
  53. package/dist/es2019/has-transform.js +2 -0
  54. package/dist/es2019/index.js +1 -2
  55. package/dist/es2019/main.js +7 -2
  56. package/dist/es2019/no-transforms-exist-error.js +1 -0
  57. package/dist/es2019/parse-transform-path.js +2 -0
  58. package/dist/es2019/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +16 -0
  59. package/dist/es2019/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +0 -16
  60. package/dist/es2019/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +3 -1
  61. package/dist/es2019/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +6 -0
  62. package/dist/es2019/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +22 -0
  63. package/dist/es2019/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +5 -0
  64. package/dist/es2019/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +19 -0
  65. package/dist/es2019/presets/migrate-to-link/codemods/migrate-to-link.js +3 -1
  66. package/dist/es2019/presets/migrate-to-link/utils/comments.js +1 -11
  67. package/dist/es2019/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +4 -0
  68. package/dist/es2019/presets/migrate-to-link/utils/style-prop-comment.js +6 -0
  69. package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +1 -1
  70. package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +5 -3
  71. package/dist/es2019/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +4 -0
  72. package/dist/es2019/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +0 -3
  73. package/dist/es2019/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +1 -10
  74. package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-element.js +39 -0
  75. package/dist/es2019/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +7 -0
  76. package/dist/es2019/presets/migrate-to-new-buttons/utils/get-icon-element.js +7 -0
  77. package/dist/es2019/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +68 -0
  78. package/dist/es2019/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +2 -1
  79. package/dist/es2019/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +12 -0
  80. package/dist/es2019/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +10 -0
  81. package/dist/es2019/presets/remove-token-fallbacks/after-all.js +139 -0
  82. package/dist/es2019/presets/remove-token-fallbacks/before-all.js +8 -0
  83. package/dist/es2019/presets/remove-token-fallbacks/remove-token-fallbacks.js +2 -150
  84. package/dist/es2019/presets/remove-token-fallbacks/utils/clear-folder.js +15 -0
  85. package/dist/es2019/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -34
  86. package/dist/es2019/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +1 -50
  87. package/dist/es2019/presets/remove-token-fallbacks/utils/compare-hex.js +17 -0
  88. package/dist/es2019/presets/remove-token-fallbacks/utils/is-valid-color.js +35 -0
  89. package/dist/es2019/presets/remove-token-fallbacks/utils/normalize-values.js +3 -1
  90. package/dist/es2019/presets/remove-token-fallbacks/utils/write-reports.js +41 -0
  91. package/dist/es2019/sinceRef.js +1 -1
  92. package/dist/es2019/types.js +1 -7
  93. package/dist/es2019/validation-error.js +1 -0
  94. package/dist/esm/cli.js +2 -1
  95. package/dist/esm/get-transform-module.js +7 -0
  96. package/dist/esm/get-transform-path.js +5 -0
  97. package/dist/esm/get-transform-version.js +9 -0
  98. package/dist/esm/{transforms.js → get-transforms.js} +16 -42
  99. package/dist/esm/has-transform.js +4 -0
  100. package/dist/esm/index.js +1 -2
  101. package/dist/esm/main.js +7 -2
  102. package/dist/esm/no-transforms-exist-error.js +16 -0
  103. package/dist/esm/parse-transform-path.js +4 -0
  104. package/dist/esm/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +16 -0
  105. package/dist/esm/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +0 -16
  106. package/dist/esm/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +3 -1
  107. package/dist/esm/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +6 -0
  108. package/dist/esm/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +22 -0
  109. package/dist/esm/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +7 -0
  110. package/dist/esm/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +22 -0
  111. package/dist/esm/presets/migrate-to-link/codemods/migrate-to-link.js +3 -1
  112. package/dist/esm/presets/migrate-to-link/utils/comments.js +1 -12
  113. package/dist/esm/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +5 -0
  114. package/dist/esm/presets/migrate-to-link/utils/style-prop-comment.js +6 -0
  115. package/dist/esm/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +1 -1
  116. package/dist/esm/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +5 -3
  117. package/dist/esm/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +5 -0
  118. package/dist/esm/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +0 -4
  119. package/dist/esm/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +1 -10
  120. package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-element.js +41 -0
  121. package/dist/esm/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +9 -0
  122. package/dist/esm/presets/migrate-to-new-buttons/utils/get-icon-element.js +7 -0
  123. package/dist/esm/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +75 -0
  124. package/dist/esm/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +2 -1
  125. package/dist/esm/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +12 -0
  126. package/dist/esm/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +10 -0
  127. package/dist/esm/presets/remove-token-fallbacks/after-all.js +331 -0
  128. package/dist/esm/presets/remove-token-fallbacks/before-all.js +27 -0
  129. package/dist/esm/presets/remove-token-fallbacks/remove-token-fallbacks.js +2 -357
  130. package/dist/esm/presets/remove-token-fallbacks/utils/clear-folder.js +62 -0
  131. package/dist/esm/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -36
  132. package/dist/esm/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +57 -180
  133. package/dist/esm/presets/remove-token-fallbacks/utils/compare-hex.js +19 -0
  134. package/dist/esm/presets/remove-token-fallbacks/utils/is-valid-color.js +35 -0
  135. package/dist/esm/presets/remove-token-fallbacks/utils/normalize-values.js +3 -1
  136. package/dist/esm/presets/remove-token-fallbacks/utils/write-reports.js +75 -0
  137. package/dist/esm/sinceRef.js +1 -1
  138. package/dist/esm/types.js +1 -29
  139. package/dist/esm/validation-error.js +16 -0
  140. package/dist/types/get-transform-module.d.ts +2 -0
  141. package/dist/types/get-transform-path.d.ts +2 -0
  142. package/dist/types/get-transform-version.d.ts +2 -0
  143. package/dist/types/get-transforms.d.ts +3 -0
  144. package/dist/types/has-transform.d.ts +1 -0
  145. package/dist/types/index.d.ts +0 -1
  146. package/dist/types/main.d.ts +1 -1
  147. package/dist/types/no-transforms-exist-error.d.ts +2 -0
  148. package/dist/types/parse-transform-path.d.ts +2 -0
  149. package/dist/types/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.d.ts +16 -0
  150. package/dist/types/presets/migrate-deprecated-icon/utils/{mock.d.ts → mock-metadata.d.ts} +0 -16
  151. package/dist/types/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.d.ts +1 -0
  152. package/dist/types/presets/migrate-icon-object-to-object/utils/get-new-import-info.d.ts +4 -0
  153. package/dist/types/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.d.ts +1 -0
  154. package/dist/types/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.d.ts +4 -0
  155. package/dist/types/presets/migrate-to-link/utils/comments.d.ts +0 -5
  156. package/dist/types/presets/migrate-to-link/utils/generic-unsupported-migration-comment.d.ts +1 -0
  157. package/dist/types/presets/migrate-to-link/utils/style-prop-comment.d.ts +4 -0
  158. package/dist/types/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.d.ts +2 -0
  159. package/dist/types/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.d.ts → find-variant-already-imported.d.ts} +0 -1
  160. package/dist/types/presets/migrate-to-new-buttons/utils/{generate-link-element.d.ts → generate-link-component.d.ts} +0 -1
  161. package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-element.d.ts +3 -0
  162. package/dist/types/presets/migrate-to-new-buttons/utils/get-icon-attributes.d.ts +2 -0
  163. package/dist/types/presets/migrate-to-new-buttons/utils/get-icon-element.d.ts +2 -0
  164. package/dist/types/presets/migrate-to-new-buttons/utils/handle-icon-attributes.d.ts +2 -0
  165. package/dist/types/presets/migrate-to-new-buttons/utils/modify-button-attributes.d.ts +2 -0
  166. package/dist/types/presets/migrate-to-new-buttons/utils/modify-link-attributes.d.ts +2 -0
  167. package/dist/types/presets/remove-token-fallbacks/after-all.d.ts +2 -0
  168. package/dist/types/presets/remove-token-fallbacks/before-all.d.ts +2 -0
  169. package/dist/types/presets/remove-token-fallbacks/remove-token-fallbacks.d.ts +0 -9
  170. package/dist/types/presets/remove-token-fallbacks/utils/clear-folder.d.ts +1 -0
  171. package/dist/types/presets/remove-token-fallbacks/utils/color-to-hex.d.ts +1 -0
  172. package/dist/types/presets/remove-token-fallbacks/utils/combine-reports.d.ts +1 -0
  173. package/dist/types/presets/remove-token-fallbacks/utils/compare-hex.d.ts +1 -0
  174. package/dist/types/presets/remove-token-fallbacks/utils/is-valid-color.d.ts +1 -0
  175. package/dist/types/presets/remove-token-fallbacks/utils/{reporter.d.ts → write-reports.d.ts} +0 -2
  176. package/dist/types/sinceRef.d.ts +1 -1
  177. package/dist/types/types.d.ts +0 -4
  178. package/dist/types/validation-error.d.ts +2 -0
  179. package/dist/types-ts4.5/get-transform-module.d.ts +2 -0
  180. package/dist/types-ts4.5/get-transform-path.d.ts +2 -0
  181. package/dist/types-ts4.5/get-transform-version.d.ts +2 -0
  182. package/dist/types-ts4.5/get-transforms.d.ts +3 -0
  183. package/dist/types-ts4.5/has-transform.d.ts +1 -0
  184. package/dist/types-ts4.5/index.d.ts +0 -1
  185. package/dist/types-ts4.5/main.d.ts +1 -1
  186. package/dist/types-ts4.5/no-transforms-exist-error.d.ts +2 -0
  187. package/dist/types-ts4.5/parse-transform-path.d.ts +2 -0
  188. package/dist/types-ts4.5/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.d.ts +16 -0
  189. package/dist/types-ts4.5/presets/migrate-deprecated-icon/utils/{mock.d.ts → mock-metadata.d.ts} +0 -16
  190. package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.d.ts +1 -0
  191. package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/get-new-import-info.d.ts +4 -0
  192. package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.d.ts +1 -0
  193. package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.d.ts +4 -0
  194. package/dist/types-ts4.5/presets/migrate-to-link/utils/comments.d.ts +0 -5
  195. package/dist/types-ts4.5/presets/migrate-to-link/utils/generic-unsupported-migration-comment.d.ts +1 -0
  196. package/dist/types-ts4.5/presets/migrate-to-link/utils/style-prop-comment.d.ts +4 -0
  197. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.d.ts +2 -0
  198. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.d.ts → find-variant-already-imported.d.ts} +0 -1
  199. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/{generate-link-element.d.ts → generate-link-component.d.ts} +0 -1
  200. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-element.d.ts +3 -0
  201. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/get-icon-attributes.d.ts +2 -0
  202. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/get-icon-element.d.ts +2 -0
  203. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/handle-icon-attributes.d.ts +2 -0
  204. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/modify-button-attributes.d.ts +2 -0
  205. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/modify-link-attributes.d.ts +2 -0
  206. package/dist/types-ts4.5/presets/remove-token-fallbacks/after-all.d.ts +2 -0
  207. package/dist/types-ts4.5/presets/remove-token-fallbacks/before-all.d.ts +2 -0
  208. package/dist/types-ts4.5/presets/remove-token-fallbacks/remove-token-fallbacks.d.ts +0 -9
  209. package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/clear-folder.d.ts +1 -0
  210. package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/color-to-hex.d.ts +1 -0
  211. package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/combine-reports.d.ts +1 -0
  212. package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/compare-hex.d.ts +1 -0
  213. package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/is-valid-color.d.ts +1 -0
  214. package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/{reporter.d.ts → write-reports.d.ts} +0 -2
  215. package/dist/types-ts4.5/sinceRef.d.ts +1 -1
  216. package/dist/types-ts4.5/types.d.ts +0 -4
  217. package/dist/types-ts4.5/validation-error.d.ts +2 -0
  218. package/package.json +4 -4
  219. package/dist/cjs/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -81
  220. package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -160
  221. package/dist/es2019/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -67
  222. package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -143
  223. package/dist/esm/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -72
  224. package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -154
  225. package/dist/types/presets/migrate-icon-object-to-object/utils/icon-mappings.d.ts +0 -29
  226. package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +0 -20
  227. package/dist/types/presets/remove-token-fallbacks/utils/color-utils.d.ts +0 -3
  228. package/dist/types/transforms.d.ts +0 -11
  229. package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/icon-mappings.d.ts +0 -29
  230. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +0 -20
  231. package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/color-utils.d.ts +0 -3
  232. package/dist/types-ts4.5/transforms.d.ts +0 -11
  233. package/transforms/package.json +0 -14
@@ -1,67 +0,0 @@
1
- /* eslint-disable @repo/internal/fs/filename-pattern-match */
2
-
3
- import { AVAILABLE_ICON_NAMES, ICON_TO_OBJECT_NAME_MAPPINGS } from './constants';
4
-
5
- /**
6
- * Converts a kebab-case string to PascalCase
7
- * @param str - The kebab-case string (e.g., 'new-feature', 'work-item')
8
- * @returns PascalCase string (e.g., 'NewFeature', 'WorkItem')
9
- */
10
- export function kebabToPascalCase(str) {
11
- return str.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('');
12
- }
13
-
14
- /**
15
- * Extracts icon name and size from an icon-object import path
16
- * @param importPath - The import path like '@atlaskit/icon-object/glyph/new-feature/16'
17
- * @returns Object with iconName and size, or null if not a valid icon-object import
18
- */
19
- export function parseIconObjectImport(importPath) {
20
- const match = importPath.match(/^@atlaskit\/icon-object\/glyph\/([^/]+)\/(16|24)$/);
21
- if (!match) {
22
- return null;
23
- }
24
- const [, iconName, size] = match;
25
-
26
- // Check if this is a valid icon name we support
27
- if (!AVAILABLE_ICON_NAMES.includes(iconName)) {
28
- return null;
29
- }
30
- return {
31
- iconName,
32
- size: size
33
- };
34
- }
35
-
36
- /**
37
- * Gets the new import specifier for an icon based on its name and size
38
- * @param iconName - The kebab-case icon name from icon-object (e.g., 'new-feature', 'issue')
39
- * @param size - The size ('16' or '24')
40
- * @returns Object with the new import path and component name
41
- */
42
- export function getNewImportInfo(iconName, size) {
43
- // Check if this icon name needs to be mapped to a different object name
44
- const objectName = ICON_TO_OBJECT_NAME_MAPPINGS[iconName] || iconName;
45
-
46
- // Convert the object name to PascalCase
47
- const pascalCaseName = kebabToPascalCase(objectName);
48
- if (size === '16') {
49
- return {
50
- importPath: `@atlaskit/object/${objectName}`,
51
- componentName: `${pascalCaseName}Object`
52
- };
53
- } else {
54
- return {
55
- importPath: `@atlaskit/object/tile/${objectName}`,
56
- componentName: `${pascalCaseName}ObjectTile`
57
- };
58
- }
59
- }
60
-
61
- /**
62
- * Creates a new default import declaration for the transformed component
63
- */
64
- export function createDefaultImportDeclaration(j, componentName, importPath) {
65
- const defaultSpecifier = j.importDefaultSpecifier(j.identifier(componentName));
66
- return j.importDeclaration([defaultSpecifier], j.stringLiteral(importPath));
67
- }
@@ -1,143 +0,0 @@
1
- import { NEW_BUTTON_VARIANTS } from '../utils/constants';
2
- export const getIconAttributes = attributes => {
3
- const iconAttr = attributes === null || attributes === void 0 ? void 0 : attributes.filter(attribute => attribute.type === 'JSXAttribute' && (attribute.name.name === 'iconBefore' || attribute.name.name === 'iconAfter'));
4
- if (iconAttr !== null && iconAttr !== void 0 && iconAttr.length) {
5
- return iconAttr;
6
- }
7
- return null;
8
- };
9
- export const getIconElement = iconAttr => {
10
- var _iconAttr$value;
11
- if (iconAttr && ((_iconAttr$value = iconAttr.value) === null || _iconAttr$value === void 0 ? void 0 : _iconAttr$value.type) === 'JSXExpressionContainer' && iconAttr.value.expression.type === 'JSXElement') {
12
- return iconAttr.value.expression;
13
- }
14
- return null;
15
- };
16
-
17
- /**
18
- * We need to do a couple of things here:
19
- *
20
- * 1. If an icon attribute has a label, elevate it to the root button element
21
- * 2. If an icon doesn't have any other attributes, move to bounded API:
22
- * {<MoreIcon />} -> {MoreIcon}
23
- * 3. If an icon has attributes other than label, move to renderProp:
24
- * {<MoreIcon primaryColor />} -> {() => <MoreIcon primaryColor />}
25
- *
26
- * @param element
27
- * @param j
28
- * @param iconRenamed
29
- */
30
- export const handleIconAttributes = (element, j, iconRenamed = false) => {
31
- const {
32
- attributes: buttonAttributes
33
- } = element.openingElement;
34
- // Get iconBefore and iconAfter attributes
35
- const buttonIconAttributes = buttonAttributes && getIconAttributes(buttonAttributes);
36
- buttonIconAttributes === null || buttonIconAttributes === void 0 ? void 0 : buttonIconAttributes.forEach(iconAttribute => {
37
- let iconElement = getIconElement(iconAttribute);
38
- if (!iconElement) {
39
- return;
40
- }
41
- const iconAttributes = iconElement.openingElement.attributes;
42
- if (!Array.isArray(iconAttributes)) {
43
- return;
44
- }
45
-
46
- // 1. Move label to root button element, only if label doesn't exist already. Button label
47
- // takes precedence over icon label.
48
-
49
- const buttonAlreadyHasLabelProp = buttonAttributes === null || buttonAttributes === void 0 ? void 0 : buttonAttributes.find(buttonAttribute => buttonAttribute.type === 'JSXAttribute' && buttonAttribute.name.name === 'label');
50
- const buttonAlreadyHasAriaLabelProp = buttonAttributes === null || buttonAttributes === void 0 ? void 0 : buttonAttributes.find(buttonAttribute => buttonAttribute.type === 'JSXAttribute' && buttonAttribute.name.name === 'aria-label');
51
- if (!buttonAlreadyHasLabelProp && !buttonAlreadyHasAriaLabelProp) {
52
- const labelAttribute = iconAttributes.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'label');
53
- if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
54
- buttonAttributes === null || buttonAttributes === void 0 ? void 0 : buttonAttributes.unshift(labelAttribute);
55
- }
56
- }
57
-
58
- // 2. If there are any other props on icon, move to render prop
59
- const attributesOtherThanLabelOrMediumSize = iconAttributes.filter(iconAttribute => {
60
- var _iconAttribute$value, _iconAttribute$value2;
61
- // Exclude size="medium"
62
- if (iconAttribute.type === 'JSXAttribute' && iconAttribute.name.name === 'size' && ((_iconAttribute$value = iconAttribute.value) === null || _iconAttribute$value === void 0 ? void 0 : _iconAttribute$value.type) === 'StringLiteral' && ((_iconAttribute$value2 = iconAttribute.value) === null || _iconAttribute$value2 === void 0 ? void 0 : _iconAttribute$value2.value) === 'medium') {
63
- return false;
64
- }
65
-
66
- // Exclude label
67
- if (iconAttribute.type === 'JSXAttribute' && iconAttribute.name.name === 'label') {
68
- return false;
69
- }
70
- return true;
71
- });
72
- if (attributesOtherThanLabelOrMediumSize.length > 0) {
73
- // Move to render prop: `<MoreIcon primaryColor />` -> `(props) => <MoreIcon {...props} primaryColor />`
74
-
75
- // Remove label and size="medium" attributes
76
- j(iconElement.openingElement).find(j.JSXAttribute).filter(attribute => attribute.value.name.name === 'label' || attribute.value.type === 'JSXAttribute' && attribute.value.name.name === 'size' && attribute.value.value && attribute.value.value.type === 'StringLiteral' && attribute.value.value.value === 'medium' || false).remove();
77
-
78
- // Add spread props
79
- iconAttributes.unshift(j.jsxSpreadAttribute(j.identifier('iconProps')));
80
-
81
- // Create new arrow function (renderProp)
82
- iconAttribute.value = j.jsxExpressionContainer(j.arrowFunctionExpression.from({
83
- params: [j.identifier('iconProps')],
84
- body: iconElement,
85
- expression: true
86
- }));
87
- } else {
88
- var _iconAttribute$value3;
89
- // Move to bounded API: {<MoreIcon />} => {MoreIcon}
90
- if (iconElement.openingElement.name.type === 'JSXIdentifier' && ((_iconAttribute$value3 = iconAttribute.value) === null || _iconAttribute$value3 === void 0 ? void 0 : _iconAttribute$value3.type) === 'JSXExpressionContainer') {
91
- iconAttribute.value.expression = j.identifier(iconElement.openingElement.name.name);
92
- }
93
- }
94
- });
95
- };
96
- export const generateNewElement = (variant, element, j) => {
97
- const {
98
- attributes
99
- } = element.openingElement;
100
- const iconAttrs = attributes && getIconAttributes(attributes);
101
- const isIconOrLinkIcon = variant === NEW_BUTTON_VARIANTS.icon || variant === NEW_BUTTON_VARIANTS.linkIcon;
102
- if (variant === NEW_BUTTON_VARIANTS.link) {
103
- j(element).find(j.JSXAttribute).filter(path => {
104
- var _path$node$value;
105
- return path.node.name.name === 'appearance' && ((_path$node$value = path.node.value) === null || _path$node$value === void 0 ? void 0 : _path$node$value.type) === 'StringLiteral' && (path.node.value.value === 'subtle-link' || path.node.value.value === 'link');
106
- }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
107
- }
108
- if (isIconOrLinkIcon && iconAttrs !== null && iconAttrs !== void 0 && iconAttrs.length) {
109
- handleIconAttributes(element, j, true);
110
-
111
- // rename iconBefore/iconAfter to icon
112
- iconAttrs[0].name.name = 'icon';
113
- const ariaLabelAttr = j(element.openingElement).find(j.JSXAttribute).filter(attribute => attribute.node.name.name === 'aria-label');
114
- if (ariaLabelAttr.length) {
115
- const hasNoLabelProp = !(attributes !== null && attributes !== void 0 && attributes.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === 'label'));
116
- if (hasNoLabelProp && attributes) {
117
- attributes.unshift(j.jsxAttribute.from({
118
- name: j.jsxIdentifier('label'),
119
- value: j.literal(ariaLabelAttr.get().value.value.value)
120
- }));
121
- }
122
- ariaLabelAttr.remove();
123
- }
124
- }
125
- return j.jsxElement.from({
126
- openingElement: j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isIconOrLinkIcon),
127
- // self closing if it's an icon button or icon link button
128
- closingElement: isIconOrLinkIcon ? null : j.jsxClosingElement(j.jsxIdentifier(variant)),
129
- children: element.children
130
- });
131
- };
132
- export const modifyButtonAttributes = (element, j, hasSpacingNone) => {
133
- j(element).find(j.JSXAttribute).filter(path => {
134
- var _path$node$value2;
135
- return path.node.name.name === 'appearance' && ((_path$node$value2 = path.node.value) === null || _path$node$value2 === void 0 ? void 0 : _path$node$value2.type) === 'StringLiteral' && (path.node.value.value === 'link' || path.node.value.value === 'subtle-link');
136
- }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
137
- if (hasSpacingNone) {
138
- j(element).find(j.JSXAttribute).filter(path => {
139
- var _path$node$value3;
140
- return path.node.name.name === 'spacing' && ((_path$node$value3 = path.node.value) === null || _path$node$value3 === void 0 ? void 0 : _path$node$value3.type) === 'StringLiteral' && path.node.value.value === 'none';
141
- }).remove();
142
- }
143
- };
@@ -1,72 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- /* eslint-disable @repo/internal/fs/filename-pattern-match */
3
-
4
- import { AVAILABLE_ICON_NAMES, ICON_TO_OBJECT_NAME_MAPPINGS } from './constants';
5
-
6
- /**
7
- * Converts a kebab-case string to PascalCase
8
- * @param str - The kebab-case string (e.g., 'new-feature', 'work-item')
9
- * @returns PascalCase string (e.g., 'NewFeature', 'WorkItem')
10
- */
11
- export function kebabToPascalCase(str) {
12
- return str.split('-').map(function (word) {
13
- return word.charAt(0).toUpperCase() + word.slice(1);
14
- }).join('');
15
- }
16
-
17
- /**
18
- * Extracts icon name and size from an icon-object import path
19
- * @param importPath - The import path like '@atlaskit/icon-object/glyph/new-feature/16'
20
- * @returns Object with iconName and size, or null if not a valid icon-object import
21
- */
22
- export function parseIconObjectImport(importPath) {
23
- var match = importPath.match(/^@atlaskit\/icon-object\/glyph\/([^/]+)\/(16|24)$/);
24
- if (!match) {
25
- return null;
26
- }
27
- var _match = _slicedToArray(match, 3),
28
- iconName = _match[1],
29
- size = _match[2];
30
-
31
- // Check if this is a valid icon name we support
32
- if (!AVAILABLE_ICON_NAMES.includes(iconName)) {
33
- return null;
34
- }
35
- return {
36
- iconName: iconName,
37
- size: size
38
- };
39
- }
40
-
41
- /**
42
- * Gets the new import specifier for an icon based on its name and size
43
- * @param iconName - The kebab-case icon name from icon-object (e.g., 'new-feature', 'issue')
44
- * @param size - The size ('16' or '24')
45
- * @returns Object with the new import path and component name
46
- */
47
- export function getNewImportInfo(iconName, size) {
48
- // Check if this icon name needs to be mapped to a different object name
49
- var objectName = ICON_TO_OBJECT_NAME_MAPPINGS[iconName] || iconName;
50
-
51
- // Convert the object name to PascalCase
52
- var pascalCaseName = kebabToPascalCase(objectName);
53
- if (size === '16') {
54
- return {
55
- importPath: "@atlaskit/object/".concat(objectName),
56
- componentName: "".concat(pascalCaseName, "Object")
57
- };
58
- } else {
59
- return {
60
- importPath: "@atlaskit/object/tile/".concat(objectName),
61
- componentName: "".concat(pascalCaseName, "ObjectTile")
62
- };
63
- }
64
- }
65
-
66
- /**
67
- * Creates a new default import declaration for the transformed component
68
- */
69
- export function createDefaultImportDeclaration(j, componentName, importPath) {
70
- var defaultSpecifier = j.importDefaultSpecifier(j.identifier(componentName));
71
- return j.importDeclaration([defaultSpecifier], j.stringLiteral(importPath));
72
- }
@@ -1,154 +0,0 @@
1
- import { NEW_BUTTON_VARIANTS } from '../utils/constants';
2
- export var getIconAttributes = function getIconAttributes(attributes) {
3
- var iconAttr = attributes === null || attributes === void 0 ? void 0 : attributes.filter(function (attribute) {
4
- return attribute.type === 'JSXAttribute' && (attribute.name.name === 'iconBefore' || attribute.name.name === 'iconAfter');
5
- });
6
- if (iconAttr !== null && iconAttr !== void 0 && iconAttr.length) {
7
- return iconAttr;
8
- }
9
- return null;
10
- };
11
- export var getIconElement = function getIconElement(iconAttr) {
12
- var _iconAttr$value;
13
- if (iconAttr && ((_iconAttr$value = iconAttr.value) === null || _iconAttr$value === void 0 ? void 0 : _iconAttr$value.type) === 'JSXExpressionContainer' && iconAttr.value.expression.type === 'JSXElement') {
14
- return iconAttr.value.expression;
15
- }
16
- return null;
17
- };
18
-
19
- /**
20
- * We need to do a couple of things here:
21
- *
22
- * 1. If an icon attribute has a label, elevate it to the root button element
23
- * 2. If an icon doesn't have any other attributes, move to bounded API:
24
- * {<MoreIcon />} -> {MoreIcon}
25
- * 3. If an icon has attributes other than label, move to renderProp:
26
- * {<MoreIcon primaryColor />} -> {() => <MoreIcon primaryColor />}
27
- *
28
- * @param element
29
- * @param j
30
- * @param iconRenamed
31
- */
32
- export var handleIconAttributes = function handleIconAttributes(element, j) {
33
- var iconRenamed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
34
- var buttonAttributes = element.openingElement.attributes;
35
- // Get iconBefore and iconAfter attributes
36
- var buttonIconAttributes = buttonAttributes && getIconAttributes(buttonAttributes);
37
- buttonIconAttributes === null || buttonIconAttributes === void 0 || buttonIconAttributes.forEach(function (iconAttribute) {
38
- var iconElement = getIconElement(iconAttribute);
39
- if (!iconElement) {
40
- return;
41
- }
42
- var iconAttributes = iconElement.openingElement.attributes;
43
- if (!Array.isArray(iconAttributes)) {
44
- return;
45
- }
46
-
47
- // 1. Move label to root button element, only if label doesn't exist already. Button label
48
- // takes precedence over icon label.
49
-
50
- var buttonAlreadyHasLabelProp = buttonAttributes === null || buttonAttributes === void 0 ? void 0 : buttonAttributes.find(function (buttonAttribute) {
51
- return buttonAttribute.type === 'JSXAttribute' && buttonAttribute.name.name === 'label';
52
- });
53
- var buttonAlreadyHasAriaLabelProp = buttonAttributes === null || buttonAttributes === void 0 ? void 0 : buttonAttributes.find(function (buttonAttribute) {
54
- return buttonAttribute.type === 'JSXAttribute' && buttonAttribute.name.name === 'aria-label';
55
- });
56
- if (!buttonAlreadyHasLabelProp && !buttonAlreadyHasAriaLabelProp) {
57
- var labelAttribute = iconAttributes.find(function (attribute) {
58
- return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
59
- });
60
- if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
61
- buttonAttributes === null || buttonAttributes === void 0 || buttonAttributes.unshift(labelAttribute);
62
- }
63
- }
64
-
65
- // 2. If there are any other props on icon, move to render prop
66
- var attributesOtherThanLabelOrMediumSize = iconAttributes.filter(function (iconAttribute) {
67
- var _iconAttribute$value, _iconAttribute$value2;
68
- // Exclude size="medium"
69
- if (iconAttribute.type === 'JSXAttribute' && iconAttribute.name.name === 'size' && ((_iconAttribute$value = iconAttribute.value) === null || _iconAttribute$value === void 0 ? void 0 : _iconAttribute$value.type) === 'StringLiteral' && ((_iconAttribute$value2 = iconAttribute.value) === null || _iconAttribute$value2 === void 0 ? void 0 : _iconAttribute$value2.value) === 'medium') {
70
- return false;
71
- }
72
-
73
- // Exclude label
74
- if (iconAttribute.type === 'JSXAttribute' && iconAttribute.name.name === 'label') {
75
- return false;
76
- }
77
- return true;
78
- });
79
- if (attributesOtherThanLabelOrMediumSize.length > 0) {
80
- // Move to render prop: `<MoreIcon primaryColor />` -> `(props) => <MoreIcon {...props} primaryColor />`
81
-
82
- // Remove label and size="medium" attributes
83
- j(iconElement.openingElement).find(j.JSXAttribute).filter(function (attribute) {
84
- return attribute.value.name.name === 'label' || attribute.value.type === 'JSXAttribute' && attribute.value.name.name === 'size' && attribute.value.value && attribute.value.value.type === 'StringLiteral' && attribute.value.value.value === 'medium' || false;
85
- }).remove();
86
-
87
- // Add spread props
88
- iconAttributes.unshift(j.jsxSpreadAttribute(j.identifier('iconProps')));
89
-
90
- // Create new arrow function (renderProp)
91
- iconAttribute.value = j.jsxExpressionContainer(j.arrowFunctionExpression.from({
92
- params: [j.identifier('iconProps')],
93
- body: iconElement,
94
- expression: true
95
- }));
96
- } else {
97
- var _iconAttribute$value3;
98
- // Move to bounded API: {<MoreIcon />} => {MoreIcon}
99
- if (iconElement.openingElement.name.type === 'JSXIdentifier' && ((_iconAttribute$value3 = iconAttribute.value) === null || _iconAttribute$value3 === void 0 ? void 0 : _iconAttribute$value3.type) === 'JSXExpressionContainer') {
100
- iconAttribute.value.expression = j.identifier(iconElement.openingElement.name.name);
101
- }
102
- }
103
- });
104
- };
105
- export var generateNewElement = function generateNewElement(variant, element, j) {
106
- var attributes = element.openingElement.attributes;
107
- var iconAttrs = attributes && getIconAttributes(attributes);
108
- var isIconOrLinkIcon = variant === NEW_BUTTON_VARIANTS.icon || variant === NEW_BUTTON_VARIANTS.linkIcon;
109
- if (variant === NEW_BUTTON_VARIANTS.link) {
110
- j(element).find(j.JSXAttribute).filter(function (path) {
111
- var _path$node$value;
112
- return path.node.name.name === 'appearance' && ((_path$node$value = path.node.value) === null || _path$node$value === void 0 ? void 0 : _path$node$value.type) === 'StringLiteral' && (path.node.value.value === 'subtle-link' || path.node.value.value === 'link');
113
- }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
114
- }
115
- if (isIconOrLinkIcon && iconAttrs !== null && iconAttrs !== void 0 && iconAttrs.length) {
116
- handleIconAttributes(element, j, true);
117
-
118
- // rename iconBefore/iconAfter to icon
119
- iconAttrs[0].name.name = 'icon';
120
- var ariaLabelAttr = j(element.openingElement).find(j.JSXAttribute).filter(function (attribute) {
121
- return attribute.node.name.name === 'aria-label';
122
- });
123
- if (ariaLabelAttr.length) {
124
- var hasNoLabelProp = !(attributes !== null && attributes !== void 0 && attributes.find(function (attribute) {
125
- return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
126
- }));
127
- if (hasNoLabelProp && attributes) {
128
- attributes.unshift(j.jsxAttribute.from({
129
- name: j.jsxIdentifier('label'),
130
- value: j.literal(ariaLabelAttr.get().value.value.value)
131
- }));
132
- }
133
- ariaLabelAttr.remove();
134
- }
135
- }
136
- return j.jsxElement.from({
137
- openingElement: j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isIconOrLinkIcon),
138
- // self closing if it's an icon button or icon link button
139
- closingElement: isIconOrLinkIcon ? null : j.jsxClosingElement(j.jsxIdentifier(variant)),
140
- children: element.children
141
- });
142
- };
143
- export var modifyButtonAttributes = function modifyButtonAttributes(element, j, hasSpacingNone) {
144
- j(element).find(j.JSXAttribute).filter(function (path) {
145
- var _path$node$value2;
146
- return path.node.name.name === 'appearance' && ((_path$node$value2 = path.node.value) === null || _path$node$value2 === void 0 ? void 0 : _path$node$value2.type) === 'StringLiteral' && (path.node.value.value === 'link' || path.node.value.value === 'subtle-link');
147
- }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
148
- if (hasSpacingNone) {
149
- j(element).find(j.JSXAttribute).filter(function (path) {
150
- var _path$node$value3;
151
- return path.node.name.name === 'spacing' && ((_path$node$value3 = path.node.value) === null || _path$node$value3 === void 0 ? void 0 : _path$node$value3.type) === 'StringLiteral' && path.node.value.value === 'none';
152
- }).remove();
153
- }
154
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * Converts a kebab-case string to PascalCase
3
- * @param str - The kebab-case string (e.g., 'new-feature', 'work-item')
4
- * @returns PascalCase string (e.g., 'NewFeature', 'WorkItem')
5
- */
6
- export declare function kebabToPascalCase(str: string): string;
7
- /**
8
- * Extracts icon name and size from an icon-object import path
9
- * @param importPath - The import path like '@atlaskit/icon-object/glyph/new-feature/16'
10
- * @returns Object with iconName and size, or null if not a valid icon-object import
11
- */
12
- export declare function parseIconObjectImport(importPath: string): {
13
- iconName: string;
14
- size: '16' | '24';
15
- } | null;
16
- /**
17
- * Gets the new import specifier for an icon based on its name and size
18
- * @param iconName - The kebab-case icon name from icon-object (e.g., 'new-feature', 'issue')
19
- * @param size - The size ('16' or '24')
20
- * @returns Object with the new import path and component name
21
- */
22
- export declare function getNewImportInfo(iconName: string, size: '16' | '24'): {
23
- importPath: string;
24
- componentName: string;
25
- };
26
- /**
27
- * Creates a new default import declaration for the transformed component
28
- */
29
- export declare function createDefaultImportDeclaration(j: any, componentName: string, importPath: string): any;
@@ -1,20 +0,0 @@
1
- import { type API, type JSXAttribute, type JSXElement, type JSXSpreadAttribute } from 'jscodeshift';
2
- import { NEW_BUTTON_VARIANTS } from '../utils/constants';
3
- export declare const getIconAttributes: (attributes: (JSXAttribute | JSXSpreadAttribute)[]) => JSXAttribute[] | null;
4
- export declare const getIconElement: (iconAttr: JSXAttribute) => JSXElement | null;
5
- /**
6
- * We need to do a couple of things here:
7
- *
8
- * 1. If an icon attribute has a label, elevate it to the root button element
9
- * 2. If an icon doesn't have any other attributes, move to bounded API:
10
- * {<MoreIcon />} -> {MoreIcon}
11
- * 3. If an icon has attributes other than label, move to renderProp:
12
- * {<MoreIcon primaryColor />} -> {() => <MoreIcon primaryColor />}
13
- *
14
- * @param element
15
- * @param j
16
- * @param iconRenamed
17
- */
18
- export declare const handleIconAttributes: (element: JSXElement, j: API['jscodeshift'], iconRenamed?: boolean) => void;
19
- export declare const generateNewElement: (variant: (typeof NEW_BUTTON_VARIANTS)[keyof typeof NEW_BUTTON_VARIANTS], element: JSXElement, j: API['jscodeshift']) => JSXElement;
20
- export declare const modifyButtonAttributes: (element: JSXElement, j: API['jscodeshift'], hasSpacingNone: boolean) => void;
@@ -1,3 +0,0 @@
1
- export declare const compareHex: (hex: string, hex2: string) => number;
2
- export declare function isValidColor(color: string): boolean;
3
- export declare function colorToHex(color: string): string;
@@ -1,11 +0,0 @@
1
- import path, { type ParsedPath } from 'path';
2
- import { type ParsedPkg } from './types';
3
- export declare const hasTransform: (transformPath: string) => boolean;
4
- /**
5
- * Retrieves transforms for `packages` if provided, otherwise all transforms including presets
6
- */
7
- export declare const getTransforms: (packages?: ParsedPkg[]) => ParsedPath[];
8
- export declare const parseTransformPath: (transformPath: string) => path.ParsedPath;
9
- export declare const getTransformPath: ({ dir, base }: ParsedPath) => string;
10
- export declare const getTransformModule: (transform: ParsedPath) => string;
11
- export declare const getTransformVersion: (transform: ParsedPath) => string;
@@ -1,29 +0,0 @@
1
- /**
2
- * Converts a kebab-case string to PascalCase
3
- * @param str - The kebab-case string (e.g., 'new-feature', 'work-item')
4
- * @returns PascalCase string (e.g., 'NewFeature', 'WorkItem')
5
- */
6
- export declare function kebabToPascalCase(str: string): string;
7
- /**
8
- * Extracts icon name and size from an icon-object import path
9
- * @param importPath - The import path like '@atlaskit/icon-object/glyph/new-feature/16'
10
- * @returns Object with iconName and size, or null if not a valid icon-object import
11
- */
12
- export declare function parseIconObjectImport(importPath: string): {
13
- iconName: string;
14
- size: '16' | '24';
15
- } | null;
16
- /**
17
- * Gets the new import specifier for an icon based on its name and size
18
- * @param iconName - The kebab-case icon name from icon-object (e.g., 'new-feature', 'issue')
19
- * @param size - The size ('16' or '24')
20
- * @returns Object with the new import path and component name
21
- */
22
- export declare function getNewImportInfo(iconName: string, size: '16' | '24'): {
23
- importPath: string;
24
- componentName: string;
25
- };
26
- /**
27
- * Creates a new default import declaration for the transformed component
28
- */
29
- export declare function createDefaultImportDeclaration(j: any, componentName: string, importPath: string): any;
@@ -1,20 +0,0 @@
1
- import { type API, type JSXAttribute, type JSXElement, type JSXSpreadAttribute } from 'jscodeshift';
2
- import { NEW_BUTTON_VARIANTS } from '../utils/constants';
3
- export declare const getIconAttributes: (attributes: (JSXAttribute | JSXSpreadAttribute)[]) => JSXAttribute[] | null;
4
- export declare const getIconElement: (iconAttr: JSXAttribute) => JSXElement | null;
5
- /**
6
- * We need to do a couple of things here:
7
- *
8
- * 1. If an icon attribute has a label, elevate it to the root button element
9
- * 2. If an icon doesn't have any other attributes, move to bounded API:
10
- * {<MoreIcon />} -> {MoreIcon}
11
- * 3. If an icon has attributes other than label, move to renderProp:
12
- * {<MoreIcon primaryColor />} -> {() => <MoreIcon primaryColor />}
13
- *
14
- * @param element
15
- * @param j
16
- * @param iconRenamed
17
- */
18
- export declare const handleIconAttributes: (element: JSXElement, j: API['jscodeshift'], iconRenamed?: boolean) => void;
19
- export declare const generateNewElement: (variant: (typeof NEW_BUTTON_VARIANTS)[keyof typeof NEW_BUTTON_VARIANTS], element: JSXElement, j: API['jscodeshift']) => JSXElement;
20
- export declare const modifyButtonAttributes: (element: JSXElement, j: API['jscodeshift'], hasSpacingNone: boolean) => void;
@@ -1,3 +0,0 @@
1
- export declare const compareHex: (hex: string, hex2: string) => number;
2
- export declare function isValidColor(color: string): boolean;
3
- export declare function colorToHex(color: string): string;
@@ -1,11 +0,0 @@
1
- import path, { type ParsedPath } from 'path';
2
- import { type ParsedPkg } from './types';
3
- export declare const hasTransform: (transformPath: string) => boolean;
4
- /**
5
- * Retrieves transforms for `packages` if provided, otherwise all transforms including presets
6
- */
7
- export declare const getTransforms: (packages?: ParsedPkg[]) => ParsedPath[];
8
- export declare const parseTransformPath: (transformPath: string) => path.ParsedPath;
9
- export declare const getTransformPath: ({ dir, base }: ParsedPath) => string;
10
- export declare const getTransformModule: (transform: ParsedPath) => string;
11
- export declare const getTransformVersion: (transform: ParsedPath) => string;
@@ -1,14 +0,0 @@
1
- {
2
- "name": "@atlaskit/codemod-cli/transforms",
3
- "main": "../dist/cjs/transforms.js",
4
- "module": "../dist/esm/transforms.js",
5
- "module:es2019": "../dist/es2019/transforms.js",
6
- "types": "../dist/types/transforms.d.ts",
7
- "typesVersions": {
8
- ">=4.5 <5.9": {
9
- "*": [
10
- "../dist/types-ts4.5/transforms.d.ts"
11
- ]
12
- }
13
- }
14
- }