From 260293601cf613ed8cea2a0b90661a7e68a4aafb Mon Sep 17 00:00:00 2001 From: Optimistic-Chen <64662582+DBSDs@users.noreply.github.com> Date: Fri, 17 Nov 2023 12:16:08 +0800 Subject: [PATCH] chore: bump dumi@2.x.x && father 4.x.x (#9) --- .dumirc.ts | 22 ++++++++++++++++++++++ .fatherrc.js => .fatherrc.ts | 0 .github/workflows/main.yml | 4 ++-- .gitignore | 9 ++++----- .umirc.ts | 17 ----------------- README.md | 2 +- docs/demo/basic.md | 9 +++++++-- docs/index.md | 4 +++- package.json | 11 +++++++---- script/update-content.js | 34 ++++++++++++++++++++++++++++++++++ tsconfig.json | 2 +- 11 files changed, 81 insertions(+), 33 deletions(-) create mode 100644 .dumirc.ts rename .fatherrc.js => .fatherrc.ts (100%) delete mode 100644 .umirc.ts create mode 100644 script/update-content.js diff --git a/.dumirc.ts b/.dumirc.ts new file mode 100644 index 0000000..3a432d9 --- /dev/null +++ b/.dumirc.ts @@ -0,0 +1,22 @@ +// more config: https://d.umijs.org/config +import { defineConfig } from 'dumi'; + +export default defineConfig({ + favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], + themeConfig: { + name: 'mutate-observer', + logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', + }, + outputPath: '.doc', + exportStatic: {}, + styles: [ + ` + section.dumi-default-header-left { + width: 240px; + } + .markdown table { + width: auto !important; + } + `, + ], +}); diff --git a/.fatherrc.js b/.fatherrc.ts similarity index 100% rename from .fatherrc.js rename to .fatherrc.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd20354..83dcb71 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 8a331ed..21dbd0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.storybook *.iml *.log .idea @@ -29,8 +28,8 @@ yarn.lock package-lock.json .doc -# umi -.umi -.umi-production -.umi-test +# dumi +.dumi/tmp +.dumi/tmp-test +.dumi/tmp-production .env.local \ No newline at end of file diff --git a/.umirc.ts b/.umirc.ts deleted file mode 100644 index 4a422ff..0000000 --- a/.umirc.ts +++ /dev/null @@ -1,17 +0,0 @@ -// more config: https://d.umijs.org/config -import { defineConfig } from 'dumi'; - -export default defineConfig({ - title: 'rc-util', - favicon: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - outputPath: '.doc', - exportStatic: {}, - styles: [ - ` - .markdown table { - width: auto !important; - } - `, - ], -}); diff --git a/README.md b/README.md index 0eaa724..5f25901 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ open http://localhost:8000 ## Usage -```tsx +```tsx | pure import React from 'react'; import MutateObserver from './src'; diff --git a/docs/demo/basic.md b/docs/demo/basic.md index 94cc536..0f22440 100644 --- a/docs/demo/basic.md +++ b/docs/demo/basic.md @@ -1,3 +1,8 @@ -## basic +--- +title: basic +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/index.md b/docs/index.md index 8dd5f2e..7e83f1c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,7 @@ --- -title: rc-mutate-observer +hero: + title: rc-mutate-observer + description: React Mutate Observer Component --- diff --git a/package.json b/package.json index e2d302c..73ec9e8 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ ], "scripts": { "compile": "father build", + "prepare": "dumi setup", "deploy": "npm run docs:build && npm run docs:deploy", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", @@ -50,18 +51,20 @@ "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.0.0", "@types/jest": "^26.0.20", + "@types/node": "^20.9.0", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", - "@umijs/fabric": "^2.5.2", - "dumi": "^1.1.0", + "@umijs/fabric": "^3.0.0", + "dumi": "^2.0.0", "eslint": "^7.18.0", - "father": "^4.0.0-rc.8", + "father": "^4.0.0", "gh-pages": "^3.1.0", + "glob": "^10.0.0", "np": "^5.0.3", "prettier": "^2.1.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "typescript": "^4.6.3", + "typescript": "^5.0.0", "umi-test": "^1.9.7" }, "peerDependencies": { diff --git a/script/update-content.js b/script/update-content.js new file mode 100644 index 0000000..e9ed487 --- /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('./docs/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 3410298..dbb677d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "esModuleInterop": true, "paths": { "@/*": ["src/*"], - "@@/*": ["src/.umi/*"], + "@@/*": [".dumi/tmp/*"], "@rc-component/mutate-observer": ["src/index.tsx"] } }