diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6559087..8e6bb9c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,10 +10,7 @@ const TRANSFORMER_INQUIRER_CHOICES = [ ..., // 新增在这里即可 - { - name: 'Notification', - value: 'Notification' - } + 'Notification' ] ``` diff --git a/README.md b/README.md index f4b5e62..503727e 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,9 @@ Replacing `` and `` with appropriate values. - [ ] Modal - [x] Slider - [x] Popover -- [ ] Col -- [ ] Row +- [x] Col +- [x] Row - [ ] Tag - [ ] Timeline - [ ] Pagination +- [ ] Form相关 \ No newline at end of file diff --git a/bin/cli.js b/bin/cli.js index 6dc18e2..b8a1f7d 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -46,51 +46,25 @@ function runTransform({ files, flags, transformer }) { } const TRANSFORMER_INQUIRER_CHOICES = [ - { - name: 'Divider', - value: 'Divider' - }, - { - name: 'Breadcrumb', - value: 'Breadcrumb' - }, - { - name: 'Notification', - value: 'Notification' - }, - { - name: 'Table', - value: 'Table' - }, - { - name: 'Tabs', - value: 'Tabs' - }, - { - name: 'Message', - value: 'Message' - }, - { - name: 'Drawer', - value: 'Drawer' - }, - { - name: 'Spin', - value: 'Spin' - }, - { - name: 'Empty', - value: 'Empty' - }, - { - name: 'Slider', - value: 'Slider' - }, - { - name: 'Popover', - value: 'Popover' - } -].sort((a, b) => a.name.localeCompare(b.name)) + 'Divider', + 'Breadcrumb', + 'Notification', + 'Table', + 'Tabs', + 'Message', + 'Drawer', + 'Spin', + 'Empty', + 'Slider', + 'Popover', + 'Col', + 'Row' +] + .sort((a, b) => a.localeCompare(b)) + .map((v) => ({ + name: v, + value: v + })) function expandFilePathsIfNeeded(filesBeforeExpansion) { const shouldExpandFiles = filesBeforeExpansion.some((file) => diff --git a/test.jsx b/test.jsx index c3f6d15..00da48e 100644 --- a/test.jsx +++ b/test.jsx @@ -1,11 +1,9 @@ -import { Button, Empty, Popover } from 'antd' - -import { Divider, Tabs, TabPane } from '@douyinfe/semi-ui' +import { Row, Col } from 'antd' function Test() { return ( - - - + + col + ) } diff --git a/transforms/Col.js b/transforms/Col.js new file mode 100644 index 0000000..7a9e827 --- /dev/null +++ b/transforms/Col.js @@ -0,0 +1,9 @@ +const { removeAntdImportAndAddSemiImport } = require('./utils') +module.exports = function transformer(file, api) { + const j = api.jscodeshift + const root = j(file.source) + + removeAntdImportAndAddSemiImport(j, root, 'Col', 'Col') + + return root.toSource() +} diff --git a/transforms/Row.js b/transforms/Row.js new file mode 100644 index 0000000..cbbaa1b --- /dev/null +++ b/transforms/Row.js @@ -0,0 +1,9 @@ +const { removeAntdImportAndAddSemiImport } = require('./utils') +module.exports = function transformer(file, api) { + const j = api.jscodeshift + const root = j(file.source) + + removeAntdImportAndAddSemiImport(j, root, 'Row', 'Row') + + return root.toSource() +}