Skip to content

Commit

Permalink
Merge branch 'feat_v3.x' into refactor_input
Browse files Browse the repository at this point in the history
  • Loading branch information
oasis-cloud committed Feb 20, 2025
2 parents de41f1d + e7eb6f1 commit cfb200a
Show file tree
Hide file tree
Showing 228 changed files with 4,187 additions and 1,172 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install pnpm
run: npm i -g pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install pnpm
run: npm i -g pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
Expand All @@ -50,7 +50,7 @@ jobs:

- name: Upload coverage reports to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -60,7 +60,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install pnpm
run: npm i -g pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install pnpm
run: npm i -g pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
Expand Down
102 changes: 59 additions & 43 deletions .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,80 @@
name: PR Review Labels

on:
schedule:
- cron: '0 */3 * * *'

pull_request_target:
types: [opened, reopened, synchronize, ready_for_review]
pull_request_review:
types: [submitted, edited, dismissed]
types:
- opened
- reopened
- synchronize

permissions:
contents: read
pull-requests: write
issues: write

jobs:
update-labels:
runs-on: ubuntu-latest
steps:
- name: Update PR labels based on reviews
- name: Update PR labels
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const pr_number = context.payload.pull_request.number;
try {
const { owner, repo } = context.repo;
// 获取 PR 的所有 reviews
const reviews = await github.rest.pulls.listReviews({
owner,
repo,
pull_number: pr_number
});
// 获取所有开放的 PRs
const { data: prs } = await github.rest.pulls.list({
owner,
repo,
state: 'open'
});
// 计算 approved 的数量
const approvedCount = reviews.data.filter(
review => review.state === 'APPROVED'
).length;
for (const pr of prs) {
// 获取 PR 的所有 reviews
const { data: reviews } = await github.rest.pulls.listReviews({
owner,
repo,
pull_number: pr.number
});
// 获取当前 PR 的标签
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number: pr_number
});
// 计算最新的 approved 数量
const latestReviews = new Map();
reviews.forEach(review => {
latestReviews.set(review.user.id, review);
});
// 移除已有的 action 标签
const labelsToRemove = currentLabels
.filter(label => label.name === 'action:merge' || label.name === 'action:review')
.map(label => label.name);
const approvedCount = Array.from(latestReviews.values())
.filter(review => review.state === 'APPROVED')
.length;
for (const label of labelsToRemove) {
await github.rest.issues.removeLabel({
owner,
repo,
issue_number: pr_number,
name: label
});
}
console.log(`PR #${pr.number} - Approved count:`, approvedCount);
// 获取当前标签
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number: pr.number
});
// 根据 approved 数量添加对应标签
const newLabel = approvedCount >= 2 ? 'action:merge' : 'action:review';
await github.rest.issues.addLabels({
owner,
repo,
issue_number: pr_number,
labels: [newLabel]
});
// 保留非 action 标签
const labelsToKeep = currentLabels
.filter(label => label.name !== 'action:merge' && label.name !== 'action:review')
.map(label => label.name);
// 添加新标签
const newLabel = approvedCount >= 2 ? 'action:merge' : 'action:review';
await github.rest.issues.setLabels({
owner,
repo,
issue_number: pr.number,
labels: [...labelsToKeep, newLabel]
});
}
} catch (error) {
console.error('Error:', error);
throw error;
}
2 changes: 1 addition & 1 deletion .github/workflows/realease-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: actions/checkout@v4

- name: Install pnpm
run: npm i -g pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/release-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release 3x Beta

on:
# pull_request:
push:
branches:
- feat_v3.x
workflow_dispatch:

jobs:
release-3x-beta:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# ref: ${{ github.event.pull_request.head.sha }}

- name: Get commit message
run: |
COMMIT_MESSAGE=$(git log --format=%s -n 1)
FILTERED_MESSAGE="${COMMIT_MESSAGE//[^a-zA-Z0-9.()_:, -]/}"
echo "COMMIT_MESSAGE=${FILTERED_MESSAGE}" >> $GITHUB_ENV
- name: Show commit message
run: echo "$COMMIT_MESSAGE"

