@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,6 +1 @@
1
- export declare const stylePropComment: ({ propName, prefix, }: {
2
- propName: string;
3
- prefix?: string;
4
- }) => string;
5
1
  export declare const spreadPropsComment = "This link could not be migrated due to usage of spread props. The codemod cannot determine the props being spread. Please manually migrate.";
6
- export declare const genericUnsupportedMigrationComment: (prefix?: string) => string;
@@ -0,0 +1 @@
1
+ export declare const genericUnsupportedMigrationComment: (prefix?: string) => string;
@@ -0,0 +1,4 @@
1
+ export declare const stylePropComment: ({ propName, prefix, }: {
2
+ propName: string;
3
+ prefix?: string;
4
+ }) => string;
@@ -0,0 +1,2 @@
1
+ import type { API, Collection } from 'jscodeshift';
2
+ export declare const checkIfVariantAlreadyImported: (variant: string, entryPoint: string, fileSource: Collection<any>, j: API["jscodeshift"], isDefaultSpecifier?: boolean) => boolean;
@@ -1,3 +1,2 @@
1
1
  import type { API, Collection } from 'jscodeshift';
2
2
  export declare const findVariantAlreadyImported: (variant: string, entryPoint: string, fileSource: Collection<any>, j: API["jscodeshift"], isDefaultSpecifier?: boolean) => Collection<any>;
3
- export declare const checkIfVariantAlreadyImported: (variant: string, entryPoint: string, fileSource: Collection<any>, j: API["jscodeshift"], isDefaultSpecifier?: boolean) => boolean;
@@ -1,3 +1,2 @@
1
1
  import { type API, type JSXElement } from 'jscodeshift';
2
- export declare const modifyLinkAttributes: (element: JSXElement, j: API['jscodeshift']) => void;
3
2
  export declare const generateLinkComponent: (element: JSXElement, j: API['jscodeshift']) => JSXElement | undefined;
