@wjwjq/release-helper 0.2.97 → 0.2.99

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.
@@ -81,7 +81,7 @@ Nginx has been installed, re-install it?[Y/N]n #
81
81
  ...
82
82
  2024-06-28 14:57:39: nginx start command: /usr/sbin/nginx -c /opt/$APP_NAME$/nginx/nginx.conf
83
83
  2024-06-28 14:57:39: $VERSION$ /opt/$APP_NAME$/nginx/nginx.conf replaced successfully!
84
- 2024-06-28 14:57:39: add $APP_NAME$.nginx.service to /usr/lib/systemd/system/
84
+ 2024-06-28 14:57:39: add $APP_NAME$.service to /usr/lib/systemd/system/
85
85
  2024-06-28 14:57:39: /opt/$APP_NAME$/assets/settings
86
86
  2024-06-28 14:57:39: $APP_NAME$ deployed successfully #安装成功
87
87
  ```
@@ -162,7 +162,7 @@ chmod +x upgrade.sh
162
162
  ...
163
163
  2024-06-28 14:57:39: nginx start command: /usr/sbin/nginx -c /opt/$APP_NAME$/nginx/nginx.conf
164
164
  2024-06-28 14:57:39: $VERSION$ /opt/$APP_NAME$/nginx/nginx.conf replaced successfully!
165
- 2024-06-28 14:57:39: add $APP_NAME$.nginx.service to /usr/lib/systemd/system/
165
+ 2024-06-28 14:57:39: add $APP_NAME$.service to /usr/lib/systemd/system/
166
166
  2024-06-28 14:57:39: /opt/$APP_NAME$/assets/settings
167
167
  2024-06-28 14:57:39: $APP_NAME$ deployed successfully #安装成功
168
168
  ```
@@ -185,7 +185,7 @@ chmod +x upgrade.sh
185
185
  | 日志文件位置 | /var/log/$APP_NAME$/nginx.log |
186
186
  | 系统静态资源目录 | /opt/$APP_NAME$/assets/ |
187
187
  | 系统配置文件 | /opt/$APP_NAME$/assets/settings |
188
- | system service位置 | /usr/lib/systemd/system/$APP_NAME$.nginx.service |
188
+ | system service位置 | /usr/lib/systemd/system/$APP_NAME$.service |
189
189
  | 日志翻转配置位置 | /etc/logrotate.d/$APP_NAME$.nginx |
190
190
 
191
191
  ## 4.2 启动命令
@@ -209,7 +209,7 @@ supervisorctl start $APP_NAME$.nginx
209
209
  需安装时选择 -cluster 模式
210
210
 
211
211
  ```bash
212
- systemctl start $APP_NAME$.nginx.service
212
+ systemctl start $APP_NAME$.service
213
213
  ```
214
214
 
215
215
  ## 4.3 验证
@@ -3,7 +3,7 @@ daemon off;
3
3
  user root;
4
4
  worker_processes 2;
5
5
 
6
- #PID_FILE_PALCEHOLDER
6
+ #PID_FILE_PLACEHOLDER
7
7
 
8
8
  # 请勿删除此处占位符
9
9
  #ERROR_LOG_PLACEHOLDER
@@ -74,8 +74,9 @@ http {
74
74
 
75
75
  server {
76
76
  # listen 80;
77
- listen 5443 default_server ssl http2;
77
+ listen 5443 default_server ssl;
78
78
  server_name localhost;
79
+ http2 on;
79
80
  root __root__; # 请勿修改 此处会在脚本中动态替换
80
81
 
81
82
  error_page 497 =301 https://$http_host$request_uri;
package/dist/cli.js CHANGED
@@ -22,12 +22,12 @@ cli.command("init", "generate release configuration").action(async (options) =>
22
22
  console.error(`release-helper error: `, e);
23
23
  }
24
24
  });