- name: Commit message compliance verification
if: |
!startsWith( env.COMMIT_MESSAGE , 'chore(release):' ) ||
!contains( env.COMMIT_MESSAGE , '-beta' )
run: echo "ABORT=true" >> $GITHUB_ENV

- name: Get Tag message
if: contains( env.COMMIT_MESSAGE , '-beta')
run: echo "RELEASE_TAG=beta" >> $GITHUB_ENV
#
- name: Install pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: '20'
cache: 'pnpm'

- name: Install dependencies
if: env.ABORT != 'true'
run: pnpm install --frozen-lockfile

- name: Run Build
if: env.ABORT != 'true'
run: |
if ! pnpm build; then
echo "构建 nutui-react 失败"
exit 1
fi
if ! pnpm build:taro; then
echo "构建 nutui-react-taro 失败"
exit 1
fi
- name: Run Release @nutui/nutui-react
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: env.ABORT != 'true'
run: pnpm --dir ./release/h5 publish:beta

- name: Run Releases @nutui/nutui-react-taro
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: env.ABORT != 'true'
run: pnpm --dir ./release/taro publish:beta
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release 3.x

on:
push:
tags:
- v3.*
workflow_dispatch:

jobs:
release-3x:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: '20'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run Build
if: env.ABORT != 'true'
run: |
if ! pnpm build; then
echo "构建 nutui-react 失败"
exit 1
fi
if ! pnpm build:taro; then
echo "构建 nutui-react-taro 失败"
exit 1
fi
- name: Run Release @nutui/nutui-react
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: env.ABORT != 'true'
run: pnpm --dir ./release/h5 publish

- name: Run Releases @nutui/nutui-react-taro
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: env.ABORT != 'true'
run: pnpm --dir ./release/taro publish
2 changes: 1 addition & 1 deletion .github/workflows/sync-h5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install pnpm
run: npm i -g pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-migrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install pnpm
run: npm i -g pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-taro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install pnpm
run: npm i -g pnpm
run: npm i -g pnpm@10

- uses: actions/setup-node@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
.npmrc
/dist
/dist-demo
/release
/libs
/jd/upload.js
# yarn.lock
Expand Down
1 change: 0 additions & 1 deletion .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ function readPackage(pkg, context) {
// delete pkg.dependencies[]
}
if (pkg.name === '@nutui/nutui-taro-demo') {
delete pkg.dependencies['@jdreact/jdreact-jsbundle-commonpack']
delete pkg.dependencies['@jdtaro/plugin-platform-jdhybrid']
delete pkg.dependencies['@jdtaro/taro-platform-jdharmony']
delete pkg.dependencies['@jdtaro/plugin-platform-jdharmony-cpp']
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ git clone https://github.com/jdf2e/nutui-react.git
cd nutui-react

# Install dependencies
pnpm install
pnpm install --ignore-pnpmfile

# Enter mini-program development mode
# Taro H5
Expand Down
8 changes: 6 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ pnpm run dev

```

### 本地运行 Taro 相关的预览
### 本地运行 Taro 环境

**注意:在 Taro 环境新增 pnpm pre 钩子,用于 H5 或小程序预览时显示未适配鸿蒙的组件,环境变量可通过 predev:taro 命令查看。**

#### 本地运行 Taro 相关的预览

````sh
# 克隆仓库
Expand All @@ -94,7 +98,7 @@ pnpm dev:taro jd
# 其他平台 参考 demo 目录中 package.json 的 script
````
### 本地运行 JDTaro 相关的预览
#### 本地运行 JDTaro 相关的预览
1. 仓库根目录下增加 .npmrc 文件,增加如下配置:
Expand Down
Loading

0 comments on commit cfb200a

Please sign in to comment.