Skip to content
Merged
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
5 changes: 0 additions & 5 deletions .gemini/settings.json

This file was deleted.

16 changes: 9 additions & 7 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ name: Claude Code Review
on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"
paths:
- "the-trash-rn/**"
- "supabase/migrations/**"
- "scripts/**"
- "Makefile"
- "README.md"
- ".github/workflows/**"
paths-ignore:
- "legacy/**"

jobs:
claude-review:
Expand Down Expand Up @@ -41,4 +44,3 @@ jobs:
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options

8 changes: 2 additions & 6 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ on:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude'))
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -47,4 +44,3 @@ jobs:
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr:*)'

46 changes: 46 additions & 0 deletions .github/workflows/rn-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: RN CI

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "the-trash-rn/**"
- "supabase/migrations/**"
- "scripts/**"
- "Makefile"
- "README.md"
- ".github/workflows/rn-ci.yml"
paths-ignore:
- "legacy/**"
workflow_dispatch:

jobs:
rn-quality:
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: "10"

- name: Install Dependencies
run: pnpm --dir the-trash-rn install --frozen-lockfile

- name: Lint RN
run: pnpm --dir the-trash-rn lint

- name: Check Backend Contracts
run: bash scripts/check_backend_contracts.sh --strict

- name: Check Migration Source
run: bash scripts/check_migration_mirror.sh --strict
36 changes: 22 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
PROJECT := The Trash.xcodeproj
SCHEME := The Trash
SIMULATOR ?= iPhone 16
DEST_SIM := platform=iOS Simulator,name=$(SIMULATOR)
DEST_DEVICE := generic/platform=iOS
RN_DIR := the-trash-rn

.PHONY: open build build-device test contracts contracts-strict migrations-check migrations-check-strict migrations-sync doctor
.PHONY: install start ios android pods lint format contracts contracts-strict migrations-check migrations-check-strict migrations-sync doctor legacy-open

open:
open "$(PROJECT)"
install:
pnpm --dir "$(RN_DIR)" install

build:
xcodebuild -project "$(PROJECT)" -scheme "$(SCHEME)" -destination '$(DEST_SIM)' build
start:
pnpm --dir "$(RN_DIR)" expo start --dev-client --tunnel --clear

build-device:
xcodebuild -project "$(PROJECT)" -scheme "$(SCHEME)" -destination '$(DEST_DEVICE)' build
ios:
pnpm --dir "$(RN_DIR)" expo run:ios

test:
xcodebuild -project "$(PROJECT)" -scheme "$(SCHEME)" -destination '$(DEST_SIM)' test
android:
pnpm --dir "$(RN_DIR)" expo run:android

pods:
pnpm --dir "$(RN_DIR)" pods:install

lint:
pnpm --dir "$(RN_DIR)" lint

format:
pnpm --dir "$(RN_DIR)" format

contracts:
bash scripts/check_backend_contracts.sh
Expand All @@ -36,3 +41,6 @@ migrations-sync:
doctor:
bash scripts/check_backend_contracts.sh --strict
bash scripts/check_migration_mirror.sh --strict

legacy-open:
open "legacy/swift-ios/The Trash.xcodeproj"
105 changes: 54 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,56 @@
# The Trash

The Trash 是一个垃圾分类与环保互动产品仓库,包含两个客户端实现:
The Trash 是一个垃圾分类与环保互动产品仓库

- `The Trash/`:SwiftUI 原生 iOS 版本(主工程)
- `the-trash-rn/`:Expo + React Native 版本(跨平台)
当前主线客户端:

- `the-trash-rn/`:Expo + React Native(主线)

已归档客户端(Legacy):

- `legacy/swift-ios/The Trash/`:SwiftUI iOS 版本(不再主线维护)

## 仓库结构

```text
.
├── The Trash/ # SwiftUI iOS 代码
├── The Trash.xcodeproj # Xcode 工程
├── the-trash-rn/ # Expo / RN 代码
├── supabase/migrations/ # Supabase 迁移源
├── The Trash/migrations/ # App 侧 SQL 镜像
├── scripts/ # 契约检查与迁移同步脚本
├── the-trash-rn/ # Expo / RN 代码(主线)
├── legacy/swift-ios/ # 归档 Swift 工程
├── supabase/migrations/ # Supabase 迁移唯一来源
├── scripts/ # 契约与迁移检查脚本
├── Makefile
└── docs/
```

## 1) Swift iOS 开发
## 1) React Native 开发(主线)

详细说明见 `the-trash-rn/README.md`。

### 环境

- Xcode 16+
- iOS Simulator 或真机
- `MobileCLIPImage.mlpackage` 放在 `The Trash/` 下
- 本地私密配置 `The Trash/Secrets.swift`(不要提交)
- Node.js 20+
- pnpm 10+
- Xcode / Android Studio(按平台需要)

### 常用命令

```bash
make open
make build
make build-device
make test
```

也可直接打开工程:

```bash
open "The Trash.xcodeproj"
```

## 2) React Native 开发(推荐先走这条)

详细说明见 `the-trash-rn/README.md`。

快速启动:

```bash
cd the-trash-rn
pnpm install
pnpm expo start --dev-client --tunnel --clear
make install
make start
make ios
make android
make lint
```

### RN iOS 真机最短路径
也可直接在 RN 目录执行:

```bash
cd the-trash-rn
pnpm install
pnpm pods:install
pnpm expo run:ios --device
pnpm expo start --dev-client --tunnel --clear
```

## 3) 数据库迁移(Supabase)
## 2) 数据库迁移(Supabase)

### 迁移执行

Expand All @@ -75,28 +60,46 @@ supabase db push --project-ref <your-project-ref>

`project-ref` 就是 Supabase 项目短 ID(Dashboard URL 里 `project/<ref>` 这段)。

### 镜像同步与契约检查
### 契约与迁移检查

```bash
make migrations-sync
make migrations-check
make contracts
make migrations-check
make doctor
```

说明:

- `supabase/migrations/` 是唯一真相源。
- `make migrations-sync` 仅保留兼容入口,现为 no-op。

建议流程:

1. 新增 `supabase/migrations/*.sql`
2. `supabase db push --project-ref <ref>`
3. `make migrations-sync`
4. `make doctor`
5. 提交 `supabase/migrations` 和 `The Trash/migrations`
3. `make contracts`
4. `make migrations-check`
5. 提交 `supabase/migrations`

## 3) Swift iOS(Legacy 归档)

Swift 工程已归档,仅在需要回溯时使用:

```bash
make legacy-open
```

或直接:

```bash
open "legacy/swift-ios/The Trash.xcodeproj"
```

## 4) 常见问题

- `Could not find table ... in schema cache`
- 说明远端 schema 还没应用完整迁移,先执行 `supabase db push`。
- Expo iOS 出现 ATS 明文连接报错
- `Could not find table ... in schema cache`
- 远端 schema 未应用完整迁移,先执行 `supabase db push`。
- Expo iOS 出现 ATS 明文连接报错
- 使用 `pnpm expo start --dev-client --tunnel --clear`。
- `Authentication with Apple Developer Portal failed / no team`
- 不能走 EAS iOS 云构建;可用本地 Xcode 真机安装,或先用 Android 开发机
- `Authentication with Apple Developer Portal failed / no team`
- iOS 云构建不可用时,可先走本地 Xcode 真机安装或 Android 开发流程
Loading