From c4a077afd8b9fd04ab38c96024b978d3c4110e2c Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 10:03:28 +0800 Subject: [PATCH 1/7] chore: standardize repository maintenance --- .github/FUNDING.yml | 2 + .github/dependabot.yml | 8 ++++ .github/workflows/codeql.yml | 43 ++++++++++++++++++ .github/workflows/main.yml | 70 ++++++------------------------ .github/workflows/react-doctor.yml | 22 ++++++++++ .github/workflows/test-npm.yml | 2 +- .github/workflows/test-utoo.yml | 2 +- .github/workflows/test.yml | 2 +- LICENSE | 21 +++++++++ README.md | 59 +++++++++++++++++++++++-- README.zh-CN.md | 62 ++++++++++++++++++++++++++ package.json | 8 ++-- 12 files changed, 234 insertions(+), 67 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/react-doctor.yml create mode 100644 LICENSE create mode 100644 README.zh-CN.md diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..758659a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: ant-design +open_collective: ant-design diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 469ba55..1a0be6a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,10 @@ updates: time: "21:00" timezone: Asia/Shanghai open-pull-requests-limit: 10 + groups: + npm-dependencies: + patterns: + - "*" - package-ecosystem: github-actions directory: "/" @@ -17,3 +21,7 @@ updates: time: "21:00" timezone: Asia/Shanghai open-pull-requests-limit: 10 + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..10f4f6b --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,43 @@ +name: "CodeQL" + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + schedule: + - cron: "36 13 * * 3" + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [javascript-typescript] + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Initialize CodeQL + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb9fdd4..1043fdf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,68 +1,24 @@ -name: CI +name: ✅ test on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] -jobs: - setup: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@master - - - uses: actions/setup-node@v1 - with: - node-version: '12' - - - name: cache package-lock.json - uses: actions/cache@v2 - with: - path: package-temp-dir - key: lock-${{ github.sha }} - - - name: create package-lock.json - run: npm i --package-lock-only - - - name: hack for singe file - run: | - if [ ! -d "package-temp-dir" ]; then - mkdir package-temp-dir - fi - cp package-lock.json package-temp-dir - - - name: cache node_modules - id: node_modules_cache_id - uses: actions/cache@v2 - with: - path: node_modules - key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} - - - name: install - if: steps.node_modules_cache_id.outputs.cache-hit != 'true' - run: npm ci +permissions: + contents: read +jobs: test: runs-on: ubuntu-latest steps: - - name: checkout - uses: actions/checkout@master - - - name: restore cache from package-lock.json - uses: actions/cache@v2 + - uses: actions/checkout@v7 with: - path: package-temp-dir - key: lock-${{ github.sha }} - - - name: restore cache from node_modules - uses: actions/cache@v2 + persist-credentials: false + - uses: actions/setup-node@v6 with: - path: node_modules - key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} - - - name: test - run: npm test - - needs: setup + node-version: 22 + - run: npm install --legacy-peer-deps + - run: npm run compile + - run: npm run test:only diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 0000000..20e282c --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,22 @@ +name: React Doctor + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + pull-requests: write + issues: write + statuses: write + +jobs: + react-doctor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index 2e0d9cd..c8831b8 100644 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -19,6 +19,6 @@ jobs: - run: npx tsc --noEmit - run: npm run compile - run: npm run test -- --coverage - - uses: codecov/codecov-action@v5 + - uses: codecov/codecov-action@v7 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/test-utoo.yml b/.github/workflows/test-utoo.yml index eed55b8..1c82995 100644 --- a/.github/workflows/test-utoo.yml +++ b/.github/workflows/test-utoo.yml @@ -23,6 +23,6 @@ jobs: - run: utx tsc --noEmit - run: ut compile - run: ut test -- --coverage - - uses: codecov/codecov-action@v5 + - uses: codecov/codecov-action@v7 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1e2b59..7e78400 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,6 @@ jobs: - run: bunx tsc --noEmit - run: bun run compile - run: bun run test -- --coverage - - uses: codecov/codecov-action@v5 + - uses: codecov/codecov-action@v7 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..378e691 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) react-component + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index df49819..ff46dd6 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,62 @@ -# rc-test +
+

rc-test

+

Ant Design Part of the Ant Design ecosystem.

+

🧪 Shared Jest workflow and test runner for rc-component packages.

-test for react component +

+ NPM version + npm downloads + bundle size + build status + Codecov +

+
+ +

