@wjwjq/release-helper 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,13 @@ log_success() {
24
24
  echo "$now: [success] $1" >>"$execute_log_path"
25
25
  }
26
26
 
27
+ log_warn() {
28
+ now=$(date "+%Y-%m-%d %H:%M:%S")
29
+ echo "$(tput setaf 3)""$now": "$1""$(tput sgr0)"
30
+
31
+ echo "$now: [success] $1" >>"$execute_log_path"
32
+ }
33
+
27
34
  log_error() {
28
35
  now=$(date "+%Y-%m-%d %H:%M:%S")
29
36
  echo "$(tput setaf 1)""$now": "$1" "$(tput sgr0)"
@@ -132,7 +139,31 @@ install_assets() {
132
139
 
133
140
  }
134
141
 
142
+ now=$(date "+%Y-%m-%d_%H:%M:%S")
143
+ time=$now
144
+ old_version=$(get_old_version)
145
+
146
+ backup(){
147
+ source_type=$1
148
+
149
+ #备份整个服务 eg: /opt/posidon-frontend
150
+ if [[ -n "${old_version}" ]]; then
151
+ backup_dir="$install_path"backup
152
+ mkdir -p $backup_dir
153
+
154
+ # 分开备份nginx 和assets
155
+ backup_path=$backup_dir"/"$old_version"_"$time
156
+ mkdir -p "$backup_path"
157
+
158
+ echo "${app_name} $source_type backup at: $backup_path"
159
+ mv "$install_path$source_type" "$backup_path"
160
+ fi
161
+ }
162
+
163
+
135
164
  start() {
165
+ callBy=$1
166
+
136
167
  # 仅静态文件
137
168
  if [[ "${mode}" != 3 ]]; then
138
169
  # 未安装
@@ -168,29 +199,51 @@ start() {
168
199
 
169
200
  # 创建用户
170
201
  create_user_csri
171
-
172
- now=$(date "+%Y-%m-%d_%H:%M:%S")
173
- old_version=$(get_old_version)
174
-
175
- #备份整个服务 eg: /opt/posidon-frontend
176
- if [[ -n "${old_version}" ]]; then
177
- parent_store_path=$(echo "$install_path" | sed -e "s/\/${app_name}//")
178
- backup_path=$parent_store_path""$app_name"_"$old_version"_"$now
179
- echo "${app_name} assets backup at: $backup_path"
180
- mv "$install_path" "$backup_path"
181
- fi
182
-
183
202
  mkdir -p "$install_path"
184
203
 
204
+
185
205
  # 仅静态文件
186
206
  if [[ "${mode}" != 3 ]]; then
187
- copy_nginx_conf_and_write_verison
188
- add_nginx_service
189
- add_log_rotate
207
+ if [ -f "${nginx_conf_path}" ]; then
208
+ while true; do
209
+ read -r -p "nginx.conf file already exists, update it?[Y/N]" yn
210
+ case $yn in
211
+ [Yy]*)
212
+ # 备份nginx配置目录
213
+ backup nginx;
214
+
215
+ copy_nginx_conf_and_write_verison
216
+ add_nginx_service
217
+ add_log_rotate
218
+
219
+ if [[ $? != 0 ]]; then
220
+ echo "$(tput setaf 1)"failed to update nginx.conf!"$(tput sgr0)"
221
+ exit 1
222
+ else
223
+ log_warn "!!!!!!!!!nginx.conf has been updated, please note the changes, such as port 5443 !!!!!!!!!!"
224
+ fi
225
+ break
226
+ ;;
227
+ [Nn]*) break ;;
228
+ *) echo "Please answer yes or no." ;;
229
+ esac
230
+ done
231
+ else
232
+ copy_nginx_conf_and_write_verison
233
+ add_nginx_service
234
+ add_log_rotate
235
+ fi
190
236
  fi
191
237
 
238
+ # 备份静态资源目录
239
+ backup assets;
240
+
192
241
  install_assets
193
242
 
243
+ # 修改/etc/nginx 用户(组)
244
+ chown -R $user:$usergroup "$nginx_binary_install_path"
245
+ chmod 744 -R "$nginx_binary_install_path"
246
+
194
247
  # 修改所属用户
195
248
  chown -R $user:$usergroup "$install_path"
196
249
  chmod 744 -R "$install_path"
@@ -4,4 +4,4 @@ basepath=$(dirname "$(realpath "${BASH_SOURCE[-1]}")")
4
4
 
5
5
  source "$basepath"/common.sh
6
6
 
7
- start
7
+ start 'install'
@@ -314,8 +314,6 @@ install_nginx_binary() {
314
314
  ln -sf "$nginx_binary_install_path"sbin/nginx /usr/sbin/nginx
315
315
  # cd ..
316
316
 
317
- # 修改/etc/nginx 用户(组)
318
- chown -R $user:$usergroup "$nginx_binary_install_path"
319
- chmod 744 -R "$nginx_binary_install_path"
317
+
320
318
  }
321
319
  #------------------------------------ nginx 可执行程序相关 end ----------------------------------
@@ -4,4 +4,4 @@ basepath=$(dirname "$(realpath "${BASH_SOURCE[-1]}")")
4
4
 
5
5
  source "$basepath"/common.sh
6
6
 
7
- start
7
+ start 'upgrade'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wjwjq/release-helper",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "generate deployment package for frontend, include nginx...",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",