@atlaskit/codemod-cli 0.34.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/cli.js +4 -3
- package/dist/cjs/get-transform-module.js +14 -0
- package/dist/cjs/get-transform-path.js +11 -0
- package/dist/cjs/get-transform-version.js +16 -0
- package/dist/cjs/{transforms.js → get-transforms.js} +19 -45
- package/dist/cjs/has-transform.js +10 -0
- package/dist/cjs/index.js +1 -14
- package/dist/cjs/main.js +18 -13
- package/dist/cjs/no-transforms-exist-error.js +23 -0
- package/dist/cjs/parse-transform-path.js +11 -0
- package/dist/cjs/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +22 -0
- package/dist/cjs/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +1 -17
- package/dist/cjs/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +6 -4
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +12 -0
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +28 -0
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +13 -0
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +29 -0
- package/dist/cjs/presets/migrate-to-link/codemods/migrate-to-link.js +4 -2
- package/dist/cjs/presets/migrate-to-link/utils/comments.js +2 -13
- package/dist/cjs/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +11 -0
- package/dist/cjs/presets/migrate-to-link/utils/style-prop-comment.js +12 -0
- package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +2 -2
- package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +18 -16
- package/dist/cjs/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +11 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +1 -5
- package/dist/cjs/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +3 -12
- package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-element.js +47 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +15 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/get-icon-element.js +13 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +81 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +4 -3
- package/dist/cjs/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +18 -0
- package/dist/cjs/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +16 -0
- package/dist/cjs/presets/remove-token-fallbacks/after-all.js +337 -0
- package/dist/cjs/presets/remove-token-fallbacks/before-all.js +33 -0
- package/dist/cjs/presets/remove-token-fallbacks/remove-token-fallbacks.js +4 -360
- package/dist/cjs/presets/remove-token-fallbacks/utils/clear-folder.js +68 -0
- package/dist/cjs/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -37
- package/dist/cjs/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +59 -182
- package/dist/cjs/presets/remove-token-fallbacks/utils/compare-hex.js +25 -0
- package/dist/cjs/presets/remove-token-fallbacks/utils/is-valid-color.js +41 -0
- package/dist/cjs/presets/remove-token-fallbacks/utils/normalize-values.js +8 -6
- package/dist/cjs/presets/remove-token-fallbacks/utils/write-reports.js +83 -0
- package/dist/cjs/sinceRef.js +2 -2
- package/dist/cjs/types.js +1 -31
- package/dist/cjs/validation-error.js +23 -0
- package/dist/es2019/cli.js +2 -1
- package/dist/es2019/get-transform-module.js +7 -0
- package/dist/es2019/get-transform-path.js +4 -0
- package/dist/es2019/get-transform-version.js +9 -0
- package/dist/es2019/{transforms.js → get-transforms.js} +10 -31
- package/dist/es2019/has-transform.js +2 -0
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/main.js +7 -2
- package/dist/es2019/no-transforms-exist-error.js +1 -0
- package/dist/es2019/parse-transform-path.js +2 -0
- package/dist/es2019/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +16 -0
- package/dist/es2019/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +0 -16
- package/dist/es2019/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +3 -1
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +6 -0
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +22 -0
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +5 -0
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +19 -0
- package/dist/es2019/presets/migrate-to-link/codemods/migrate-to-link.js +3 -1
- package/dist/es2019/presets/migrate-to-link/utils/comments.js +1 -11
- package/dist/es2019/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +4 -0
- package/dist/es2019/presets/migrate-to-link/utils/style-prop-comment.js +6 -0
- package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +1 -1
- package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +5 -3
- package/dist/es2019/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +4 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +0 -3
- package/dist/es2019/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +1 -10
- package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-element.js +39 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +7 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/get-icon-element.js +7 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +68 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +2 -1
- package/dist/es2019/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +12 -0
- package/dist/es2019/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +10 -0
- package/dist/es2019/presets/remove-token-fallbacks/after-all.js +139 -0
- package/dist/es2019/presets/remove-token-fallbacks/before-all.js +8 -0
- package/dist/es2019/presets/remove-token-fallbacks/remove-token-fallbacks.js +2 -150
- package/dist/es2019/presets/remove-token-fallbacks/utils/clear-folder.js +15 -0
- package/dist/es2019/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -34
- package/dist/es2019/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +1 -50
- package/dist/es2019/presets/remove-token-fallbacks/utils/compare-hex.js +17 -0
- package/dist/es2019/presets/remove-token-fallbacks/utils/is-valid-color.js +35 -0
- package/dist/es2019/presets/remove-token-fallbacks/utils/normalize-values.js +3 -1
- package/dist/es2019/presets/remove-token-fallbacks/utils/write-reports.js +41 -0
- package/dist/es2019/sinceRef.js +1 -1
- package/dist/es2019/types.js +1 -7
- package/dist/es2019/validation-error.js +1 -0
- package/dist/esm/cli.js +2 -1
- package/dist/esm/get-transform-module.js +7 -0
- package/dist/esm/get-transform-path.js +5 -0
- package/dist/esm/get-transform-version.js +9 -0
- package/dist/esm/{transforms.js → get-transforms.js} +16 -42
- package/dist/esm/has-transform.js +4 -0
- package/dist/esm/index.js +1 -2
- package/dist/esm/main.js +8 -3
- package/dist/esm/no-transforms-exist-error.js +16 -0
- package/dist/esm/parse-transform-path.js +4 -0
- package/dist/esm/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.js +16 -0
- package/dist/esm/presets/migrate-deprecated-icon/utils/{mock.js → mock-metadata.js} +0 -16
- package/dist/esm/presets/migrate-icon-object-to-object/codemods/migrate-icon-object-to-object.js +3 -1
- package/dist/esm/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.js +6 -0
- package/dist/esm/presets/migrate-icon-object-to-object/utils/get-new-import-info.js +22 -0
- package/dist/esm/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.js +7 -0
- package/dist/esm/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.js +22 -0
- package/dist/esm/presets/migrate-to-link/codemods/migrate-to-link.js +3 -1
- package/dist/esm/presets/migrate-to-link/utils/comments.js +1 -12
- package/dist/esm/presets/migrate-to-link/utils/generic-unsupported-migration-comment.js +5 -0
- package/dist/esm/presets/migrate-to-link/utils/style-prop-comment.js +6 -0
- package/dist/esm/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +1 -1
- package/dist/esm/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +5 -3
- package/dist/esm/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.js +5 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.js → find-variant-already-imported.js} +0 -4
- package/dist/esm/presets/migrate-to-new-buttons/utils/{generate-link-element.js → generate-link-component.js} +1 -10
- package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-element.js +41 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/get-icon-attributes.js +9 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/get-icon-element.js +7 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/handle-icon-attributes.js +75 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/migrate-fit-container-icon-button.js +2 -1
- package/dist/esm/presets/migrate-to-new-buttons/utils/modify-button-attributes.js +12 -0
- package/dist/esm/presets/migrate-to-new-buttons/utils/modify-link-attributes.js +10 -0
- package/dist/esm/presets/remove-token-fallbacks/after-all.js +331 -0
- package/dist/esm/presets/remove-token-fallbacks/before-all.js +27 -0
- package/dist/esm/presets/remove-token-fallbacks/remove-token-fallbacks.js +2 -357
- package/dist/esm/presets/remove-token-fallbacks/utils/clear-folder.js +62 -0
- package/dist/esm/presets/remove-token-fallbacks/utils/{color-utils.js → color-to-hex.js} +0 -36
- package/dist/esm/presets/remove-token-fallbacks/utils/{reporter.js → combine-reports.js} +57 -180
- package/dist/esm/presets/remove-token-fallbacks/utils/compare-hex.js +19 -0
- package/dist/esm/presets/remove-token-fallbacks/utils/is-valid-color.js +35 -0
- package/dist/esm/presets/remove-token-fallbacks/utils/normalize-values.js +3 -1
- package/dist/esm/presets/remove-token-fallbacks/utils/write-reports.js +75 -0
- package/dist/esm/sinceRef.js +1 -1
- package/dist/esm/types.js +1 -29
- package/dist/esm/validation-error.js +16 -0
- package/dist/types/get-transform-module.d.ts +2 -0
- package/dist/types/get-transform-path.d.ts +2 -0
- package/dist/types/get-transform-version.d.ts +2 -0
- package/dist/types/get-transforms.d.ts +3 -0
- package/dist/types/has-transform.d.ts +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/main.d.ts +1 -1
- package/dist/types/no-transforms-exist-error.d.ts +2 -0
- package/dist/types/parse-transform-path.d.ts +2 -0
- package/dist/types/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.d.ts +16 -0
- package/dist/types/presets/migrate-deprecated-icon/utils/{mock.d.ts → mock-metadata.d.ts} +0 -16
- package/dist/types/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.d.ts +1 -0
- package/dist/types/presets/migrate-icon-object-to-object/utils/get-new-import-info.d.ts +4 -0
- package/dist/types/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.d.ts +1 -0
- package/dist/types/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.d.ts +4 -0
- package/dist/types/presets/migrate-to-link/utils/comments.d.ts +0 -5
- package/dist/types/presets/migrate-to-link/utils/generic-unsupported-migration-comment.d.ts +1 -0
- package/dist/types/presets/migrate-to-link/utils/style-prop-comment.d.ts +4 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/{if-variant-already-imported.d.ts → find-variant-already-imported.d.ts} +0 -1
- package/dist/types/presets/migrate-to-new-buttons/utils/{generate-link-element.d.ts → generate-link-component.d.ts} +0 -1
- package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-element.d.ts +3 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/get-icon-attributes.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/get-icon-element.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/handle-icon-attributes.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/modify-button-attributes.d.ts +2 -0
- package/dist/types/presets/migrate-to-new-buttons/utils/modify-link-attributes.d.ts +2 -0
- package/dist/types/presets/remove-token-fallbacks/after-all.d.ts +2 -0
- package/dist/types/presets/remove-token-fallbacks/before-all.d.ts +2 -0
- package/dist/types/presets/remove-token-fallbacks/remove-token-fallbacks.d.ts +0 -9
- package/dist/types/presets/remove-token-fallbacks/utils/clear-folder.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/color-to-hex.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/combine-reports.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/compare-hex.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/is-valid-color.d.ts +1 -0
- package/dist/types/presets/remove-token-fallbacks/utils/{reporter.d.ts → write-reports.d.ts} +0 -2
- package/dist/types/sinceRef.d.ts +1 -1
- package/dist/types/types.d.ts +0 -4
- package/dist/types/validation-error.d.ts +2 -0
- package/dist/types-ts4.5/get-transform-module.d.ts +2 -0
- package/dist/types-ts4.5/get-transform-path.d.ts +2 -0
- package/dist/types-ts4.5/get-transform-version.d.ts +2 -0
- package/dist/types-ts4.5/get-transforms.d.ts +3 -0
- package/dist/types-ts4.5/has-transform.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/main.d.ts +1 -1
- package/dist/types-ts4.5/no-transforms-exist-error.d.ts +2 -0
- package/dist/types-ts4.5/parse-transform-path.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-deprecated-icon/utils/mock-deprecated-icons.d.ts +16 -0
- package/dist/types-ts4.5/presets/migrate-deprecated-icon/utils/{mock.d.ts → mock-metadata.d.ts} +0 -16
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/create-default-import-declaration.d.ts +1 -0
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/get-new-import-info.d.ts +4 -0
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.d.ts +1 -0
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/parse-icon-object-import.d.ts +4 -0
- package/dist/types-ts4.5/presets/migrate-to-link/utils/comments.d.ts +0 -5
- package/dist/types-ts4.5/presets/migrate-to-link/utils/generic-unsupported-migration-comment.d.ts +1 -0
- package/dist/types-ts4.5/presets/migrate-to-link/utils/style-prop-comment.d.ts +4 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/check-if-variant-already-imported.d.ts +2 -0
- 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
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/{generate-link-element.d.ts → generate-link-component.d.ts} +0 -1
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-element.d.ts +3 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/get-icon-attributes.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/get-icon-element.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/handle-icon-attributes.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/modify-button-attributes.d.ts +2 -0
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/modify-link-attributes.d.ts +2 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/after-all.d.ts +2 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/before-all.d.ts +2 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/remove-token-fallbacks.d.ts +0 -9
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/clear-folder.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/color-to-hex.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/combine-reports.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/compare-hex.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/is-valid-color.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/{reporter.d.ts → write-reports.d.ts} +0 -2
- package/dist/types-ts4.5/sinceRef.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +0 -4
- package/dist/types-ts4.5/validation-error.d.ts +2 -0
- package/package.json +3 -3
- package/dist/cjs/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -81
- package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -160
- package/dist/es2019/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -67
- package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -143
- package/dist/esm/presets/migrate-icon-object-to-object/utils/icon-mappings.js +0 -72
- package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +0 -154
- package/dist/types/presets/migrate-icon-object-to-object/utils/icon-mappings.d.ts +0 -29
- package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +0 -20
- package/dist/types/presets/remove-token-fallbacks/utils/color-utils.d.ts +0 -3
- package/dist/types/transforms.d.ts +0 -11
- package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/icon-mappings.d.ts +0 -29
- package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +0 -20
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/color-utils.d.ts +0 -3
- package/dist/types-ts4.5/transforms.d.ts +0 -11
- 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;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|
package/dist/types/presets/remove-token-fallbacks/utils/{reporter.d.ts → write-reports.d.ts}
RENAMED
|
@@ -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>;
|
package/dist/types/sinceRef.d.ts
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -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 @@
|
|
|
1
|
+
export declare const hasTransform: (transformPath: string) => boolean;
|
|
@@ -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
|
+
};
|
package/dist/types-ts4.5/presets/migrate-deprecated-icon/utils/{mock.d.ts → mock-metadata.d.ts}
RENAMED
|
@@ -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;
|
package/dist/types-ts4.5/presets/migrate-icon-object-to-object/utils/kebab-to-pascal-case.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function kebabToPascalCase(str: string): string;
|
|
@@ -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;
|
package/dist/types-ts4.5/presets/migrate-to-link/utils/generic-unsupported-migration-comment.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const genericUnsupportedMigrationComment: (prefix?: string) => string;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|
package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/{reporter.d.ts → write-reports.d.ts}
RENAMED
|
@@ -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>;
|
|
@@ -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
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/codemod-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A cli for distributing codemods for atlassian-frontend components and services",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
32
32
|
"@atlaskit/icon": "^34.0.0",
|
|
33
|
-
"@atlaskit/icon-lab": "^6.
|
|
34
|
-
"@atlaskit/tokens": "^
|
|
33
|
+
"@atlaskit/icon-lab": "^6.4.0",
|
|
34
|
+
"@atlaskit/tokens": "^12.0.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
|
-
};
|