{"id":13533761,"url":"https://github.com/ant-design/codemod-v4","last_synced_at":"2025-04-08T04:17:58.602Z","repository":{"id":50741062,"uuid":"221335429","full_name":"ant-design/codemod-v4","owner":"ant-design","description":"codemod cli for antd v4 upgrade","archived":false,"fork":false,"pushed_at":"2022-11-24T15:57:56.000Z","size":165,"stargazers_count":98,"open_issues_count":55,"forks_count":26,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-01T00:01:44.829Z","etag":null,"topics":["antd","antd4","cli","codemod","jscodeshift"],"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}},"created_at":"2019-11-13T00:00:29.000Z","updated_at":"2025-03-18T08:44:03.000Z","dependencies_parsed_at":"2023-01-22T15:16:04.057Z","dependency_job_id":null,"html_url":"https://github.com/ant-design/codemod-v4","commit_stats":null,"previous_names":["ant-design/codemod"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ant-design%2Fcodemod-v4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ant-design%2Fcodemod-v4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ant-design%2Fcodemod-v4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ant-design%2Fcodemod-v4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ant-design","download_url":"https://codeload.github.com/ant-design/codemod-v4/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773722,"owners_count":20993639,"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":["antd","antd4","cli","codemod","jscodeshift"],"created_at":"2024-08-01T07:01:22.849Z","updated_at":"2025-04-08T04:17:58.585Z","avatar_url":"https://github.com/ant-design.png","language":"JavaScript","readme":"English | [简体中文](./README.zh-CN.md)\n\n# Ant Design v4 Codemod\n\nA collection of codemod scripts that help upgrade antd v4 using [jscodeshift](https://github.com/facebook/jscodeshift).(Inspired by [react-codemod](https://github.com/reactjs/react-codemod))\n\n[![NPM version](https://img.shields.io/npm/v/@ant-design/codemod-v4.svg?style=flat)](https://npmjs.org/package/@ant-design/codemod-v4)\n[![NPM downloads](http://img.shields.io/npm/dm/@ant-design/codemod-v4.svg?style=flat)](https://npmjs.org/package/@ant-design/codemod-v4)\n[![Github Action](https://github.com/@ant-design/codemod-v4/actions/workflows/test.yml/badge.svg)](https://github.com/@ant-design/codemod-v4/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# global installation\nnpm i -g @ant-design/codemod-v4\n# or for yarn user\n#  yarn global add @ant-design/codemod-v4\nantd4-codemod src\n\n# use npx\nnpx -p @ant-design/codemod-v4 antd4-codemod src\n```\n\n## Codemod scripts introduction\n\n#### `v3-Component-to-compatible`\n\nReplace deprecated `Form` and `Mention` from `@ant-design/compatible`:\n\n```diff\n- import { Form, Input, Button, Mention } from 'antd';\n+ import { Form, Mention } from '@ant-design/compatible';\n+ import '@ant-design/compatible/assets/index.css';\n+ import { Input, Button } from 'antd';\n\n  ReactDOM.render( (\n    \u003cdiv\u003e\n      \u003cForm\u003e\n        {getFieldDecorator('username')(\u003cInput /\u003e)}\n        \u003cButton\u003eSubmit\u003c/Button\u003e\n      \u003c/Form\u003e\n      \u003cMention\n        style={{ width: '100%' }}\n        onChange={onChange}\n        defaultValue={toContentState('@afc163')}\n        defaultSuggestions={['afc163', 'benjycui']}\n        onSelect={onSelect}\n      /\u003e\n    \u003c/div\u003e\n  );\n```\n\n#### `v3-component-with-string-icon-props-to-v4`\n\nUpdate component which contains string icon props with specific v4 Icon component from `@ant-design/icons`.\n\n```diff\n  import { Avatar, Button, Result } from 'antd';\n+ import { QuestionOutlined, UserOutlined } from '@ant-design/icons';\n\n  ReactDOM.render(\n    \u003cdiv\u003e\n-     \u003cButton type=\"primary\" shape=\"circle\" icon=\"search\" /\u003e\n+     \u003cButton type=\"primary\" shape=\"circle\" icon={SearchOutlined} /\u003e\n-     \u003cAvatar shape=\"square\" icon=\"user\" /\u003e\n+     \u003cAvatar shape=\"square\" icon={UserOutlined} /\u003e\n      \u003cResult\n-       icon=\"question\"\n+       icon={\u003cQuestionOutlined /\u003e}\n        title=\"Great, we have done all the operations!\"\n        extra={\u003cButton type=\"primary\"\u003eNext\u003c/Button\u003e}\n      /\u003e\n    \u003c/div\u003e,\n    mountNode,\n  );\n\n```\n\n#### `v3-Icon-to-v4-Icon`\n\nReplace v3 Icon with specific v4 Icon component.\n\n```diff\n- import { Icon, Input } from 'antd';\n+ import { Input } from 'antd';\n+ import Icon, { CodeFilled, SmileOutlined, SmileTwoTone } from '@ant-design/icons';\n\n  const HeartSvg = () =\u003e (\n    \u003csvg width=\"1em\" height=\"1em\" fill=\"currentColor\" viewBox=\"0 0 1024 1024\"\u003e\n      \u003cpath d=\"M923 plapla...\" /\u003e\n    \u003c/svg\u003e\n  );\n\n  const HeartIcon = props =\u003e \u003cIcon component={HeartSvg} {...props} /\u003e;\n\n  ReactDOM.render(\n    \u003cdiv\u003e\n-     \u003cIcon type=\"code\" theme=\"filled\" /\u003e\n+     \u003cCodeFilled /\u003e\n-     \u003cIcon type=\"smile\" theme=\"twoTone\" twoToneColor=\"#eb2f96\" /\u003e\n+     \u003cSmileTwoTone twoToneColor=\"#eb2f96\" /\u003e\n-     \u003cIcon type=\"code\" theme={props.fill ? 'filled' : 'outlined'} /\u003e\n+     \u003cLegacyIcon type=\"code\" theme={props.fill ? 'filled' : 'outlined'} /\u003e\n      \u003cHeartIcon /\u003e\n      \u003cIcon viewBox=\"0 0 24 24\"\u003e\n        \u003ctitle\u003eCool Home\u003c/title\u003e\n        \u003cpath d=\"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z\" /\u003e\n      \u003c/Icon\u003e\n      \u003cInput suffix={\u003cSmileOutlined /\u003e} /\u003e\n    \u003c/div\u003e,\n    mountNode,\n  );\n\n```\n\n#### `v3-LocaleProvider-to-v4-ConfigProvider`\n\nReplace v3 LocaleProvider with v4 ConfigProvider component.\n\n```diff\n- import { LocaleProvider } from 'antd';\n+ import { ConfigProvider } from 'antd';\n\n  ReactDOM.render(\n-   \u003cLocaleProvider {...yourConfig}\u003e\n+   \u003cConfigProvider {...yourConfig}\u003e\n      \u003cMain /\u003e\n-   \u003c/LocaleProvider\u003e\n+   \u003c/ConfigProvider\u003e\n    mountNode,\n  );\n```\n\n#### `v3-Modal-method-with-icon-to-v4`\n\nUpdate `Modal.method()` which contains string icon property with specific v4 Icon component.\n\n```diff\nimport { Modal } from 'antd';\n+ import { AntDesignOutlined } from '@ant-design/icons';\n\n  Modal.confirm({\n-   icon: 'ant-design',\n+   icon: \u003cAntDesignOutlined /\u003e,\n    title: 'Do you Want to delete these items?',\n    content: 'Some descriptions',\n    onOk() {\n      console.log('OK');\n    },\n    onCancel() {\n      console.log('Cancel');\n    },\n  });\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":["Libraries","cli"],"sub_categories":["ant-design"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fant-design%2Fcodemod-v4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fant-design%2Fcodemod-v4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fant-design%2Fcodemod-v4/lists"}