Skip to content

Commit b02ee2f

Browse files
authored
refactor: upgrade project (#411)
* chore(deps): bump `father@4.1.3` * chore(deps): add `@rc-component/father-plugin` * chore: update config * chore(deps): bump `@umijs/fabric@3.x` * chore(deps): remove local eslint ref: umijs/fabric#136 * chore: add eslint eq @umijs/fabric * chore: add rc-test remove coveralls * ci: update config * remove jest config * remove deps * test: update test 这里的用例遇到点问题,需要进一步确定 * chore: lock version * chore: update script * update dumi@2.x * ci: add site-deploy workflow * docs: update * remove unused
1 parent 12a535a commit b02ee2f

25 files changed

+145
-78
lines changed

.dumirc.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// more config: https://d.umijs.org/config
2+
import { defineConfig } from 'dumi';
3+
4+
const basePath = process.env.GITHUB_ACTIONS ? '/util/' : '/';
5+
const publicPath = process.env.GITHUB_ACTIONS ? '/util/' : '/';
6+
7+
export default defineConfig({
8+
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
9+
themeConfig: {
10+
name: 'Util',
11+
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
12+
},
13+
outputPath: '.doc',
14+
exportStatic: {},
15+
base: basePath,
16+
publicPath,
17+
});

.eslintrc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
const config = {
1+
module.exports = {
22
extends: [require.resolve('@umijs/fabric/dist/eslint')],
33
rules: {
44
'react/no-did-update-set-state': 0,
55
'react/no-find-dom-node': 0,
66
'import/no-extraneous-dependencies': 0,
7-
'react/sort-comp': 0,
87
},
98
};
10-
11-
module.exports = config;

.fatherrc.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

.fatherrc.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from 'father';
2+
3+
export default defineConfig({
4+
// Locked version only supports 1.0.0
5+
plugins: ['@rc-component/father-plugin'],
6+
});

.github/workflows/react-component-ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646

4747
lint:
4848
runs-on: ubuntu-latest
49+
needs: setup
4950
steps:
5051
- name: checkout
5152
uses: actions/checkout@master
@@ -64,11 +65,10 @@ jobs:
6465

6566
- name: lint
6667
run: npm run lint
67-
68-
needs: setup
6968

7069
compile:
7170
runs-on: ubuntu-latest
71+
needs: setup
7272
steps:
7373
- name: checkout
7474
uses: actions/checkout@master
@@ -87,11 +87,10 @@ jobs:
8787

8888
- name: compile
8989
run: npm run compile
90-
91-
needs: setup
9290

9391
coverage:
9492
runs-on: ubuntu-latest
93+
needs: setup
9594
steps:
9695
- name: checkout
9796
uses: actions/checkout@master
@@ -109,6 +108,4 @@ jobs:
109108
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
110109

111110
- name: coverage
112-
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
113-
114-
needs: setup
111+
run: npm run coverage && bash <(curl -s https://codecov.io/bash)

.github/workflows/site-deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy website
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: checkout
16+
uses: actions/checkout@v3
17+
18+
- name: setup node
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: 14
22+
23+
- name: create package-lock.json
24+
run: npm i --package-lock-only --ignore-scripts
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: build Docs
30+
run: npm run build
31+
32+
- name: Deploy to GitHub Pages
33+
uses: peaceiris/actions-gh-pages@v3
34+
with:
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
publish_dir: ./.doc
37+
force_orphan: true
38+
user_name: 'github-actions[bot]'
39+
user_email: 'github-actions[bot]@users.noreply.github.com'

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ package-lock.json
3333
.umi
3434
.umi-production
3535
.umi-test
36-
.env.local
36+
.env.local
37+
38+
.dumi/tmp
39+
.dumi/tmp-test
40+
.dumi/tmp-production

.umirc.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/demo/dynaymicCSS.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
## dynaymicCSS
2-
<code src="../examples/dynaymicCSS.tsx">
1+
---
2+
title: dynaymicCSS
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/dynaymicCSS.tsx" iframe></code>

docs/demo/getScrollBarSize.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
## getScrollBarSize
2-
<code src="../examples/getScrollBarSize.tsx">
1+
---
2+
title: getScrollBarSize
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/getScrollBarSize.tsx"></code>

docs/demo/portal.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
## portal
2-
<code src="../examples/portal.tsx">
1+
---
2+
title: portal
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/portal.tsx"></code>

docs/demo/styleChecker.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
## styleChecker
2-
<code src="../examples/styleChecker.tsx">
1+
---
2+
title: styleChecker
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/styleChecker.tsx"></code>

docs/demo/toArray.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
## toArray
2-
<code src="../examples/toArray.tsx">
1+
---
2+
title: toArray
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/toArray.tsx"></code>

docs/examples/dynaymicCSS.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import { updateCSS, removeCSS } from '../../src/Dom/dynamicCSS';
3-
import type { Prepend } from '../../src/Dom/dynamicCSS';
2+
import { updateCSS, removeCSS } from 'rc-util/es/Dom/dynamicCSS';
3+
import type { Prepend } from 'rc-util/es/Dom/dynamicCSS';
44

55
function injectStyle(id: number, prepend?: Prepend) {
66
const randomColor = Math.floor(Math.random() * 16777215).toString(16);

docs/examples/getScrollBarSize.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
/* eslint-disable react/no-danger */
2-
31
import React from 'react';
42
import getScrollBarSize, {
53
getTargetScrollBarSize,
6-
} from '../../src/getScrollBarSize';
4+
} from 'rc-util/es/getScrollBarSize';
75

86
export default () => {
97
const divRef = React.useRef<HTMLDivElement>();

docs/examples/portal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import PortalWrapper from '../../src/PortalWrapper';
2+
import PortalWrapper from 'rc-util/es/PortalWrapper';
33

44
export default () => {
55
const divRef = React.useRef();

docs/examples/styleChecker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { isStyleSupport } from '../../src/Dom/styleChecker';
2+
import { isStyleSupport } from 'rc-util/es/Dom/styleChecker';
33

44
export default () => {
55
const supportFlex = isStyleSupport('flex');

docs/examples/toArray.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import toArray, { type Option } from '../../src/Children/toArray';
2+
import toArray, { type Option } from 'rc-util/es/Children/toArray';
33

44
const initialState = {
55
'no-children': false,
@@ -25,14 +25,14 @@ const DemoBox = React.memo(({ children, name }: { children?: any, name: Action }
2525
return (
2626
<React.Fragment key={name}>
2727
<label style={{ display: 'inline-block', width: 180 }}>
28-
<input type="checkbox" checked={show} onChange={e => setShow(prev => !prev)} />
28+
<input type="checkbox" checked={show} onChange={() => setShow(prev => !prev)} />
2929
{name}
3030
</label>
3131
<label>
3232
<input
3333
type="checkbox"
3434
checked={keepEmpty}
35-
onChange={e => setkeepEmpty(prev => !prev)}
35+
onChange={() => setkeepEmpty(prev => !prev)}
3636
disabled={!show}
3737
/>
3838
keepEmpty={keepEmpty ? 'true' : 'false'}

docs/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
hero:
3+
title: rc-util
4+
description: Common Utils For React Component
5+
---
6+
7+
<embed src="../README.md"></embed>

jest.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,34 @@
2121
],
2222
"scripts": {
2323
"compile": "father build",
24-
"coverage": "father test --coverage && cat ./coverage/lcov.info | coveralls",
25-
"docs:build": "dumi build",
24+
"coverage": "npm test -- --coverage",
25+
"build": "dumi build",
2626
"lint": "eslint src/ --ext .tsx,.ts & eslint tests/ --ext .js",
27-
"now-build": "npm run docs:build",
2827
"prepublishOnly": "npm run compile && np --yolo --no-publish",
2928
"start": "dumi dev",
30-
"test": "father test"
29+
"test": "rc-test"
3130
},
3231
"dependencies": {
3332
"@babel/runtime": "^7.18.3",
3433
"react-is": "^16.12.0"
3534
},
3635
"devDependencies": {
37-
"@testing-library/jest-dom": "^5.16.4",
36+
"@rc-component/father-plugin": "1.0.0",
3837
"@testing-library/react": "^13.0.0",
3938
"@types/jest": "^25.2.3",
4039
"@types/react": "^18.0.0",
4140
"@types/react-dom": "^18.0.0",
4241
"@types/responselike": "^1.0.0",
4342
"@types/warning": "^3.0.0",
44-
"@umijs/fabric": "^2.0.8",
45-
"coveralls": "^3.1.0",
43+
"@umijs/fabric": "^3.0.0",
4644
"create-react-class": "^15.6.3",
4745
"cross-env": "^7.0.2",
48-
"dumi": "^1.1.4",
49-
"eslint": "^6.6.0",
50-
"father": "^2.29.9",
46+
"dumi": "^2.1.3",
47+
"eslint": "~7.32.0",
48+
"father": "^4.1.3",
5149
"glob": "^7.1.6",
5250
"np": "^6.2.3",
51+
"rc-test": "^7.0.14",
5352
"react": "^18.0.0",
5453
"react-dom": "^18.0.0",
5554
"typescript": "^4.1.3"

tests/scrollLocker.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('ScrollLocker', () => {
1010
let scrollLocker: ScrollLocker;
1111

1212
const effectStyle =
13-
'overflow: hidden; overflow-x: hidden; overflow-y: hidden;';
13+
'width: calc(100% - 20px); overflow: hidden; overflow-x: hidden; overflow-y: hidden;';
1414

1515
// jsdom can not capture calc
1616
const initialStyle = '';

tests/setup.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/switchScrollingEffect.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('switchScrollingEffect', () => {
3636

3737
switchScrollingEffect();
3838

39-
expect(document.body.style.cssText).toBe('position: relative;');
39+
expect(document.body.style.cssText).toBe('position: relative; width: calc(100% - 20px);');
4040
expect(document.body.className).toBe('ant-scrolling-effect');
4141

4242
// when closed

tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
"jsx": "preserve",
77
"declaration": true,
88
"skipLibCheck": true,
9-
"esModuleInterop": true
9+
"esModuleInterop": true,
10+
"paths": {
11+
"@/*": ["src/*"],
12+
"@@/*": ["src/.dumi/*"],
13+
"rc-util": ["src/index.tsx"],
14+
"rc-util/es/*": ["src/*"]
15+
}
1016
}
1117
}

0 commit comments

Comments
 (0)