diff --git a/README.md b/README.md index f196e3a7911f7b47233e8831b047e655db6a9562..ef5055a2b33666a5b84fedc28ab691a20b542ac3 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,18 @@ -## 介绍 -自动化项目管理工具:批量 clone 项目、创建新分支、切换分支、修改项目 pom.xml 版本、push 项目等工具 +# 介绍 +自动化项目管理工具,包括:批量 clone 项目、创建新分支、切换分支、修改项目 pom.xml 版本、push 项目等工具,可以根据需求执行按照《组件开发规范》自定义工具。 -## 软件架构 -使用 shell 脚本编写,支持自定义工具扩展 -## 使用说明 -### 一、目录升级 +# 软件架构 +使用 shell、awk 脚本编写 + + + +# 使用说明 + + + +## 一、目录升级 目录分为两级目录(最多有两级目录),如下所示: @@ -20,9 +26,11 @@ ![image](./image/0008.png) -### 二、具体功能 +## 二、具体功能 -#### 1、Git Tools + + +### 1、Git Tools 1. Batch Clone Project @@ -62,8 +70,10 @@ ![image](./image/0007.png) 按照现在项目的分支和 remote origin push 到仓库 + + -#### 2、Project Tools +### 2、Project Tools 1. Batch Modify Maven Version @@ -74,3 +84,8 @@ - 版本类型:这个是根据我们项目需要设置(若有需要可以调整为其他),就修改 pom.xml 中第一个和第二个 version 标签内容 - 待修改的版本:替换现在 version 中的内容 + + +# 自定义组件 + +详见 document 目录中《组件开发规范》 diff --git a/component/Git-Tools/Batch-Checkout-Branch/index.sh b/component/Git Tools/Batch Checkout Branch/index.sh similarity index 100% rename from component/Git-Tools/Batch-Checkout-Branch/index.sh rename to component/Git Tools/Batch Checkout Branch/index.sh diff --git a/component/Git-Tools/Batch-Clone-Project/config/projects.txt b/component/Git Tools/Batch Clone Project/config/projects.txt similarity index 100% rename from component/Git-Tools/Batch-Clone-Project/config/projects.txt rename to component/Git Tools/Batch Clone Project/config/projects.txt diff --git a/component/Git-Tools/Batch-Clone-Project/index.sh b/component/Git Tools/Batch Clone Project/index.sh similarity index 100% rename from component/Git-Tools/Batch-Clone-Project/index.sh rename to component/Git Tools/Batch Clone Project/index.sh diff --git a/component/Git-Tools/Batch-Creating-Branch/index.sh b/component/Git Tools/Batch Creating Branch/index.sh similarity index 100% rename from component/Git-Tools/Batch-Creating-Branch/index.sh rename to component/Git Tools/Batch Creating Branch/index.sh diff --git a/component/Git-Tools/Batch-Delete-Remote-Branch/config/retain-branches.txt b/component/Git Tools/Batch Delete Remote Branch/config/retain-branches.txt similarity index 100% rename from component/Git-Tools/Batch-Delete-Remote-Branch/config/retain-branches.txt rename to component/Git Tools/Batch Delete Remote Branch/config/retain-branches.txt diff --git a/component/Git-Tools/Batch-Delete-Remote-Branch/index.sh b/component/Git Tools/Batch Delete Remote Branch/index.sh similarity index 100% rename from component/Git-Tools/Batch-Delete-Remote-Branch/index.sh rename to component/Git Tools/Batch Delete Remote Branch/index.sh diff --git a/component/Git-Tools/Batch-Push-Repository/index.sh b/component/Git Tools/Batch Push Repository/index.sh similarity index 100% rename from component/Git-Tools/Batch-Push-Repository/index.sh rename to component/Git Tools/Batch Push Repository/index.sh diff --git a/component/Project-Tools/Batch-Modify-Maven-Version/awk/update_version.awk b/component/Project Tools/Batch Modify Maven Version/awk/update_version.awk similarity index 100% rename from component/Project-Tools/Batch-Modify-Maven-Version/awk/update_version.awk rename to component/Project Tools/Batch Modify Maven Version/awk/update_version.awk diff --git a/component/Project-Tools/Batch-Modify-Maven-Version/index.sh b/component/Project Tools/Batch Modify Maven Version/index.sh similarity index 100% rename from component/Project-Tools/Batch-Modify-Maven-Version/index.sh rename to component/Project Tools/Batch Modify Maven Version/index.sh diff --git "a/document/\347\273\204\344\273\266\345\274\200\345\217\221\350\247\204\350\214\203.md" "b/document/\347\273\204\344\273\266\345\274\200\345\217\221\350\247\204\350\214\203.md" new file mode 100644 index 0000000000000000000000000000000000000000..2bf7f9afdb0cda9f362cdb28753e045542d218ee --- /dev/null +++ "b/document/\347\273\204\344\273\266\345\274\200\345\217\221\350\247\204\350\214\203.md" @@ -0,0 +1,133 @@ +# 组件目录结构 + +component +​ |--- 组件一级菜单目录 +​ | |--- 组件目录 +​ | |--- 组件目录 +​ | +​ |--- 组件一级菜单目录 +​ |--- 组件目录 + + + +**组件一级菜单目录** + +对同类型的组件进行归类,该目录名称对应程序的一级菜单,如下: + +![image](../image/0010.png) + +![image](../image/0001.png) + + + +**组件目录** + +具体功能组件的目录,用于保存组件相关脚本和文件,如下: + +![image](../image/0011.png) + +![image](../image/0002.png) + + + +# 组件目录 + +组件目录 +​ |--- config(配置文件目录) +​ | |--- 配置文件 +​ | +​ |--- index.sh(组件入口脚本) + +> 注:组件目录中 `index.sh` 是必须存在的 + + + +# index.sh + +index.sh 基本模板如下: + +```bash +#!/bin/bash + +#========================================================================================= +# 作者:赵海春 +# 日期:2022.04.12 +# 作用:批量创建分支 +# 使用:在需要批量创建分支项目的脚本中通过以下步骤使用该脚本 +# 1、命令:. ./index.sh +# 2、配置环境变量:PROJECTS_TARGET_PATH +#========================================================================================= + +echo -e "\e[34m" +echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓" +echo -e "┃ 批量创建分支 ┃" +echo -e "┃ Batch Creating Branch ┃" +echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" + + +# 当前脚本所在目录路径 +SCRIPT_PATH=`pwd` + +# 业务代码编写区域 + +cd ${SCRIPT_PATH} +echo -e "\n\n" +``` + + + +**1、注释** + +```bash +#========================================================================================= +# 作者:赵海春 +# 日期:2022.04.12 +# 作用:批量创建分支 +# 使用:在需要批量创建分支项目的脚本中通过以下步骤使用该脚本 +# 1、命令:. ./index.sh +# 2、配置环境变量:PROJECTS_TARGET_PATH +#========================================================================================= +``` + +用于标注脚本相关信息 + +**2、组件标识** + +```bash +echo -e "\e[34m" +echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓" +echo -e "┃ 批量创建分支 ┃" +echo -e "┃ Batch Creating Branch ┃" +echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" +``` + +用于通过菜单进入具体组件,可以显示当前组件名称 + +**3、组件根目录变量** + +```bash +# 当前脚本所在目录路径 +SCRIPT_PATH=`pwd` +``` + +用于保存当前组件的根目录(即组件 index.sh 脚本所在目录) + +**4、退回到组件根目录** + +```bash +cd ${SCRIPT_PATH} +echo -e "\n\n" +``` + +业务代码中可能会进入到其他目录进行操作,组件 index.sh 执行完成,最终需要在组件跟目录中 + + + +# 全局环境变量 + +全局环境变量定义在软件根目录 index.sh 脚本中,现在可用的变量为: + +- ROOT_PATH:软件根目录 +- PROJECTS_TARGET_PATH:执行 clone 组件后,项目保存的目录 +- COMPONENT_PATH:组件一级菜单所在目录 + diff --git a/image/0010.png b/image/0010.png new file mode 100644 index 0000000000000000000000000000000000000000..5a1caa308bf90a4d83c2918a0da0c8dc789f79f8 Binary files /dev/null and b/image/0010.png differ diff --git a/image/0011.png b/image/0011.png new file mode 100644 index 0000000000000000000000000000000000000000..edef1b662231fdd022a890c4ee1ecc82b4a96e4e Binary files /dev/null and b/image/0011.png differ diff --git a/index.sh b/index.sh index e70f24def0ff1a343e5d1109ae7c0429843f4371..1b4fb339f730e79b498fbab5ff47309727eb3214 100644 --- a/index.sh +++ b/index.sh @@ -18,11 +18,14 @@ while [ true ]; do echo -e "║ ║" INDEX=0 - for COMPONENT in `ls`; do - COMPONENTS[${INDEX}]=${COMPONENT} - printf "║\t%-50.42s║\n" "${INDEX}、${COMPONENT}" | sed 's/-/ /g' + OLD_IFS="$IFS" + IFS=$'\n' + COMPONENTS=(`ls`) + for COMPONENT in ${COMPONENTS[@]}; do + printf "║\t%-50.42s║\n" "${INDEX}、${COMPONENT}" INDEX=$[${INDEX} + 1] done + IFS=${OLD_IFS} echo -e "║ ║" @@ -56,13 +59,13 @@ while [ true ]; do if [[ ${CURRENT_DIR_LEVEL} -eq 1 ]]; then CURRENT_DIR_LEVEL=$[${CURRENT_DIR_LEVEL} + 1] - cd ${COMPONENTS[${OPERATOR}]} + cd "./${COMPONENTS[${OPERATOR}]}" clear continue fi if [[ ${CURRENT_DIR_LEVEL} -eq 2 ]]; then - cd ${COMPONENTS[${OPERATOR}]} + cd "./${COMPONENTS[${OPERATOR}]}" if [[ ! -e "./index.sh" ]]; then echo -e "\n不存在 index.sh 脚本,执行异常\e[0m" exit 1