From 0170dedd0ec659b0078578c23164c9076e0e5f7a Mon Sep 17 00:00:00 2001 From: "Z.To" Date: Sat, 11 Apr 2026 02:40:14 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20add=20discussion=20and=E8=AE=A4?= =?UTF-8?q?=E7=9F=A5=E4=BF=AE=E6=AD=A3=20about=20gitea=20runner=20and=20sq?= =?UTF-8?q?l.js=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bun.lock | 9 ++++++-- changelog.md | 30 ++++++++++++++++++++++++++ docs/taolun.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 4 files changed, 97 insertions(+), 3 deletions(-) diff --git a/bun.lock b/bun.lock index f6e7cee..6df192f 100644 --- a/bun.lock +++ b/bun.lock @@ -13,6 +13,7 @@ }, "devDependencies": { "@types/bun": "latest", + "@types/node": "^25.6.0", }, "peerDependencies": { "typescript": "^5", @@ -98,7 +99,7 @@ "@types/bun": ["@types/bun@1.2.20", "", { "dependencies": { "bun-types": "1.2.20" } }, "sha512-dX3RGzQ8+KgmMw7CsW4xT5ITBSCrSbfHc36SNT31EOUg/LA9JWq0VDdEXDRSe1InVWpd2yLUM1FUF/kEOyTzYA=="], - "@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@types/node": ["@types/node@25.6.0", "", { "dependencies": { "undici-types": "~7.19.0" } }, "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ=="], "@types/react": ["@types/react@19.1.11", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-lr3jdBw/BGj49Eps7EvqlUaoeA0xpj3pc0RoJkHpYaCHkVK7i28dKyImLQb3JVlqs3aYSXf7qYuWOW/fgZnTXQ=="], @@ -212,7 +213,7 @@ "typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="], - "undici-types": ["undici-types@7.10.0", "", {}, "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="], + "undici-types": ["undici-types@7.19.2", "", {}, "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg=="], "utif2": ["utif2@4.1.0", "", { "dependencies": { "pako": "^1.0.11" } }, "sha512-+oknB9FHrJ7oW7A2WZYajOcv4FcDR4CfoGB0dPNfxbi4GO05RRnFmt5oa23+9w32EanrYcSJWspUiJkLMs+37w=="], @@ -232,10 +233,14 @@ "@opentui/core/marked": ["marked@17.0.1", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg=="], + "bun-types/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "image-q/@types/node": ["@types/node@16.9.1", "", {}, "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g=="], "pixelmatch/pngjs": ["pngjs@6.0.0", "", {}, "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg=="], "react-devtools-core/ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="], + + "bun-types/@types/node/undici-types": ["undici-types@7.10.0", "", {}, "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="], } } diff --git a/changelog.md b/changelog.md index 84bc76c..458d17f 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,36 @@ All notable changes to this project will be documented in this file. +## 认知修正 + +### 1. Bun 编译与 native 模块 +Bun 的 `bun build --compile` 无法正确处理 native 模块(如 `@libsql/client`),运行时会报错 "Cannot find module"。这是 Bun 1.3.4+ 的已知 bug。 + +**解决方案**:使用纯 JS 实现的 `sql.js` 替代 `@libsql/client`,可正常编译运行。 + +### 2. Gitea Actions 镜像问题 +自定义镜像默认未安装 git,需要在 workflow 中手动安装: + +```yaml +- name: Install git + run: apt-get update && apt-get install -y git +``` + +### 3. Release 自动生成 changelog +在 workflow 中使用 git log 生成变更记录: + +```bash +PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") +CHANGES=$(git log --pretty=format:"- %s (%h)" "$PREV_TAG..HEAD" 2>/dev/null || echo "") +``` + +### 4. Gitea 发布二进制文件的限制 +由于 runner 运行在 Linux 环境,无法直接编译 Windows/macOS 可执行文件。如需跨平台发布,考虑: +- 使用 Go/Rust 等支持交叉编译的语言 +- 或仅发布源代码压缩包 + +--- + ## [0.1.0] - 2026-04-11 ### Added diff --git a/docs/taolun.md b/docs/taolun.md index 492c08b..2da8d5c 100644 --- a/docs/taolun.md +++ b/docs/taolun.md @@ -52,6 +52,64 @@ 1. **Multi-select feature**: Double-click selection mode experience is not ideal, keyboard modifier key approach couldn't be implemented 2. **TypeScript type errors**: Some type errors in NoteEditor (bold attribute doesn't exist, etc.) +## Gitea Runner and Release Workflow + +### Runner Configuration + +- **Image**: `hub.gaomia.site/titor/bun:latest` (based on Debian bookworm with Bun installed) +- **Default label**: `ubuntu-latest` +- **Issue**: Custom image doesn't have git pre-installed + +**Solution**: Install git in workflow: + +```yaml +- name: Install git + run: apt-get update && apt-get install -y git +``` + +### Release Workflow (Auto-changelog) + +Trigger on push tag (`v*`): + +1. Clone repository using token +2. Install dependencies: `bun install` +3. Build: `bun run build` +4. Create release and upload source archive: + +```bash +TAG_NAME="${GITHUB_REF#refs/tags/}" +PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") +CHANGES=$(git log --pretty=format:"- %s (%h)" "$PREV_TAG..HEAD" 2>/dev/null || echo "") + +# Create release via Gitea API +curl -X POST "https://hub.gaomia.site/api/v1/repos/titor/mio/releases" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${CHANGES}\"}" +``` + +### Cross-platform Build Limitation + +- Bun's `bun build --compile` runs on Linux runner → can only produce Linux executable +- Cannot compile Windows/macOS binaries on Linux environment +- Workaround: Publish source code archive instead of binaries + +### Bun Compilation Bug with Native Modules + +**Problem**: Using `@libsql/client` (native SQLite binding) causes runtime error: +``` +error: Cannot find module '@libsql/win32-x64-msvc' from 'B:\~BUN\root\mio.exe' +``` + +This is a known bug in Bun 1.3.4+ with native modules. + +**Solution**: Replace `@libsql/client` with `sql.js` (pure JavaScript SQLite implementation): + +1. Replace dependency in package.json +2. Rewrite db.ts to use sql.js API (async initialization, different query syntax) +3. Update all function calls in index.tsx and NoteEditor.tsx + +Result: `bun build --compile` works correctly on all platforms. + ## Build Instructions ```bash diff --git a/package.json b/package.json index acf3e7e..d26c8e5 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "build": "bun build src/index.tsx --compile --outfile mio.exe" }, "devDependencies": { - "@types/bun": "latest" + "@types/bun": "latest", + "@types/node": "^25.6.0" }, "peerDependencies": { "typescript": "^5"