File tree Expand file tree Collapse file tree 3 files changed +29
-4
lines changed
Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ dev-dependencies = [
2222
2323[tool .uv .workspace ]
2424members = [" apps/*" , " packages/*" ]
25+ exclude = [" apps/data" , " apps/desktop" , " apps/web" ]
2526
2627[tool .ruff ]
2728target-version = " py311"
Original file line number Diff line number Diff line change @@ -131,6 +131,17 @@ setup_env_files() {
131131 warn " 已创建 apps/api/.env,请按需修改"
132132 fi
133133
134+ # Auto-generate ENCRYPTION_KEY if still placeholder
135+ if [ -f " $API_DIR /.env" ] && grep -q ' ENCRYPTION_KEY=your-fernet-key-here' " $API_DIR /.env" 2> /dev/null; then
136+ local fernet_key
137+ fernet_key=" $( python3 -c ' from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())' 2> /dev/null || true) "
138+ if [ -n " $fernet_key " ]; then
139+ sed -i.bak " s|ENCRYPTION_KEY=your-fernet-key-here|ENCRYPTION_KEY=$fernet_key |" " $API_DIR /.env"
140+ rm -f " $API_DIR /.env.bak"
141+ success " 已自动生成 ENCRYPTION_KEY"
142+ fi
143+ fi
144+
134145 if [ ! -f " $WEB_DIR /.env.local" ]; then
135146 echo " NEXT_PUBLIC_API_URL=http://localhost:8000" > " $WEB_DIR /.env.local"
136147 success " 已创建 apps/web/.env.local"
Original file line number Diff line number Diff line change 11create_venv_if_needed () {
22 ensure_python_selected
3- if [ ! -d " $API_DIR /.venv" ]; then
3+ if [ ! -d " $API_DIR /.venv" ] || [ ! -x " $( venv_python ) " ] ; then
44 info " 创建 Python 虚拟环境..."
5- (cd " $API_DIR " && " $PYTHON_CMD " -m venv .venv)
5+ if command -v uv > /dev/null 2>&1 ; then
6+ (cd " $API_DIR " && uv venv .venv --python " $PYTHON_CMD " )
7+ else
8+ (cd " $API_DIR " && " $PYTHON_CMD " -m venv .venv --clear)
9+ fi
10+ fi
11+ }
12+
13+ # Use uv pip if available, fall back to venv pip
14+ _pip_install () {
15+ if command -v uv > /dev/null 2>&1 ; then
16+ uv pip install --python " $( venv_python) " " $@ "
17+ else
18+ " $( venv_pip) " install " $@ "
619 fi
720}
821
@@ -22,7 +35,7 @@ install_python_profile() {
2235 fi
2336
2437 info " 安装 Python $profile 依赖..."
25- (cd " $API_DIR " && " $( venv_pip ) " install -e " $install_target " )
38+ (cd " $API_DIR " && _pip_install -e " $install_target " )
2639 mkdir -p " $( dirname " $fingerprint_file " ) "
2740 echo " $expected_fingerprint " > " $fingerprint_file "
2841 success " Python $profile 依赖已就绪"
@@ -45,6 +58,6 @@ ensure_aiosqlite() {
4558 py=" $( venv_python) "
4659 if ! " $py " -c " import aiosqlite" > /dev/null 2>&1 ; then
4760 info " 补装 aiosqlite..."
48- " $( venv_pip ) " install aiosqlite > /dev/null
61+ _pip_install aiosqlite > /dev/null
4962 fi
5063}
You can’t perform that action at this time.
0 commit comments