English | [简体中文](./README.zh-CN.md)

+ +## Highlights + +| Area | Support | +| ------- | --------------------------------------------------------------- | +| Purpose | Shared Jest workflow and test runner for rc-component packages. | +| Package | `rc-test` | +| Release | `@rc-component/np` / `rc-np` | + +## Install + +```bash +npm install rc-test --save-dev +``` ## Usage +```bash +npx rc-test --coverage +``` + +## API + +| Command | Description | +| -------------------- | ------------------------------------ | +| `rc-test` | Run Jest with rc-component defaults. | +| `rc-test --coverage` | Run tests and collect coverage. | + +## Development + +```bash +npm install +npm run compile +npm run test:only ``` -$ rc-test + +## Release + +```bash +npm run prepublishOnly ``` + +The release flow is handled by `@rc-component/np` through the `rc-np` command when the package uses the shared release flow. + +## License + +rc-test is released under the [MIT](./LICENSE) license. diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 0000000..186de70 --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,62 @@ +
+

rc-test

+

Ant Design Ant Design 生态的一部分。

+

🧪 rc-component 包共享的 Jest 测试运行器与 GitHub Actions 工作流。

+ +

+ NPM version + npm downloads + bundle size + build status + Codecov +

+
+ +

简体中文 | [English](./README.md)

+ +## 亮点 + +| 方向 | 支持 | +| ---- | --------------------------------------------------------------- | +| 定位 | rc-component 包共享的 Jest 测试运行器与 GitHub Actions 工作流。 | +| 包名 | `rc-test` | +| 发布 | `@rc-component/np` / `rc-np` | + +## 安装 + +```bash +npm install rc-test --save-dev +``` + +## 用法 + +```bash +npx rc-test --coverage +``` + +## API + +| 名称 | 说明 | +| -------------------- | ------------------------------------- | +| `rc-test` | 使用 rc-component 默认配置运行 Jest。 | +| `rc-test --coverage` | 运行测试并收集覆盖率。 | + +## 本地开发 + +```bash +npm install +npm run compile +npm run test:only +``` + +## 发布 + +```bash +npm run prepublishOnly +``` + +发布流程通过 `@rc-component/np` 提供的 `rc-np` 命令处理。 + +## 许可证 + +rc-test 基于 [MIT](./LICENSE) 协议发布。 diff --git a/package.json b/package.json index 435fd9e..1155983 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "rc-test", "version": "7.1.2", - "description": "test tools for react component", + "description": "🧪 Shared Jest workflow and test runner for rc-component packages.", "keywords": [ "react", "test" @@ -31,7 +31,7 @@ ], "scripts": { "compile": "father build", - "prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", + "prepublishOnly": "npm run compile && rc-np", "test": "npm run compile && npm run test:only", "test:only": "node ./bin/rc-test.js" }, @@ -62,11 +62,11 @@ "enzyme-adapter-react-16": "^1.15.6", "eslint": "^7.18.0", "father": "^4.0.0-rc.8", - "np": "^10.0.7", "prettier": "^2.1.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "typescript": "^5.0.0" + "typescript": "^5.0.0", + "@rc-component/np": "^1.0.4" }, "peerDependencies": { "react": ">=16.9.0", From e30f29e3fd2afb0bdde1a5c3dd1e6ae2649f1cfb Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 11:59:29 +0800 Subject: [PATCH 2/7] chore: address review feedback --- README.md | 4 ++-- README.zh-CN.md | 4 ++-- package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ff46dd6..9c60dbc 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@

-

English | [简体中文](./README.zh-CN.md)

+

English | 简体中文

## Highlights @@ -44,7 +44,7 @@ npx rc-test --coverage ## Development ```bash -npm install +ut install npm run compile npm run test:only ``` diff --git a/README.zh-CN.md b/README.zh-CN.md index 186de70..5334631 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -12,7 +12,7 @@

-

简体中文 | [English](./README.md)

+

简体中文 | English

