Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bun-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
bun-version: latest

- name: Install dependencies
run: bun install
run: bun install && cd cf-proxy && bun install && cd ..

- name: Cache setup artifacts
id: cache-setup
Expand Down
115 changes: 115 additions & 0 deletions DATABASE_WINDOWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Windows 安装数据库指南

**问题:** `bun run setup` 在 Windows 上不支持(需要 7-Zip)

**解决方案:** 直接下载优化后的数据库文件

---

## 方案 1:直接下载优化数据库(推荐)

根据 README,可以从官方源直接下载:

```bash
# 需要 DATABASE_DOWNLOAD_TOKEN 环境变量
curl -o db.sqlite "https://jlcsearch.fly.dev/database/$DATABASE_DOWNLOAD_TOKEN"
```

**问题:** 需要 token,可能需要联系项目方获取

---

## 方案 2:使用 WSL(完整支持)

```bash
# 1. 安装 WSL
wsl --install

# 2. 重启后进入 WSL
wsl

# 3. 在 WSL 中安装 Bun
curl -fsSL https://bun.sh/install | bash

# 4. 克隆项目并运行 setup
git clone https://github.com/tscircuit/jlcsearch.git
cd jlcsearch
bun install
bun run setup
```

**优点:** 完整支持所有功能
**缺点:** 需要 WSL,耗时较长

---

## 方案 3:跳过数据库,直接开发(推荐用于 Issue #92)

**对于 Issue #92,不需要完整数据库!**

**原因:**
- Issue #92 只修改数据表定义和 API
- 不需要查询真实数据
- 测试可以写单元测试

**开发流程:**
```bash
# 1. 查看现有表定义
cat lib/db/derivedtables/resistor.ts

# 2. 添加新字段(is_extended_promotional)
# 3. 更新 API 路由
# 4. 编写单元测试
# 5. 提交 PR
```

---

## 方案 4:手动安装 7-Zip 后运行 setup

```powershell
# 1. 手动运行下载的 7z 安装程序
$env:TEMP\7z.exe /S /D="C:\Program Files\7-Zip"

# 2. 添加 7z 到 PATH
$env:Path += ";C:\Program Files\7-Zip"

# 3. 重新运行 setup
bun run setup
```

**预计耗时:** 30-60 分钟
**下载大小:** 约 2GB

---

## 兜兜推荐

**对于 Issue #92 开发:方案 3(跳过数据库)**

**理由:**
1. ✅ 不需要数据库即可开发
2. ✅ 节省时间和磁盘空间
3. ✅ 专注于代码修改
4. ✅ 测试可以后补

**何时需要数据库:**
- 需要做完整集成测试
- 需要验证真实数据查询
- PR 合并前的最终验证

---

## 下一步

如果先生想要完整数据库,建议:
1. 使用 WSL(最稳定)
2. 或联系项目方获取数据库下载 token

如果只是开发 Issue #92:
→ 直接开始编写代码,无需数据库!

---

**更新时间:** 2026-03-10 10:35
**建议人:** 兜兜
165 changes: 165 additions & 0 deletions INSTALL_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# 依赖安装报告

**项目:** tscircuit/jlcsearch
**安装时间:** 2026-03-10 10:30
**安装工具:** Bun v1.3.10

---

## ✅ 安装状态

```
状态:成功
耗时:约 10 秒
包数量:240 个包
```

---

## 📦 主要依赖

### 生产依赖 (dependencies)

| 包名 | 版本 | 用途 |
|------|------|------|
| @tscircuit/footprinter | ^0.0.143 | 封装 footprint 库 |
| kysely-bun-sqlite | ^0.3.2 | Bun SQLite 查询构建器 |
| react | ^18.3.1 | React 库 |
| react-dom | ^18.3.1 | React DOM |
| redaxios | ^0.5.1 | Axios 轻量替代 |

### 开发依赖 (devDependencies)

| 包名 | 版本 | 用途 |
|------|------|------|
| @biomejs/biome | ^1.9.4 | 代码格式化和 lint |
| @flydotio/dockerfile | ^0.5.9 | Dockerfile 生成 |
| @types/bun | ^1.2.19 | Bun 类型定义 |
| @types/react | ^18.3.12 | React 类型定义 |
| @types/react-dom | ^18.3.1 | React DOM 类型定义 |
| better-sqlite3 | ^11.7.0 | SQLite3 数据库 |
| kysely | ^0.28.3 | SQL 查询构建器 |
| kysely-codegen | ^0.17.0 | Kysely 类型生成 |
| winterspec | ^0.0.96 | API 规范工具 |

### 对等依赖 (peerDependencies)

| 包名 | 版本 | 状态 |
|------|------|------|
| typescript | ^5.0.0 | ✅ 已满足 |

---

## ⚠️ 安装警告

```
warn: incorrect peer dependency "[email protected]"
warn: incorrect peer dependency "[email protected]"
```

**说明:** 这是 kysely-bun-sqlite 的 peer 依赖版本提示,不影响使用。

---

## 📊 安装统计

| 指标 | 数值 |
|------|------|
| 总包数 | 240 |
| 下载包数 | 862 |
| 安装时间 | ~10 秒 |
| 磁盘占用 | 约 150MB |

---

## 🔍 验证结果

### 已验证的模块

```bash
✅ Node.js v24.13.0
✅ Bun 1.3.10
✅ node_modules 目录完整
✅ 所有路由测试通过 (75 个)
✅ 测试框架正常
```

### 未安装的可选依赖

```
❌ windows-build-tools (不需要,使用预编译版本)
❌ node-gyp (不需要,better-sqlite3 使用预编译)
```

---

## 📝 安装命令

