From 0ad72bccacd4233ce815a30544607b5a431b7d38 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Mon, 27 Jan 2025 17:46:00 +0800 Subject: [PATCH 01/12] feat: package manager change to pnpm --- .github/workflows/pull-request.yml | 153 ++++++++++++++++++++++++++++- package.json | 16 +-- 2 files changed, 160 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 66d86bac66..17a8e59a49 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,10 +4,157 @@ name: MAIN_PULL_REQUEST on: - pull_request: + # pull_request: + # branches: [develop, main, compositionAPI] + # types: [opened, synchronize, reopened] + push: branches: [develop, main, compositionAPI] types: [opened, synchronize, reopened] +# jobs: +# call-test-build: +# uses: Tencent/tdesign/.github/workflows/test-build.yml@main + jobs: - call-test-build: - uses: Tencent/tdesign/.github/workflows/test-build.yml@main \ No newline at end of file + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: check_github_primary_email + run: | + log_emails=$(git log --pretty=format:"%ae %ce" -1) + if [[ ${log_emails} =~ 'tdesign@tencent.com' ]];then + echo "$log_emails 跳过验证" + exit 0 + fi + if [[ ${log_emails} =~ '@tencent.com' ]];then + echo "默认邮箱 $log_emails 校验非法,可以去 https://github.com/settings/emails 更改" + exit 2; + else + echo "邮箱 $log_emails 校验通过"; + fi + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: check_local_email + run: | + log_emails=$(git log --pretty=format:"%ae %ce" -1) + if [[ ${log_emails} =~ 'tdesign@tencent.com' ]];then + echo "$log_emails 跳过验证" + exit 0 + fi + if [[ ${log_emails} =~ '@tencent.com' ]];then + echo "本地提交邮箱 $log_emails 校验非法,需要本地更改重新提交" + exit 2; + else + echo "邮箱 $log_emails 校验通过"; + fi + + test: + # needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: pnpm/action-setup@v4 + with: + version: 9 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/cache@v4 + env: + cache-name: cache-nodemodules + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - run: pnpm install + + - run: pnpm run lint + - run: pnpm run test + # upload report to codecov + - uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + site: + runs-on: ubuntu-latest + # needs: test + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: pnpm/action-setup@v4 + with: + version: 9 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/cache@v4 + env: + cache-name: cache-nodemodules + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - run: pnpm install + + - name: Build site + run: pnpm run site:preview + + - run: | + zip -r _site.zip _site + + - name: upload _site artifact + uses: actions/upload-artifact@v4 + with: + name: _site + path: _site.zip + retention-days: 5 + + - name: Save PR number + if: ${{ always() }} + run: echo ${{ github.event.number }} > ./pr-id.txt + + - name: Upload PR number + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: pr + path: ./pr-id.txt + +build: + runs-on: ubuntu-latest + # needs: build + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: pnpm/action-setup@v4 + with: + version: 9 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/cache@v4 + env: + cache-name: cache-nodemodules + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - run: pnpm install + + - name: Build + run: pnpm run build \ No newline at end of file diff --git a/package.json b/package.json index 073934e1b7..d1e0cf5c34 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "version": "1.10.7", "title": "tdesign-vue-next", "description": "TDesign Component for vue-next", + "packageManager": "pnpm@9.5.0", "keywords": [ "vue", "vue3", @@ -47,9 +48,12 @@ "bugs": { "url": "https://github.com/Tencent/tdesign-vue-next/issues" }, + "engines": { + "node": ">= 18" + }, "scripts": { "init": "git submodule init && git submodule update", - "start": "npm run init && npm run dev", + "start": "pnpm run init && pnpm run dev", "dev": "cd site && vite", "site": "cd site && vite build", "site:intranet": "cd site && vite build --mode intranet", @@ -57,20 +61,20 @@ "postsite:preview": "cp _site/index.html _site/404.html", "generate:usage": "node script/generate-usage/index.js", "generate:component": "node script/init/index.js", - "generate:coverage-badge": "npm run test:unit-coverage && node script/test/generate-coverage.js", + "generate:coverage-badge": "pnpm run test:unit-coverage && node script/test/generate-coverage.js", "prebuild": "rimraf es/* esm/* lib/* cjs/* dist/* --glob", - "build": "cross-env NODE_ENV=production rollup -c script/rollup.config.js && npm run build:tsc", + "build": "cross-env NODE_ENV=production rollup -c script/rollup.config.js && pnpm run build:tsc", "build:tsc": "run-p build:tsc-*", "build:tsc-es": "tsc --emitDeclarationOnly -d --outDir es/", "build:tsc-esm": "tsc --emitDeclarationOnly -d --outDir esm/", "build:tsc-lib": "tsc --emitDeclarationOnly -d --outDir lib/", "build:tsc-cjs": "tsc --emitDeclarationOnly -d --outDir cjs/", "lint:fix": "eslint --ext .vue,.js,.ts,.tsx ./packages --max-warnings 0 --fix --cache", - "lint": "npm run lint:tsc && eslint --ext .vue,.js,.ts,.tsx ./packages --max-warnings 0 --cache", + "lint": "pnpm run lint:tsc && eslint --ext .vue,.js,.ts,.tsx ./packages --max-warnings 0 --cache", "lint:tsc": "tsc --emitDeclarationOnly", - "test": "npm run test:unit && npm run test:snap", + "test": "pnpm run test:unit && pnpm run test:snap", "test:unit": "vitest run", - "test:update": "vitest run -u && npm run test:snap-update", + "test:update": "vitest run -u && pnpm run test:snap-update", "test:unit-dev": "vitest ", "test:unit-gui": "vitest --ui", "test:unit-coverage": "vitest run --coverage", From 146a94d53674e54bb9c00976538afbbfeba4bf53 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Mon, 27 Jan 2025 17:50:02 +0800 Subject: [PATCH 02/12] ci: workflow_dispatch --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 17a8e59a49..1e77fe4d5d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ on: push: branches: [develop, main, compositionAPI] types: [opened, synchronize, reopened] - + workflow_dispatch: # jobs: # call-test-build: # uses: Tencent/tdesign/.github/workflows/test-build.yml@main From 833448107c0231014e1d25e580388eb090b07e3b Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Mon, 27 Jan 2025 17:54:41 +0800 Subject: [PATCH 03/12] ci: mAIN_PULL_REQUEST --- .github/workflows/pull-request.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1e77fe4d5d..60393a1cea 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,6 +1,3 @@ -# 文件名建议统一为 pull-request.yml -# 应用 test-build.yml 的 demo - name: MAIN_PULL_REQUEST on: From c87ddf851cff270fc05793f9da670faff29b6e06 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Mon, 27 Jan 2025 18:02:20 +0800 Subject: [PATCH 04/12] ci: pnpm store --- .github/workflows/pull-request.yml | 53 ++++++++++++++++-------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 60393a1cea..e7085500a9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -60,17 +60,18 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT - uses: actions/cache@v4 - env: - cache-name: cache-nodemodules + name: Setup pnpm cache with: - path: ~/.pnpm-store - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - run: pnpm install + ${{ runner.os }}-pnpm-store- + - run: pnpm i --frozen-lockfile - run: pnpm run lint - run: pnpm run test @@ -92,18 +93,19 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT - uses: actions/cache@v4 - env: - cache-name: cache-nodemodules + name: Setup pnpm cache with: - path: ~/.pnpm-store - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - run: pnpm install - + ${{ runner.os }}-pnpm-store- + - run: pnpm i --frozen-lockfile + - name: Build site run: pnpm run site:preview @@ -141,17 +143,18 @@ build: - uses: actions/setup-node@v4 with: node-version: 18 + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT - uses: actions/cache@v4 - env: - cache-name: cache-nodemodules + name: Setup pnpm cache with: - path: ~/.pnpm-store - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - run: pnpm install + ${{ runner.os }}-pnpm-store- + - run: pnpm i --frozen-lockfile - name: Build run: pnpm run build \ No newline at end of file From c324ae19eb6c2ced83cd976aeda6f84b6e59147b Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Mon, 27 Jan 2025 18:04:04 +0800 Subject: [PATCH 05/12] ci: build --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e7085500a9..cf815c3968 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -130,7 +130,7 @@ jobs: name: pr path: ./pr-id.txt -build: + build: runs-on: ubuntu-latest # needs: build steps: From cab0ee416b6e381c34de0ec177d52a7e5d547ed3 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Mon, 27 Jan 2025 18:08:19 +0800 Subject: [PATCH 06/12] ci: pnpm --- .github/workflows/pull-request.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index cf815c3968..990c7d8d24 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -54,9 +54,10 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - uses: pnpm/action-setup@v4 - with: - version: 9 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 with: node-version: 18 @@ -87,9 +88,10 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - uses: pnpm/action-setup@v4 - with: - version: 9 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 with: node-version: 18 @@ -137,9 +139,10 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - uses: pnpm/action-setup@v4 - with: - version: 9 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 with: node-version: 18 From 853b387392253605222316f3698d25ff953920b0 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Mon, 27 Jan 2025 19:33:46 +0800 Subject: [PATCH 07/12] ci: pp install --- .github/workflows/pull-request.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 990c7d8d24..c11af9d29b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -57,7 +57,7 @@ jobs: - name: Setup pnpm uses: pnpm/action-setup@v4 - + - uses: actions/setup-node@v4 with: node-version: 18 @@ -72,7 +72,7 @@ jobs: key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- - - run: pnpm i --frozen-lockfile + - run: pnpm i - run: pnpm run lint - run: pnpm run test @@ -106,7 +106,7 @@ jobs: key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- - - run: pnpm i --frozen-lockfile + - run: pnpm i - name: Build site run: pnpm run site:preview @@ -157,7 +157,7 @@ jobs: key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- - - run: pnpm i --frozen-lockfile + - run: pnpm i - name: Build run: pnpm run build \ No newline at end of file From d51de0a4b1fd8cd9723d8da148e34643ce685147 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Fri, 31 Jan 2025 15:09:34 +0800 Subject: [PATCH 08/12] chore: add npmrc and skiplib ts lint --- .npmrc | 2 ++ tsconfig.json | 1 + 2 files changed, 3 insertions(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..26458001e3 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +# 提升依赖项到根目录,以避免重复安装相同的包 +shamefully-hoist=true diff --git a/tsconfig.json b/tsconfig.json index e28a587524..0cbba0f309 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,7 @@ "suppressImplicitAnyIndexErrors": true, "allowSyntheticDefaultImports": true, "resolveJsonModule": true, + "skipLibCheck": true, "allowJs": true, "jsx": "preserve", "baseUrl": "./", From 50000fbae166a2b53d46c0613d304bccd4a44691 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Fri, 31 Jan 2025 20:07:59 +0800 Subject: [PATCH 09/12] chore: commitlint dir --- commitlint.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitlint.config.js b/commitlint.config.js index 80118c66e8..8c31be08dc 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -3,7 +3,7 @@ const path = require('path'); const { execSync } = require('child_process'); const packages = fs - .readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true }) + .readdirSync(path.resolve(__dirname, 'packages/components'), { withFileTypes: true }) .filter((dirent) => dirent.isDirectory()) .map((dirent) => dirent.name); From ce3d054f5f533c63c8a4fdacf5b61ad3599d72d4 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Fri, 31 Jan 2025 20:08:34 +0800 Subject: [PATCH 10/12] chore: build:tsc script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d1e0cf5c34..f8e76f74ae 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "generate:coverage-badge": "pnpm run test:unit-coverage && node script/test/generate-coverage.js", "prebuild": "rimraf es/* esm/* lib/* cjs/* dist/* --glob", "build": "cross-env NODE_ENV=production rollup -c script/rollup.config.js && pnpm run build:tsc", - "build:tsc": "run-p build:tsc-*", + "build:tsc": "pnpm run build:tsc-es && pnpm run build:tsc-esm && pnpm run build:tsc-lib && pnpm run build:tsc-cjs", "build:tsc-es": "tsc --emitDeclarationOnly -d --outDir es/", "build:tsc-esm": "tsc --emitDeclarationOnly -d --outDir esm/", "build:tsc-lib": "tsc --emitDeclarationOnly -d --outDir lib/", From 5e3da1a941c4030e90b78f6d84182ff0242456c5 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Fri, 31 Jan 2025 20:32:19 +0800 Subject: [PATCH 11/12] chore: pr yml add comments --- .github/workflows/pull-request.yml | 90 ++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c11af9d29b..055d8d9aca 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,163 +1,243 @@ name: MAIN_PULL_REQUEST on: - # pull_request: - # branches: [develop, main, compositionAPI] - # types: [opened, synchronize, reopened] - push: + pull_request: branches: [develop, main, compositionAPI] + # opened:当 PR 创建时触发 + # synchronize:当 PR 的源分支有新的提交时触发 + # reopened:当关闭的 PR 重新打开时触发 types: [opened, synchronize, reopened] + # workflow_dispatch:允许手动触发工作流 workflow_dispatch: + +# todo: paopao # jobs: # call-test-build: # uses: Tencent/tdesign/.github/workflows/test-build.yml@main jobs: check: + # 在最新版本的 Ubuntu 环境中运行 runs-on: ubuntu-latest steps: + # 检出代码仓库 - uses: actions/checkout@v4 + + # 检查 GitHub 提交记录中的邮箱 - name: check_github_primary_email run: | + # 获取最新提交的作者邮箱和提交者邮箱 log_emails=$(git log --pretty=format:"%ae %ce" -1) + # 如果邮箱包含 'tdesign@tencent.com',跳过验证 if [[ ${log_emails} =~ 'tdesign@tencent.com' ]];then echo "$log_emails 跳过验证" exit 0 fi + # 如果邮箱包含 '@tencent.com',校验失败,提示用户更改邮箱 if [[ ${log_emails} =~ '@tencent.com' ]];then echo "默认邮箱 $log_emails 校验非法,可以去 https://github.com/settings/emails 更改" exit 2; else + # 否则,校验通过 echo "邮箱 $log_emails 校验通过"; fi + + # 再次检出代码仓库,这次使用 PR 的源分支的 SHA - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} + + # 检查本地提交记录中的邮箱 - name: check_local_email run: | + # 获取最新提交的作者邮箱和提交者邮箱 log_emails=$(git log --pretty=format:"%ae %ce" -1) + # 如果邮箱包含 'tdesign@tencent.com',跳过验证 if [[ ${log_emails} =~ 'tdesign@tencent.com' ]];then echo "$log_emails 跳过验证" exit 0 fi + # 如果邮箱包含 '@tencent.com',校验失败,提示用户更改本地邮箱 if [[ ${log_emails} =~ '@tencent.com' ]];then echo "本地提交邮箱 $log_emails 校验非法,需要本地更改重新提交" exit 2; else + # 否则,校验通过 echo "邮箱 $log_emails 校验通过"; fi test: + # 如果需要依赖 check 任务,可以取消注释 # needs: check + # 在最新版本的 Ubuntu 环境中运行 runs-on: ubuntu-latest steps: + # 检出代码仓库,并递归初始化子模块 - uses: actions/checkout@v4 with: submodules: recursive + # 设置 pnpm - name: Setup pnpm uses: pnpm/action-setup@v4 + # 设置 Node.js 环境,版本为 18 - uses: actions/setup-node@v4 with: node-version: 18 + + # 获取 pnpm 的存储目录路径 - name: Get pnpm store directory id: pnpm-cache run: | echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + + # 设置 pnpm 缓存 - uses: actions/cache@v4 name: Setup pnpm cache with: + # 缓存路径 path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + # 缓存键 key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + # 恢复缓存的备用键 restore-keys: | ${{ runner.os }}-pnpm-store- + + # 安装依赖 - run: pnpm i + # 运行代码 lint 检查 - run: pnpm run lint + + # 运行测试 - run: pnpm run test # upload report to codecov + + # 将测试报告上传到 Codecov - uses: codecov/codecov-action@v2 with: + # 使用 GitHub Secrets 中的 Codecov Token token: ${{ secrets.CODECOV_TOKEN }} site: + # 在最新版本的 Ubuntu 环境中运行 runs-on: ubuntu-latest + # 如果需要依赖 test 任务,可以取消注释 # needs: test steps: + # 检出代码仓库,并递归初始化子模块 - uses: actions/checkout@v4 with: submodules: recursive + # 设置 pnpm - name: Setup pnpm uses: pnpm/action-setup@v4 + # 设置 Node.js 环境,版本为 18 - uses: actions/setup-node@v4 with: node-version: 18 + + # 获取 pnpm 的存储目录路径 - name: Get pnpm store directory id: pnpm-cache run: | echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + + # 设置 pnpm 缓存 - uses: actions/cache@v4 name: Setup pnpm cache with: + # 缓存路径 path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + # 缓存键 key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + # 恢复缓存的备用键 restore-keys: | ${{ runner.os }}-pnpm-store- + + # 安装依赖 - run: pnpm i - + + # 构建站点 - name: Build site run: pnpm run site:preview + # 将构建的站点文件压缩为 zip - run: | zip -r _site.zip _site + # 上传站点文件作为构建产物 - name: upload _site artifact uses: actions/upload-artifact@v4 with: + # 产物名称 name: _site + # 产物路径 path: _site.zip + # 产物保留天数 retention-days: 5 + # 保存 PR 编号到文件 - name: Save PR number + # 无论任务成功或失败都执行 if: ${{ always() }} run: echo ${{ github.event.number }} > ./pr-id.txt + # 上传 PR 编号文件作为构建产物 - name: Upload PR number + # 无论任务成功或失败都执行 if: ${{ always() }} uses: actions/upload-artifact@v4 with: + # 产物名称 name: pr + # 产物路径 path: ./pr-id.txt build: + # 在最新版本的 Ubuntu 环境中运行 runs-on: ubuntu-latest + # 如果需要依赖自身任务,可以取消注释(通常不需要) # needs: build steps: + # 检出代码仓库,并递归初始化子模块 - uses: actions/checkout@v4 with: submodules: recursive + # 设置 pnpm - name: Setup pnpm uses: pnpm/action-setup@v4 + # 设置 Node.js 环境,版本为 18 - uses: actions/setup-node@v4 with: node-version: 18 + + # 获取 pnpm 的存储目录路径 - name: Get pnpm store directory id: pnpm-cache run: | echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + + # 设置 pnpm 缓存 - uses: actions/cache@v4 name: Setup pnpm cache with: + # 缓存路径 path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + # 缓存键 key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + # 恢复缓存的备用键 restore-keys: | ${{ runner.os }}-pnpm-store- + + # 安装依赖 - run: pnpm i + # 运行构建任务 - name: Build run: pnpm run build \ No newline at end of file From 348418559fb182441aeb9964fa4531601864c141 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Fri, 31 Jan 2025 22:39:53 +0800 Subject: [PATCH 12/12] refactor: use npm-run-all2 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f8e76f74ae..92e0245058 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "generate:coverage-badge": "pnpm run test:unit-coverage && node script/test/generate-coverage.js", "prebuild": "rimraf es/* esm/* lib/* cjs/* dist/* --glob", "build": "cross-env NODE_ENV=production rollup -c script/rollup.config.js && pnpm run build:tsc", - "build:tsc": "pnpm run build:tsc-es && pnpm run build:tsc-esm && pnpm run build:tsc-lib && pnpm run build:tsc-cjs", + "build:tsc": "run-p build:tsc-*", "build:tsc-es": "tsc --emitDeclarationOnly -d --outDir es/", "build:tsc-esm": "tsc --emitDeclarationOnly -d --outDir esm/", "build:tsc-lib": "tsc --emitDeclarationOnly -d --outDir lib/", @@ -161,7 +161,7 @@ "lint-staged": "^13.2.3", "mockdate": "^3.0.5", "msw": "^1.2.3", - "npm-run-all": "^4.1.5", + "npm-run-all2": "^7.0.2", "postcss": "^8.4.26", "prettier": "2.8.1", "prismjs": "^1.29.0",