From ac1990b47a1f971c2339ecb71c5d6ca55a0a86c2 Mon Sep 17 00:00:00 2001 From: DBSDs <379712747@qq.com> Date: Thu, 16 Nov 2023 00:24:27 +0800 Subject: [PATCH 1/4] chore: bump dumi@2.x.x --- .dumirc.ts | 20 ++++++++++++++++++++ .github/workflows/main.yml | 4 ++-- .gitignore | 10 +++++++--- .umirc.ts | 21 --------------------- docs/demo/base.md | 3 --- docs/demo/basic.md | 8 ++++++++ docs/demo/blink.md | 9 +++++++-- docs/demo/fill-width.md | 9 +++++++-- docs/demo/raw-render.md | 9 +++++++-- docs/index.md | 6 ++++-- package.json | 9 +++++---- script/update-content.js | 34 ++++++++++++++++++++++++++++++++++ tsconfig.json | 2 +- 13 files changed, 102 insertions(+), 42 deletions(-) create mode 100644 .dumirc.ts delete mode 100644 .umirc.ts delete mode 100644 docs/demo/base.md create mode 100644 docs/demo/basic.md create mode 100644 script/update-content.js diff --git a/.dumirc.ts b/.dumirc.ts new file mode 100644 index 0000000..a52da6c --- /dev/null +++ b/.dumirc.ts @@ -0,0 +1,20 @@ +import { defineConfig } from 'dumi'; + +export default defineConfig({ + favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], + themeConfig: { + name: 'rc-overflow', + logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', + }, + exportStatic: {}, + outputPath: 'docs-dist', + base: '/rc-overflow/', + publicPath: '/rc-overflow/', + styles: [ + ` + .markdown table { + width: auto !important; + } + `, + ], +}); diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 432a3fb..b0a4263 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-node@v1 with: - node-version: '12' + node-version: '18' - name: cache package-lock.json uses: actions/cache@v2 @@ -24,7 +24,7 @@ jobs: key: lock-${{ github.sha }} - name: create package-lock.json - run: npm i --package-lock-only + run: npm i --package-lock-only --ignore-scripts - name: hack for singe file run: | diff --git a/.gitignore b/.gitignore index dfa72e1..d222701 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.storybook *.iml *.log .idea/ @@ -29,5 +28,10 @@ yarn.lock package-lock.json coverage/ .doc -.umi -dist/ \ No newline at end of file +dist/ + +# dumi +.dumi/tmp +.dumi/tmp-test +.dumi/tmp-production +.env.local diff --git a/.umirc.ts b/.umirc.ts deleted file mode 100644 index a15b3dd..0000000 --- a/.umirc.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { defineConfig } from 'dumi'; - -export default defineConfig({ - title: 'rc-overflow', - favicon: - 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - logo: - 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - exportStatic: {}, - outputPath: 'docs-dist', - resolve: { - examples: ['none'], - }, - styles: [ - ` - .markdown table { - width: auto !important; - } - `, - ] -}); diff --git a/docs/demo/base.md b/docs/demo/base.md deleted file mode 100644 index 3d1c229..0000000 --- a/docs/demo/base.md +++ /dev/null @@ -1,3 +0,0 @@ -## base - - diff --git a/docs/demo/basic.md b/docs/demo/basic.md new file mode 100644 index 0000000..edb9e62 --- /dev/null +++ b/docs/demo/basic.md @@ -0,0 +1,8 @@ +--- +title: basic +nav: + title: Demo + path: /demo +--- + + diff --git a/docs/demo/blink.md b/docs/demo/blink.md index 7362231..778c112 100644 --- a/docs/demo/blink.md +++ b/docs/demo/blink.md @@ -1,3 +1,8 @@ -## blink +--- +title: blink +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/fill-width.md b/docs/demo/fill-width.md index acf87dd..b9b3935 100644 --- a/docs/demo/fill-width.md +++ b/docs/demo/fill-width.md @@ -1,3 +1,8 @@ -## fill-width +--- +title: fill-width +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/raw-render.md b/docs/demo/raw-render.md index 0b2479d..204a6dd 100644 --- a/docs/demo/raw-render.md +++ b/docs/demo/raw-render.md @@ -1,3 +1,8 @@ -## Raw Render +--- +title: raw-render +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/index.md b/docs/index.md index e99bdf3..9bb192a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,7 @@ --- -title: rc-overflow +hero: + title: rc-overflow + description: React Overflow Component --- - + diff --git a/package.json b/package.json index ca02002..62a53d2 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "start": "dumi dev", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", - "compile": "father-build", + "compile": "father build", + "prepare": "dumi setup", "deploy": "npm run docs:build && npm run docs:deploy", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", "test": "father test", @@ -57,14 +58,14 @@ "@types/react": "^16.14.2", "@types/react-dom": "^16.9.10", "@umijs/fabric": "^2.0.8", + "glob": "^10.0.0", "cross-env": "^7.0.2", - "dumi": "^1.1.10", + "dumi": "^2.0.0", "enzyme": "^3.0.0", "enzyme-adapter-react-16": "^1.0.1", "enzyme-to-json": "^3.4.0", "eslint": "^7.0.0", - "father": "^2.13.4", - "father-build": "^1.19.1", + "father": "^4.0.0", "less": "^3.10.3", "np": "^7.0.0", "prettier": "^2.0.5", diff --git a/script/update-content.js b/script/update-content.js new file mode 100644 index 0000000..60452da --- /dev/null +++ b/script/update-content.js @@ -0,0 +1,34 @@ +/* + 用于 dumi 改造使用, + 可用于将 examples 的文件批量修改为 demo 引入形式, + 其他项目根据具体情况使用。 +*/ + +const fs = require('fs'); +const glob = require('glob'); + +const paths = glob.sync('./examples/*.tsx'); + +paths.forEach(path => { + const name = path.split('/').pop().split('.')[0]; + fs.writeFile( + `./docs/demo/${name}.md`, + `--- +title: ${name} +nav: + title: Demo + path: /demo +--- + + +`, + 'utf8', + function(error) { + if(error){ + console.log(error); + return false; + } + console.log(`${name} 更新成功~`); + } + ) +}); diff --git a/tsconfig.json b/tsconfig.json index 1248088..d52cfbf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "esModuleInterop": true, "paths": { "@/*": ["src/*"], - "@@/*": ["src/.umi/*"], + "@@/*": [".dumi/tmp/*"], "rc-overflow": ["src/index.tsx"] } } From dfde94fcbe3a4028bc55a0a10fd799d2ba0f8a87 Mon Sep 17 00:00:00 2001 From: DBSDs <379712747@qq.com> Date: Thu, 16 Nov 2023 21:24:07 +0800 Subject: [PATCH 2/4] chore: fix father 4.x compile --- .fatherrc.js | 9 --------- .fatherrc.ts | 5 +++++ package.json | 3 ++- 3 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 .fatherrc.js create mode 100644 .fatherrc.ts diff --git a/.fatherrc.js b/.fatherrc.js deleted file mode 100644 index 912aa0a..0000000 --- a/.fatherrc.js +++ /dev/null @@ -1,9 +0,0 @@ -export default { - cjs: 'babel', - esm: { type: 'babel', importLibToEs: true }, - preCommit: { - eslint: true, - prettier: true, - }, - runtimeHelpers: true, -}; diff --git a/.fatherrc.ts b/.fatherrc.ts new file mode 100644 index 0000000..96268ae --- /dev/null +++ b/.fatherrc.ts @@ -0,0 +1,5 @@ +import { defineConfig } from 'father'; + +export default defineConfig({ + plugins: ['@rc-component/father-plugin'], +}); diff --git a/package.json b/package.json index 62a53d2..3108326 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "rc-util": "^5.37.0" }, "devDependencies": { + "@rc-component/father-plugin": "^1.0.0", "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^12.0.0", "@types/classnames": "^2.2.9", @@ -57,7 +58,7 @@ "@types/jest": "^26.0.23", "@types/react": "^16.14.2", "@types/react-dom": "^16.9.10", - "@umijs/fabric": "^2.0.8", + "@umijs/fabric": "^3.0.0", "glob": "^10.0.0", "cross-env": "^7.0.2", "dumi": "^2.0.0", From 355332271b2251cd38f1c05dc66f5cd5d0d4d2a3 Mon Sep 17 00:00:00 2001 From: DBSDs <379712747@qq.com> Date: Sun, 3 Dec 2023 01:10:52 +0800 Subject: [PATCH 3/4] chore: use rc-test --- jest.config.js | 1 - package.json | 10 ++++++---- tests/setup.js | 18 ++++++++---------- tests/setupFilesAfterEnv.ts | 1 - tests/wrapper.ts | 3 ++- tsconfig.json | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 tests/setupFilesAfterEnv.ts diff --git a/jest.config.js b/jest.config.js index 9a92751..86627c3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,4 @@ module.exports = { setupFiles: ['./tests/setup.js'], snapshotSerializers: [require.resolve('enzyme-to-json/serializer')], - setupFilesAfterEnv: ['/tests/setupFilesAfterEnv.ts'] }; diff --git a/package.json b/package.json index 3108326..bbd61bf 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "prepare": "dumi setup", "deploy": "npm run docs:build && npm run docs:deploy", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", - "test": "father test", - "test:coverage": "umi-test --coverage", + "test": "rc-test", + "test:coverage": "rc-test --coverage", "prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", "lint": "eslint src/ --ext .tsx,.ts", "lint:tsc": "tsc -p tsconfig.json --noEmit", @@ -70,9 +70,11 @@ "less": "^3.10.3", "np": "^7.0.0", "prettier": "^2.0.5", + "rc-test": "^7.0", "react": "^16.0.0", "react-dom": "^16.0.0", - "regenerator-runtime": "^0.13.7" + "regenerator-runtime": "^0.13.7", + "typescript": "^5.0.0" }, "peerDependencies": { "react": ">=16.9.0", @@ -84,4 +86,4 @@ "tnpm": { "mode": "npm" } -} +} \ No newline at end of file diff --git a/tests/setup.js b/tests/setup.js index 511c8ef..1d5b617 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -11,22 +11,20 @@ Enzyme.configure({ adapter: new Adapter() }); Object.assign(Enzyme.ReactWrapper.prototype, { triggerResize(clientWidth) { + const target = this.find('ResizeObserver').first() + target.invoke('onResize')({}, { clientWidth }) act(() => { - this.find('ResizeObserver').first().props().onResize({}, { clientWidth }); jest.runAllTimers(); - this.update(); - }); + }) + this.update() }, triggerItemResize(index, offsetWidth) { + const target = this.find('Item').at(index).find('ResizeObserver') + target.invoke('onResize')({ offsetWidth }); act(() => { - this.find('Item') - .at(index) - .find('ResizeObserver') - .props() - .onResize({ offsetWidth }); jest.runAllTimers(); - this.update(); - }); + }) + this.update() }, initSize(width, itemWidth) { this.triggerResize(width); diff --git a/tests/setupFilesAfterEnv.ts b/tests/setupFilesAfterEnv.ts deleted file mode 100644 index 7b0828b..0000000 --- a/tests/setupFilesAfterEnv.ts +++ /dev/null @@ -1 +0,0 @@ -import '@testing-library/jest-dom'; diff --git a/tests/wrapper.ts b/tests/wrapper.ts index 24739d8..8a52aa6 100644 --- a/tests/wrapper.ts +++ b/tests/wrapper.ts @@ -1,4 +1,5 @@ -import { mount as enzymeMount, ReactWrapper } from 'enzyme'; +import type { ReactWrapper } from 'enzyme'; +import { mount as enzymeMount } from 'enzyme'; export type MountParam = Parameters; diff --git a/tsconfig.json b/tsconfig.json index d52cfbf..168ea06 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "target": "esnext", "moduleResolution": "node", "baseUrl": "./", - "jsx": "preserve", + "jsx": "react", "declaration": true, "skipLibCheck": true, "esModuleInterop": true, From dc4a559d991b705cf8b72cd2c7ee176a935a38e7 Mon Sep 17 00:00:00 2001 From: "liangjun.chen" Date: Wed, 6 Dec 2023 10:28:21 +0800 Subject: [PATCH 4/4] chore: vercel deploy --- .dumirc.ts | 5 +++-- now.json | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index a52da6c..221cb46 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'dumi'; +const isGitPagesSite = process.env.GITHUB_ACTIONS; export default defineConfig({ favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], @@ -8,8 +9,8 @@ export default defineConfig({ }, exportStatic: {}, outputPath: 'docs-dist', - base: '/rc-overflow/', - publicPath: '/rc-overflow/', + base: isGitPagesSite ? `/rc-overflow/` : ``, + publicPath: isGitPagesSite ? `/rc-overflow/` : ``, styles: [ ` .markdown table { diff --git a/now.json b/now.json index 01a4be8..7b2f649 100644 --- a/now.json +++ b/now.json @@ -4,11 +4,8 @@ "builds": [ { "src": "package.json", - "use": "@now/static-build", + "use": "@vercel/static-build", "config": { "distDir": "docs-dist" } } - ], - "routes": [ - { "src": "/(.*)", "dest": "/dist/$1" } ] } \ No newline at end of file