@taole/deploy-helper 0.5.0 → 0.5.2

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.
package/index.mjs CHANGED
@@ -7,6 +7,12 @@ import { simpleGit } from 'simple-git';
7
7
  import { homedir } from 'os'
8
8
  import { runPipeline, checkYunxiaoToken, triggerPipeline } from './lib/pipelineApi.mjs';
9
9
  import { setDebug, log } from './lib/util.mjs';
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+
10
16
 
11
17
  const TEST_SERVER_HOST = "192.168.0.35";
12
18
  /**
@@ -79,10 +85,15 @@ async function getScpClient() {
79
85
  return scpClient;
80
86
  }
81
87
 
82
-
88
+ async function getVersion() {
89
+ const packageJsonPath = join(__dirname, "package.json");
90
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
91
+ return packageJson.version;
92
+ }
83
93
 
84
94
 
85
95
  async function main() {
96
+ const version = await getVersion();
86
97
 
87
98
  // process.argv.includes("--debug") ||
88
99
  // 默认开启debug debug目前只是打印日志的时候额外打印时间
@@ -100,7 +111,7 @@ async function main() {
100
111
  }
101
112
 
102
113
  if (command === "help") {
103
- console.log(`deploy-helper 部署脚本`);
114
+ console.log(`deploy-helper v${version}`);
104
115
  console.log(`usage: deploy-helper [command]`);
105
116
  console.log(`command: init 初始化配置`);
106
117
  console.log(`command: prod 生产环境部署`);
@@ -112,7 +123,7 @@ async function main() {
112
123
  console.log(`command: pipeline {pipelineName|pipelineId} [branch] 触发流水线{pipelineName|pipelineId}, 指定分支(可省略)`);
113
124
  process.exit(0);
114
125
  }
115
- log("deploy-helper start");
126
+ log(`deploy-helper v${version} start`);
116
127
 
117
128
  // 其他命令
118
129
  if (command === "init") {
@@ -163,7 +163,7 @@ async function waitPipelineRunFinish(pipelineID, runId, interval = 5000) {
163
163
  let passFailedMaxCount = 3;
164
164
  while (runDetail.status === "RUNNING" || runDetail.status === "WAITING" || runDetail.status === "INIT") {
165
165
  const { stage, job } = getCurrentJob(runDetail);
166
- log(`流水线执行状态: ${runDetail.status},阶段: ${stage.name},任务: ${job.name},等${interval / 1000}秒后重新轮询`);
166
+ log(`流水线执行状态: ${runDetail.status},阶段: ${stage.name},任务: ${job.name},${interval / 1000}秒后再次查询`);
167
167
  if (runDetail.status === "WAITING") {
168
168
  if (stage && job) {
169
169
  log(`尝试自动通过人工卡点`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taole/deploy-helper",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "脚本部署工具,用于将项目部署到测试环境或生产环境",
5
5
  "main": "index.mjs",
6
6
  "type": "module",