## 亮点 @@ -44,7 +44,7 @@ npx rc-test --coverage ## 本地开发 ```bash -npm install +ut install npm run compile npm run test:only ``` diff --git a/package.json b/package.json index 1155983..c181907 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "yargs-parser": "^21.1.1" }, "devDependencies": { + "@rc-component/np": "^1.0.4", "@types/fs-extra": "^9.0.13", "@types/jest": "^29.2.0", "@types/node": "^22.7.5", @@ -65,8 +66,7 @@ "prettier": "^2.1.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "typescript": "^5.0.0", - "@rc-component/np": "^1.0.4" + "typescript": "^5.0.0" }, "peerDependencies": { "react": ">=16.9.0", From 84991acf12bcef9afc3a3e57c9ddb81e8b73fb1c Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:03:16 +0800 Subject: [PATCH 3/7] chore: align maintenance dependencies --- package.json | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index c181907..0df82d0 100644 --- a/package.json +++ b/package.json @@ -36,41 +36,41 @@ "test:only": "node ./bin/rc-test.js" }, "dependencies": { - "@babel/core": "^7.25.2", - "@babel/preset-typescript": "^7.18.6", - "@babel/runtime": "^7.18.0", - "@testing-library/jest-dom": "^5.16.4", - "@testing-library/react": "^13.0.0", - "@umijs/fabric": "^4.0.0", - "babel-jest": "^29.7.0", + "@babel/core": "^7.29.7", + "@babel/preset-typescript": "^7.29.7", + "@babel/runtime": "^7.29.7", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^16.3.2", + "@umijs/fabric": "^4.0.1", + "babel-jest": "^30.4.1", "babel-plugin-module-resolver": "^4.1.0", "babel-preset-umi": "^1.8.4", "core-js": "^3.25.5", "fs-extra": "^10.1.0", - "jest": "^29.2.1", - "jest-environment-jsdom": "^29.2.0", + "jest": "^30.4.2", + "jest-environment-jsdom": "^30.4.1", "regenerator-runtime": "^0.13.10", "umi-utils": "^1.7.3", "yargs-parser": "^21.1.1" }, "devDependencies": { "@rc-component/np": "^1.0.4", - "@types/fs-extra": "^9.0.13", - "@types/jest": "^29.2.0", - "@types/node": "^22.7.5", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", + "@types/fs-extra": "^11.0.4", + "@types/jest": "^30.0.0", + "@types/node": "^26.0.1", + "@types/react": "^19.2.17", + "@types/react-dom": "^19.2.3", "enzyme-adapter-react-16": "^1.15.6", - "eslint": "^7.18.0", - "father": "^4.0.0-rc.8", - "prettier": "^2.1.2", - "react": "^18.0.0", - "react-dom": "^18.0.0", - "typescript": "^5.0.0" + "eslint": "^9.39.4", + "father": "^4.6.24", + "prettier": "^3.9.4", + "react": "^19.2.7", + "react-dom": "^19.2.7", + "typescript": "^6.0.3" }, "peerDependencies": { - "react": ">=16.9.0", - "react-dom": ">=16.9.0" + "react": "^19.2.7", + "react-dom": "^19.2.7" }, "engines": { "node": ">=12.x" From 1554c4da896bb61227cdefa38db47b826e74268b Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:26:49 +0800 Subject: [PATCH 4/7] docs: align Chinese README language switch --- README.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 5334631..0c82905 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -12,7 +12,7 @@

-

简体中文 | English

+

English | 简体中文

## 亮点 From 60c925897c78c066b839cbac3e4b191384afd0aa Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:35:16 +0800 Subject: [PATCH 5/7] fix: preserve React peer dependency range --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0df82d0..5d236f3 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,8 @@ "typescript": "^6.0.3" }, "peerDependencies": { - "react": "^19.2.7", - "react-dom": "^19.2.7" + "react": ">=16.9.0", + "react-dom": ">=16.9.0" }, "engines": { "node": ">=12.x" From 09801e2ff71e607e7c9fd58ab95f078bbe145169 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:45:47 +0800 Subject: [PATCH 6/7] chore: fix upgraded tooling checks --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 5d236f3..f417bde 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@babel/core": "^7.29.7", "@babel/preset-typescript": "^7.29.7", "@babel/runtime": "^7.29.7", + "@testing-library/dom": "^10.4.1", "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", "@umijs/fabric": "^4.0.1", From 75c160934ee1664a7f985ac992e5f9217a1c7b56 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 18:37:04 +0800 Subject: [PATCH 7/7] docs: use npm install in README --- README.md | 2 +- README.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9c60dbc..5fed80e 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ npx rc-test --coverage ## Development ```bash -ut install +npm install npm run compile npm run test:only ``` diff --git a/README.zh-CN.md b/README.zh-CN.md index 0c82905..8e467ca 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -44,7 +44,7 @@ npx rc-test --coverage ## 本地开发 ```bash -ut install +npm install npm run compile npm run test:only ```