25
- cli.command("pack", "start to pack assets").action(async (options) => {
25
+ cli.command("pack", "start to pack assets").option("--ver <version>", `[version] specify version`).action(async (options) => {
26
26
  filterDuplicateOptions(options);
27
27
  try {
28
28
  logger.info("start to pack assets");
29
29
  const { pack } = await import('./pack.js');
30
- await pack();
30
+ await pack(options["ver"]);
31
31
  } catch (e) {
32
32
  process.exit(1);
33
33
  }
@@ -19,7 +19,6 @@ PermissionsStartOnly=true
19
19
  # 应用安装目录,需手动修改
20
20
  WorkingDirectory=/etc/nginx
21
21
 
22
- [Service]
23
22
  Type=forking
24
23
  PIDFile=_pid_file_
25
24
  ExecStart=_exec_cmd_
@@ -8,10 +8,12 @@
8
8
  # # 下载 ansible 依赖包
9
9
  # yumdownloader --resolve --destdir=/deps openssl openssl-devel pcre pcre-devel gcc gcc-c++ zlib zlib-devel
10
10
 
11
+ # x86_64 使用centos 7.9 从源码编译 并打包
12
+ # arm 使用ctyunos 2.0.1 从源码编译 并打包
11
13
 
12
- nginx_version="1.22.1"
14
+ nginx_version="1.31.0"
13
15
 
14
- wget https://nginx.org/download/nginx-${nginx_version}.tar.gz
16
+ curl -LO https://nginx.org/download/nginx-${nginx_version}.tar.gz
15
17
 
16
18
  tar -zxvf nginx-${nginx_version}.tar.gz
17
19
 
@@ -28,6 +30,7 @@ cd nginx-${nginx_version} || exit
28
30
  --with-http_gzip_static_module \
29
31
  --with-http_stub_status_module \
30
32
  --with-stream \
33
+ --with-http_grpc_module \
31
34
  --with-pcre
32
35
 
33
36
  make
@@ -39,25 +42,28 @@ cp -f /etc/nginx/conf/mime.types /etc/nginx/
39
42
  echo '------------------compile and install done----------------------------'
40
43
 
41
44
  arch=$(uname -m)
42
- # system_name=$(uname -r | awk -F'.' '{print $(NF-1)"."$NF}')
43
- system_name=$(uname -r | awk -F'.' '{print $(NF-1)}')
44
- ssl_version=$(openssl version | awk '{print $2}')
45
- system_name_with_arch=$system_name"."$arch
45
+ ssl_version=$(openssl version | awk '{print $2}' | cut -d'-' -f1)
46
+ # 只保留 x.x.x 版本号,去掉后缀如 "1.1.1f" -> "1.1.1"
47
+ ssl_version=$(echo "$ssl_version" | grep -oP '^\d+\.\d+\.\d+')
46
48
 
47
49
 
48
50
  if [[ -z "${arch}" ]]; then
49
51
  arch="x86_64"
50
52
  fi
51
53
 
52
- if [[ $arch == arm* ]] || [[ $arch == aarch64 ]]; then
54
+ if [[ $arch == arm* ]] || [[ $arch == aarch* ]]; then
53
55
  arch="arm"
54
56
  fi
55
57
 
58
+ if [[ $arch == x86_64 ]]; then
59
+ arch="x86_64"
60
+ fi
61
+
56
62
 
57
63
  if [[ -z "${ssl_version}" ]]; then
58
64
  ssl_version="1.0.2"
59
65
  fi
60
66
 
61
- tar -zcvf nginx-"$system_name_with_arch"-ssl"$ssl_version".tar.gz -C /etc nginx/
67
+ tar -zcvf nginx-"$arch"-ssl"$ssl_version".tar.gz -C /etc nginx/
62
68
 
63
- echo "-----------done to pack: nginx-${system_name_with_arch}-ssl${ssl_version}.tar.gz--------------"
69
+ echo "-----------done to pack: nginx-${arch}-ssl${ssl_version}.tar.gz--------------"
@@ -257,8 +257,8 @@ start() {
257
257
  chmod 744 -R "$INSTALL_PATH"
258
258
 
259
259
  if [[ $? == 0 ]]; then
260
- log_success "posidon-frontend deployed successfully"
260
+ log_success "${APP_NAME} deployed successfully"
261
261
  else
262
- log_error "posidon-frontend deployment failed"
262
+ log_error "${APP_NAME} deployment failed"
263
263
  fi
264
264
  }
@@ -161,12 +161,12 @@ add_nginx_service() {
161
161
 
162
162
  if ((mode == 2)); then
163
163
  # systemctl enable nginx
164
- cp ./nginx.service /usr/lib/systemd/system/"$APP_NAME".nginx.service
164
+ cp ./nginx.service /usr/lib/systemd/system/"$APP_NAME".service
165
165
  systemctl daemon-reload
166
166
 
167
- log_success "add ${APP_NAME}.nginx.service to /usr/lib/systemd/system/"
167
+ log_success "add ${APP_NAME}.service to /usr/lib/systemd/system/"
168
168
  else
169
- rm -rf /usr/lib/systemd/system/"$APP_NAME".nginx.service
169
+ rm -rf /usr/lib/systemd/system/"$APP_NAME".service
170
170
  fi
171
171
  }
172
172
 
@@ -179,7 +179,7 @@ add_log_rotate(){
179
179
 
180
180
  sed -i "s#__usergroup__#$usergroup#g" ./nginx.logrotate
181
181
  sed -i "s#__user__#$user#g" ./nginx.logrotate
182
- sed -i "s#__APP_NAME__#$APP_NAME#g" ./nginx.logrotate
182
+ sed -i "s#__app_name__#$APP_NAME#g" ./nginx.logrotate
183
183
  sed -i "s#__pid_file__#$NGINX_PID_FILE_PATH#g" ./nginx.logrotate
184
184
 
185
185
  cp -f ./nginx.logrotate /etc/logrotate.d/${APP_NAME}.nginx
@@ -213,25 +213,23 @@ install_nginx_from_binary(){
213
213
  log "start to install nginx binary"
214
214
 
215
215
  arch=$(uname -m)
216
- system_name=$(uname -r | awk -F'.' '{print $(NF-1)}')
217
216
  ssl_full_version=$(openssl version | awk '{print $2}')
218
217
  ssl_fuzzy_version=$(openssl version | grep -oP '\d+\.\d+' | sed -n '1p' 2>&1)
219
- system_name_with_arch=$system_name"."$arch
220
218
 
221
- # 若存在完整的系统名称.架构.ssl版本的包则优先使用该包安装
222
- pkg="$NGINX_BINARY_PKG_PATH"/binary/nginx-"$system_name_with_arch"-ssl"$ssl_full_version".tar.gz
219
+ if [[ -z "${arch}" ]]; then
220
+ arch="x86_64"
221
+ fi
223
222
 
224
- if [ -f "$pkg" ]; then
225
- log "current arch: $system_name_with_arch, current ssl_version: $ssl_full_version"
226
- else
227
- if [[ -z "${arch}" ]]; then
228
- arch="x86_64"
229
- fi
223
+ if [[ $arch == arm* ]] || [[ $arch = aarch64 ]]; then
224
+ arch="arm"
225
+ fi
230
226
 
231
- if [[ $arch == arm* ]] || [[ $arch = aarch64 ]]; then
232
- arch="arm"
233
- fi
227
+ # 优先用完整 OpenSSL 版本号匹配(如 nginx-x86_64-ssl3.2.1.tar.gz)
228
+ pkg="$NGINX_BINARY_PKG_PATH"/binary/nginx-"$arch"-ssl"$ssl_full_version".tar.gz
234
229
 
230
+ if [ -f "$pkg" ]; then
231
+ log "current arch: $arch, current ssl_version: $ssl_full_version (full version match)"
232
+ else
235
233
  if [[ "${ssl_fuzzy_version}" == "1.0" ]]; then
236
234
  ssl_fuzzy_version="1.0.2"
237
235
  fi
@@ -244,6 +242,10 @@ install_nginx_from_binary(){
244
242
  ssl_fuzzy_version="3.0.7"
245
243
  fi
246
244
 
245
+ if [[ "${ssl_fuzzy_version}" == "3.2" ]]; then
246
+ ssl_fuzzy_version="3.2.1"
247
+ fi
248
+
247
249
  if [[ -z "${ssl_fuzzy_version}" ]]; then
248
250
  ssl_fuzzy_version="1.0.2"
249
251
  fi
@@ -255,7 +257,7 @@ install_nginx_from_binary(){
255
257
  exit 1
256
258
  fi
257
259
 
258
- log "current arch: $arch, current ssl_version $ssl_fuzzy_version"
260
+ log "current arch: $arch, current ssl_version: $ssl_fuzzy_version (fuzzy version match)"
259
261
  fi
260
262
 
261
263
  tar -zxvhf "$pkg" -C "$NGINX_BINARY_INSTALL_PATH" --strip-components 1
@@ -301,7 +303,8 @@ install_nginx_from_source(){
301
303
  # 安装nginx可执行程序
302
304
  install_nginx_binary() {
303
305
  log "install nginx to path: ${NGINX_BINARY_INSTALL_PATH}"
304
-
306
+ mkdir -p $NGINX_BINARY_INSTALL_PATH
307
+
305
308
  if [[ "${nginx_install_mode}" == "source" ]]; then
306
309
  install_nginx_from_source
307
310
  else
@@ -6,5 +6,5 @@ Install
6
6
  a. 若无 --> 安装
7
7
  b. 若有 --> 询问是否替换安装
8
8
  --> 资源部署
9
- 1. 生成对应 xxx.nginx.conf (替换对应日志xxx.nginx.log、进程和生成 xxx.nginx.service)
9
+ 1. 生成对应 xxx.nginx.conf (替换对应日志xxx.nginx.log、进程和生成 xxx.service)
10
10
  2. 复制静态资源文件
package/dist/publish.js CHANGED
@@ -15,7 +15,7 @@ import 'picocolors';
15
15
 
16
16
  async function isGitFlowRepo() {
17
17
  try {
18
- let { stdout } = await execa("git config", ["--get-regexp", `^gitflow.`]);
18
+ let { stdout } = await execa("git", ["config", "--get-regexp", `^gitflow.`]);
19
19
  return stdout.toString().length > 0;
20
20
  } catch (error) {
21
21
  console.error("\u{1F680} ~ doGitFlowRelease ~ error:", error);
@@ -24,13 +24,10 @@ async function isGitFlowRepo() {
24
24
  }
25
25
  async function getRepo() {
26
26
  let repo;
27
- try {
28
- const res = await execa(`git remote -v `).pipe(` sed -n '1p'`).pipe(`awk -F ' ' '{print $2}'`).pipe(`sed -e 's/.git//'`);
29
- repo = res.stdout.replace("\n", "");
30
- } catch (error) {
31
- const res = await $`git remote -v`;
32
- repo = res.stdout.split("\n")[1].split(" ")[0].split(" ")[1].replace(".git", "").replace("\n", "");
33
- }
27
+ const res = await $`git remote -v`;
28
+ const lines = res.stdout.split("\n").filter(Boolean);
29
+ const firstLine = lines[0] || "";
30
+ repo = firstLine.split(/\s+/)[1]?.replace(".git", "") || "";
34
31
  if (repo.startsWith("git@")) {
35
32
  const ps2 = repo.split("/");
36
33
  return {
package/dist/release.js CHANGED
@@ -136,7 +136,7 @@ async function doGitFlowRelease(version) {
136
136
  const hasUncommitted = await hasUncommittedChanges(true);
137
137
  if (hasUncommitted) {
138
138
  await $`git add -A`;
139
- await execa("git commit", ["-m", `Release version: ${version}`, "--no-verify"]);
139
+ await execa("git", ["commit", "-m", `Release version: ${version}`, "--no-verify"]);
140
140
  }
141
141
  await execWithPipe(`git flow release finish`, [version, "-m", `Release version: ${version}`]);
142
142
  await $`git push --all --no-verify`;
@@ -175,7 +175,7 @@ async function execGitPullOrigin(remoteTargetBranch) {
175
175
  }
176
176
  }
177
177
  async function execWithPipe(...args) {
178
- const execRes = execa(...args);
178
+ const execRes = execa(args[0], args[1], { shell: true });
179
179
  execRes.stdout.pipe(process.stdout);
180
180
  execRes.stderr.pipe(process.stderr);
181
181
  const result = await execRes;
@@ -185,14 +185,11 @@ async function execGitCheckout(remoteTargetBranch) {
185
185
  await hasUncommittedChanges();
186
186
  const { stdout: prevCurrentBranch } = await $`git branch --show-current`;
187
187
  if (prevCurrentBranch !== remoteTargetBranch) {
188
- const execRes = execa(`git checkout ${remoteTargetBranch}`);
189
- execRes.stdout.pipe(process.stdout);
190
- execRes.stderr.pipe(process.stderr);
191
- const result = await execRes;
188
+ await $`git checkout ${remoteTargetBranch}`;
192
189
  const { stdout: currentBranch } = await $`git branch --show-current`;
193
190
  if (currentBranch !== remoteTargetBranch) {
194
191
  logger.error(`\u76EE\u6807\u53D1\u5E03\u5206\u652F[${remoteTargetBranch}] checkout \u5931\u8D25`);
195
- return Promise.reject(result);
192
+ return Promise.reject(new Error(`\u76EE\u6807\u53D1\u5E03\u5206\u652F[${remoteTargetBranch}] checkout \u5931\u8D25`));
196
193
  }
197
194
  }
198
195
  }
@@ -0,0 +1,71 @@
1
+ # Example Project
2
+
3
+ 用于测试 release-helper 完整发版流程的示例项目。
4
+
5
+ ## 目录结构
6
+
7
+ ```
8
+ example-frontend/
9
+ ├── package.json # 前端项目配置,引用本地 release-helper
10
+ ├── dist/ # 构建产物目录
11
+ │ └── index.html # 模拟的构建产物
12
+ └── .release/ # 发版配置目录
13
+ ├── release.conf.yaml # 打包发版配置
14
+ ├── nginx/ # nginx 配置
15
+ │ ├── nginx.conf
16
+ │ └── ca/ # SSL 证书
17
+ └── doc/ # 发版附带文档
18
+ └── 部署手册.md
19
+ ```
20
+
21
+ ## 使用
22
+
23
+ ### 1. 安装依赖
24
+
25
+ ```bash
26
+ cd example/example-frontend
27
+ pnpm install
28
+ ```
29
+
30
+ ### 2. 配置
31
+
32
+ 编辑 `.release/release.conf.yaml`,填写真实的 GitLab 地址和 token:
33
+
34
+ ```yaml
35
+ host: 'https://your-gitlab.example.com'
36
+ token: 'your-token-here'
37
+ ```
38
+
39
+ ### 3. 测试打包
40
+
41
+ ```bash
42
+ pnpm pack
43
+ # 或
44
+ pnpm release-helper pack
45
+ ```
46
+
47
+ 打包完成后,在 `example-frontend/.release/` 目录下会生成 `example-frontend_x.tar.gz` 文件。
48
+
49
+ ### 4. 测试发版
50
+
51
+ 配置好 GitLab 信息后:
52
+
53
+ ```bash
54
+ pnpm release
55
+ # 或
56
+ pnpm release-helper release
57
+ ```
58
+
59
+ ## 验证打包产物
60
+
61
+ 解压 tar.gz 检查内部结构:
62
+
63
+ ```bash
64
+ tar -tzf .release/example-frontend_*.tar.gz | head -30
65
+ ```
66
+
67
+ 应包含:
68
+ - `example-frontend/script/` — 安装脚本
69
+ - `example-frontend/pkg/assets/` — 前端静态资源
70
+ - `example-frontend/pkg/nginx/` — nginx 配置
71
+ - `example-frontend/pkg/version` — 版本文件
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "example-frontend",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "example project for testing release-helper",
6
+ "scripts": {
7
+ "build": "echo 'simulating build...' && mkdir -p dist && echo '<!DOCTYPE html><html><head><meta x-v=__version__></head><body><h1>Example Frontend</h1></body></html>' > dist/index.html",
8
+ "pack": "release-helper pack",
9
+ "release": "release-helper release"
10
+ },
11
+ "devDependencies": {
12
+ "@wjwjq/release-helper": "file:../../"
13
+ }
14
+ }