Files
wwjcloud-nest-v1/push_wwjcloud_nest.sh
wanwu e7a1d6b4d6 🧹 清理重复配置文件
- 删除根目录中重复的 NestJS 配置文件
- 删除 tsconfig.json, tsconfig.build.json, eslint.config.mjs, .prettierrc
- 保留 wwjcloud-nest/ 目录中的完整配置
- 避免配置冲突,确保项目结构清晰
2025-10-14 23:56:20 +08:00

104 lines
2.9 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# WWJCloud 安全推送脚本
# 功能:只允许从 wwjcloud-nest 子仓库推送到 wwjcloud 远程
# 作者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
# 检查是否在 wwjcloud-nest 目录
current_dir=$(basename "$PWD")
if [[ "$current_dir" != "wwjcloud-nest" ]]; then
echo -e "${RED}❌ 错误:此脚本只能在 wwjcloud-nest 目录中运行${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.git"* ]]; then
echo -e "${RED}❌ 错误当前仓库的origin不是wwjcloud.git${NC}"
echo -e "${YELLOW}当前origin: $remote_url${NC}"
exit 1
fi
}
# 检查分支状态
check_branch_status() {
# 检查是否有未提交的更改
if ! git diff-index --quiet HEAD --; then
echo -e "${RED}❌ 错误:存在未提交的更改${NC}"
echo -e "${YELLOW}💡 请先提交所有更改git add . && git commit -m \"your message\"${NC}"
exit 1
fi
# 获取当前分支
current_branch=$(git branch --show-current)
echo -e "${BLUE}📍 当前分支:$current_branch${NC}"
# 检查是否在保护分支
if [[ "$current_branch" == "v0.1.1-branch" ]]; then
echo -e "${RED}❌ 错误不能从v0.1.1-branch推送这是纯净底板${NC}"
echo -e "${YELLOW}💡 请切换到master分支git checkout master${NC}"
exit 1
fi
}
# 推送到wwjcloud远程发布版本
push_to_release() {
echo -e "${GREEN}🚀 开始推送到发布仓库...${NC}"
# 显示即将推送的提交
echo -e "${BLUE}📋 即将推送的提交:${NC}"
git log --oneline -5
# 确认推送
echo -e "${YELLOW}⚠️ 这将推送到用户可见的发布仓库,确认继续? (y/N)${NC}"
read -r confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}❌ 推送已取消${NC}"
exit 0
fi
# 执行推送
echo -e "${GREEN}📤 推送到 origin (wwjcloud.git)...${NC}"
git push origin HEAD
echo -e "${GREEN}✅ 发布推送完成!${NC}"
echo -e "${BLUE}🌐 用户现在可以看到最新版本${NC}"
}
# 主函数
main() {
echo -e "${BLUE}🔒 WWJCloud 安全推送脚本 v1.0${NC}"
echo -e "${BLUE}================================${NC}"
# 执行检查
check_directory
check_remote
check_branch_status
# 执行推送
push_to_release
}
# 运行主函数
main "$@"