{"id":13533777,"url":"https://github.com/ant-design/codemod-v5","last_synced_at":"2025-04-19T17:16:30.478Z","repository":{"id":63937410,"uuid":"569520550","full_name":"ant-design/codemod-v5","owner":"ant-design","description":"codemod cli for antd v5 upgrade","archived":false,"fork":false,"pushed_at":"2023-04-19T06:03:40.000Z","size":194,"stargazers_count":18,"open_issues_count":10,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T14:41:01.871Z","etag":null,"topics":["ant-design-v5","antd","antd-design","codemod","jscodeshift","postcss"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ant-design.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-11-23T02:26:42.000Z","updated_at":"2025-02-20T07:06:32.000Z","dependencies_parsed_at":"2024-01-14T01:09:30.798Z","dependency_job_id":"a919fb67-203c-413f-a6e1-803a9e76a444","html_url":"https://github.com/ant-design/codemod-v5","commit_stats":{"total_commits":54,"total_committers":3,"mean_commits":18.0,"dds":"0.42592592592592593","last_synced_commit":"c959664834ac338394d2c3ff16690953ed6c5167"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ant-design%2Fcodemod-v5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ant-design%2Fcodemod-v5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ant-design%2Fcodemod-v5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ant-design%2Fcodemod-v5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ant-design","download_url":"https://codeload.github.com/ant-design/codemod-v5/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249228271,"owners_count":21233852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ant-design-v5","antd","antd-design","codemod","jscodeshift","postcss"],"created_at":"2024-08-01T07:01:23.007Z","updated_at":"2025-04-16T10:31:40.938Z","avatar_url":"https://github.com/ant-design.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["ant-design"],"readme":"English | [简体中文](./README.zh-CN.md)\n\n# Ant Design v5 Codemod\n\nA collection of codemod scripts that help upgrade antd v5 using [jscodeshift](https://github.com/facebook/jscodeshift) and [postcss](https://github.com/postcss/postcss).(Inspired by [react-codemod](https://github.com/reactjs/react-codemod))\n\n[![NPM version](https://img.shields.io/npm/v/@ant-design/codemod-v5.svg?style=flat)](https://npmjs.org/package/@ant-design/codemod-v5) [![NPM downloads](http://img.shields.io/npm/dm/@ant-design/codemod-v5.svg?style=flat)](https://npmjs.org/package/@ant-design/codemod-v5) [![Github Action](https://github.com/ant-design/codemod-v5/actions/workflows/test.yml/badge.svg)](https://github.com/ant-design/codemod-v5/actions/workflows/test.yml)\n\n## Usage\n\nBefore run codemod scripts, you'd better make sure to commit your local git changes firstly.\n\n```shell\n# Run directly through npx\nnpx -p @ant-design/codemod-v5 antd5-codemod src\n\n# Or run directly through pnpm\npnpm --package=@ant-design/codemod-v5 dlx antd5-codemod src\n```\n\n## Codemod scripts introduction\n\n#### `v5-removed-component-migration`\n\nReplace import for removed component in v5.\n\n- Change `Comment` import from `@ant-design/compatible`.\n- Change `PageHeader` import from `@ant-design/pro-layout`.\n- Use `BackTop` from `FloatButton.BackTop`.\n\n```diff\n- import { Avatar, BackTop, Comment, PageHeader } from 'antd';\n+ import { Comment } from '@ant-design/compatible';\n+ import { PageHeader } from '@ant-design/pro-layout';\n+ import { Avatar, FloatButton } from 'antd';\n\n  ReactDOM.render( (\n    \u003cdiv\u003e\n      \u003cPageHeader\n        className=\"site-page-header\"\n        onBack={() =\u003e null}\n        title=\"Title\"\n        subTitle=\"This is a subtitle\"\n      /\u003e\n      \u003cComment\n        actions={actions}\n        author={\u003ca\u003eHan Solo\u003c/a\u003e}\n        avatar={\u003cAvatar src=\"https://joeschmoe.io/api/v1/random\" alt=\"Han Solo\" /\u003e}\n        content={\n          \u003cp\u003e\n            We supply a series of design principles, practical patterns and high quality design\n            resources (Sketch and Axure), to help people create their product prototypes beautifully\n            and efficiently.\n          \u003c/p\u003e\n        }\n        datetime={\n          \u003cspan title=\"2016-11-22 11:22:33\"\u003e8 hours ago\u003c/span\u003e\n        }\n      /\u003e\n-     \u003cBackTop /\u003e\n+     \u003cFloatButton.BackTop /\u003e\n    \u003c/div\u003e\n  );\n```\n\n#### `v5-props-changed-migration`\n\nChange props usage from v4 to v5.\n\n```diff\nimport { Tag, Modal, Slider } from 'antd';\n\nconst App = () =\u003e {\n  const [visible, setVisible] = useState(false);\n\n  return (\n    \u003c\u003e\n-     \u003cTag\n-       visible={visible}\n-     /\u003e\n+     {visible ? \u003cTag /\u003e : null}\n      \u003cModal\n-       visible={visible}\n+       open={visible}\n      /\u003e\n-     \u003cSlider tooltipVisible={visible} tooltipPlacement=\"bottomLeft\" /\u003e\n+     \u003cSlider tooltip={{ placement: \"bottomLeft\", open: visible }} /\u003e\n    \u003c/\u003e\n  );\n};\n```\n\n#### `v5-removed-static-method-migration`\n\n* Replace `message.warn` with `message.warning`.\n* Replace `notification.close` with `notification.destroy`.\n\n```diff\nimport { message, notification } from 'antd';\n\nconst App = () =\u003e {\n  const [messageApi, contextHolder] = message.useMessage();\n  const onClick1 = () =\u003e {\n-   message.warn();\n+   message.warning();\n  }\n  const onClick2 = () =\u003e {\n-   messageApi.warn();\n+   messageApi.warning();\n  };\n\n  const [notificationApi] = notification.useNotification();\n  const onClick3 = () =\u003e {\n-   notification.close();\n+   notification.destroy();\n  }\n  const onClick4 = () =\u003e {\n-   notificationApi.close();\n+   notificationApi.destroy();\n  };\n\n  return \u003c\u003e{contextHolder}\u003c/\u003e;\n};\n```\n\n#### `v5-remove-style-import`\n\nComment out the style file import from antd (in js file).\n\n```diff\n- import 'antd/es/auto-complete/style';\n- import 'antd/lib/button/style/index.less';\n- import 'antd/dist/antd.compact.min.css';\n+ // import 'antd/es/auto-complete/style';\n+ // import 'antd/lib/button/style/index.less';\n+ // import 'antd/dist/antd.compact.min.css';\n```\n\n#### `Remove Antd Less` in less file\n\nComment out the style file import from antd in less file.\n\n```diff\n- @import (reference) '~antd/dist/antd.less';\n- @import '~antd/es/button/style/index.less';\n+ /* @import (reference) '~antd/dist/antd.less'; */\n+ /* @import '~antd/es/button/style/index.less'; */\n@import './styles.less';\n\nbody {\n  font-size: 14px;\n}\n```\n\n## Development\n\n```bash\n  npm run release\n  npm publish\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fant-design%2Fcodemod-v5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fant-design%2Fcodemod-v5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fant-design%2Fcodemod-v5/lists"}