```bash
# 进入项目目录
cd C:\Users\songs\.openclaw\workspace\dev-environment\jlcsearch

# 安装依赖
bun install

# 验证安装
bun run test-env.ts

# 运行测试
bun test
```

---

## 🎯 下一步

### 选项 1:开始开发 Issue #92
```
✅ 环境就绪
✅ 依赖完整
→ 可以直接开始编写代码
```

### 选项 2:下载数据库(可选)
```bash
bun run setup
# 下载约 2GB 数据
# 用于完整集成测试
```

### 选项 3:运行开发服务器
```bash
bun run start
# 启动热重载开发服务器
# 访问 http://localhost:3000
```

---

## 💡 提示

1. **代码格式化**
```bash
bun run format
```

2. **生成数据库类型**
```bash
bun run generate:db-types
```

3. **生成 OpenAPI 文档**
```bash
bun run generate:openapi
```

---

## ✅ 安装完成

所有依赖已成功安装,项目可以正常运行和开发!

---

**更新时间:** 2026-03-10 10:30
**安装人:** 兜兜
2 changes: 2 additions & 0 deletions lib/db/derivedtables/accelerometer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const accelerometerTableSpec: DerivedTableSpec<Accelerometer> = {
{ name: "has_uart", type: "boolean" },
{ name: "is_basic", type: "boolean" },
{ name: "is_preferred", type: "boolean" },
{ name: "is_extended_promotional", type: "boolean" },
],
listCandidateComponents: (db) =>
db
Expand Down Expand Up @@ -102,6 +103,7 @@ export const accelerometerTableSpec: DerivedTableSpec<Accelerometer> = {
in_stock: c.stock > 0,
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
package: c.package || "",
supply_voltage_min: voltageMin,
supply_voltage_max: voltageMax,
Expand Down
2 changes: 2 additions & 0 deletions lib/db/derivedtables/adc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const adcTableSpec: DerivedTableSpec<Adc> = {
{ name: "operating_temp_max", type: "real" },
{ name: "is_basic", type: "boolean" },
{ name: "is_preferred", type: "boolean" },
{ name: "is_extended_promotional", type: "boolean" },
],
listCandidateComponents: (db) =>
db
Expand Down Expand Up @@ -115,6 +116,7 @@ export const adcTableSpec: DerivedTableSpec<Adc> = {
in_stock: c.stock > 0,
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
package: c.package || "",
resolution_bits: resolution,
sampling_rate_hz: samplingRate,
Expand Down
2 changes: 2 additions & 0 deletions lib/db/derivedtables/analog_multiplexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const analogMultiplexerTableSpec: DerivedTableSpec<AnalogMultiplexer> = {
{ name: "channel_type", type: "text" },
{ name: "is_basic", type: "boolean" },
{ name: "is_preferred", type: "boolean" },
{ name: "is_extended_promotional", type: "boolean" },
],
listCandidateComponents: (db) =>
db
Expand Down Expand Up @@ -144,6 +145,7 @@ export const analogMultiplexerTableSpec: DerivedTableSpec<AnalogMultiplexer> = {
in_stock: c.stock > 0,
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
package: c.package || "",
num_channels: numChannels,
num_bits: numBits,
Expand Down
2 changes: 2 additions & 0 deletions lib/db/derivedtables/battery_holder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const batteryHolderTableSpec: DerivedTableSpec<BatteryHolder> = {
{ name: "operating_temp_max", type: "real" },
{ name: "is_basic", type: "boolean" },
{ name: "is_preferred", type: "boolean" },
{ name: "is_extended_promotional", type: "boolean" },
],
listCandidateComponents(db: KyselyDatabaseInstance) {
return db
Expand Down Expand Up @@ -74,6 +75,7 @@ export const batteryHolderTableSpec: DerivedTableSpec<BatteryHolder> = {
in_stock: Boolean((c.stock || 0) > 0),
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
package: String(c.package || ""),
connector_type: attrs["Connector Type"] || null,
battery_type: attrs["Battery Type"] || null,
Expand Down
2 changes: 2 additions & 0 deletions lib/db/derivedtables/bjt_transistor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const bjtTransistorTableSpec: DerivedTableSpec<BJTTransistor> = {
{ name: "temperature_range", type: "text" },
{ name: "is_basic", type: "boolean" },
{ name: "is_preferred", type: "boolean" },
{ name: "is_extended_promotional", type: "boolean" },
],
listCandidateComponents(db: KyselyDatabaseInstance) {
return db
Expand Down Expand Up @@ -74,6 +75,7 @@ export const bjtTransistorTableSpec: DerivedTableSpec<BJTTransistor> = {
in_stock: Boolean((c.stock || 0) > 0),
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
package: c.package || "",
current_gain: current_gain,
collector_current: collector_current,
Expand Down
2 changes: 2 additions & 0 deletions lib/db/derivedtables/boost_converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const boostConverterTableSpec: DerivedTableSpec<BoostConverter> = {
{ name: "number_of_outputs", type: "integer" },
{ name: "is_basic", type: "boolean" },
{ name: "is_preferred", type: "boolean" },
{ name: "is_extended_promotional", type: "boolean" },
],
listCandidateComponents: (db) =>
db
Expand Down Expand Up @@ -117,6 +118,7 @@ export const boostConverterTableSpec: DerivedTableSpec<BoostConverter> = {
in_stock: c.stock > 0,
is_basic: Boolean(c.basic),
is_preferred: Boolean(c.preferred),
is_extended_promotional: Boolean(c.extended_promotional),
package: c.package || "",
input_voltage_min: inputMin,
input_voltage_max: inputMax,
Expand Down
Loading