@@ -0,0 +1,3 @@
1
+ import { type API, type JSXElement } from 'jscodeshift';
2
+ import { NEW_BUTTON_VARIANTS } from './constants';
3
+ export declare const generateNewElement: (variant: (typeof NEW_BUTTON_VARIANTS)[keyof typeof NEW_BUTTON_VARIANTS], element: JSXElement, j: API['jscodeshift']) => JSXElement;
@@ -0,0 +1,2 @@
1
+ import { type JSXAttribute, type JSXSpreadAttribute } from 'jscodeshift';
2
+ export declare const getIconAttributes: (attributes: (JSXAttribute | JSXSpreadAttribute)[]) => JSXAttribute[] | null;
@@ -0,0 +1,2 @@
1
+ import { type JSXAttribute, type JSXElement } from 'jscodeshift';
2
+ export declare const getIconElement: (iconAttr: JSXAttribute) => JSXElement | null;
@@ -0,0 +1,2 @@
1
+ import { type API, type JSXElement } from 'jscodeshift';
2
+ export declare const handleIconAttributes: (element: JSXElement, j: API['jscodeshift'], iconRenamed?: boolean) => void;
@@ -0,0 +1,2 @@
1
+ import { type API, type JSXElement } from 'jscodeshift';
2
+ export declare const modifyButtonAttributes: (element: JSXElement, j: API['jscodeshift'], hasSpacingNone: boolean) => void;
@@ -0,0 +1,2 @@
1
+ import { type API, type JSXElement } from 'jscodeshift';
2
+ export declare const modifyLinkAttributes: (element: JSXElement, j: API['jscodeshift']) => void;
@@ -0,0 +1,2 @@
1
+ import { type RemoveTokenFallbackOptions } from './types';
2
+ export declare function afterAll(options: RemoveTokenFallbackOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { type RemoveTokenFallbackOptions } from './types';
2
+ export declare function beforeAll(options: RemoveTokenFallbackOptions): Promise<void>;
@@ -26,12 +26,3 @@ import { type RemoveTokenFallbackOptions } from './types';
26
26
  */
27
27
  export default function transformer(fileInfo: FileInfo, { jscodeshift: j }: API, options: RemoveTokenFallbackOptions): Promise<string>;
28
28
  export declare const parser = "tsx";
29
- /**
30
- * Function executed before all transformations to prepare the environment by clearing the report folder.
31
- */
32
- export declare function beforeAll(options: RemoveTokenFallbackOptions): Promise<void>;
33
- /**
34
- * Function executed after all transformations to combine individual file reports into a comprehensive transformation report.
35
- * It also applies prettier and eslint (to remove dangling suppressions) to the affected files.
36
- */
37
- export declare function afterAll(options: RemoveTokenFallbackOptions): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function clearFolder(reportFolder: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function colorToHex(color: string): string;
@@ -0,0 +1 @@
1
+ export declare function combineReports(reportFolder: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const compareHex: (hex: string, hex2: string) => number;
@@ -0,0 +1 @@
1
+ export declare function isValidColor(color: string): boolean;
@@ -1,4 +1,2 @@
1
1
  import { type TransformationDetails } from '../types';
2
- export declare function clearFolder(reportFolder: string): Promise<void>;
3
- export declare function combineReports(reportFolder: string): Promise<void>;
4
2
  export declare function writeReports(details: TransformationDetails, reportFolder: string): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { type ParsedPkg } from './types';
1
+ import type { ParsedPkg } from './types';
2
2
  /**
3
3
  * Returns packages that have been upgraded in package.json since ref. The version refers to their previous
4
4
  * version
@@ -54,7 +54,3 @@ export type ParsedPkg = {
54
54
  */
55
55
  export type Default<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
56
56
  export type ValidateShape<T, Shape> = T extends Shape ? Exclude<keyof T, keyof Shape> extends never ? T : never : never;
57
- export declare class ValidationError extends Error {
58
- }
59
- export declare class NoTransformsExistError extends Error {
60
- }
@@ -0,0 +1,2 @@
1
+ export declare class ValidationError extends Error {
2
+ }
@@ -0,0 +1,2 @@
1
+ import { type ParsedPath } from 'path';
2
+ export declare const getTransformModule: (transform: ParsedPath) => string;
@@ -0,0 +1,2 @@
1
+ import { type ParsedPath } from 'path';
2
+ export declare const getTransformPath: ({ dir, base }: ParsedPath) => string;
@@ -0,0 +1,2 @@
1
+ import { type ParsedPath } from 'path';
2
+ export declare const getTransformVersion: (transform: ParsedPath) => string;
@@ -0,0 +1,3 @@
1
+ import { type ParsedPath } from 'path';
2
+ import { type ParsedPkg } from './types';
3
+ export declare const getTransforms: (packages?: ParsedPkg[]) => ParsedPath[];
@@ -0,0 +1 @@
1
+ export declare const hasTransform: (transformPath: string) => boolean;
@@ -1,4 +1,3 @@
1
1
  export { default } from './main';
2
2
  export type { UserFlags } from './main';
3
- export { ValidationError, NoTransformsExistError } from './types';
4
3
  export type { Flags } from './types';
@@ -1,4 +1,4 @@
1
- import { type Default, type Flags } from './types';
1
+ import type { Default, Flags } from './types';
2
2
  declare const defaultFlags: {
3
3
  parser: 'babel';
4
4
  extensions: string;
@@ -0,0 +1,2 @@
1
+ export declare class NoTransformsExistError extends Error {
2
+ }
@@ -0,0 +1,2 @@
1
+ import path from 'path';
2
+ export declare const parseTransformPath: (transformPath: string) => path.ParsedPath;
@@ -0,0 +1,16 @@
1
+ export declare const mockDeprecatedIcons: {
2
+ deprecatedCore: {
3
+ '@atlaskit/icon/core/capture': {
4
+ message: string;
5
+ };
6
+ '@atlaskit/icon/core/chart-matrix': {
7
+ message: string;
8
+ };
9
+ '@atlaskit/icon/core/close': {
10
+ message: string;
11
+ };
12
+ '@atlaskit/icon/core/error': {
13
+ message: string;
14
+ };
15
+ };
16
+ };
@@ -57,19 +57,3 @@ export declare const mockMetadata: {
57
57
  };
58
58
  };
59
59
  };
60
- export declare const mockDeprecatedIcons: {
61
- deprecatedCore: {
62
- '@atlaskit/icon/core/capture': {
63
- message: string;
64
- };
65
- '@atlaskit/icon/core/chart-matrix': {
66
- message: string;
67
- };
68
- '@atlaskit/icon/core/close': {
69
- message: string;
70
- };
71
- '@atlaskit/icon/core/error': {
72
- message: string;
73
- };
74
- };
75
- };
@@ -0,0 +1 @@
1
+ export declare function createDefaultImportDeclaration(j: any, componentName: string, importPath: string): any;
@@ -0,0 +1,4 @@
1
+ export declare function getNewImportInfo(iconName: string, size: '16' | '24'): {
2
+ importPath: string;
3
+ componentName: string;
4
+ };
@@ -0,0 +1 @@
1
+ export declare function kebabToPascalCase(str: string): string;
@@ -0,0 +1,4 @@
1
+ export declare function parseIconObjectImport(importPath: string): {
2
+ iconName: string;
3
+ size: '16' | '24';
4
+ } | null;
@@ -1,6 +1 @@
1
- export declare const stylePropComment: ({ propName, prefix, }: {
2
- propName: string;
3
- prefix?: string;
4
- }) => string;
5
1
  export declare const spreadPropsComment = "This link could not be migrated due to usage of spread props. The codemod cannot determine the props being spread. Please manually migrate.";
6
- export declare const genericUnsupportedMigrationComment: (prefix?: string) => string;
@@ -0,0 +1 @@
1
+ export declare const genericUnsupportedMigrationComment: (prefix?: string) => string;
@@ -0,0 +1,4 @@
1
+ export declare const stylePropComment: ({ propName, prefix, }: {
2
+ propName: string;
3
+ prefix?: string;
4
+ }) => string;
@@ -0,0 +1,2 @@
1
+ import type { API, Collection } from 'jscodeshift';
2
+ export declare const checkIfVariantAlreadyImported: (variant: string, entryPoint: string, fileSource: Collection<any>, j: API["jscodeshift"], isDefaultSpecifier?: boolean) => boolean;
@@ -1,3 +1,2 @@
1
1
  import type { API, Collection } from 'jscodeshift';
2
2
  export declare const findVariantAlreadyImported: (variant: string, entryPoint: string, fileSource: Collection<any>, j: API["jscodeshift"], isDefaultSpecifier?: boolean) => Collection<any>;
3
- export declare const checkIfVariantAlreadyImported: (variant: string, entryPoint: string, fileSource: Collection<any>, j: API["jscodeshift"], isDefaultSpecifier?: boolean) => boolean;
@@ -1,3 +1,2 @@
1
1
  import { type API, type JSXElement } from 'jscodeshift';
2
- export declare const modifyLinkAttributes: (element: JSXElement, j: API['jscodeshift']) => void;
3
2
  export declare const generateLinkComponent: (element: JSXElement, j: API['jscodeshift']) => JSXElement | undefined;
@@ -0,0 +1,3 @@
1
+ import { type API, type JSXElement } from 'jscodeshift';
2
+ import { NEW_BUTTON_VARIANTS } from './constants';
3
+ export declare const generateNewElement: (variant: (typeof NEW_BUTTON_VARIANTS)[keyof typeof NEW_BUTTON_VARIANTS], element: JSXElement, j: API['jscodeshift']) => JSXElement;
@@ -0,0 +1,2 @@
1
+ import { type JSXAttribute, type JSXSpreadAttribute } from 'jscodeshift';
2
+ export declare const getIconAttributes: (attributes: (JSXAttribute | JSXSpreadAttribute)[]) => JSXAttribute[] | null;
@@ -0,0 +1,2 @@
1
+ import { type JSXAttribute, type JSXElement } from 'jscodeshift';
2
+ export declare const getIconElement: (iconAttr: JSXAttribute) => JSXElement | null;
@@ -0,0 +1,2 @@
1
+ import { type API, type JSXElement } from 'jscodeshift';
2
+ export declare const handleIconAttributes: (element: JSXElement, j: API['jscodeshift'], iconRenamed?: boolean) => void;
@@ -0,0 +1,2 @@
1
+ import { type API, type JSXElement } from 'jscodeshift';
2
+ export declare const modifyButtonAttributes: (element: JSXElement, j: API['jscodeshift'], hasSpacingNone: boolean) => void;
@@ -0,0 +1,2 @@
1
+ import { type API, type JSXElement } from 'jscodeshift';
2
+ export declare const modifyLinkAttributes: (element: JSXElement, j: API['jscodeshift']) => void;
@@ -0,0 +1,2 @@
1
+ import { type RemoveTokenFallbackOptions } from './types';
2
+ export declare function afterAll(options: RemoveTokenFallbackOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { type RemoveTokenFallbackOptions } from './types';
2
+ export declare function beforeAll(options: RemoveTokenFallbackOptions): Promise<void>;
@@ -26,12 +26,3 @@ import { type RemoveTokenFallbackOptions } from './types';
26
26
  */
27
27
  export default function transformer(fileInfo: FileInfo, { jscodeshift: j }: API, options: RemoveTokenFallbackOptions): Promise<string>;
28
28
  export declare const parser = "tsx";
29
- /**
30
- * Function executed before all transformations to prepare the environment by clearing the report folder.
31
- */
32
- export declare function beforeAll(options: RemoveTokenFallbackOptions): Promise<void>;
33
- /**
34
- * Function executed after all transformations to combine individual file reports into a comprehensive transformation report.
35
- * It also applies prettier and eslint (to remove dangling suppressions) to the affected files.
36
- */
37
- export declare function afterAll(options: RemoveTokenFallbackOptions): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function clearFolder(reportFolder: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function colorToHex(color: string): string;
@@ -0,0 +1 @@
1
+ export declare function combineReports(reportFolder: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const compareHex: (hex: string, hex2: string) => number;
@@ -0,0 +1 @@
1
+ export declare function isValidColor(color: string): boolean;
@@ -1,4 +1,2 @@
1
1
  import { type TransformationDetails } from '../types';
2
- export declare function clearFolder(reportFolder: string): Promise<void>;
3
- export declare function combineReports(reportFolder: string): Promise<void>;
4
2
  export declare function writeReports(details: TransformationDetails, reportFolder: string): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { type ParsedPkg } from './types';
1
+ import type { ParsedPkg } from './types';
2
2
  /**
3
3
  * Returns packages that have been upgraded in package.json since ref. The version refers to their previous
4
4
  * version
@@ -54,7 +54,3 @@ export type ParsedPkg = {
54
54
  */
55
55
  export type Default<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
56
56
  export type ValidateShape<T, Shape> = T extends Shape ? Exclude<keyof T, keyof Shape> extends never ? T : never : never;
57
- export declare class ValidationError extends Error {
58
- }
59
- export declare class NoTransformsExistError extends Error {
60
- }
@@ -0,0 +1,2 @@
1
+ export declare class ValidationError extends Error {
2
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.34.8",
3
+ "version": "1.0.0",
4
4
  "description": "A cli for distributing codemods for atlassian-frontend components and services",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,9 +29,9 @@
29
29
  "bin": "./bin/codemod-cli.js",
30
30
  "dependencies": {
31
31
  "@atlaskit/codemod-utils": "^4.2.0",
32
- "@atlaskit/icon": "^33.0.0",
33
- "@atlaskit/icon-lab": "^6.0.0",
34
- "@atlaskit/tokens": "^11.1.0",
32
+ "@atlaskit/icon": "^34.0.0",
33
+ "@atlaskit/icon-lab": "^6.4.0",
34
+ "@atlaskit/tokens": "^11.4.0",
35
35
  "@babel/runtime": "^7.0.0",
36
36
  "@codeshift/utils": "^0.2.4",
37
37
  "@hypermod/utils": "^0.4.2",
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createDefaultImportDeclaration = createDefaultImportDeclaration;
8
- exports.getNewImportInfo = getNewImportInfo;
9
- exports.kebabToPascalCase = kebabToPascalCase;
10
- exports.parseIconObjectImport = parseIconObjectImport;
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _constants = require("./constants");
13
- /* eslint-disable @repo/internal/fs/filename-pattern-match */
14
-
15
- /**
16
- * Converts a kebab-case string to PascalCase
17
- * @param str - The kebab-case string (e.g., 'new-feature', 'work-item')
18
- * @returns PascalCase string (e.g., 'NewFeature', 'WorkItem')
19
- */
20
- function kebabToPascalCase(str) {
21
- return str.split('-').map(function (word) {
22
- return word.charAt(0).toUpperCase() + word.slice(1);
23
- }).join('');
24
- }
25
-
26
- /**
27
- * Extracts icon name and size from an icon-object import path
28
- * @param importPath - The import path like '@atlaskit/icon-object/glyph/new-feature/16'
29
- * @returns Object with iconName and size, or null if not a valid icon-object import
30
- */
31
- function parseIconObjectImport(importPath) {
32
- var match = importPath.match(/^@atlaskit\/icon-object\/glyph\/([^/]+)\/(16|24)$/);
33
- if (!match) {
34
- return null;
35
- }
36
- var _match = (0, _slicedToArray2.default)(match, 3),
37
- iconName = _match[1],
38
- size = _match[2];
39
-
40
- // Check if this is a valid icon name we support
41
- if (!_constants.AVAILABLE_ICON_NAMES.includes(iconName)) {
42
- return null;
43
- }
44
- return {
45
- iconName: iconName,
46
- size: size
47
- };
48
- }
49
-
50
- /**
51
- * Gets the new import specifier for an icon based on its name and size
52
- * @param iconName - The kebab-case icon name from icon-object (e.g., 'new-feature', 'issue')
53
- * @param size - The size ('16' or '24')
54
- * @returns Object with the new import path and component name
55
- */
56
- function getNewImportInfo(iconName, size) {
57
- // Check if this icon name needs to be mapped to a different object name
58
- var objectName = _constants.ICON_TO_OBJECT_NAME_MAPPINGS[iconName] || iconName;
59
-
60
- // Convert the object name to PascalCase
61
- var pascalCaseName = kebabToPascalCase(objectName);
62
- if (size === '16') {
63
- return {
64
- importPath: "@atlaskit/object/".concat(objectName),
65
- componentName: "".concat(pascalCaseName, "Object")
66
- };
67
- } else {
68
- return {
69
- importPath: "@atlaskit/object/tile/".concat(objectName),
70
- componentName: "".concat(pascalCaseName, "ObjectTile")
71
- };
72
- }
73
- }
74
-
75
- /**
76
- * Creates a new default import declaration for the transformed component
77
- */
78
- function createDefaultImportDeclaration(j, componentName, importPath) {
79
- var defaultSpecifier = j.importDefaultSpecifier(j.identifier(componentName));
80
- return j.importDeclaration([defaultSpecifier], j.stringLiteral(importPath));
81
- }
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.modifyButtonAttributes = exports.handleIconAttributes = exports.getIconElement = exports.getIconAttributes = exports.generateNewElement = void 0;
7
- var _constants = require("../utils/constants");
8
- var getIconAttributes = exports.getIconAttributes = function getIconAttributes(attributes) {
9
- var iconAttr = attributes === null || attributes === void 0 ? void 0 : attributes.filter(function (attribute) {
10
- return attribute.type === 'JSXAttribute' && (attribute.name.name === 'iconBefore' || attribute.name.name === 'iconAfter');
11
- });
12
- if (iconAttr !== null && iconAttr !== void 0 && iconAttr.length) {
13
- return iconAttr;
14
- }
15
- return null;
16
- };
17
- var getIconElement = exports.getIconElement = function getIconElement(iconAttr) {
18
- var _iconAttr$value;
19
- if (iconAttr && ((_iconAttr$value = iconAttr.value) === null || _iconAttr$value === void 0 ? void 0 : _iconAttr$value.type) === 'JSXExpressionContainer' && iconAttr.value.expression.type === 'JSXElement') {
20
- return iconAttr.value.expression;
21
- }
22
- return null;
23
- };
24
-
25
- /**
26
- * We need to do a couple of things here:
27
- *
28
- * 1. If an icon attribute has a label, elevate it to the root button element
29
- * 2. If an icon doesn't have any other attributes, move to bounded API:
30
- * {<MoreIcon />} -> {MoreIcon}
31
- * 3. If an icon has attributes other than label, move to renderProp:
32
- * {<MoreIcon primaryColor />} -> {() => <MoreIcon primaryColor />}
33
- *
34
- * @param element
35
- * @param j
36
- * @param iconRenamed
37
- */
38
- var handleIconAttributes = exports.handleIconAttributes = function handleIconAttributes(element, j) {
39
- var iconRenamed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
40
- var buttonAttributes = element.openingElement.attributes;
41
- // Get iconBefore and iconAfter attributes
42
- var buttonIconAttributes = buttonAttributes && getIconAttributes(buttonAttributes);
43
- buttonIconAttributes === null || buttonIconAttributes === void 0 || buttonIconAttributes.forEach(function (iconAttribute) {
44
- var iconElement = getIconElement(iconAttribute);
45
- if (!iconElement) {
46
- return;
47
- }
48
- var iconAttributes = iconElement.openingElement.attributes;
49
- if (!Array.isArray(iconAttributes)) {
50
- return;
51
- }
52
-
53
- // 1. Move label to root button element, only if label doesn't exist already. Button label
54
- // takes precedence over icon label.
55
-
56
- var buttonAlreadyHasLabelProp = buttonAttributes === null || buttonAttributes === void 0 ? void 0 : buttonAttributes.find(function (buttonAttribute) {
57
- return buttonAttribute.type === 'JSXAttribute' && buttonAttribute.name.name === 'label';
58
- });
59
- var buttonAlreadyHasAriaLabelProp = buttonAttributes === null || buttonAttributes === void 0 ? void 0 : buttonAttributes.find(function (buttonAttribute) {
60
- return buttonAttribute.type === 'JSXAttribute' && buttonAttribute.name.name === 'aria-label';
61
- });
62
- if (!buttonAlreadyHasLabelProp && !buttonAlreadyHasAriaLabelProp) {
63
- var labelAttribute = iconAttributes.find(function (attribute) {
64
- return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
65
- });
66
- if (labelAttribute && labelAttribute.type === 'JSXAttribute' && iconRenamed) {
67
- buttonAttributes === null || buttonAttributes === void 0 || buttonAttributes.unshift(labelAttribute);
68
- }
69
- }
70
-
71
- // 2. If there are any other props on icon, move to render prop
72
- var attributesOtherThanLabelOrMediumSize = iconAttributes.filter(function (iconAttribute) {
73
- var _iconAttribute$value, _iconAttribute$value2;
74
- // Exclude size="medium"
75
- 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') {
76
- return false;
77
- }
78
-
79
- // Exclude label
80
- if (iconAttribute.type === 'JSXAttribute' && iconAttribute.name.name === 'label') {
81
- return false;
82
- }
83
- return true;
84
- });
85
- if (attributesOtherThanLabelOrMediumSize.length > 0) {
86
- // Move to render prop: `<MoreIcon primaryColor />` -> `(props) => <MoreIcon {...props} primaryColor />`
87
-
88
- // Remove label and size="medium" attributes
89
- j(iconElement.openingElement).find(j.JSXAttribute).filter(function (attribute) {
90
- 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;
91
- }).remove();
92
-
93
- // Add spread props
94
- iconAttributes.unshift(j.jsxSpreadAttribute(j.identifier('iconProps')));
95
-
96
- // Create new arrow function (renderProp)
97
- iconAttribute.value = j.jsxExpressionContainer(j.arrowFunctionExpression.from({
98
- params: [j.identifier('iconProps')],
99
- body: iconElement,
100
- expression: true
101
- }));
102
- } else {
103
- var _iconAttribute$value3;
104
- // Move to bounded API: {<MoreIcon />} => {MoreIcon}
105
- if (iconElement.openingElement.name.type === 'JSXIdentifier' && ((_iconAttribute$value3 = iconAttribute.value) === null || _iconAttribute$value3 === void 0 ? void 0 : _iconAttribute$value3.type) === 'JSXExpressionContainer') {
106
- iconAttribute.value.expression = j.identifier(iconElement.openingElement.name.name);
107
- }
108
- }
109
- });
110
- };
111
- var generateNewElement = exports.generateNewElement = function generateNewElement(variant, element, j) {
112
- var attributes = element.openingElement.attributes;
113
- var iconAttrs = attributes && getIconAttributes(attributes);
114
- var isIconOrLinkIcon = variant === _constants.NEW_BUTTON_VARIANTS.icon || variant === _constants.NEW_BUTTON_VARIANTS.linkIcon;
115
- if (variant === _constants.NEW_BUTTON_VARIANTS.link) {
116
- j(element).find(j.JSXAttribute).filter(function (path) {
117
- var _path$node$value;
118
- 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');
119
- }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
120
- }
121
- if (isIconOrLinkIcon && iconAttrs !== null && iconAttrs !== void 0 && iconAttrs.length) {
122
- handleIconAttributes(element, j, true);
123
-
124
- // rename iconBefore/iconAfter to icon
125
- iconAttrs[0].name.name = 'icon';
126
- var ariaLabelAttr = j(element.openingElement).find(j.JSXAttribute).filter(function (attribute) {
127
- return attribute.node.name.name === 'aria-label';
128
- });
129
- if (ariaLabelAttr.length) {
130
- var hasNoLabelProp = !(attributes !== null && attributes !== void 0 && attributes.find(function (attribute) {
131
- return attribute.type === 'JSXAttribute' && attribute.name.name === 'label';
132
- }));
133
- if (hasNoLabelProp && attributes) {
134
- attributes.unshift(j.jsxAttribute.from({
135
- name: j.jsxIdentifier('label'),
136
- value: j.literal(ariaLabelAttr.get().value.value.value)
137
- }));
138
- }
139
- ariaLabelAttr.remove();
140
- }
141
- }
142
- return j.jsxElement.from({
143
- openingElement: j.jsxOpeningElement(j.jsxIdentifier(variant), attributes, isIconOrLinkIcon),
144
- // self closing if it's an icon button or icon link button
145
- closingElement: isIconOrLinkIcon ? null : j.jsxClosingElement(j.jsxIdentifier(variant)),
146
- children: element.children
147
- });
148
- };
149
- var modifyButtonAttributes = exports.modifyButtonAttributes = function modifyButtonAttributes(element, j, hasSpacingNone) {
150
- j(element).find(j.JSXAttribute).filter(function (path) {
151
- var _path$node$value2;
152
- 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');
153
- }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
154
- if (hasSpacingNone) {
155
- j(element).find(j.JSXAttribute).filter(function (path) {
156
- var _path$node$value3;
157
- 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';
158
- }).remove();
159
- }
160
- };