Skip to content

Commit bf4e41b

Browse files
apoint123Linho1219
andauthored
更换各个工具链 (#476)
* chore: 将 pnpm 更换为 bun * chore: 将打包工具从 vite 更换为 tsdown * chore: 更换为预览版 tsgo 编译器 * fix: 删除不需要的包 * chore: 更新 TS 配置 * chore: 简化 files 配置 * ci: 允许 publish-libs dry-run 在非 main 运行 * docs: 修复 typedoc 自动引入 node 类型导致报错 * chore: 移除 core Canvas 渲染器 * chore: core 启用 isolatedDeclarations * fix: 修复 core isolatedDeclarations 若干错误 * fix: 移除 react-full 中的 canvas 引擎配置 * chore: 移除 canvas 渲染器发布计划 * ci: PR 检查工作流移除 node * ci: 文档构建工作流移除 node * fix: 修正 glsl 和 svg 的导入 * fix: 修正 react-full 构建 * refactor: 将 playground 从 react-full 中抽离 * ci: 更新工作流依赖版本 * ci: 迁移发布工作流适配 --------- Co-authored-by: Linho <linho1219@outlook.com>
1 parent eec2bd5 commit bf4e41b

115 files changed

Lines changed: 4176 additions & 17789 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
shopt -s nullglob
5+
plans=(.nx/version-plans/*.md)
6+
7+
if [ ${#plans[@]} -eq 0 ]; then
8+
echo "No release plans were found in .nx/version-plans."
9+
exit 1
10+
fi
11+
12+
echo "Found ${#plans[@]} release plan(s)."
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require("node:fs");
4+
const path = require("node:path");
5+
6+
const nxJsonPath = path.resolve(process.cwd(), "nx.json");
7+
8+
const nxJson = JSON.parse(fs.readFileSync(nxJsonPath, "utf8"));
9+
nxJson.cli = { ...(nxJson.cli || {}), packageManager: "npm" };
10+
fs.writeFileSync(nxJsonPath, `${JSON.stringify(nxJson, null, 2)}\n`);
11+
12+
const { detectPackageManager } = require("nx/src/utils/package-manager");
13+
console.log(`Nx detected package manager: ${detectPackageManager()}`);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { execSync } from "node:child_process";
2+
3+
console.log(process.version);
4+
console.log(execSync("npm --version", { encoding: "utf8" }).trim());
5+
6+
const [nodeMajor, nodeMinor] = process.versions.node.split(".").map(Number);
7+
if (nodeMajor < 22 || (nodeMajor === 22 && nodeMinor < 14)) {
8+
throw new Error("Node.js 22.14.0+ is required for trusted publishing.");
9+
}
10+
11+
const [npmMajor, npmMinor, npmPatch] = execSync("npm --version", {
12+
encoding: "utf8",
13+
})
14+
.trim()
15+
.split(".")
16+
.map(Number);
17+
18+
const npmOk =
19+
npmMajor > 11 ||
20+
(npmMajor === 11 && npmMinor > 5) ||
21+
(npmMajor === 11 && npmMinor === 5 && npmPatch >= 1);
22+
23+
if (!npmOk) {
24+
throw new Error("npm 11.5.1+ is required for trusted publishing.");
25+
}

.github/workflows/deploy-docs.yaml

Lines changed: 0 additions & 66 deletions
This file was deleted.

.github/workflows/deploy-site.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Deploy Site"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: deploy-site
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build-docs:
21+
name: Build docs
22+
runs-on: ubuntu-latest
23+
environment:
24+
name: github-pages
25+
steps:
26+
- uses: actions/checkout@v6
27+
name: Checkout repository
28+
29+
- name: Setup Github Pages
30+
uses: actions/configure-pages@v6
31+
32+
- name: Setup Bun
33+
uses: oven-sh/setup-bun@v2
34+
35+
- name: Install dependencies
36+
run: bun install
37+
38+
- name: Build docs
39+
run: bun nx build docs
40+
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v5
43+
with:
44+
path: packages/docs/dist
45+
46+
deploy-docs:
47+
name: Deploy site
48+
runs-on: ubuntu-latest
49+
needs: build-docs
50+
environment:
51+
name: github-pages
52+
url: ${{ steps.deployment.outputs.page_url }}
53+
steps:
54+
- name: Deploy to Github Pages
55+
id: deployment
56+
uses: actions/deploy-pages@v5

.github/workflows/pr-release-check.yaml

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,36 @@ jobs:
2828

2929
steps:
3030
- name: Checkout repository
31-
uses: actions/checkout@v4
31+
uses: actions/checkout@v6
3232
with:
3333
fetch-depth: 0
3434

35-
- name: Setup Node.js
36-
uses: actions/setup-node@v4
37-
with:
38-
node-version: lts/*
35+
- name: Setup Bun
36+
uses: oven-sh/setup-bun@v2
3937

4038
- name: Decide whether a release plan is required
4139
id: release-requirements
42-
run: node .github/scripts/check-release-requirements.mjs
40+
run: bun .github/scripts/check-release-requirements.mjs
4341
env:
4442
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4543
GITHUB_REPOSITORY: ${{ github.repository }}
4644
PR_NUMBER: ${{ github.event.pull_request.number }}
4745

48-
- name: Setup pnpm
49-
uses: pnpm/action-setup@v4
50-
51-
- name: Setup cached Node.js for pnpm
52-
if: steps.release-requirements.outputs.requires_release_plan == 'true'
53-
uses: actions/setup-node@v4
54-
with:
55-
node-version: lts/*
56-
cache: pnpm
57-
5846
- name: Install dependencies
5947
if: steps.release-requirements.outputs.requires_release_plan == 'true'
60-
run: pnpm install --frozen-lockfile --ignore-scripts
48+
run: bun install --frozen-lockfile
6149

6250
- name: Set Nx SHAs
6351
if: steps.release-requirements.outputs.requires_release_plan == 'true'
64-
uses: nrwl/nx-set-shas@v4
52+
uses: nrwl/nx-set-shas@v5
6553

6654
- name: Keep only release plans from this PR
6755
if: steps.release-requirements.outputs.requires_release_plan == 'true'
6856
run: bash .github/scripts/keep-pr-release-plans.sh "${{ env.NX_BASE }}" "${{ env.NX_HEAD }}"
6957

7058
- name: Check release plans
7159
if: steps.release-requirements.outputs.requires_release_plan == 'true'
72-
run: pnpm release:plan:check --base="${{ env.NX_BASE }}" --head="${{ env.NX_HEAD }}"
60+
run: bun run release:plan:check --base="${{ env.NX_BASE }}" --head="${{ env.NX_HEAD }}"
7361

7462
build-libraries:
7563
name: Build libs
@@ -78,21 +66,15 @@ jobs:
7866

7967
steps:
8068
- name: Checkout repository
81-
uses: actions/checkout@v4
69+
uses: actions/checkout@v6
8270
with:
8371
fetch-depth: 0
8472

85-
- name: Setup pnpm
86-
uses: pnpm/action-setup@v4
87-
88-
- name: Setup Node.js
89-
uses: actions/setup-node@v4
90-
with:
91-
node-version: lts/*
92-
cache: pnpm
73+
- name: Setup Bun
74+
uses: oven-sh/setup-bun@v2
9375

9476
- name: Install dependencies
95-
run: pnpm install --frozen-lockfile --ignore-scripts
77+
run: bun install --frozen-lockfile
9678

9779
- name: Install Rust toolchain
9880
uses: dtolnay/rust-toolchain@v1
@@ -106,6 +88,6 @@ jobs:
10688
version: v0.13.1
10789

10890
- name: Build publishable libraries
109-
run: pnpm ci:build:libs
91+
run: bun run ci:build:libs
11092
env:
11193
AMLL_GITHUB_IS_ACTION: true

.github/workflows/publish-libs.yaml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,32 @@ jobs:
2626
runs-on: ubuntu-latest
2727

2828
steps:
29-
- name: Ensure this workflow runs from main
30-
if: github.ref_name != 'main'
29+
- name: Ensure publish runs from main
30+
if: github.event.inputs.mode == 'publish' && github.ref_name != 'main'
3131
run: |
32-
echo "This workflow must be dispatched from the main branch."
32+
echo "Publishing must be dispatched from the main branch. Use dry-run mode to test from other branches."
3333
exit 1
3434
3535
- name: Checkout repository
36-
uses: actions/checkout@v4
36+
uses: actions/checkout@v6
3737
with:
3838
fetch-depth: 0
3939
ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }}
4040

41-
- name: Setup pnpm
42-
uses: pnpm/action-setup@v4
41+
- name: Setup Bun
42+
uses: oven-sh/setup-bun@v2
4343

4444
- name: Setup Node.js
4545
uses: actions/setup-node@v6
4646
with:
47-
node-version: '24'
48-
cache: pnpm
47+
node-version: "24"
4948
registry-url: https://registry.npmjs.org
5049

5150
- name: Verify trusted publishing runtime requirements
52-
run: |
53-
node --version
54-
npm --version
55-
node -e "const [major, minor] = process.versions.node.split('.').map(Number); if (major < 22 || (major === 22 && minor < 14)) process.exit(1)"
56-
node -e "const version = require('child_process').execSync('npm --version', { encoding: 'utf8' }).trim().split('.').map(Number); if (version[0] < 11 || (version[0] === 11 && version[1] < 5) || (version[0] === 11 && version[1] === 5 && version[2] < 1)) process.exit(1)"
51+
run: node .github/scripts/verify-trusted-publishing-runtime.mjs
5752

5853
- name: Install dependencies
59-
run: pnpm install --frozen-lockfile --ignore-scripts
54+
run: bun install --frozen-lockfile
6055

6156
- name: Install Rust toolchain
6257
uses: dtolnay/rust-toolchain@v1
@@ -75,29 +70,28 @@ jobs:
7570
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
7671
7772
- name: Ensure release plans exist
78-
run: |
79-
shopt -s nullglob
80-
plans=(.nx/version-plans/*.md)
81-
if [ ${#plans[@]} -eq 0 ]; then
82-
echo "No release plans were found in .nx/version-plans."
83-
exit 1
84-
fi
73+
run: bash .github/scripts/ensure-release-plans-exist.sh
8574

8675
- name: Dry-run release
87-
run: pnpm nx release --dry-run --preid alpha
76+
if: github.event.inputs.mode == 'dry-run'
77+
run: npx nx release --dry-run --preid alpha
8878
env:
8979
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9080

9181
- name: Create release commit and tags
9282
if: github.event.inputs.mode == 'publish'
93-
run: pnpm nx release --skip-publish --preid alpha
83+
run: npx nx release --skip-publish --preid alpha
9484
env:
9585
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9686

87+
- name: Force Nx publish executor to npm for OIDC
88+
if: github.event.inputs.mode == 'publish'
89+
run: node .github/scripts/force-nx-publish-package-manager-npm.cjs
90+
9791
- name: Push release commit and tags
9892
if: github.event.inputs.mode == 'publish'
9993
run: git push origin HEAD:main --follow-tags
10094

10195
- name: Publish packages to npm
10296
if: github.event.inputs.mode == 'publish'
103-
run: pnpm nx release publish
97+
run: npx nx release publish

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ target/
1919
.vscode/
2020
*.tsbuildinfo
2121
.million/
22+
**/dist

0 commit comments

Comments
 (0)