Commit c879cfdfbbf055d7f39b55ba89a1ec14bfc664a0

Authored by ly525
Committed by 小小鲁班
1 parent 4353d3d2

chore(luban-h5.sh): add clean command

Showing 1 changed file with 33 additions and 3 deletions
luban-h5.sh
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 # @Author: ly525 4 # @Author: ly525
5 # @Date: 2020-01-10 22:23:34 5 # @Date: 2020-01-10 22:23:34
6 # @LastEditors : ly525 6 # @LastEditors : ly525
7 - # @LastEditTime : 2020-01-11 09:37:40 7 + # @LastEditTime : 2020-01-12 15:44:23
8 # @FilePath: /luban-h5/luban-h5.sh 8 # @FilePath: /luban-h5/luban-h5.sh
9 # @Github: https://github.com/ly525/luban-h5 9 # @Github: https://github.com/ly525/luban-h5
10 # @Description: Do not edit 10 # @Description: Do not edit
@@ -22,9 +22,13 @@ cat << EOT @@ -22,9 +22,13 @@ cat << EOT
22 --------------------------------------------------------------------------- 22 ---------------------------------------------------------------------------
23 23
24 Usage: 24 Usage:
25 - $(basename $0) [--help|-h] [init|start|restart|stop] 25 + $(basename $0) [--help|-h] [version|clean|init|start|restart|stop]
26 26
27 help Show usage. 27 help Show usage.
  28 + version Show version.
  29 +
  30 + clean #!en Install dependencies, build front-end && back-end.
  31 + #!zh 初始化: 安装依赖并编译前后端
28 32
29 init #!en Install dependencies, build front-end && back-end. 33 init #!en Install dependencies, build front-end && back-end.
30 #!zh 初始化: 安装依赖并编译前后端 34 #!zh 初始化: 安装依赖并编译前后端
@@ -39,6 +43,7 @@ Usage: @@ -39,6 +43,7 @@ Usage:
39 #!zh 停止luban-h5 43 #!zh 停止luban-h5
40 44
41 e.g. 45 e.g.
  46 + ./luban-h5.sh version
42 ./luban-h5.sh init 47 ./luban-h5.sh init
43 ./luban-h5.sh start 48 ./luban-h5.sh start
44 ./luban-h5.sh stop 49 ./luban-h5.sh stop
@@ -47,6 +52,31 @@ exit @@ -47,6 +52,31 @@ exit
47 } 52 }
48 53
49 54
  55 +luban_h5_version() {
  56 + # https://gist.github.com/yvele/e98e3a155335a6e00e71
  57 + # Version key/value should be on his own line
  58 + PACKAGE_VERSION=$(cat package.json \
  59 + | grep version \
  60 + | head -1 \
  61 + | awk -F: '{ print $2 }' \
  62 + | sed 's/[",]//g' \
  63 + | tr -d '[[:space:]]')
  64 +
  65 + echo $PACKAGE_VERSION
  66 +}
  67 +
  68 +luban_h5_clean() {
  69 + luban_h5_stop
  70 + cd back-end/h5-api && rm -rf node_modules .cache build
  71 +
  72 + echo "===========================================================================\n"
  73 + echo "clean node_modules, .cache, build finish."
  74 + echo "please run the following commands to start the app\n"
  75 + echo "1. ./luban-h5 init"
  76 + echo "1. ./luban-h5 start"
  77 + echo "==========================================================================="
  78 +}
  79 +
50 luban_h5_init() { 80 luban_h5_init() {
51 # 到前端目录安装依赖,并编译核心编辑器 + 预览引擎 81 # 到前端目录安装依赖,并编译核心编辑器 + 预览引擎
52 # #!en compile the core editor and preview engine 82 # #!en compile the core editor and preview engine
@@ -78,7 +108,7 @@ luban_h5_stop() { @@ -78,7 +108,7 @@ luban_h5_stop() {
78 # Initialization step 108 # Initialization step
79 action=$1 109 action=$1
80 case "$action" in 110 case "$action" in
81 - init|start|restart|stop) 111 + version|clean|init|start|restart|stop)
82 luban_h5_${action} 112 luban_h5_${action}
83 ;; 113 ;;
84 *) 114 *)