- 删除根目录中重复的 NestJS 配置文件 - 删除 tsconfig.json, tsconfig.build.json, eslint.config.mjs, .prettierrc - 保留 wwjcloud-nest/ 目录中的完整配置 - 避免配置冲突,确保项目结构清晰
123 lines
3.6 KiB
Bash
Executable File
123 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
# WWJCloud 开发推送脚本
|
||
# 功能:用于日常开发推送到主仓库 (wwjcloud-nsetjs.git)
|
||
# 作者:WWJCloud Team
|
||
# 版本:v1.0
|
||
|
||
set -e
|
||
|
||
# 颜色定义
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
BLUE='\033[0;34m'
|
||
NC='\033[0m' # No Color
|
||
|
||
# 检查当前目录
|
||
check_directory() {
|
||
if [[ ! -d ".git" ]]; then
|
||
echo -e "${RED}❌ 错误:当前目录不是Git仓库${NC}"
|
||
exit 1
|
||
fi
|
||
|
||
# 检查是否在主仓库目录
|
||
if [[ -f "wwjcloud-nest/package.json" ]]; then
|
||
echo -e "${GREEN}✅ 检测到主仓库环境${NC}"
|
||
else
|
||
echo -e "${RED}❌ 错误:此脚本只能在主仓库根目录运行${NC}"
|
||
echo -e "${YELLOW}💡 提示:请在包含 wwjcloud-nest 子目录的主仓库根目录运行${NC}"
|
||
exit 1
|
||
fi
|
||
}
|
||
|
||
# 检查远程仓库配置
|
||
check_remote() {
|
||
local remote_url=$(git remote get-url origin 2>/dev/null || echo "")
|
||
if [[ "$remote_url" != *"wwjcloud-nsetjs.git"* ]]; then
|
||
echo -e "${RED}❌ 错误:当前仓库的origin不是wwjcloud-nsetjs.git${NC}"
|
||
echo -e "${YELLOW}当前origin: $remote_url${NC}"
|
||
exit 1
|
||
fi
|
||
|
||
# 确保没有wwjcloud远程(避免污染)
|
||
if git remote | grep -q "wwjcloud"; then
|
||
echo -e "${RED}❌ 危险:检测到wwjcloud远程配置!${NC}"
|
||
echo -e "${YELLOW}💡 正在自动移除以避免污染...${NC}"
|
||
git remote remove wwjcloud
|
||
echo -e "${GREEN}✅ 已移除危险的wwjcloud远程${NC}"
|
||
fi
|
||
}
|
||
|
||
# 检查分支状态
|
||
check_branch_status() {
|
||
# 获取当前分支
|
||
current_branch=$(git branch --show-current)
|
||
echo -e "${BLUE}📍 当前分支:$current_branch${NC}"
|
||
|
||
# 检查工作区状态
|
||
if ! git diff-index --quiet HEAD --; then
|
||
echo -e "${YELLOW}⚠️ 检测到未提交的更改${NC}"
|
||
git status --short
|
||
echo -e "${YELLOW}💡 是否要添加并提交这些更改? (y/N)${NC}"
|
||
read -r confirm
|
||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||
git add .
|
||
echo -e "${BLUE}📝 请输入提交信息:${NC}"
|
||
read -r commit_msg
|
||
if [[ -z "$commit_msg" ]]; then
|
||
commit_msg="feat: 开发进度更新 $(date '+%Y-%m-%d %H:%M')"
|
||
fi
|
||
git commit -m "$commit_msg"
|
||
echo -e "${GREEN}✅ 更改已提交${NC}"
|
||
else
|
||
echo -e "${RED}❌ 存在未提交更改,推送已取消${NC}"
|
||
exit 1
|
||
fi
|
||
fi
|
||
}
|
||
|
||
# 推送到开发仓库
|
||
push_to_dev() {
|
||
echo -e "${GREEN}🚀 开始推送到开发仓库...${NC}"
|
||
|
||
# 显示即将推送的提交
|
||
echo -e "${BLUE}📋 最近的提交:${NC}"
|
||
git log --oneline -3
|
||
|
||
# 执行推送
|
||
echo -e "${GREEN}📤 推送到 origin (wwjcloud-nsetjs.git)...${NC}"
|
||
git push origin HEAD
|
||
|
||
echo -e "${GREEN}✅ 开发推送完成!${NC}"
|
||
echo -e "${BLUE}💻 开发进度已同步到主仓库${NC}"
|
||
}
|
||
|
||
# 显示使用提示
|
||
show_usage() {
|
||
echo -e "${BLUE}📖 使用说明:${NC}"
|
||
echo -e "${YELLOW} 开发推送:${NC} ./push_dev.sh"
|
||
echo -e "${YELLOW} 发布推送:${NC} cd wwjcloud-nest && ../push_wwjcloud_nest.sh"
|
||
echo -e "${YELLOW} 紧急重置:${NC} cd wwjcloud-nest && git checkout v0.1.1-branch"
|
||
}
|
||
|
||
# 主函数
|
||
main() {
|
||
echo -e "${BLUE}💻 WWJCloud 开发推送脚本 v1.0${NC}"
|
||
echo -e "${BLUE}====================================${NC}"
|
||
|
||
# 执行检查
|
||
check_directory
|
||
check_remote
|
||
check_branch_status
|
||
|
||
# 执行推送
|
||
push_to_dev
|
||
|
||
# 显示使用提示
|
||
echo ""
|
||
show_usage
|
||
}
|
||
|
||
# 运行主函数
|
||
main "$@" |