@wjwjq/release-helper 0.2.95 → 0.2.96

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.
@@ -42,10 +42,6 @@ log "-----------execute ${app_name} script-------------"
42
42
 
43
43
  source "$basepath"/prompt.sh
44
44
 
45
- if [[ $(whoami) != "root" ]]; then
46
- echo "user:root is required!"
47
- exit 1
48
- fi
49
45
 
50
46
  if [[ -z "${install_path}" ]]; then
51
47
  echo "install path not found"
@@ -156,11 +152,13 @@ backup(){
156
152
  backup_path=$backup_dir"/"$old_version"_"$time
157
153
  mkdir -p "$backup_path"
158
154
 
159
- echo "${app_name} $source_type backup at: $backup_path"
155
+ echo "${app_name} $source_type backup at: $backup_path" >&2
160
156
  mv "$install_path$source_type" "$backup_path"
157
+
158
+ echo "$backup_path/$source_type"
161
159
  fi
162
160
  }
163
-
161
+
164
162
 
165
163
  start() {
166
164
  callBy=$1
@@ -237,10 +235,18 @@ start() {
237
235
  fi
238
236
 
239
237
  # 备份静态资源目录
240
- backup assets;
238
+ backup_dir=$(backup assets);
241
239
 
242
240
  install_assets
243
241
 
242
+ # 执行after.sh 脚本
243
+
244
+ # 如果backup_dir 不为空,且after.sh 脚本存在,则执行after.sh 脚本
245
+ if [[ -n "$backup_dir" && -f "$basepath/after.sh" ]]; then
246
+ source "$basepath/after.sh"
247
+ execute $backup_dir $install_path/assets $install_path
248
+ fi
249
+
244
250
  # 修改/etc/nginx 用户(组)
245
251
  chown -R $user:$usergroup "$nginx_binary_install_path"
246
252
  chmod 744 -R "$nginx_binary_install_path"
package/dist/pack.js CHANGED
@@ -35,6 +35,7 @@ async function pack(version) {
35
35
  const projectDir = resolve(__releaseDir, projectName);
36
36
  const assetsDir = resolve(projectDir, "pkg/assets");
37
37
  const nginxDir = resolve(projectDir, "pkg/nginx");
38
+ const scriptDir = resolve(projectDir, "script");
38
39
  fs.cpSync(resolve(__dirname, "deploy"), projectDir, { recursive: true });
39
40
  fs.cpSync(resolve(__work_dir, releaseConf.assetsDir), assetsDir, { recursive: true });
40
41
  fs.writeFileSync(resolve(projectDir, "pkg", "version"), version, { encoding: "utf-8" });
@@ -80,6 +81,9 @@ async function pack(version) {
80
81
  replaced: [["__root__", `${assetInstallPath}assets/`]]
81
82
  // writeToNewFilePath: resolve(nginxDir, `${projectName}.conf`)
82
83
  });
84
+ if (fs.existsSync(resolve(__releaseDir, "script", "after.sh"))) {
85
+ fs.copyFileSync(resolve(__releaseDir, "script", "after.sh"), resolve(scriptDir, "after.sh"));
86
+ }
83
87
  logger.info(pc.green(`start to generate ${zipFileName}`));
84
88
  const zipFilePath = resolve(__releaseDir, zipFileName);
85
89
  await genTarPkg(__releaseDir, projectName, zipFilePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wjwjq/release-helper",
3
- "version": "0.2.95",
3
+ "version": "0.2.96",
4
4
  "description": "generate deployment package for frontend, include nginx...",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",