@oceanbase/codemod 0.2.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.
- package/LICENSE +22 -0
- package/README.md +119 -0
- package/package.json +44 -0
- package/src/bin/cli.js +271 -0
- package/src/bin/codemod.ignore +9 -0
- package/src/bin/codemod.js +3 -0
- package/src/bin/upgrade-list.json +23 -0
- package/src/transforms/__testfixtures__/.eslintrc.js +7 -0
- package/src/transforms/__testfixtures__/antd-charts-to-oceanbase-charts/antd-charts.input.tsx +9 -0
- package/src/transforms/__testfixtures__/antd-charts-to-oceanbase-charts/antd-charts.output.tsx +9 -0
- package/src/transforms/__testfixtures__/antd-to-oceanbase-design/antd.input.tsx +92 -0
- package/src/transforms/__testfixtures__/antd-to-oceanbase-design/antd.output.tsx +92 -0
- package/src/transforms/__testfixtures__/antd-to-oceanbase-design/bigfish-antd.input.tsx +92 -0
- package/src/transforms/__testfixtures__/antd-to-oceanbase-design/bigfish-antd.output.tsx +92 -0
- package/src/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.input.tsx +11 -0
- package/src/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.output.tsx +12 -0
- package/src/transforms/__testfixtures__/obutil-to-oceanbase-util/obutil.input.tsx +8 -0
- package/src/transforms/__testfixtures__/obutil-to-oceanbase-util/obutil.output.tsx +8 -0
- package/src/transforms/__testfixtures__/techui-to-oceanbase-ui/pro-components.input.tsx +9 -0
- package/src/transforms/__testfixtures__/techui-to-oceanbase-ui/pro-components.output.tsx +11 -0
- package/src/transforms/__testfixtures__/techui-to-oceanbase-ui/techui.input.tsx +9 -0
- package/src/transforms/__testfixtures__/techui-to-oceanbase-ui/techui.output.tsx +11 -0
- package/src/transforms/__tests__/antd-charts-to-oceanbase-charts.test.ts +10 -0
- package/src/transforms/__tests__/antd-to-oceanbase-design.test.ts +10 -0
- package/src/transforms/__tests__/obui-to-oceanbase-design-and-ui.test.ts +10 -0
- package/src/transforms/__tests__/obutil-to-oceanbase-util.test.ts +10 -0
- package/src/transforms/__tests__/techui-to-oceanbase-ui.test.ts +10 -0
- package/src/transforms/antd-charts-to-oceanbase-charts.js +17 -0
- package/src/transforms/antd-to-oceanbase-design.js +17 -0
- package/src/transforms/obui-to-oceanbase-design-and-ui.js +50 -0
- package/src/transforms/obutil-to-oceanbase-util.js +15 -0
- package/src/transforms/techui-to-oceanbase-ui.js +18 -0
- package/src/transforms/utils/config.js +11 -0
- package/src/transforms/utils/import-component.js +72 -0
- package/src/transforms/utils/index.js +224 -0
- package/src/transforms/utils/marker.js +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present OceanBase, https://www.oceanbase.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# OceanBase Codemod
|
|
2
|
+
|
|
3
|
+
A collection of codemod scripts that help migrate to OceanBase Design using [jscodeshift](https://github.com/facebook/jscodeshift) and [postcss](https://github.com/postcss/postcss).(Inspired by [@oceanbase/codemod](https://github.com/ant-design/codemod-v5))
|
|
4
|
+
|
|
5
|
+
[](https://npmjs.org/package/@oceanbase/codemod) [](https://npmjs.org/package/@oceanbase/codemod) [](https://github.com/oceanbase/design/actions/workflows/ci.yml)
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Before run codemod scripts, you'd better make sure to commit your local git changes firstly.
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
# Run directly through npx
|
|
13
|
+
npx -p @oceanbase/codemod codemod src
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Codemod scripts introduction
|
|
17
|
+
|
|
18
|
+
### `antd-to-oceanbase-design`
|
|
19
|
+
|
|
20
|
+
import components and typs from `antd` and `@alipay/bigfish/antd` to `@oceanbase/design`.
|
|
21
|
+
|
|
22
|
+
```diff
|
|
23
|
+
import React from 'react';
|
|
24
|
+
- import { Button, Card } from 'antd';
|
|
25
|
+
- import type { ButtonProps, CardProps } from 'antd';
|
|
26
|
+
- import type { ModalProps } from 'antd/es/modal';
|
|
27
|
+
- import type { Route } from 'antd/es/breadcrumb/Breadcrumb';
|
|
28
|
+
- import type { TooltipProps } from 'antd/lib/tooltip';
|
|
29
|
+
- import type { FilterDropdownProps } from 'antd/lib/table/interface';
|
|
30
|
+
+ import { Button, Card } from '@oceanbase/design';
|
|
31
|
+
+ import type { ButtonProps, CardProps } from '@oceanbase/design';
|
|
32
|
+
+ import type { ModalProps } from '@oceanbase/design/es/modal';
|
|
33
|
+
+ import type { Route } from '@oceanbase/design/es/breadcrumb/Breadcrumb';
|
|
34
|
+
+ import type { TooltipProps } from '@oceanbase/design/lib/tooltip';
|
|
35
|
+
+ import type { FilterDropdownProps } from '@oceanbase/design/lib/table/interface';
|
|
36
|
+
|
|
37
|
+
const Demo = () => {
|
|
38
|
+
return <div />;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default Demo;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### `obui-to-oceanbase-design-and-ui`
|
|
45
|
+
|
|
46
|
+
import components and typs from `antd` to `@oceanbase/design` and `@oceanbase/ui`.
|
|
47
|
+
|
|
48
|
+
```diff
|
|
49
|
+
import React from 'react';
|
|
50
|
+
- import { Alert, Button, BasicLayout, Login, PageContainer } from '@alipay/ob-ui';
|
|
51
|
+
- import type { BasicLayoutProps } from '@alipay/ob-ui/es/BasicLayout';
|
|
52
|
+
- import type { LoginProps } from '@alipay/ob-ui/es/Login';
|
|
53
|
+
- import type { PageContainerProps } from '@alipay/ob-ui/es/PageContainer';
|
|
54
|
+
+ import { Alert, Button } from '@oceanbase/design';
|
|
55
|
+
+ import { BasicLayout, Login, PageContainer } from '@oceanbase/ui';
|
|
56
|
+
+ import type { BasicLayoutProps } from '@oceanbase/ui/es/BasicLayout';
|
|
57
|
+
+ import type { LoginProps } from '@oceanbase/ui/es/Login';
|
|
58
|
+
+ import type { PageContainerProps } from '@oceanbase/ui/es/PageContainer';
|
|
59
|
+
|
|
60
|
+
const Demo = () => {
|
|
61
|
+
return <div />;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default Demo;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `techui-to-oceanbase-ui`
|
|
68
|
+
|
|
69
|
+
import `PageContainer` from `@alipay/tech-ui` to `@ant-design/pro-components` and `@oceanbase/ui`.
|
|
70
|
+
|
|
71
|
+
```diff
|
|
72
|
+
import React from 'react';
|
|
73
|
+
- import { PageContainer, ProTable, WelcomeCard } from '@alipay/tech-ui';
|
|
74
|
+
- import type { PageContainerProps, ProTableProps, WelcomeCardProps } from '@alipay/tech-ui';
|
|
75
|
+
+ import { ProTable, WelcomeCard } from '@alipay/tech-ui';
|
|
76
|
+
+ import { PageContainer } from '@oceanbase/ui';
|
|
77
|
+
+ import type { ProTableProps, WelcomeCardProps } from '@alipay/tech-ui';
|
|
78
|
+
+ import type { PageContainerProps } from '@oceanbase/ui';
|
|
79
|
+
|
|
80
|
+
const Demo = () => {
|
|
81
|
+
return <div />;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default Demo;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### `antd-charts-to-oceanbase-charts`
|
|
88
|
+
|
|
89
|
+
import components and typs from `@ant-design/charts` to `@oceanbase/charts`.
|
|
90
|
+
|
|
91
|
+
```diff
|
|
92
|
+
import React from 'react';
|
|
93
|
+
- import { Bar, Line } from '@ant-design/charts';
|
|
94
|
+
- import type { BarConfig, LineConfig } from '@ant-design/charts';
|
|
95
|
+
+ import { Bar, Line } from '@oceanbase/charts';
|
|
96
|
+
+ import type { BarConfig, LineConfig } from '@oceanbase/charts';
|
|
97
|
+
|
|
98
|
+
const Demo = () => {
|
|
99
|
+
return <div />;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default Demo;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### `obutil-to-oceanbase-util`
|
|
106
|
+
|
|
107
|
+
import components and typs from `@alipay/ob-util` to `@oceanbase/util`.
|
|
108
|
+
|
|
109
|
+
```diff
|
|
110
|
+
import React from 'react';
|
|
111
|
+
- import { isNullValue, sortByNumber } from '@alipay/ob-util';
|
|
112
|
+
+ import { isNullValue, sortByNumber } from '@oceanbase/util';
|
|
113
|
+
|
|
114
|
+
const Demo = () => {
|
|
115
|
+
return <div />;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default Demo;
|
|
119
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oceanbase/codemod",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Codemod for OceanBase Design upgrade",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"oceanbase",
|
|
7
|
+
"oceanbase design",
|
|
8
|
+
"codemod"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/oceanbase/oceanbase-design/packages/codemod",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git@github.com:oceanbase/design.git"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"registry": "https://registry.npmjs.org",
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"codemod": "./bin/codemod.js"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "father build"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"chalk": "^3.0.0",
|
|
27
|
+
"find-up": "^4.1.0",
|
|
28
|
+
"glob": "^8.0.3",
|
|
29
|
+
"is-git-clean": "^1.1.0",
|
|
30
|
+
"jscodeshift": "^0.14.0",
|
|
31
|
+
"lodash": "^4.17.15",
|
|
32
|
+
"read-pkg-up": "^9.1.0",
|
|
33
|
+
"semver": "^7.1.3",
|
|
34
|
+
"update-check": "^1.5.3",
|
|
35
|
+
"yargs-parser": "^21.1.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/jest": "^29.2.3",
|
|
39
|
+
"@types/jscodeshift": "^0.11.5",
|
|
40
|
+
"enzyme": "^3.0.0",
|
|
41
|
+
"enzyme-to-json": "^3.4.0"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "6f801e95ba5ddc345f6d2c462bcf2af1abc74c84"
|
|
44
|
+
}
|
package/src/bin/cli.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/* eslint no-console: 0 */
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
const _ = require('lodash');
|
|
8
|
+
const chalk = require('chalk');
|
|
9
|
+
const isGitClean = require('is-git-clean');
|
|
10
|
+
const updateCheck = require('update-check');
|
|
11
|
+
const findUp = require('find-up');
|
|
12
|
+
const semver = require('semver');
|
|
13
|
+
const { run: jscodeshift } = require('jscodeshift/src/Runner');
|
|
14
|
+
|
|
15
|
+
const pkg = require('../package.json');
|
|
16
|
+
const pkgUpgradeList = require('./upgrade-list');
|
|
17
|
+
const { getDependencies } = require('../transforms/utils/marker');
|
|
18
|
+
|
|
19
|
+
// jscodeshift codemod scripts dir
|
|
20
|
+
const transformersDir = path.join(__dirname, '../transforms');
|
|
21
|
+
|
|
22
|
+
// jscodeshift bin#--ignore-config
|
|
23
|
+
const ignoreConfig = path.join(__dirname, './codemod.ignore');
|
|
24
|
+
|
|
25
|
+
const transformers = [
|
|
26
|
+
'antd-to-oceanbase-design',
|
|
27
|
+
'obui-to-oceanbase-design',
|
|
28
|
+
'techui-to-oceanbase-ui',
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const dependencyProperties = [
|
|
32
|
+
'dependencies',
|
|
33
|
+
'devDependencies',
|
|
34
|
+
'clientDependencies',
|
|
35
|
+
'isomorphicDependencies',
|
|
36
|
+
'buildDependencies',
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
async function ensureGitClean() {
|
|
40
|
+
let clean = false;
|
|
41
|
+
try {
|
|
42
|
+
clean = await isGitClean();
|
|
43
|
+
} catch (err) {
|
|
44
|
+
if (err && err.stderr && err.stderr.toLowerCase().includes('not a git repository')) {
|
|
45
|
+
clean = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!clean) {
|
|
50
|
+
console.log(chalk.yellow('Sorry that there are still some git changes'));
|
|
51
|
+
console.log('\n you must commit or stash them firstly');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function checkUpdates() {
|
|
57
|
+
let update;
|
|
58
|
+
try {
|
|
59
|
+
update = await updateCheck(pkg);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.log(chalk.yellow(`Failed to check for updates: ${err}`));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (update) {
|
|
65
|
+
console.log(chalk.blue(`Latest version is ${update.latest}. Please update firstly`));
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function getMaxWorkers(options = {}) {
|
|
71
|
+
// limit usage for cpus
|
|
72
|
+
return options.cpus || Math.max(2, Math.ceil(os.cpus().length / 3));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getRunnerArgs(transformerPath, parser = 'tsx', options = {}) {
|
|
76
|
+
const args = {
|
|
77
|
+
verbose: 2,
|
|
78
|
+
// limit usage for cpus
|
|
79
|
+
cpus: getMaxWorkers(options),
|
|
80
|
+
parser,
|
|
81
|
+
extensions: ['tsx', 'ts', 'jsx', 'js'].join(','),
|
|
82
|
+
transform: transformerPath,
|
|
83
|
+
ignorePattern: '**/node_modules',
|
|
84
|
+
ignoreConfig,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return args;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function run(filePath, args = {}) {
|
|
91
|
+
for (const transformer of transformers) {
|
|
92
|
+
await transform(transformer, 'tsx', filePath, args);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function transform(transformer, parser, filePath, options) {
|
|
97
|
+
console.log(chalk.bgGreen.bold('Transform'), transformer);
|
|
98
|
+
const transformerPath = path.join(transformersDir, `${transformer}.js`);
|
|
99
|
+
|
|
100
|
+
const args = getRunnerArgs(transformerPath, parser, {
|
|
101
|
+
...options,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
if (process.env.NODE_ENV === 'local') {
|
|
106
|
+
console.log(`Running jscodeshift with: ${JSON.stringify(args)}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// js part
|
|
110
|
+
await jscodeshift(transformerPath, [filePath], args);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
console.error(err);
|
|
113
|
+
if (process.env.NODE_ENV === 'local') {
|
|
114
|
+
const errorLogFile = path.join(__dirname, './error.log');
|
|
115
|
+
fs.appendFileSync(errorLogFile, err);
|
|
116
|
+
fs.appendFileSync(errorLogFile, '\n');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function upgradeDetect(targetDir, needOBCharts, needObUtil) {
|
|
122
|
+
const result = [];
|
|
123
|
+
const cwd = path.join(process.cwd(), targetDir);
|
|
124
|
+
const { readPackageUp } = await import('read-pkg-up');
|
|
125
|
+
const closetPkgJson = await readPackageUp({ cwd });
|
|
126
|
+
|
|
127
|
+
let pkgJsonPath;
|
|
128
|
+
if (!closetPkgJson) {
|
|
129
|
+
pkgJsonPath = "we didn't find your package.json";
|
|
130
|
+
// unknown dependency property
|
|
131
|
+
result.push(['install', '@oceanbase/design', pkgUpgradeList['@oceanbase/design']]);
|
|
132
|
+
result.push(['install', '@oceanbase/ui', pkgUpgradeList['@oceanbase/ui']]);
|
|
133
|
+
if (needOBCharts) {
|
|
134
|
+
result.push(['install', '@oceanbase/charts', pkgUpgradeList['@oceanbase/charts'].version]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (needObUtil) {
|
|
138
|
+
result.push(['install', '@oceanbase/util', pkgUpgradeList['@oceanbase/util'].version]);
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
const { packageJson } = closetPkgJson;
|
|
142
|
+
pkgJsonPath = closetPkgJson.path;
|
|
143
|
+
|
|
144
|
+
// dependencies must be installed or upgraded with correct version
|
|
145
|
+
const mustInstallOrUpgradeDeps = ['@oceanbase/design', '@oceanbase/ui'];
|
|
146
|
+
if (needOBCharts) {
|
|
147
|
+
mustInstallOrUpgradeDeps.push('@oceanbase/charts');
|
|
148
|
+
}
|
|
149
|
+
if (needObUtil) {
|
|
150
|
+
mustInstallOrUpgradeDeps.push('@oceanbase/util');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// handle mustInstallOrUpgradeDeps
|
|
154
|
+
mustInstallOrUpgradeDeps.forEach(depName => {
|
|
155
|
+
let hasDependency = false;
|
|
156
|
+
const expectVersion = pkgUpgradeList[depName].version;
|
|
157
|
+
// const upgradePkgDescription = pkgUpgradeList[depName].description;
|
|
158
|
+
dependencyProperties.forEach(property => {
|
|
159
|
+
const versionRange = _.get(packageJson, `${property}.${depName}`);
|
|
160
|
+
// mark dependency installment state
|
|
161
|
+
hasDependency = hasDependency || !!versionRange;
|
|
162
|
+
// no dependency or improper version dependency
|
|
163
|
+
if (versionRange && !semver.satisfies(semver.minVersion(versionRange), expectVersion)) {
|
|
164
|
+
result.push(['update', depName, expectVersion, property]);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
if (!hasDependency) {
|
|
168
|
+
// unknown dependency property
|
|
169
|
+
result.push(['install', depName, pkgUpgradeList[depName].version]);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// dependencies must be upgraded to correct version
|
|
174
|
+
const mustUpgradeDeps = _.without(Object.keys(pkgUpgradeList), ...mustInstallOrUpgradeDeps);
|
|
175
|
+
mustUpgradeDeps.forEach(depName => {
|
|
176
|
+
dependencyProperties.forEach(property => {
|
|
177
|
+
const expectVersion = pkgUpgradeList[depName].version;
|
|
178
|
+
const versionRange = _.get(packageJson, `${property}.${depName}`);
|
|
179
|
+
/**
|
|
180
|
+
* we may have dependencies in `package.json`
|
|
181
|
+
* make sure that they can `work well` with `oceanbase design system`
|
|
182
|
+
* so we check dependency's version here
|
|
183
|
+
*/
|
|
184
|
+
if (versionRange && !semver.satisfies(semver.minVersion(versionRange), expectVersion)) {
|
|
185
|
+
result.push(['update', depName, expectVersion, property]);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!result.length) {
|
|
192
|
+
console.log(chalk.green('Checking passed'));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
console.log(
|
|
197
|
+
chalk.yellow(
|
|
198
|
+
"It's recommended to install or upgrade these dependencies to ensure working well with oceanbase design system\n"
|
|
199
|
+
)
|
|
200
|
+
);
|
|
201
|
+
console.log(`> package.json file: ${pkgJsonPath} \n`);
|
|
202
|
+
const dependencies = result.map(([operateType, depName, expectVersion, dependencyProperty]) =>
|
|
203
|
+
[
|
|
204
|
+
_.capitalize(operateType),
|
|
205
|
+
`${depName}${expectVersion}`,
|
|
206
|
+
dependencyProperty ? `in ${dependencyProperty}` : '',
|
|
207
|
+
].join(' ')
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
console.log(dependencies.map(n => `* ${n}`).join('\n'));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* options
|
|
215
|
+
* --force // force skip git checking (dangerously)
|
|
216
|
+
* --cpus=1 // specify cpus cores to use
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
async function bootstrap() {
|
|
220
|
+
const dir = process.argv[2];
|
|
221
|
+
// eslint-disable-next-line global-require
|
|
222
|
+
const args = require('yargs-parser')(process.argv.slice(3));
|
|
223
|
+
if (process.env.NODE_ENV !== 'local') {
|
|
224
|
+
// check for updates
|
|
225
|
+
await checkUpdates();
|
|
226
|
+
// check for git status
|
|
227
|
+
if (!args.force) {
|
|
228
|
+
await ensureGitClean();
|
|
229
|
+
} else {
|
|
230
|
+
console.log(
|
|
231
|
+
Array(3)
|
|
232
|
+
.fill(1)
|
|
233
|
+
.map(() =>
|
|
234
|
+
chalk.yellow('WARNING: You are trying to skip git status checking, please be careful')
|
|
235
|
+
)
|
|
236
|
+
.join('\n')
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// check for `path`
|
|
242
|
+
if (!dir || !fs.existsSync(dir)) {
|
|
243
|
+
console.log(chalk.yellow('Invalid dir:', dir, ', please pass a valid dir'));
|
|
244
|
+
process.exit(1);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
await run(dir, args);
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
console.log('----------- dependencies alert -----------\n');
|
|
251
|
+
const depsList = await getDependencies();
|
|
252
|
+
await upgradeDetect(
|
|
253
|
+
dir,
|
|
254
|
+
depsList.includes('@ant-design/charts'),
|
|
255
|
+
depsList.includes('@alipay/ob-util')
|
|
256
|
+
);
|
|
257
|
+
} catch (err) {
|
|
258
|
+
console.log('skip summary due to', err);
|
|
259
|
+
} finally {
|
|
260
|
+
console.log(`\n----------- Thanks for using @oceanbase/codemod ${pkg.version} -----------`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
module.exports = {
|
|
265
|
+
bootstrap,
|
|
266
|
+
ensureGitClean,
|
|
267
|
+
transform,
|
|
268
|
+
run,
|
|
269
|
+
getRunnerArgs,
|
|
270
|
+
checkUpdates,
|
|
271
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@oceanbase/design": {
|
|
3
|
+
"version": "^0.2.0"
|
|
4
|
+
},
|
|
5
|
+
"@oceanbase/icons": {
|
|
6
|
+
"version": "^0.2.0"
|
|
7
|
+
},
|
|
8
|
+
"@oceanbase/ui": {
|
|
9
|
+
"version": "^0.2.0"
|
|
10
|
+
},
|
|
11
|
+
"@oceanbase/charts": {
|
|
12
|
+
"version": "^0.2.0"
|
|
13
|
+
},
|
|
14
|
+
"@oceanbase/util": {
|
|
15
|
+
"version": "^0.2.0"
|
|
16
|
+
},
|
|
17
|
+
"react": {
|
|
18
|
+
"version": "^16.9.0"
|
|
19
|
+
},
|
|
20
|
+
"react-dom": {
|
|
21
|
+
"version": "^16.9.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
// Genaral
|
|
4
|
+
Button,
|
|
5
|
+
FloatButton,
|
|
6
|
+
Typography,
|
|
7
|
+
// Layout
|
|
8
|
+
Divider,
|
|
9
|
+
Grid,
|
|
10
|
+
Layout,
|
|
11
|
+
Space,
|
|
12
|
+
// Navigation
|
|
13
|
+
Anchor,
|
|
14
|
+
Breadcrumb,
|
|
15
|
+
Dropdown,
|
|
16
|
+
Menu,
|
|
17
|
+
Pagination,
|
|
18
|
+
Steps,
|
|
19
|
+
// Data Entry
|
|
20
|
+
AutoComplete,
|
|
21
|
+
Cascader,
|
|
22
|
+
Checkbox,
|
|
23
|
+
ColorPicker,
|
|
24
|
+
DatePicker,
|
|
25
|
+
Form,
|
|
26
|
+
Input,
|
|
27
|
+
InputNumber,
|
|
28
|
+
Mentions,
|
|
29
|
+
Radio,
|
|
30
|
+
Rate,
|
|
31
|
+
Select,
|
|
32
|
+
Slider,
|
|
33
|
+
Switch,
|
|
34
|
+
TimePicker,
|
|
35
|
+
Transfer,
|
|
36
|
+
TreeSelect,
|
|
37
|
+
Upload,
|
|
38
|
+
// Data Display
|
|
39
|
+
Avatar,
|
|
40
|
+
Badge,
|
|
41
|
+
Calendar,
|
|
42
|
+
Card,
|
|
43
|
+
Carousel,
|
|
44
|
+
Callapse,
|
|
45
|
+
Descripions,
|
|
46
|
+
Empty,
|
|
47
|
+
Image,
|
|
48
|
+
List,
|
|
49
|
+
Popover,
|
|
50
|
+
QRCode,
|
|
51
|
+
Segmented,
|
|
52
|
+
Statistic,
|
|
53
|
+
Table,
|
|
54
|
+
Tabs,
|
|
55
|
+
Tag,
|
|
56
|
+
Timeline,
|
|
57
|
+
Tooltip,
|
|
58
|
+
Tour,
|
|
59
|
+
Tree,
|
|
60
|
+
// Feedback
|
|
61
|
+
Alert,
|
|
62
|
+
Drawer,
|
|
63
|
+
message,
|
|
64
|
+
Modal,
|
|
65
|
+
notification,
|
|
66
|
+
Popconfirm,
|
|
67
|
+
Progress,
|
|
68
|
+
Result,
|
|
69
|
+
Skeleton,
|
|
70
|
+
Spin,
|
|
71
|
+
Watermark,
|
|
72
|
+
// Other
|
|
73
|
+
Affix,
|
|
74
|
+
App,
|
|
75
|
+
ConfigProvider,
|
|
76
|
+
// Theme
|
|
77
|
+
theme,
|
|
78
|
+
} from 'antd';
|
|
79
|
+
// type
|
|
80
|
+
import type { ButtonProps, CardProps } from 'antd';
|
|
81
|
+
// es
|
|
82
|
+
import type { ModalProps } from 'antd/es/modal';
|
|
83
|
+
import type { Route } from 'antd/es/breadcrumb/Breadcrumb';
|
|
84
|
+
// lib
|
|
85
|
+
import type { TooltipProps } from 'antd/lib/tooltip';
|
|
86
|
+
import type { FilterDropdownProps } from 'antd/lib/table/interface';
|
|
87
|
+
|
|
88
|
+
const Demo = () => {
|
|
89
|
+
return <div />;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default Demo;
|