cli-z-develop 0.10.4 → 0.10.6
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/dist/index.js +817 -720
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { program as
|
|
1
|
+
import { program as x } from "commander";
|
|
2
2
|
import $t from "node:child_process";
|
|
3
3
|
import { existsSync as $, readdirSync as vt, lstatSync as bt } from "node:fs";
|
|
4
|
-
import { readdir as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import { readdir as ke, mkdir as ce, writeFile as _, rename as Be, readFile as Ae, stat as Nt } from "node:fs/promises";
|
|
5
|
+
import m from "node:path";
|
|
6
|
+
import pe, { AxiosError as St } from "axios";
|
|
7
|
+
import S from "chalk";
|
|
8
8
|
import jt from "dayjs";
|
|
9
9
|
import D from "shelljs";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { confirm as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { select as
|
|
10
|
+
import Et from "node:os";
|
|
11
|
+
import Me from "child_process";
|
|
12
|
+
import { confirm as Ue, select as T, input as F, password as At, checkbox as Te, number as ze } from "@inquirer/prompts";
|
|
13
|
+
import w from "ora";
|
|
14
|
+
import E from "fs-extra";
|
|
15
|
+
import { select as ie } from "inquirer-select-pro";
|
|
16
16
|
import Tt from "lint-staged";
|
|
17
17
|
import kt from "semver";
|
|
18
18
|
import { run as Ct } from "npm-check-updates";
|
|
19
19
|
import It from "p-limit";
|
|
20
|
-
import
|
|
21
|
-
const
|
|
22
|
-
var v = /* @__PURE__ */ ((e) => (e[e.DEV =
|
|
23
|
-
const
|
|
20
|
+
import xt from "minimist";
|
|
21
|
+
const Je = "dev", Ge = "test", We = "release", Rt = "production", Lt = "master";
|
|
22
|
+
var v = /* @__PURE__ */ ((e) => (e[e.DEV = Je] = "DEV", e[e.TEST = Ge] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.PROD = Rt] = "PROD", e))(v || {}), y = /* @__PURE__ */ ((e) => (e[e.DEV = Je] = "DEV", e[e.TEST = Ge] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.MASTER = Lt] = "MASTER", e))(y || {}), Z = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(Z || {});
|
|
23
|
+
const qe = [
|
|
24
24
|
{
|
|
25
25
|
name: `开发环境 - ${v.DEV}`,
|
|
26
26
|
value: v.DEV
|
|
@@ -37,7 +37,7 @@ const We = [
|
|
|
37
37
|
name: `正式环境 - ${v.PROD}`,
|
|
38
38
|
value: v.PROD
|
|
39
39
|
}
|
|
40
|
-
],
|
|
40
|
+
], Dt = [
|
|
41
41
|
{
|
|
42
42
|
name: "网页 - h5",
|
|
43
43
|
value: "h5"
|
|
@@ -54,7 +54,7 @@ const We = [
|
|
|
54
54
|
/* SERVER */
|
|
55
55
|
}
|
|
56
56
|
];
|
|
57
|
-
var
|
|
57
|
+
var le = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(le || {}), re = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(re || {}), L = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e))(L || {});
|
|
58
58
|
const Pt = {
|
|
59
59
|
1: "研发",
|
|
60
60
|
2: "测试",
|
|
@@ -65,10 +65,10 @@ const Pt = {
|
|
|
65
65
|
7: "行政",
|
|
66
66
|
8: "财务",
|
|
67
67
|
9: "其他"
|
|
68
|
-
},
|
|
68
|
+
}, me = "http://git.cxlqd.com", Ot = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
69
69
|
var b = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(b || {});
|
|
70
|
-
const Mt = "fe-biz7tvsd",
|
|
71
|
-
var
|
|
70
|
+
const Mt = "fe-biz7tvsd", Ve = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
71
|
+
var k = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(k || {});
|
|
72
72
|
const zt = [
|
|
73
73
|
{
|
|
74
74
|
name: "模块",
|
|
@@ -80,44 +80,44 @@ const zt = [
|
|
|
80
80
|
value: "case"
|
|
81
81
|
/* CASE */
|
|
82
82
|
}
|
|
83
|
-
],
|
|
84
|
-
function
|
|
85
|
-
return
|
|
83
|
+
], _t = ".z", Ft = "develop-config.json", V = ".z", Bt = ".commit-msg-tpl", Ut = "project.json";
|
|
84
|
+
function C(e = "") {
|
|
85
|
+
return m.join(V, e);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
return
|
|
87
|
+
function Ce() {
|
|
88
|
+
return C(Ut);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
90
|
+
function ye() {
|
|
91
|
+
return C(Bt);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
93
|
+
function Ze() {
|
|
94
|
+
Me.spawnSync("git", ["config", "core.hooksPath", C()]), Me.spawnSync("git", ["config", "commit.template", ye()]);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
96
|
+
function fe(e = "") {
|
|
97
|
+
return m.resolve(Et.homedir(), _t, e);
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
return
|
|
99
|
+
function $e() {
|
|
100
|
+
return fe(Ft);
|
|
101
101
|
}
|
|
102
102
|
function Jt() {
|
|
103
|
-
return $(
|
|
103
|
+
return $(fe());
|
|
104
104
|
}
|
|
105
105
|
function He() {
|
|
106
|
-
return Jt() && $(
|
|
106
|
+
return Jt() && $($e());
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function Ke(e) {
|
|
109
109
|
let t = e.trim();
|
|
110
110
|
const i = t.match(/^git@([^:]+):(.+)$/);
|
|
111
111
|
if (i)
|
|
112
112
|
t = i[2];
|
|
113
113
|
else {
|
|
114
|
-
const
|
|
115
|
-
t = t.replace(/^https?:\/\//, ""), t.startsWith(`${
|
|
114
|
+
const a = me.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
115
|
+
t = t.replace(/^https?:\/\//, ""), t.startsWith(`${a}/`) ? t = t.slice(a.length + 1) : t = t.replace(`${me.replace(/\/$/, "")}/`, "");
|
|
116
116
|
}
|
|
117
117
|
return encodeURIComponent(t.replace(/\.git$/, ""));
|
|
118
118
|
}
|
|
119
|
-
const { red:
|
|
120
|
-
function
|
|
119
|
+
const { red: _e, green: Gt, blue: yn, magenta: Wt, yellow: qt } = S;
|
|
120
|
+
function he(...e) {
|
|
121
121
|
}
|
|
122
122
|
function Vt(...e) {
|
|
123
123
|
console.log(qt(...e));
|
|
@@ -125,74 +125,74 @@ function Vt(...e) {
|
|
|
125
125
|
function B(...e) {
|
|
126
126
|
console.log(Gt(...e));
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(
|
|
128
|
+
function Qe(e) {
|
|
129
|
+
e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(S.cyan(" 👋 下次见~")), console.log(), process.exit(1));
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
|
|
131
|
+
function l(e, t = !1) {
|
|
132
|
+
Qe(e);
|
|
133
133
|
let i = e;
|
|
134
|
-
e instanceof Error ? (i = e.message,
|
|
134
|
+
e instanceof Error ? (i = e.message, pe.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(_e(i)), console.log(Wt(e.stack))) : console.log(_e(e)), t || process.exit(1);
|
|
135
135
|
}
|
|
136
136
|
function Fe(e) {
|
|
137
137
|
return $(e) ? bt(e).isDirectory() : !1;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
return Fe(e) ? vt(e).filter((i) => Fe(
|
|
139
|
+
function Ye(e = process.cwd()) {
|
|
140
|
+
return Fe(e) ? vt(e).filter((i) => Fe(m.resolve(e, i))) : [];
|
|
141
141
|
}
|
|
142
|
-
async function
|
|
142
|
+
async function p(e, t = {
|
|
143
143
|
removeTailLinkBreak: !0,
|
|
144
144
|
silent: !0
|
|
145
145
|
}) {
|
|
146
|
-
let i = await new Promise((
|
|
146
|
+
let i = await new Promise((a, n) => {
|
|
147
147
|
try {
|
|
148
148
|
const s = D.exec(e, {
|
|
149
149
|
silent: t.silent
|
|
150
150
|
});
|
|
151
|
-
n(s);
|
|
152
|
-
} catch (s) {
|
|
153
151
|
a(s);
|
|
152
|
+
} catch (s) {
|
|
153
|
+
n(s);
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
return i = i.toString(), t.removeTailLinkBreak && (i = i.replace(/\n$/, "")), i;
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function Xe(e) {
|
|
159
159
|
$t.execSync(e, {
|
|
160
160
|
stdio: "inherit"
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
-
function
|
|
163
|
+
function et() {
|
|
164
164
|
return jt(Date.now()).format("YYMMDD");
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function Zt(e, t) {
|
|
167
167
|
for (const i of t)
|
|
168
168
|
if (!e.includes(i))
|
|
169
169
|
return !1;
|
|
170
170
|
return !0;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
$(
|
|
172
|
+
function ae() {
|
|
173
|
+
$(C()) || l("当前不在项目根目录。请切换到项目根目录");
|
|
174
174
|
}
|
|
175
175
|
function Q() {
|
|
176
|
-
$(
|
|
176
|
+
$(m.resolve(".git")) || l("当前不是git项目根目录,请先执行git init,或切换到根目录");
|
|
177
177
|
}
|
|
178
|
-
async function
|
|
179
|
-
await
|
|
178
|
+
async function ue() {
|
|
179
|
+
await p("git status -s") !== "" && l("请先提交代码变动,再进行操作");
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function Ht(e) {
|
|
182
182
|
return e === y.MASTER ? v.PROD : e;
|
|
183
183
|
}
|
|
184
184
|
function Kt(e) {
|
|
185
185
|
return e === v.PROD ? y.MASTER : e;
|
|
186
186
|
}
|
|
187
|
-
async function
|
|
187
|
+
async function M(e, ...t) {
|
|
188
188
|
try {
|
|
189
189
|
await e(...t);
|
|
190
190
|
} catch (i) {
|
|
191
|
-
throw
|
|
191
|
+
throw Qe(i), i;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
async function Qt(e) {
|
|
195
|
-
return (await
|
|
195
|
+
return (await ke(e)).length === 0;
|
|
196
196
|
}
|
|
197
197
|
function Yt(e = "项目中文名", t = "项目描述") {
|
|
198
198
|
return `
|
|
@@ -295,30 +295,59 @@ dist/
|
|
|
295
295
|
# 垃圾文件
|
|
296
296
|
.Trashes
|
|
297
297
|
`, ti = {
|
|
298
|
-
[
|
|
298
|
+
[L.JAVA]: {
|
|
299
299
|
// TODO: 需要优化
|
|
300
300
|
// "**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml",
|
|
301
301
|
"**/*.{java}": "echo 'todo'"
|
|
302
302
|
},
|
|
303
|
-
[
|
|
303
|
+
[L.JAVASCRIPT]: {
|
|
304
304
|
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
305
305
|
"*": "prettier -wu"
|
|
306
306
|
},
|
|
307
|
-
[
|
|
307
|
+
[L.PYTHON]: {
|
|
308
308
|
// TODO: 需要优化
|
|
309
309
|
// "**/*.{py}": "python --fix",
|
|
310
310
|
"**/*.{py}": "echo 'todo'"
|
|
311
311
|
}
|
|
312
|
-
}, ii = `
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
312
|
+
}, ii = `
|
|
313
|
+
- case_id: 1
|
|
314
|
+
name: "用例描述"
|
|
315
|
+
# 前置条件
|
|
316
|
+
precondition: ""
|
|
317
|
+
# 优先级
|
|
318
|
+
pri: 3
|
|
319
|
+
# 严重程度
|
|
320
|
+
severity: 3
|
|
321
|
+
# 请求相关
|
|
322
|
+
request:
|
|
323
|
+
method: POST
|
|
324
|
+
url: ""
|
|
325
|
+
# 请求参数
|
|
326
|
+
json: {}
|
|
327
|
+
# 返回结果校验
|
|
328
|
+
validate:
|
|
329
|
+
# 包含内容
|
|
330
|
+
- contains: {}
|
|
331
|
+
|
|
332
|
+
- case_id: 2
|
|
333
|
+
name: "用例描述"
|
|
334
|
+
# 前置条件
|
|
335
|
+
precondition: ""
|
|
336
|
+
# 优先级
|
|
337
|
+
pri: 3
|
|
338
|
+
# 严重程度
|
|
339
|
+
severity: 3
|
|
340
|
+
# 请求相关
|
|
341
|
+
request:
|
|
342
|
+
method: POST
|
|
343
|
+
url: ""
|
|
344
|
+
# 请求参数
|
|
345
|
+
json: {}
|
|
346
|
+
# 返回结果校验
|
|
347
|
+
validate:
|
|
348
|
+
# 包含内容
|
|
349
|
+
- contains: {}
|
|
350
|
+
`, ai = "# from assets", ni = "cli-z-develop", si = "0.10.6", ri = "技术团队开发流程管理工具", oi = "dist/index.js", ci = { z: "bin/z.js", "z-develop": "bin/z.js" }, ui = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", eslint: "eslint '**/*.{ts,js}' --fix", prettier: "prettier -wu .", upload: "npm run build && npm publish --access public --registry https://registry.npmjs.org/", "upload:patch": "npm version patch && npm run upload", "upload:minor": "npm version minor && npm run upload", "upload:major": "npm version major && npm run upload" }, li = "module", pi = "z", mi = { "@lonely9/eslint-config-team": "^1.3.5", "@tsconfig/node22": "^22.0.5", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.9", "@types/minimist": "^1.2.5", "@types/node": "^22.15.29", "@types/semver": "^7.7.1", "@types/shelljs": "^0.10.0", "@typescript-eslint/eslint-plugin": "^8.53.0", "@typescript-eslint/parser": "^8.53.0", eslint: "^9.39.2", jiti: "^2.6.1", prettier: "^3.7.4", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.2.2" }, di = { "@inquirer/prompts": "^8.2.0", axios: "^1.13.6", chalk: "^5.6.2", commander: "^14.0.2", dayjs: "^1.11.19", "fs-extra": "^11.3.3", "inquirer-select-pro": "^1.0.0-alpha.9", "lint-staged": "^16.2.7", minimist: "^1.2.8", "npm-check-updates": "^19.3.1", ora: "^9.0.0", "p-limit": "^7.3.0", semver: "^7.7.3", shelljs: "^0.10.0" }, te = {
|
|
322
351
|
name: ni,
|
|
323
352
|
version: si,
|
|
324
353
|
description: ri,
|
|
@@ -329,7 +358,7 @@ dist/
|
|
|
329
358
|
author: pi,
|
|
330
359
|
devDependencies: mi,
|
|
331
360
|
dependencies: di
|
|
332
|
-
},
|
|
361
|
+
}, I = {
|
|
333
362
|
// 个人数据
|
|
334
363
|
profile: {
|
|
335
364
|
ldapAccount: "",
|
|
@@ -341,13 +370,13 @@ dist/
|
|
|
341
370
|
gitEmail: "",
|
|
342
371
|
weWorkName: "",
|
|
343
372
|
weWorkUserId: "",
|
|
344
|
-
jobType:
|
|
373
|
+
jobType: re.FRONT_END,
|
|
345
374
|
zenTaoToken: "",
|
|
346
375
|
k8sToken: ""
|
|
347
376
|
},
|
|
348
377
|
// 包数据
|
|
349
378
|
main: {
|
|
350
|
-
version:
|
|
379
|
+
version: te.version,
|
|
351
380
|
latestCheckVersionTimestamp: 0,
|
|
352
381
|
// 3天检查一次
|
|
353
382
|
versionCheckDuring: 3,
|
|
@@ -363,40 +392,40 @@ dist/
|
|
|
363
392
|
}
|
|
364
393
|
};
|
|
365
394
|
function A(e) {
|
|
366
|
-
return e ?
|
|
395
|
+
return e ? I.profile[e] : I.profile;
|
|
367
396
|
}
|
|
368
|
-
function
|
|
369
|
-
return e ?
|
|
397
|
+
function de(e) {
|
|
398
|
+
return e ? I.main[e] : I.main;
|
|
370
399
|
}
|
|
371
|
-
function
|
|
372
|
-
return e ?
|
|
400
|
+
function Y(e) {
|
|
401
|
+
return e ? I.constants[e] : I.constants;
|
|
373
402
|
}
|
|
374
403
|
let U = null, J = null;
|
|
375
|
-
function
|
|
404
|
+
function ve() {
|
|
376
405
|
if (U)
|
|
377
406
|
return U;
|
|
378
|
-
const e =
|
|
379
|
-
return $(e) ||
|
|
407
|
+
const e = m.join("package.json");
|
|
408
|
+
return $(e) || l(`当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), U = E.readJsonSync(e), U;
|
|
380
409
|
}
|
|
381
|
-
function
|
|
410
|
+
function be() {
|
|
382
411
|
if (J)
|
|
383
412
|
return J;
|
|
384
|
-
const e =
|
|
385
|
-
return $(e) ||
|
|
413
|
+
const e = Ce();
|
|
414
|
+
return $(e) || l(
|
|
386
415
|
`当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
387
|
-
), J =
|
|
416
|
+
), J = E.readJsonSync(e), J;
|
|
388
417
|
}
|
|
389
|
-
function
|
|
418
|
+
function tt(e) {
|
|
390
419
|
J ? J = {
|
|
391
420
|
...J,
|
|
392
421
|
...e
|
|
393
|
-
} : J = e,
|
|
422
|
+
} : J = e, E.writeJSONSync(Ce(), J, { spaces: 2 });
|
|
394
423
|
}
|
|
395
424
|
function fi(e) {
|
|
396
425
|
U ? U = {
|
|
397
426
|
...U,
|
|
398
427
|
...e
|
|
399
|
-
} : U = e,
|
|
428
|
+
} : U = e, E.writeJSONSync(m.join("package.json"), U, { spaces: 2 });
|
|
400
429
|
}
|
|
401
430
|
const q = {
|
|
402
431
|
id: 0,
|
|
@@ -408,58 +437,58 @@ const q = {
|
|
|
408
437
|
async function gi() {
|
|
409
438
|
if (!q.id)
|
|
410
439
|
try {
|
|
411
|
-
const e =
|
|
440
|
+
const e = be(), t = Ke(e.repository.url), i = await nt(t);
|
|
412
441
|
q.id = i.id, q.path = t, q.group = i.namespace.full_path, q.mergeRequestUrl = `${i.web_url}/merge_requests`;
|
|
413
442
|
} catch (e) {
|
|
414
|
-
|
|
443
|
+
l(e);
|
|
415
444
|
}
|
|
416
|
-
return q.sourceBranch || (q.sourceBranch = await
|
|
445
|
+
return q.sourceBranch || (q.sourceBranch = await p("git branch --show-current")), q;
|
|
417
446
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
420
|
-
|
|
447
|
+
function ne() {
|
|
448
|
+
E.writeJSONSync(
|
|
449
|
+
$e(),
|
|
421
450
|
{
|
|
422
|
-
main:
|
|
451
|
+
main: de(),
|
|
423
452
|
profile: A(),
|
|
424
|
-
constants:
|
|
453
|
+
constants: Y()
|
|
425
454
|
},
|
|
426
455
|
{
|
|
427
456
|
spaces: 2
|
|
428
457
|
}
|
|
429
458
|
);
|
|
430
459
|
}
|
|
431
|
-
function
|
|
432
|
-
t !== void 0 ?
|
|
433
|
-
...
|
|
460
|
+
function O(e, t) {
|
|
461
|
+
t !== void 0 ? I.profile[e] = t : I.profile = {
|
|
462
|
+
...I.profile,
|
|
434
463
|
...e
|
|
435
464
|
};
|
|
436
465
|
}
|
|
437
|
-
function
|
|
438
|
-
|
|
439
|
-
...
|
|
466
|
+
function Ie(e, t) {
|
|
467
|
+
I.constants = {
|
|
468
|
+
...I.constants,
|
|
440
469
|
...e
|
|
441
470
|
};
|
|
442
471
|
}
|
|
443
|
-
function
|
|
444
|
-
t !== void 0 ?
|
|
445
|
-
...
|
|
472
|
+
function oe(e, t) {
|
|
473
|
+
t !== void 0 ? I.main[e] = t : I.main = {
|
|
474
|
+
...I.main,
|
|
446
475
|
...e
|
|
447
476
|
};
|
|
448
477
|
}
|
|
449
|
-
async function
|
|
450
|
-
const t = e.method || "get", i = e.headers || {},
|
|
478
|
+
async function H(e) {
|
|
479
|
+
const t = e.method || "get", i = e.headers || {}, a = e.data || {}, n = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
|
|
451
480
|
try {
|
|
452
481
|
const s = {
|
|
453
482
|
url: e.url,
|
|
454
483
|
method: t,
|
|
455
|
-
[
|
|
484
|
+
[n]: a,
|
|
456
485
|
headers: i
|
|
457
486
|
};
|
|
458
|
-
|
|
459
|
-
const o = await
|
|
460
|
-
return
|
|
487
|
+
he(S.magenta(s.method.toUpperCase()), S.yellow(s.url), JSON.stringify(s.headers)), he(S.gray(JSON.stringify(s[n], null, 2)));
|
|
488
|
+
const o = await pe(s);
|
|
489
|
+
return he(S.green("Response"), S.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
|
|
461
490
|
} catch (s) {
|
|
462
|
-
return s instanceof St &&
|
|
491
|
+
return s instanceof St && he(S.red("Error"), S.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
|
|
463
492
|
}
|
|
464
493
|
}
|
|
465
494
|
async function hi() {
|
|
@@ -467,8 +496,8 @@ async function hi() {
|
|
|
467
496
|
if (e)
|
|
468
497
|
return e;
|
|
469
498
|
{
|
|
470
|
-
const { access_token: t } = await
|
|
471
|
-
url: `${
|
|
499
|
+
const { access_token: t } = await H({
|
|
500
|
+
url: `${me}/oauth/token`,
|
|
472
501
|
method: "post",
|
|
473
502
|
data: {
|
|
474
503
|
grant_type: "password",
|
|
@@ -476,11 +505,11 @@ async function hi() {
|
|
|
476
505
|
password: A("ldapPassword")
|
|
477
506
|
}
|
|
478
507
|
}), i = `Bearer ${t}`;
|
|
479
|
-
return
|
|
508
|
+
return O("gitToken", i), ne(), i;
|
|
480
509
|
}
|
|
481
510
|
}
|
|
482
511
|
async function R(e) {
|
|
483
|
-
return
|
|
512
|
+
return H({
|
|
484
513
|
...e,
|
|
485
514
|
headers: {
|
|
486
515
|
Authorization: await hi()
|
|
@@ -492,19 +521,19 @@ async function wi() {
|
|
|
492
521
|
if (e)
|
|
493
522
|
return e;
|
|
494
523
|
{
|
|
495
|
-
const { token: t } = await
|
|
496
|
-
url: `${
|
|
524
|
+
const { token: t } = await H({
|
|
525
|
+
url: `${Y("ZenTaoDomain")}/api.php/v1/tokens`,
|
|
497
526
|
method: "post",
|
|
498
527
|
data: {
|
|
499
528
|
account: A("ldapAccount"),
|
|
500
529
|
password: A("ldapPassword")
|
|
501
530
|
}
|
|
502
531
|
});
|
|
503
|
-
return
|
|
532
|
+
return O("zenTaoToken", t), ne(), t;
|
|
504
533
|
}
|
|
505
534
|
}
|
|
506
|
-
async function
|
|
507
|
-
const t = await
|
|
535
|
+
async function we(e) {
|
|
536
|
+
const t = await H({
|
|
508
537
|
...e,
|
|
509
538
|
headers: {
|
|
510
539
|
Token: await wi()
|
|
@@ -516,16 +545,16 @@ async function he(e) {
|
|
|
516
545
|
return JSON.parse(i.data);
|
|
517
546
|
}
|
|
518
547
|
if (typeof t == "object")
|
|
519
|
-
return t.error === "Unauthorized" || t.data.indexOf("<script>") < 0 ? (
|
|
548
|
+
return t.error === "Unauthorized" || t.data.indexOf("<script>") < 0 ? (O("zenTaoToken", ""), we({
|
|
520
549
|
...e
|
|
521
550
|
})) : t;
|
|
522
551
|
} else {
|
|
523
|
-
const { status: i, data:
|
|
552
|
+
const { status: i, data: a } = t;
|
|
524
553
|
if (i === "success") {
|
|
525
|
-
const
|
|
526
|
-
return
|
|
554
|
+
const n = JSON.parse(a);
|
|
555
|
+
return n.title === "用户登录" ? (O("zenTaoToken", ""), we({
|
|
527
556
|
...e
|
|
528
|
-
})) :
|
|
557
|
+
})) : n;
|
|
529
558
|
} else
|
|
530
559
|
return {};
|
|
531
560
|
}
|
|
@@ -535,8 +564,8 @@ async function yi() {
|
|
|
535
564
|
if (e)
|
|
536
565
|
return e;
|
|
537
566
|
{
|
|
538
|
-
const { access_token: t } = await
|
|
539
|
-
url: `${
|
|
567
|
+
const { access_token: t } = await H({
|
|
568
|
+
url: `${Y("K8sDomain")}/oauth/login/LDAP`,
|
|
540
569
|
method: "post",
|
|
541
570
|
headers: {
|
|
542
571
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -546,125 +575,125 @@ async function yi() {
|
|
|
546
575
|
password: A("ldapPassword")
|
|
547
576
|
}
|
|
548
577
|
}), i = `Bearer ${t}`;
|
|
549
|
-
return
|
|
578
|
+
return O("k8sToken", i), ne(), i;
|
|
550
579
|
}
|
|
551
580
|
}
|
|
552
|
-
async function
|
|
553
|
-
const t = await
|
|
581
|
+
async function it(e) {
|
|
582
|
+
const t = await H({
|
|
554
583
|
...e,
|
|
555
584
|
headers: {
|
|
556
585
|
Authorization: await yi()
|
|
557
586
|
}
|
|
558
587
|
});
|
|
559
|
-
return t.code === 401 ? (
|
|
588
|
+
return t.code === 401 ? (O("k8sToken", ""), it({
|
|
560
589
|
...e
|
|
561
590
|
})) : t;
|
|
562
591
|
}
|
|
563
|
-
const
|
|
592
|
+
const z = () => `${me}/api/v4`, xe = (e) => `${z()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
|
|
564
593
|
function $i() {
|
|
565
594
|
return R({
|
|
566
|
-
url:
|
|
595
|
+
url: xe("src/data/template-projects.json")
|
|
567
596
|
});
|
|
568
597
|
}
|
|
569
|
-
function
|
|
598
|
+
function at() {
|
|
570
599
|
return R({
|
|
571
|
-
url:
|
|
600
|
+
url: xe("src/data/z-develop-config.json")
|
|
572
601
|
});
|
|
573
602
|
}
|
|
574
603
|
function vi() {
|
|
575
604
|
return R({
|
|
576
|
-
url:
|
|
605
|
+
url: xe("src/data/project-group-chats.json")
|
|
577
606
|
});
|
|
578
607
|
}
|
|
579
608
|
function bi() {
|
|
580
609
|
return R({
|
|
581
|
-
url: `${
|
|
610
|
+
url: `${z()}/user`
|
|
582
611
|
});
|
|
583
612
|
}
|
|
584
613
|
function Ni() {
|
|
585
614
|
return R({
|
|
586
|
-
url: `${
|
|
615
|
+
url: `${z()}/groups`
|
|
587
616
|
});
|
|
588
617
|
}
|
|
589
618
|
function Si(e) {
|
|
590
619
|
return R({
|
|
591
|
-
url: `${
|
|
620
|
+
url: `${z()}/projects`,
|
|
592
621
|
method: "post",
|
|
593
622
|
data: e
|
|
594
623
|
});
|
|
595
624
|
}
|
|
596
|
-
function
|
|
625
|
+
function nt(e) {
|
|
597
626
|
return R({
|
|
598
|
-
url: `${
|
|
627
|
+
url: `${z()}/projects/${e}`
|
|
599
628
|
});
|
|
600
629
|
}
|
|
601
630
|
function ji(e) {
|
|
602
631
|
return R({
|
|
603
|
-
url: `${
|
|
632
|
+
url: `${z()}/projects`,
|
|
604
633
|
data: {
|
|
605
634
|
search: e,
|
|
606
635
|
search_namespaces: !0
|
|
607
636
|
}
|
|
608
637
|
});
|
|
609
638
|
}
|
|
610
|
-
function
|
|
639
|
+
function Ei(e) {
|
|
611
640
|
return R({
|
|
612
|
-
url: `${
|
|
641
|
+
url: `${z()}/projects/${e.id}/merge_requests`,
|
|
613
642
|
method: "post",
|
|
614
643
|
data: e
|
|
615
644
|
});
|
|
616
645
|
}
|
|
617
|
-
function
|
|
646
|
+
function Ai(e) {
|
|
618
647
|
return R({
|
|
619
|
-
url: `${
|
|
648
|
+
url: `${z()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
620
649
|
method: "put"
|
|
621
650
|
});
|
|
622
651
|
}
|
|
623
652
|
function Ti(e) {
|
|
624
653
|
return R({
|
|
625
|
-
url: `${
|
|
654
|
+
url: `${z()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
626
655
|
method: "put",
|
|
627
656
|
data: e
|
|
628
657
|
});
|
|
629
658
|
}
|
|
630
659
|
function ki(e) {
|
|
631
660
|
return R({
|
|
632
|
-
url: `${
|
|
661
|
+
url: `${z()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
633
662
|
method: "get"
|
|
634
663
|
});
|
|
635
664
|
}
|
|
636
665
|
function Ci(e) {
|
|
637
666
|
return R({
|
|
638
|
-
url: `${
|
|
667
|
+
url: `${z()}/projects/${e.id}/repository/branches`,
|
|
639
668
|
method: "post",
|
|
640
669
|
data: e
|
|
641
670
|
});
|
|
642
671
|
}
|
|
643
672
|
function Ii(e) {
|
|
644
673
|
return R({
|
|
645
|
-
url: `${
|
|
674
|
+
url: `${z()}/projects/${e}/repository/branches`
|
|
646
675
|
});
|
|
647
676
|
}
|
|
648
|
-
function
|
|
649
|
-
const e =
|
|
650
|
-
return $(e) ?
|
|
677
|
+
function xi() {
|
|
678
|
+
const e = fe("fe-groups.json");
|
|
679
|
+
return $(e) ? E.readJSONSync(e) : { groups: [] };
|
|
651
680
|
}
|
|
652
|
-
async function
|
|
681
|
+
async function Ri() {
|
|
653
682
|
const e = await Ni(), t = Ot.map((i) => {
|
|
654
|
-
const
|
|
655
|
-
return
|
|
656
|
-
name:
|
|
657
|
-
id:
|
|
658
|
-
description:
|
|
683
|
+
const a = e.find((n) => n.name === i);
|
|
684
|
+
return a ? {
|
|
685
|
+
name: a.name,
|
|
686
|
+
id: a.id,
|
|
687
|
+
description: a.description
|
|
659
688
|
} : !1;
|
|
660
689
|
}).filter((i) => !!i);
|
|
661
|
-
|
|
690
|
+
E.writeJSONSync(fe("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
662
691
|
}
|
|
663
|
-
async function
|
|
664
|
-
const t = `${
|
|
692
|
+
async function N(e) {
|
|
693
|
+
const t = `${Y("FEServerDomain")}/api`, { data: i } = await H({
|
|
665
694
|
url: `${t}/auth/z-develop/login`,
|
|
666
695
|
method: "post"
|
|
667
|
-
}),
|
|
696
|
+
}), a = await H({
|
|
668
697
|
url: t + e.url,
|
|
669
698
|
headers: {
|
|
670
699
|
Authorization: `Bearer ${i}`
|
|
@@ -672,20 +701,20 @@ async function T(e) {
|
|
|
672
701
|
data: e.data,
|
|
673
702
|
method: e.method || "post"
|
|
674
703
|
});
|
|
675
|
-
return
|
|
704
|
+
return a.code !== 0 && l(`${a.code}: ${a.message}`), a.data;
|
|
676
705
|
}
|
|
677
|
-
function
|
|
678
|
-
return
|
|
706
|
+
function Li() {
|
|
707
|
+
return N({
|
|
679
708
|
url: "/user/list2"
|
|
680
709
|
});
|
|
681
710
|
}
|
|
682
|
-
function
|
|
683
|
-
return
|
|
711
|
+
function Di() {
|
|
712
|
+
return N({
|
|
684
713
|
url: "/zen/testcase/product/list"
|
|
685
714
|
});
|
|
686
715
|
}
|
|
687
|
-
function
|
|
688
|
-
return
|
|
716
|
+
function st(e) {
|
|
717
|
+
return N({
|
|
689
718
|
url: "/zen/testcase/product/module/list",
|
|
690
719
|
data: {
|
|
691
720
|
product: e
|
|
@@ -693,7 +722,7 @@ function nt(e) {
|
|
|
693
722
|
});
|
|
694
723
|
}
|
|
695
724
|
function Pi(e) {
|
|
696
|
-
return
|
|
725
|
+
return N({
|
|
697
726
|
url: "/zen/testcase/product/name",
|
|
698
727
|
data: {
|
|
699
728
|
product: e
|
|
@@ -701,7 +730,7 @@ function Pi(e) {
|
|
|
701
730
|
});
|
|
702
731
|
}
|
|
703
732
|
function Oi(e, t) {
|
|
704
|
-
return
|
|
733
|
+
return N({
|
|
705
734
|
url: "/zen/testcase/product/auto-case/list",
|
|
706
735
|
data: {
|
|
707
736
|
product: e,
|
|
@@ -710,7 +739,7 @@ function Oi(e, t) {
|
|
|
710
739
|
});
|
|
711
740
|
}
|
|
712
741
|
function Mi(e) {
|
|
713
|
-
return
|
|
742
|
+
return N({
|
|
714
743
|
url: "/zen/testcase/step/list",
|
|
715
744
|
data: {
|
|
716
745
|
id: e
|
|
@@ -718,169 +747,196 @@ function Mi(e) {
|
|
|
718
747
|
});
|
|
719
748
|
}
|
|
720
749
|
function zi(e) {
|
|
721
|
-
return
|
|
750
|
+
return N({
|
|
722
751
|
url: "/zen/testcase/module/create",
|
|
723
752
|
data: e
|
|
724
753
|
});
|
|
725
754
|
}
|
|
726
|
-
function
|
|
727
|
-
return
|
|
755
|
+
function _i(e) {
|
|
756
|
+
return N({
|
|
728
757
|
url: "/zen/testcase/create",
|
|
729
758
|
data: e
|
|
730
759
|
});
|
|
731
760
|
}
|
|
732
|
-
function
|
|
733
|
-
return
|
|
761
|
+
function Fi(e) {
|
|
762
|
+
return N({
|
|
734
763
|
url: "/zen/testcase/step/create",
|
|
735
764
|
data: e
|
|
736
765
|
});
|
|
737
766
|
}
|
|
738
767
|
function Bi(e) {
|
|
739
|
-
return
|
|
768
|
+
return N({
|
|
740
769
|
url: "/zen/testcase/modules/remove",
|
|
741
770
|
data: e
|
|
742
771
|
});
|
|
743
772
|
}
|
|
744
773
|
function Ui(e) {
|
|
745
|
-
return
|
|
774
|
+
return N({
|
|
746
775
|
url: "/zen/testcase/cases/remove",
|
|
747
776
|
data: e
|
|
748
777
|
});
|
|
749
778
|
}
|
|
750
779
|
function Ji(e) {
|
|
751
|
-
return
|
|
780
|
+
return N({
|
|
752
781
|
url: "/zen/testcase/module/update/name",
|
|
753
782
|
data: e
|
|
754
783
|
});
|
|
755
784
|
}
|
|
756
785
|
function Gi(e) {
|
|
757
|
-
return
|
|
786
|
+
return N({
|
|
758
787
|
url: "/zen/testcase/case/update/name",
|
|
759
788
|
data: e
|
|
760
789
|
});
|
|
761
790
|
}
|
|
762
791
|
function Wi(e) {
|
|
763
|
-
return
|
|
792
|
+
return N({
|
|
764
793
|
url: "/zen/testcase/case/update/priority",
|
|
765
794
|
data: e
|
|
766
795
|
});
|
|
767
796
|
}
|
|
768
797
|
function qi(e) {
|
|
769
|
-
return
|
|
798
|
+
return N({
|
|
770
799
|
url: "/zen/testcase/case/update/precondition",
|
|
771
800
|
data: e
|
|
772
801
|
});
|
|
773
802
|
}
|
|
774
|
-
function Vi(e
|
|
803
|
+
function Vi(e) {
|
|
804
|
+
return N({
|
|
805
|
+
url: "/zen/testcase/case/result/create",
|
|
806
|
+
data: e
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
function Zi() {
|
|
810
|
+
return N({
|
|
811
|
+
url: "/zen/testcase/project/list"
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
function Hi(e) {
|
|
815
|
+
return N({
|
|
816
|
+
url: "/zen/testcase/project/execution/list",
|
|
817
|
+
data: {
|
|
818
|
+
project: e
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
function Ki(e) {
|
|
823
|
+
return N({
|
|
824
|
+
url: "/zen/testcase/execution/build/list",
|
|
825
|
+
data: {
|
|
826
|
+
id: e
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
function Qi(e, t) {
|
|
775
831
|
const i = [];
|
|
776
832
|
t.forEach((s) => {
|
|
777
833
|
e.includes(s.value) && i.push(s);
|
|
778
834
|
});
|
|
779
|
-
const
|
|
835
|
+
const a = de("weWorkListCache"), n = a.map((s) => s.value);
|
|
780
836
|
i.forEach((s) => {
|
|
781
|
-
const o =
|
|
782
|
-
o > -1 ?
|
|
837
|
+
const o = n.indexOf(s.value);
|
|
838
|
+
o > -1 ? a[o].usageCount += 1 : a.push({
|
|
783
839
|
...s,
|
|
784
840
|
usageCount: 1
|
|
785
841
|
});
|
|
786
|
-
}),
|
|
787
|
-
weWorkListCache:
|
|
788
|
-
}),
|
|
842
|
+
}), oe({
|
|
843
|
+
weWorkListCache: a.sort((s, o) => o.usageCount - s.usageCount)
|
|
844
|
+
}), ne();
|
|
789
845
|
}
|
|
790
|
-
async function
|
|
791
|
-
const t = (await
|
|
846
|
+
async function rt() {
|
|
847
|
+
const t = (await Li()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
792
848
|
name: `${s.nick} - ${Pt[s.title]}`,
|
|
793
849
|
value: s.weWorkUserId
|
|
794
|
-
})), i =
|
|
850
|
+
})), i = de("weWorkListCache"), a = i.map((s) => s.value), n = [];
|
|
795
851
|
return t.forEach((s) => {
|
|
796
|
-
const o =
|
|
797
|
-
|
|
852
|
+
const o = a.indexOf(s.value);
|
|
853
|
+
n.push({
|
|
798
854
|
...s,
|
|
799
855
|
usageCount: o > -1 ? i[o].usageCount : 0
|
|
800
856
|
});
|
|
801
|
-
}),
|
|
857
|
+
}), n.sort((s, o) => o.usageCount - s.usageCount);
|
|
802
858
|
}
|
|
803
|
-
async function
|
|
804
|
-
const
|
|
805
|
-
let
|
|
859
|
+
async function ot(e, t, i) {
|
|
860
|
+
const a = await rt();
|
|
861
|
+
let n = await ie({
|
|
806
862
|
message: e,
|
|
807
863
|
loop: !0,
|
|
808
|
-
pageSize:
|
|
864
|
+
pageSize: a.length || 5,
|
|
809
865
|
clearInputWhenSelected: !0,
|
|
810
866
|
multiple: i,
|
|
811
|
-
options: (s) => s ?
|
|
867
|
+
options: (s) => s ? a.filter((o) => o.name.includes(s)) : a,
|
|
812
868
|
validate: t
|
|
813
869
|
});
|
|
814
|
-
return
|
|
870
|
+
return n = Array.isArray(n) ? n : [n], Qi(n, a), n;
|
|
815
871
|
}
|
|
816
|
-
async function
|
|
817
|
-
const { groups:
|
|
872
|
+
async function Yi(e, t, i) {
|
|
873
|
+
const { groups: a } = await vi(), n = a.map((o) => ({
|
|
818
874
|
name: o.name,
|
|
819
875
|
value: o.url
|
|
820
876
|
}));
|
|
821
|
-
let s = await
|
|
877
|
+
let s = await ie({
|
|
822
878
|
message: e,
|
|
823
879
|
loop: !0,
|
|
824
|
-
pageSize:
|
|
880
|
+
pageSize: n.length || 5,
|
|
825
881
|
clearInputWhenSelected: !0,
|
|
826
882
|
multiple: i,
|
|
827
|
-
options: (o) => o ?
|
|
883
|
+
options: (o) => o ? n.filter((r) => r.name.includes(o)) : n,
|
|
828
884
|
validate: t
|
|
829
885
|
});
|
|
830
886
|
return s = Array.isArray(s) ? s : [s], s;
|
|
831
887
|
}
|
|
832
|
-
async function
|
|
888
|
+
async function Xi() {
|
|
833
889
|
try {
|
|
834
|
-
He() && (await
|
|
890
|
+
He() && (await Ue({
|
|
835
891
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
836
|
-
}) ? D.rm("-rf",
|
|
837
|
-
const t = await
|
|
892
|
+
}) ? D.rm("-rf", $e()) : process.exit(0)), await ce(fe(), { recursive: !0 });
|
|
893
|
+
const t = await T({
|
|
838
894
|
message: "请选择岗位类型",
|
|
839
895
|
choices: [
|
|
840
896
|
{
|
|
841
897
|
name: "前端",
|
|
842
|
-
value:
|
|
898
|
+
value: re.FRONT_END
|
|
843
899
|
},
|
|
844
900
|
{
|
|
845
901
|
name: "后端",
|
|
846
|
-
value:
|
|
902
|
+
value: re.BACK_END
|
|
847
903
|
},
|
|
848
904
|
{
|
|
849
905
|
name: "测试",
|
|
850
|
-
value:
|
|
906
|
+
value: re.QUALITY_ASSURANCE
|
|
851
907
|
}
|
|
852
908
|
]
|
|
853
909
|
}), i = await F({
|
|
854
910
|
message: "请输入LDAP账号:"
|
|
855
|
-
}),
|
|
911
|
+
}), a = await At({
|
|
856
912
|
message: "请输入LDAP密码:",
|
|
857
913
|
mask: !0
|
|
858
914
|
});
|
|
859
|
-
|
|
860
|
-
const
|
|
861
|
-
|
|
862
|
-
const s = await
|
|
863
|
-
|
|
915
|
+
O("jobType", t), O("ldapAccount", i), O("ldapPassword", a);
|
|
916
|
+
const n = await at();
|
|
917
|
+
Ie(n);
|
|
918
|
+
const s = await rt(), o = await ot("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((u) => u.value === o[0]);
|
|
919
|
+
O({
|
|
864
920
|
weWorkName: r,
|
|
865
921
|
weWorkUserId: c
|
|
866
922
|
});
|
|
867
923
|
} catch (t) {
|
|
868
|
-
|
|
924
|
+
l(t);
|
|
869
925
|
}
|
|
870
|
-
const e =
|
|
926
|
+
const e = w("配置信息初始化中").start();
|
|
871
927
|
try {
|
|
872
928
|
const t = await bi();
|
|
873
|
-
|
|
929
|
+
O({
|
|
874
930
|
gitUserId: t.id,
|
|
875
931
|
gitName: t.name,
|
|
876
932
|
gitEnglishName: t.username,
|
|
877
933
|
gitEmail: t.email
|
|
878
|
-
}),
|
|
934
|
+
}), oe("latestCheckVersionTimestamp", Date.now()), ne(), A("jobType") === re.FRONT_END && await Ri(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
879
935
|
} catch (t) {
|
|
880
|
-
e.fail("配置信息初始化失败"),
|
|
936
|
+
e.fail("配置信息初始化失败"), pe.isAxiosError(t) && l("请检查你的域名及令牌配置"), l(t);
|
|
881
937
|
}
|
|
882
938
|
}
|
|
883
|
-
const
|
|
939
|
+
const ea = `{
|
|
884
940
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
885
941
|
"_version": "0.0.1",
|
|
886
942
|
"compilerOptions": {
|
|
@@ -927,7 +983,7 @@ const Ki = `{
|
|
|
927
983
|
"skipLibCheck": true
|
|
928
984
|
}
|
|
929
985
|
}
|
|
930
|
-
`,
|
|
986
|
+
`, ta = `{
|
|
931
987
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
932
988
|
"_version": "0.0.1",
|
|
933
989
|
"compilerOptions": {
|
|
@@ -967,111 +1023,111 @@ const Ki = `{
|
|
|
967
1023
|
}
|
|
968
1024
|
}
|
|
969
1025
|
`;
|
|
970
|
-
async function
|
|
971
|
-
await
|
|
972
|
-
`, { mode: 493 }), await
|
|
973
|
-
z run commit-msg`, { mode: 493 }), await
|
|
1026
|
+
async function ia() {
|
|
1027
|
+
await _(ye(), "", { mode: 493 }), await _(C(".gitignore"), `.commit-msg-tpl
|
|
1028
|
+
`, { mode: 493 }), await _(C("commit-msg"), `#!/usr/bin/env sh
|
|
1029
|
+
z run commit-msg`, { mode: 493 }), await _(C("pre-commit"), `#!/usr/bin/env sh
|
|
974
1030
|
z run commit-files`, { mode: 493 });
|
|
975
|
-
const { language: e } =
|
|
976
|
-
e ===
|
|
1031
|
+
const { language: e } = be();
|
|
1032
|
+
e === L.JAVASCRIPT && (await _(C(".prettierrc.json"), Xt, { mode: 493 }), await _(C(".prettierignore"), ei, { mode: 493 }), await _(C("tsconfig.node.json"), ta, { mode: 493 }), await _(C("tsconfig.browser.json"), ea, {
|
|
977
1033
|
mode: 493
|
|
978
|
-
})),
|
|
1034
|
+
})), Ze();
|
|
979
1035
|
}
|
|
980
|
-
async function
|
|
981
|
-
const i = await
|
|
982
|
-
i ||
|
|
983
|
-
let
|
|
984
|
-
|
|
1036
|
+
async function aa(e, t) {
|
|
1037
|
+
const i = await p("git remote get-url --push origin");
|
|
1038
|
+
i || l("获取项目远程git地址失败,请配置后重试");
|
|
1039
|
+
let a = e;
|
|
1040
|
+
a || (a = await T({
|
|
985
1041
|
message: "请选择项目语言",
|
|
986
1042
|
choices: [
|
|
987
1043
|
{
|
|
988
|
-
name:
|
|
989
|
-
value:
|
|
1044
|
+
name: L.JAVASCRIPT,
|
|
1045
|
+
value: L.JAVASCRIPT
|
|
990
1046
|
},
|
|
991
1047
|
{
|
|
992
|
-
name:
|
|
993
|
-
value:
|
|
1048
|
+
name: L.JAVA,
|
|
1049
|
+
value: L.JAVA
|
|
994
1050
|
},
|
|
995
1051
|
{
|
|
996
|
-
name:
|
|
997
|
-
value:
|
|
1052
|
+
name: L.PYTHON,
|
|
1053
|
+
value: L.PYTHON
|
|
998
1054
|
}
|
|
999
1055
|
]
|
|
1000
1056
|
}));
|
|
1001
|
-
let
|
|
1002
|
-
if (!
|
|
1003
|
-
const s =
|
|
1057
|
+
let n = t;
|
|
1058
|
+
if (!n) {
|
|
1059
|
+
const s = Ke(i), o = await nt(s);
|
|
1004
1060
|
if (!o)
|
|
1005
|
-
return
|
|
1006
|
-
|
|
1061
|
+
return l(`未找到项目,请确认项目${i}是否存在,或者当前账号权限`);
|
|
1062
|
+
n = o.namespace.full_path;
|
|
1007
1063
|
}
|
|
1008
|
-
|
|
1009
|
-
language:
|
|
1010
|
-
"lint-staged": ti[
|
|
1064
|
+
tt({
|
|
1065
|
+
language: a,
|
|
1066
|
+
"lint-staged": ti[a],
|
|
1011
1067
|
repository: {
|
|
1012
1068
|
url: i,
|
|
1013
|
-
group:
|
|
1069
|
+
group: n
|
|
1014
1070
|
}
|
|
1015
1071
|
});
|
|
1016
1072
|
}
|
|
1017
|
-
async function
|
|
1018
|
-
e ? D.rm("-rf", V) : $(
|
|
1073
|
+
async function Re(e, t) {
|
|
1074
|
+
e ? D.rm("-rf", V) : $(C()) && (await Ue({
|
|
1019
1075
|
message: `当前项目中已存在配置文件夹${V},确认重新配置?`
|
|
1020
|
-
}) ? D.rm("-rf", V) : process.exit(0)), await
|
|
1076
|
+
}) ? D.rm("-rf", V) : process.exit(0)), await ce(C(), { recursive: !0 }), await aa(e, t), await ia(), B("项目初始化完成");
|
|
1021
1077
|
}
|
|
1022
|
-
async function
|
|
1023
|
-
$(
|
|
1078
|
+
async function na() {
|
|
1079
|
+
$(C()) && $(ye()) ? Ze() : await Re(), process.exit(0);
|
|
1024
1080
|
}
|
|
1025
|
-
async function
|
|
1026
|
-
t.projectLanguage && !Object.values(
|
|
1081
|
+
async function sa(e, t) {
|
|
1082
|
+
t.projectLanguage && !Object.values(L).includes(t.projectLanguage) && l("项目语言不支持"), e ? (Q(), e === "." ? (await Re(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await na() : l("参数错误。执行 z init -h 查看帮助。")) : await Xi();
|
|
1027
1083
|
}
|
|
1028
|
-
|
|
1029
|
-
async function
|
|
1084
|
+
x.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(L).join("/")} `).action((...e) => M(sa, ...e));
|
|
1085
|
+
async function ra(e, t) {
|
|
1030
1086
|
if (!e)
|
|
1031
1087
|
return "不能为空";
|
|
1032
1088
|
if (!/^[a-z0-9-]+$/.test(e))
|
|
1033
1089
|
return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
|
|
1034
|
-
if (
|
|
1090
|
+
if (Ye().includes(e))
|
|
1035
1091
|
return "当前目录下已存在同名文件夹,请先处理。";
|
|
1036
|
-
const
|
|
1037
|
-
return
|
|
1092
|
+
const n = (await ji(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
|
|
1093
|
+
return n ? `远程仓库中已存在同名项目(${n.http_url_to_repo}),请更名后重试` : !0;
|
|
1038
1094
|
}
|
|
1039
|
-
function
|
|
1095
|
+
function oa(e) {
|
|
1040
1096
|
return e ? !0 : "不能为空";
|
|
1041
1097
|
}
|
|
1042
|
-
function
|
|
1098
|
+
function ca(e) {
|
|
1043
1099
|
return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
|
|
1044
1100
|
}
|
|
1045
|
-
async function
|
|
1046
|
-
|
|
1101
|
+
async function ua(e) {
|
|
1102
|
+
ae(), Q(), await ue();
|
|
1047
1103
|
let t, i;
|
|
1048
|
-
e.branchType ? t = e.branchType : t = await
|
|
1104
|
+
e.branchType ? t = e.branchType : t = await T({
|
|
1049
1105
|
message: "请选择创建分支的类型",
|
|
1050
1106
|
choices: [
|
|
1051
1107
|
{
|
|
1052
1108
|
name: "开发新功能(feat)",
|
|
1053
|
-
value:
|
|
1109
|
+
value: le.FEAT
|
|
1054
1110
|
},
|
|
1055
1111
|
{
|
|
1056
1112
|
name: "修复BUG(fix)",
|
|
1057
|
-
value:
|
|
1113
|
+
value: le.FIX
|
|
1058
1114
|
},
|
|
1059
1115
|
{
|
|
1060
1116
|
name: "重构/优化代码(refactor)",
|
|
1061
|
-
value:
|
|
1117
|
+
value: le.REFACTOR
|
|
1062
1118
|
}
|
|
1063
1119
|
]
|
|
1064
1120
|
}), e.branchPurpose ? i = e.branchPurpose : i = await F({
|
|
1065
1121
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1066
|
-
validate:
|
|
1122
|
+
validate: ca
|
|
1067
1123
|
});
|
|
1068
|
-
const
|
|
1069
|
-
await
|
|
1124
|
+
const a = `${t}_${i}_${et()}`;
|
|
1125
|
+
await p(`git fetch origin ${y.MASTER}`), await p(`git checkout -b ${a} origin/${y.MASTER}`), await p(`git push -u origin ${a}`), process.exit(0);
|
|
1070
1126
|
}
|
|
1071
|
-
const
|
|
1072
|
-
async function
|
|
1073
|
-
const e = await
|
|
1074
|
-
url:
|
|
1127
|
+
const ct = (e) => `${Y("ZenTaoDomain")}${e}`;
|
|
1128
|
+
async function la() {
|
|
1129
|
+
const e = await we({
|
|
1130
|
+
url: ct("/my-work-task.json?tid=mrrferp8"),
|
|
1075
1131
|
method: "get"
|
|
1076
1132
|
});
|
|
1077
1133
|
return e?.tasks ? e.tasks.filter((t) => t.status !== "done").map(({ id: t, name: i }) => ({
|
|
@@ -1082,9 +1138,9 @@ async function ra() {
|
|
|
1082
1138
|
name: i
|
|
1083
1139
|
})) : [];
|
|
1084
1140
|
}
|
|
1085
|
-
async function
|
|
1086
|
-
const e = await
|
|
1087
|
-
url:
|
|
1141
|
+
async function pa() {
|
|
1142
|
+
const e = await we({
|
|
1143
|
+
url: ct("/my-work-bug.json?tid=mrrferp8"),
|
|
1088
1144
|
method: "get"
|
|
1089
1145
|
});
|
|
1090
1146
|
return e?.bugs ? Object.values(e.bugs).map(({ id: t, title: i }) => ({
|
|
@@ -1095,16 +1151,16 @@ async function oa() {
|
|
|
1095
1151
|
}
|
|
1096
1152
|
})) : [];
|
|
1097
1153
|
}
|
|
1098
|
-
async function
|
|
1154
|
+
async function Ee(e, t) {
|
|
1099
1155
|
let i = "";
|
|
1100
1156
|
if ([b.FEAT, b.FIX, b.REFACTOR].includes(e)) {
|
|
1101
|
-
const
|
|
1102
|
-
i = `${e}(${
|
|
1157
|
+
const a = t.map((s) => s.value).join(","), n = t.map((s) => s.name).join(";");
|
|
1158
|
+
i = `${e}(${a}): ${n}`;
|
|
1103
1159
|
}
|
|
1104
|
-
e === b.CHORE && (i = `${e}: ${t}`), await
|
|
1160
|
+
e === b.CHORE && (i = `${e}: ${t}`), await _(ye(), i, "utf-8"), console.log(S.yellow(i)), B("commit msg模板写入成功,可以进行提交了");
|
|
1105
1161
|
}
|
|
1106
|
-
async function
|
|
1107
|
-
const e = await
|
|
1162
|
+
async function ma() {
|
|
1163
|
+
const e = await T({
|
|
1108
1164
|
message: "请选择你要创建的模板类型",
|
|
1109
1165
|
choices: [
|
|
1110
1166
|
{
|
|
@@ -1126,85 +1182,85 @@ async function ca() {
|
|
|
1126
1182
|
]
|
|
1127
1183
|
});
|
|
1128
1184
|
if ([b.FEAT, b.REFACTOR].includes(e)) {
|
|
1129
|
-
const t = await
|
|
1185
|
+
const t = await la();
|
|
1130
1186
|
if (!t.length)
|
|
1131
1187
|
return B("🤷 暂无开发任务");
|
|
1132
|
-
const i = await
|
|
1188
|
+
const i = await Te({
|
|
1133
1189
|
message: "请关联开发任务(可多选):",
|
|
1134
|
-
validate: (
|
|
1135
|
-
choices: t.map((
|
|
1136
|
-
...
|
|
1137
|
-
name: `[${
|
|
1190
|
+
validate: (a) => a.length === 0 ? "请选择项" : !0,
|
|
1191
|
+
choices: t.map((a) => ({
|
|
1192
|
+
...a,
|
|
1193
|
+
name: `[${a.value.value}]: ${a.name}`
|
|
1138
1194
|
})),
|
|
1139
1195
|
pageSize: t.length
|
|
1140
1196
|
});
|
|
1141
|
-
await
|
|
1197
|
+
await Ee(b.FEAT, i);
|
|
1142
1198
|
}
|
|
1143
1199
|
if (e === b.FIX) {
|
|
1144
|
-
const t = await
|
|
1200
|
+
const t = await pa();
|
|
1145
1201
|
if (!t.length)
|
|
1146
1202
|
return B("🤷 暂无BUG");
|
|
1147
|
-
const i = await
|
|
1203
|
+
const i = await Te({
|
|
1148
1204
|
message: "请关联Bug(可多选):",
|
|
1149
|
-
validate: (
|
|
1150
|
-
choices: t.map((
|
|
1151
|
-
...
|
|
1152
|
-
name: `[${
|
|
1205
|
+
validate: (a) => a.length === 0 ? "请选择项" : !0,
|
|
1206
|
+
choices: t.map((a) => ({
|
|
1207
|
+
...a,
|
|
1208
|
+
name: `[${a.value.value}]: ${a.name}`
|
|
1153
1209
|
})),
|
|
1154
1210
|
pageSize: t.length
|
|
1155
1211
|
});
|
|
1156
|
-
await
|
|
1212
|
+
await Ee(b.FIX, i);
|
|
1157
1213
|
}
|
|
1158
1214
|
if (e === b.CHORE) {
|
|
1159
1215
|
const t = await F({
|
|
1160
1216
|
message: "请输入commit msg:",
|
|
1161
1217
|
validate: (i) => i.length === 0 ? "请输入commit msg" : !0
|
|
1162
1218
|
});
|
|
1163
|
-
await
|
|
1219
|
+
await Ee(b.CHORE, t);
|
|
1164
1220
|
}
|
|
1165
1221
|
process.exit(0);
|
|
1166
1222
|
}
|
|
1167
|
-
async function
|
|
1223
|
+
async function da() {
|
|
1168
1224
|
try {
|
|
1169
1225
|
const e = {}, t = async () => {
|
|
1170
|
-
const
|
|
1171
|
-
const
|
|
1172
|
-
name: `${
|
|
1173
|
-
value:
|
|
1226
|
+
const P = Ye(), { projects: ee } = await $i(), W = ee.map((se) => {
|
|
1227
|
+
const Oe = {
|
|
1228
|
+
name: `${se.name} [${se.desc}]`,
|
|
1229
|
+
value: se.name,
|
|
1174
1230
|
disabled: !1
|
|
1175
1231
|
};
|
|
1176
|
-
return
|
|
1177
|
-
}), yt = await
|
|
1232
|
+
return P.includes(se.name) && (Oe.disabled = "目录下已存在同名文件夹"), Oe;
|
|
1233
|
+
}), yt = await T({
|
|
1178
1234
|
message: "请选择一个项目模板",
|
|
1179
1235
|
choices: W
|
|
1180
|
-
}),
|
|
1181
|
-
e.tplName =
|
|
1236
|
+
}), je = ee.find((se) => se.name === yt);
|
|
1237
|
+
e.tplName = je.name, e.tplUrl = je.url, e.tplLanguage = je.language;
|
|
1182
1238
|
}, i = async () => {
|
|
1183
|
-
const { groups:
|
|
1239
|
+
const { groups: P } = xi(), ee = await T({
|
|
1184
1240
|
message: "请选择一个分组",
|
|
1185
|
-
choices:
|
|
1241
|
+
choices: P.map((W) => ({
|
|
1186
1242
|
name: `${W.name} [${W.description}]`,
|
|
1187
1243
|
value: W.id,
|
|
1188
1244
|
short: W.name
|
|
1189
1245
|
}))
|
|
1190
1246
|
});
|
|
1191
1247
|
e.group = {
|
|
1192
|
-
id:
|
|
1193
|
-
name:
|
|
1248
|
+
id: ee,
|
|
1249
|
+
name: P.find((W) => W.id === ee)?.name
|
|
1194
1250
|
};
|
|
1195
|
-
},
|
|
1251
|
+
}, a = async () => {
|
|
1196
1252
|
e.projectName = await F({
|
|
1197
1253
|
message: "请输入项目名称",
|
|
1198
|
-
validate: (
|
|
1254
|
+
validate: (P) => ra(P, e.group?.name || "")
|
|
1199
1255
|
}), e.projectDesc = await F({
|
|
1200
1256
|
message: "请输入项目描述",
|
|
1201
|
-
validate:
|
|
1257
|
+
validate: oa
|
|
1202
1258
|
});
|
|
1203
1259
|
};
|
|
1204
|
-
await t(), await i(), await
|
|
1205
|
-
const
|
|
1206
|
-
await
|
|
1207
|
-
const o =
|
|
1260
|
+
await t(), await i(), await a();
|
|
1261
|
+
const n = `${me}/${e.group?.name}/${e.projectName}.git`, s = w("模版初始化中").start();
|
|
1262
|
+
await p(`git clone --depth=1 ${e.tplUrl}`), await Be(e.tplName, e.projectName), D.cd(e.projectName), D.rm("-rf", ".git"), await p(`git init --initial-branch=${y.MASTER}`), await p(`git remote add origin ${n}`), await p(`git config user.name ${A("gitName")}`), await p(`git config user.email ${A("gitEmail")}`);
|
|
1263
|
+
const o = ve();
|
|
1208
1264
|
fi({
|
|
1209
1265
|
...o,
|
|
1210
1266
|
name: e.projectName,
|
|
@@ -1213,11 +1269,11 @@ async function ua() {
|
|
|
1213
1269
|
...o.scripts,
|
|
1214
1270
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1215
1271
|
}
|
|
1216
|
-
}), await
|
|
1217
|
-
const r =
|
|
1218
|
-
await
|
|
1219
|
-
const c =
|
|
1220
|
-
await
|
|
1272
|
+
}), await E.writeFile(m.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Re(e.tplLanguage, e.group?.name);
|
|
1273
|
+
const r = w("依赖安装中").start();
|
|
1274
|
+
await p("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1275
|
+
const c = w("项目推送中").start();
|
|
1276
|
+
await p('git add . && git commit -m "chore: 项目初始化"'), await p("git tag v0.0.1");
|
|
1221
1277
|
const u = await Si({
|
|
1222
1278
|
name: e.projectName,
|
|
1223
1279
|
description: e.projectDesc,
|
|
@@ -1225,26 +1281,26 @@ async function ua() {
|
|
|
1225
1281
|
visibility: "private",
|
|
1226
1282
|
namespace_id: e.group?.id
|
|
1227
1283
|
});
|
|
1228
|
-
await
|
|
1229
|
-
const d =
|
|
1284
|
+
await p(`git push -u origin ${y.MASTER}`), await p(`git push origin HEAD:${y.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${S.blue(n)}`);
|
|
1285
|
+
const d = w("初始化分支中").start(), f = `feat_init_${et()}`, g = [y.DEV, y.TEST, y.RELEASE, f], h = await Promise.allSettled(
|
|
1230
1286
|
g.map(
|
|
1231
|
-
(
|
|
1287
|
+
(P) => Ci({
|
|
1232
1288
|
id: u.id,
|
|
1233
|
-
branch:
|
|
1289
|
+
branch: P,
|
|
1234
1290
|
ref: y.MASTER
|
|
1235
1291
|
})
|
|
1236
1292
|
)
|
|
1237
|
-
),
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
}), await
|
|
1241
|
-
const
|
|
1242
|
-
console.log(`输入 ${
|
|
1293
|
+
), j = [];
|
|
1294
|
+
h.forEach(({ status: P }, ee) => {
|
|
1295
|
+
P === "fulfilled" && j.push(g[ee]);
|
|
1296
|
+
}), await p("git pull"), j.includes(f) ? (await p(`git checkout -b ${f} origin/${f}`), d.succeed(`项目已切换到初始分支: ${S.blue(f)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
|
|
1297
|
+
const X = `cd ${e.projectName} && z start`;
|
|
1298
|
+
console.log(`输入 ${S.green(X)} 开始开发吧~`), process.exit(0);
|
|
1243
1299
|
} catch (e) {
|
|
1244
|
-
|
|
1300
|
+
l(e);
|
|
1245
1301
|
}
|
|
1246
1302
|
}
|
|
1247
|
-
async function
|
|
1303
|
+
async function fa(e, t) {
|
|
1248
1304
|
let i;
|
|
1249
1305
|
e ? [
|
|
1250
1306
|
"project",
|
|
@@ -1258,7 +1314,7 @@ async function la(e, t) {
|
|
|
1258
1314
|
"commit-msg",
|
|
1259
1315
|
"cm"
|
|
1260
1316
|
/* CommitMsgAbbr */
|
|
1261
|
-
].includes(e) ? i = "commit-msg" :
|
|
1317
|
+
].includes(e) ? i = "commit-msg" : l("参数输入错误") : i = await T({
|
|
1262
1318
|
message: "请选择你要创建的类型",
|
|
1263
1319
|
choices: [
|
|
1264
1320
|
{
|
|
@@ -1277,21 +1333,21 @@ async function la(e, t) {
|
|
|
1277
1333
|
/* Project */
|
|
1278
1334
|
}
|
|
1279
1335
|
]
|
|
1280
|
-
}), i === "project" ? await
|
|
1336
|
+
}), i === "project" ? await da() : (ae(), Q(), i === "branch" ? (await ue(), await ua(t)) : i === "commit-msg" && await ma());
|
|
1281
1337
|
}
|
|
1282
|
-
|
|
1283
|
-
function
|
|
1284
|
-
return
|
|
1285
|
-
url: `${
|
|
1338
|
+
x.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(le).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").action((...e) => M(fa, ...e));
|
|
1339
|
+
function ga(e) {
|
|
1340
|
+
return it({
|
|
1341
|
+
url: `${Y("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${Mt}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
|
|
1286
1342
|
method: "post",
|
|
1287
1343
|
data: e.params
|
|
1288
1344
|
});
|
|
1289
1345
|
}
|
|
1290
|
-
async function
|
|
1291
|
-
const t =
|
|
1346
|
+
async function ha(e) {
|
|
1347
|
+
const t = w("部署任务创建中").start(), { targetBranch: i, notify: a, projectName: n } = e, s = a ? [.../* @__PURE__ */ new Set([A("weWorkUserId"), ...a])] : [A("weWorkUserId")];
|
|
1292
1348
|
try {
|
|
1293
|
-
const { metadata: o, spec: r } = await
|
|
1294
|
-
projectName:
|
|
1349
|
+
const { metadata: o, spec: r } = await ga({
|
|
1350
|
+
projectName: n,
|
|
1295
1351
|
branchName: i,
|
|
1296
1352
|
params: {
|
|
1297
1353
|
parameters: [
|
|
@@ -1305,73 +1361,73 @@ async function ma(e) {
|
|
|
1305
1361
|
}
|
|
1306
1362
|
]
|
|
1307
1363
|
}
|
|
1308
|
-
}), c = `${
|
|
1309
|
-
t.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${
|
|
1364
|
+
}), c = `${Y("K8SWebDomain")}/youshou-local/clusters/youshou-local/devops/${o.namespace}/pipelines/${r.pipelineRef.name}/branch/${r.scm.refName}/run/${o.name}/task-status`;
|
|
1365
|
+
t.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${S.blue(c)}`), process.exit(0);
|
|
1310
1366
|
} catch (o) {
|
|
1311
|
-
t.fail("部署任务创建失败"),
|
|
1367
|
+
t.fail("部署任务创建失败"), l(o);
|
|
1312
1368
|
}
|
|
1313
1369
|
}
|
|
1314
|
-
function
|
|
1315
|
-
const i =
|
|
1316
|
-
if (
|
|
1317
|
-
const
|
|
1318
|
-
i?.scripts[
|
|
1370
|
+
function wa(e, t) {
|
|
1371
|
+
const i = ve();
|
|
1372
|
+
if (be()?.repository?.url || l(".z/project.json中缺少repository.url"), t === Z.H5) {
|
|
1373
|
+
const n = `build:${e}`;
|
|
1374
|
+
i?.scripts[n] || l(`项目package.json文件scripts不存在命令${n}。`);
|
|
1319
1375
|
}
|
|
1320
|
-
t ===
|
|
1376
|
+
t === Z.NPM && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。")), t === Z.SERVER && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。"));
|
|
1321
1377
|
}
|
|
1322
|
-
async function
|
|
1323
|
-
|
|
1324
|
-
let i = e,
|
|
1325
|
-
if (i && !Object.values(y).includes(i) &&
|
|
1378
|
+
async function ut(e, t) {
|
|
1379
|
+
ae(), Q(), await ue();
|
|
1380
|
+
let i = e, a = t.platform;
|
|
1381
|
+
if (i && !Object.values(y).includes(i) && l("仅支持发布指定环境分支"), a && !Object.values(Z).includes(a) && l("发布平台错误"), a || (a = await T({
|
|
1326
1382
|
message: "请选择平台",
|
|
1327
|
-
choices:
|
|
1328
|
-
})),
|
|
1329
|
-
const c = await
|
|
1383
|
+
choices: Dt
|
|
1384
|
+
})), a === Z.NPM && (i = y.MASTER), !i) {
|
|
1385
|
+
const c = await T({
|
|
1330
1386
|
message: "请选择部署环境",
|
|
1331
|
-
choices:
|
|
1387
|
+
choices: qe
|
|
1332
1388
|
});
|
|
1333
1389
|
i = Kt(c);
|
|
1334
1390
|
}
|
|
1335
|
-
let
|
|
1336
|
-
t.skipSelectionNotification || (
|
|
1391
|
+
let n = [];
|
|
1392
|
+
t.skipSelectionNotification || (n = await ot("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1337
1393
|
let s = [];
|
|
1338
|
-
t.skipGroupNotification || (s = await
|
|
1339
|
-
const o =
|
|
1340
|
-
|
|
1341
|
-
const r =
|
|
1342
|
-
await
|
|
1394
|
+
t.skipGroupNotification || (s = await Yi("请选择部署成功要通知的群组:", () => !0, !0));
|
|
1395
|
+
const o = Ht(i);
|
|
1396
|
+
wa(o, a);
|
|
1397
|
+
const r = ve();
|
|
1398
|
+
await ha({
|
|
1343
1399
|
projectName: r.name,
|
|
1344
1400
|
targetBranch: i,
|
|
1345
|
-
notify:
|
|
1401
|
+
notify: n,
|
|
1346
1402
|
notifyGroup: s
|
|
1347
1403
|
});
|
|
1348
1404
|
}
|
|
1349
|
-
async function
|
|
1350
|
-
const
|
|
1405
|
+
async function lt(e, t, i, a) {
|
|
1406
|
+
const n = w(`分支合并中,${e} -> ${t}`).start();
|
|
1351
1407
|
let s = 0;
|
|
1352
1408
|
try {
|
|
1353
|
-
const { iid: r } = await
|
|
1409
|
+
const { iid: r } = await Ei({
|
|
1354
1410
|
title: `${e} -> ${t} by z-develop`,
|
|
1355
1411
|
id: i.id,
|
|
1356
1412
|
source_branch: e,
|
|
1357
1413
|
target_branch: t,
|
|
1358
1414
|
// 合到主分支上的分支需要在合并完成后被移除
|
|
1359
|
-
remove_source_branch:
|
|
1415
|
+
remove_source_branch: a ? !1 : y.MASTER === t
|
|
1360
1416
|
});
|
|
1361
1417
|
s = r;
|
|
1362
1418
|
} catch (r) {
|
|
1363
|
-
|
|
1419
|
+
pe.isAxiosError(r) && r?.response?.status === 409 && l(`存在重复的合并请求,前往查看${i.mergeRequestUrl}`), l(r);
|
|
1364
1420
|
}
|
|
1365
1421
|
const o = async () => {
|
|
1366
1422
|
try {
|
|
1367
1423
|
await new Promise((r) => {
|
|
1368
1424
|
setTimeout(r, 5e3);
|
|
1369
|
-
}), await
|
|
1425
|
+
}), await Ai({
|
|
1370
1426
|
id: i.id,
|
|
1371
1427
|
iid: s
|
|
1372
|
-
}),
|
|
1428
|
+
}), n.succeed(`分支${e}已合并到分支${t}`);
|
|
1373
1429
|
} catch (r) {
|
|
1374
|
-
|
|
1430
|
+
pe.isAxiosError(r) || l(r);
|
|
1375
1431
|
const c = r?.response?.status;
|
|
1376
1432
|
if (c === 406)
|
|
1377
1433
|
return await o();
|
|
@@ -1385,86 +1441,86 @@ async function ut(e, t, i, n) {
|
|
|
1385
1441
|
iid: s
|
|
1386
1442
|
});
|
|
1387
1443
|
if (u.merge_status === "cannot_be_merged" && u.diff_refs.base_sha === u.diff_refs.head_sha) {
|
|
1388
|
-
|
|
1444
|
+
n.warn("MR已关闭。判定为空的合并请求(没有新内容),可继续进行部署");
|
|
1389
1445
|
return;
|
|
1390
1446
|
}
|
|
1391
1447
|
}
|
|
1392
|
-
|
|
1448
|
+
n.fail("合并过程中出现冲突,MR已关闭。建议在本地完成合并。"), process.exit(1);
|
|
1393
1449
|
}
|
|
1394
1450
|
};
|
|
1395
1451
|
await o();
|
|
1396
1452
|
}
|
|
1397
|
-
async function
|
|
1398
|
-
const i = `origin/${e.sourceBranch}`,
|
|
1399
|
-
`git log ${
|
|
1453
|
+
async function ya(e, t) {
|
|
1454
|
+
const i = `origin/${e.sourceBranch}`, a = await p(`git log -b origin/${y.MASTER} -1 --format=%H`), n = await p(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await p(
|
|
1455
|
+
`git log ${a}...${n} -b ${i}`
|
|
1400
1456
|
);
|
|
1401
|
-
if (s ||
|
|
1402
|
-
`git branch --contains ${
|
|
1403
|
-
) || (console.log(
|
|
1457
|
+
if (s || l(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await p(
|
|
1458
|
+
`git branch --contains ${a} -r ${i}`
|
|
1459
|
+
) || (console.log(S.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt(y.MASTER, e.sourceBranch, e)), t === y.MASTER) {
|
|
1404
1460
|
const r = s.split(`
|
|
1405
|
-
`).filter((f) => f), c = await
|
|
1406
|
-
`git log ${
|
|
1461
|
+
`).filter((f) => f), c = await p(`git log -b origin/${v.TEST} -1 --format=%H`), d = (await p(
|
|
1462
|
+
`git log ${a}...${c} -b origin/${v.TEST}`
|
|
1407
1463
|
)).split(`
|
|
1408
1464
|
`).filter((f) => f);
|
|
1409
|
-
|
|
1465
|
+
Zt(d, r) || l("请先在测试环境发布要部署的代码");
|
|
1410
1466
|
}
|
|
1411
1467
|
}
|
|
1412
|
-
async function
|
|
1413
|
-
|
|
1468
|
+
async function $a(e, t) {
|
|
1469
|
+
ae(), Q(), await ue();
|
|
1414
1470
|
const i = await gi();
|
|
1415
|
-
Object.values(y).includes(i.sourceBranch) &&
|
|
1416
|
-
const
|
|
1471
|
+
Object.values(y).includes(i.sourceBranch) && l(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1472
|
+
const n = (await Ii(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
|
|
1417
1473
|
let u = c.name;
|
|
1418
|
-
return Object.values(y).includes(u) && (u =
|
|
1474
|
+
return Object.values(y).includes(u) && (u = S.bold.blue(u)), {
|
|
1419
1475
|
name: u,
|
|
1420
1476
|
value: c.name
|
|
1421
1477
|
};
|
|
1422
1478
|
});
|
|
1423
1479
|
let s;
|
|
1424
|
-
e && !
|
|
1480
|
+
e && !n.filter((c) => c.value === e).length && l(`未找到目标分支${e}`), e ? s = e : s = await T({
|
|
1425
1481
|
message: "请选择要合并到的目标分支:",
|
|
1426
|
-
choices:
|
|
1482
|
+
choices: n
|
|
1427
1483
|
});
|
|
1428
|
-
const o =
|
|
1429
|
-
if (await
|
|
1430
|
-
o.text = `存在远程分支origin/${i.sourceBranch}`, await
|
|
1431
|
-
const c = await
|
|
1432
|
-
await
|
|
1484
|
+
const o = w(`本地分支${i.sourceBranch}检测中`).start();
|
|
1485
|
+
if (await p(`git ls-remote --heads origin ${i.sourceBranch}`)) {
|
|
1486
|
+
o.text = `存在远程分支origin/${i.sourceBranch}`, await p("git fetch");
|
|
1487
|
+
const c = await p(`git rev-parse ${i.sourceBranch}`), u = await p(`git rev-parse origin/${i.sourceBranch}`);
|
|
1488
|
+
await p(`git merge-base ${u} HEAD`) === u ? (await p(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`)) : await p(`git merge-base ${c} ${u}`) === c ? (await p("git pull"), o.succeed(`本地分支${i.sourceBranch}已更新`)) : (o.fail(
|
|
1433
1489
|
`远程分支origin/${i.sourceBranch}和本地分支${i.sourceBranch}都有新的提交,请手动合并后再试。`
|
|
1434
1490
|
), process.exit(1));
|
|
1435
1491
|
} else
|
|
1436
|
-
await
|
|
1437
|
-
await
|
|
1492
|
+
await p(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`);
|
|
1493
|
+
await ya(i, s), await lt(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster), y.MASTER === s && !t.keepBranchAfterMergeMaster && (await p(`git checkout ${y.MASTER}`), await p(`git pull origin ${y.MASTER}`), await p(`git branch -d ${i.sourceBranch}`), B(
|
|
1438
1494
|
`${i.sourceBranch}分支已移除,当前已切换到最新的${y.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1439
|
-
)), Object.values(y).includes(s) && await
|
|
1495
|
+
)), Object.values(y).includes(s) && await ut(s, {
|
|
1440
1496
|
platform: t.deployPlatform,
|
|
1441
1497
|
skipSelectionNotification: t.deploySkipSelectionNotification,
|
|
1442
1498
|
skipGroupNotification: t.skipGroupNotification
|
|
1443
1499
|
});
|
|
1444
1500
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
function
|
|
1448
|
-
const e =
|
|
1501
|
+
x.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(Z).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => M($a, ...e));
|
|
1502
|
+
x.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(y).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(Z).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => M(ut, ...e));
|
|
1503
|
+
function va() {
|
|
1504
|
+
const e = Ce();
|
|
1449
1505
|
if ($(e)) {
|
|
1450
|
-
const t =
|
|
1506
|
+
const t = E.readJsonSync(e);
|
|
1451
1507
|
if (t["lint-staged"])
|
|
1452
1508
|
return t["lint-staged"];
|
|
1453
1509
|
throw new Error("未找到lint配置");
|
|
1454
1510
|
} else
|
|
1455
1511
|
throw new Error("请先初始化项目(z i .)。");
|
|
1456
1512
|
}
|
|
1457
|
-
async function
|
|
1458
|
-
const e =
|
|
1513
|
+
async function ba() {
|
|
1514
|
+
const e = w("代码风格检测中...").start();
|
|
1459
1515
|
await Tt({
|
|
1460
1516
|
concurrent: 4,
|
|
1461
1517
|
debug: !1,
|
|
1462
|
-
config:
|
|
1518
|
+
config: va(),
|
|
1463
1519
|
quiet: !0,
|
|
1464
1520
|
relative: !0
|
|
1465
1521
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
1466
1522
|
}
|
|
1467
|
-
function
|
|
1523
|
+
function Na(e) {
|
|
1468
1524
|
if (e.includes("Merge") && e.includes("# Conflicts:") || kt.valid(e))
|
|
1469
1525
|
return !0;
|
|
1470
1526
|
const t = e.split(": ");
|
|
@@ -1473,12 +1529,12 @@ function ya(e) {
|
|
|
1473
1529
|
const i = t[0];
|
|
1474
1530
|
return /^(feat|fix|refactor)/.test(i) ? /\(\d+(?:,\d+)*\)/.test(i) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(i) ? [b.CHORE, b.CI].includes(i) ? !0 : "chore/ci类型无需填写ID。" : b.Break === i ? !0 : "不存在的提交类型。";
|
|
1475
1531
|
}
|
|
1476
|
-
async function
|
|
1477
|
-
const e = await Ae(
|
|
1532
|
+
async function Sa() {
|
|
1533
|
+
const e = await Ae(m.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = w("提交信息格式校验中...").start(), i = Na(e);
|
|
1478
1534
|
i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
|
|
1479
1535
|
}
|
|
1480
|
-
async function
|
|
1481
|
-
await
|
|
1536
|
+
async function ja() {
|
|
1537
|
+
await ue();
|
|
1482
1538
|
const e = await Ct({
|
|
1483
1539
|
// 分组,展示仓库链接
|
|
1484
1540
|
format: ["group", "repo"],
|
|
@@ -1491,28 +1547,28 @@ async function va() {
|
|
|
1491
1547
|
});
|
|
1492
1548
|
if (e && Object.keys(e).length) {
|
|
1493
1549
|
B("升级完成 🎉");
|
|
1494
|
-
const t = Object.entries(e).map(([i,
|
|
1495
|
-
await
|
|
1550
|
+
const t = Object.entries(e).map(([i, a]) => `${i}@${a}`).join("; ");
|
|
1551
|
+
await p(`git add . && git commit -m "chore: 依赖升级。${t}"`);
|
|
1496
1552
|
}
|
|
1497
1553
|
process.exit(0);
|
|
1498
1554
|
}
|
|
1499
|
-
async function
|
|
1500
|
-
$(
|
|
1501
|
-
const t =
|
|
1555
|
+
async function Ea(e) {
|
|
1556
|
+
$(m.resolve("node_modules", ".bin", "eslint")) || l("该项目未安装eslint,请安装后重试");
|
|
1557
|
+
const t = w("eslint执行中...").start();
|
|
1502
1558
|
try {
|
|
1503
1559
|
let i = "npx eslint '**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}' --fix";
|
|
1504
|
-
process.platform === "win32" && (i = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (i += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? i += ` --max-warnings ${Number(e.maxWarnings)}` : i += " --max-warnings 100", await
|
|
1560
|
+
process.platform === "win32" && (i = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (i += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? i += ` --max-warnings ${Number(e.maxWarnings)}` : i += " --max-warnings 100", await p(i, {
|
|
1505
1561
|
silent: !1
|
|
1506
1562
|
}), t.succeed("eslint执行成功"), process.exit(0);
|
|
1507
1563
|
} catch {
|
|
1508
1564
|
t.fail("eslint校验出错"), process.exit(1);
|
|
1509
1565
|
}
|
|
1510
1566
|
}
|
|
1511
|
-
async function
|
|
1512
|
-
$(
|
|
1513
|
-
const e =
|
|
1567
|
+
async function Aa() {
|
|
1568
|
+
$(m.resolve("node_modules", ".bin", "prettier")) || l("该项目未安装prettier,请安装后重试");
|
|
1569
|
+
const e = w("prettier执行中...").start();
|
|
1514
1570
|
try {
|
|
1515
|
-
await
|
|
1571
|
+
await p(
|
|
1516
1572
|
"npx prettier --write . --config .z/.prettierrc.json --ignore-path .z/.prettierignore --ignore-unknown --no-error-on-unmatched-pattern",
|
|
1517
1573
|
{
|
|
1518
1574
|
silent: !1
|
|
@@ -1522,11 +1578,11 @@ async function Na() {
|
|
|
1522
1578
|
e.fail("prettier校验出错"), process.exit(1);
|
|
1523
1579
|
}
|
|
1524
1580
|
}
|
|
1525
|
-
function
|
|
1526
|
-
$(
|
|
1581
|
+
function Ta() {
|
|
1582
|
+
$(m.resolve("./node_modules/.bin/vue-tsc")) || l("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), Xe("npx vue-tsc --build"), process.exit(0);
|
|
1527
1583
|
}
|
|
1528
|
-
async function
|
|
1529
|
-
|
|
1584
|
+
async function ka(e, t) {
|
|
1585
|
+
ae(), Q();
|
|
1530
1586
|
let i;
|
|
1531
1587
|
e ? [
|
|
1532
1588
|
"commit-msg",
|
|
@@ -1552,7 +1608,7 @@ async function ja(e, t) {
|
|
|
1552
1608
|
"dependency-check",
|
|
1553
1609
|
"dc"
|
|
1554
1610
|
/* DependencyCheckAbbr */
|
|
1555
|
-
].includes(e) ? i = "dependency-check" :
|
|
1611
|
+
].includes(e) ? i = "dependency-check" : l("参数输入错误") : i = await T({
|
|
1556
1612
|
message: "请选择你要执行的操作",
|
|
1557
1613
|
choices: [
|
|
1558
1614
|
{
|
|
@@ -1576,29 +1632,29 @@ async function ja(e, t) {
|
|
|
1576
1632
|
/* DependencyCheck */
|
|
1577
1633
|
}
|
|
1578
1634
|
]
|
|
1579
|
-
}), i === "commit-msg" ? await
|
|
1635
|
+
}), i === "commit-msg" ? await Sa() : i === "commit-files" ? await ba() : i === "prettier" ? await Aa() : i === "eslint" ? await Ea(t) : i === "type-check" ? Ta() : i === "dependency-check" && await ja();
|
|
1580
1636
|
}
|
|
1581
|
-
|
|
1637
|
+
x.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check 脚本。").argument(
|
|
1582
1638
|
"[type]",
|
|
1583
1639
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc。"
|
|
1584
|
-
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) =>
|
|
1585
|
-
async function
|
|
1586
|
-
const t =
|
|
1587
|
-
await
|
|
1640
|
+
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => M(ka, ...e));
|
|
1641
|
+
async function pt(e = "latest") {
|
|
1642
|
+
const t = w("安装中...").start();
|
|
1643
|
+
await p(`npm i -g ${te.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", oe("latestCheckVersionTimestamp", Date.now()), oe("version", e), ne(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1588
1644
|
}
|
|
1589
|
-
|
|
1590
|
-
async function
|
|
1645
|
+
x.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => M(pt, ...e));
|
|
1646
|
+
async function Ca(e) {
|
|
1591
1647
|
let t = e;
|
|
1592
|
-
t ? [v.DEV, v.TEST, v.RELEASE, v.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = v.DEV : t === "t" ? t = v.TEST : t === "r" ? t = v.RELEASE : t === "p" && (t = v.PROD) :
|
|
1648
|
+
t ? [v.DEV, v.TEST, v.RELEASE, v.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = v.DEV : t === "t" ? t = v.TEST : t === "r" ? t = v.RELEASE : t === "p" && (t = v.PROD) : l("参数输入有误") : t = await T({
|
|
1593
1649
|
message: "请选择环境",
|
|
1594
|
-
choices:
|
|
1650
|
+
choices: qe
|
|
1595
1651
|
});
|
|
1596
|
-
const i =
|
|
1597
|
-
i.scripts[
|
|
1652
|
+
const i = ve(), a = `dev:${t}`;
|
|
1653
|
+
i.scripts[a] ? Xe(`npm run ${a}`) : l(`项目中(package.json > scripts)不存在命令${a},请先添加!`);
|
|
1598
1654
|
}
|
|
1599
|
-
|
|
1600
|
-
const
|
|
1601
|
-
function
|
|
1655
|
+
x.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => M(Ca, ...e));
|
|
1656
|
+
const Le = /Thumbs\.db|\.git|DS_Store|idea/, mt = "testcase";
|
|
1657
|
+
function dt(e) {
|
|
1602
1658
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
1603
1659
|
if (t && !e.startsWith("["))
|
|
1604
1660
|
return {
|
|
@@ -1618,14 +1674,14 @@ function mt(e) {
|
|
|
1618
1674
|
};
|
|
1619
1675
|
}
|
|
1620
1676
|
async function K(e, t = {}) {
|
|
1621
|
-
const { exclude: i =
|
|
1622
|
-
async function
|
|
1623
|
-
const o =
|
|
1677
|
+
const { exclude: i = Le } = t, a = [];
|
|
1678
|
+
async function n(s) {
|
|
1679
|
+
const o = m.basename(s);
|
|
1624
1680
|
if ((await Nt(s)).isFile())
|
|
1625
1681
|
return null;
|
|
1626
|
-
const c = await
|
|
1627
|
-
c.filter((
|
|
1628
|
-
)).filter(Boolean), { type: d, id: f, displayName: g } =
|
|
1682
|
+
const c = await ke(s, { withFileTypes: !0 }), u = (await Promise.all(
|
|
1683
|
+
c.filter((j) => j.isDirectory() && !i.test(j.name)).map((j) => n(m.join(s, j.name)))
|
|
1684
|
+
)).filter(Boolean), { type: d, id: f, displayName: g } = dt(o), h = {
|
|
1629
1685
|
name: o,
|
|
1630
1686
|
id: f,
|
|
1631
1687
|
displayName: g,
|
|
@@ -1633,19 +1689,19 @@ async function K(e, t = {}) {
|
|
|
1633
1689
|
type: d,
|
|
1634
1690
|
children: u
|
|
1635
1691
|
};
|
|
1636
|
-
return (t.hasRoot ||
|
|
1692
|
+
return (t.hasRoot || m.resolve(e) !== s) && a.push(h), h;
|
|
1637
1693
|
}
|
|
1638
|
-
return await
|
|
1694
|
+
return await n(m.resolve(e)), a;
|
|
1639
1695
|
}
|
|
1640
|
-
async function
|
|
1641
|
-
const { exclude: i =
|
|
1696
|
+
async function ft(e, t = {}) {
|
|
1697
|
+
const { exclude: i = Le } = t;
|
|
1642
1698
|
try {
|
|
1643
|
-
const
|
|
1699
|
+
const a = await ke(m.resolve(e), { withFileTypes: !0 });
|
|
1644
1700
|
return await Promise.all(
|
|
1645
|
-
|
|
1646
|
-
const s =
|
|
1701
|
+
a.filter((n) => n.isDirectory() && !i.test(n.name)).map((n) => {
|
|
1702
|
+
const s = m.join(e, n.name), { type: o, id: r, displayName: c } = dt(n.name);
|
|
1647
1703
|
return {
|
|
1648
|
-
name:
|
|
1704
|
+
name: n.name,
|
|
1649
1705
|
id: r,
|
|
1650
1706
|
displayName: c,
|
|
1651
1707
|
path: s,
|
|
@@ -1653,8 +1709,8 @@ async function dt(e, t = {}) {
|
|
|
1653
1709
|
};
|
|
1654
1710
|
})
|
|
1655
1711
|
);
|
|
1656
|
-
} catch (
|
|
1657
|
-
return
|
|
1712
|
+
} catch (a) {
|
|
1713
|
+
return l(`读取目录失败: ${e} : ${a}`), [];
|
|
1658
1714
|
}
|
|
1659
1715
|
}
|
|
1660
1716
|
function G(e, t, i) {
|
|
@@ -1667,254 +1723,254 @@ function G(e, t, i) {
|
|
|
1667
1723
|
return t;
|
|
1668
1724
|
}
|
|
1669
1725
|
}
|
|
1670
|
-
async function
|
|
1726
|
+
async function ge(e, t, i, a) {
|
|
1671
1727
|
try {
|
|
1672
|
-
const
|
|
1673
|
-
if (
|
|
1728
|
+
const n = m.basename(e), s = G(i, t, a);
|
|
1729
|
+
if (n === s)
|
|
1674
1730
|
return !0;
|
|
1675
|
-
const o =
|
|
1676
|
-
return await Qt(e) ? await
|
|
1677
|
-
} catch (
|
|
1678
|
-
return
|
|
1731
|
+
const o = m.dirname(e), r = m.join(o, s);
|
|
1732
|
+
return await Qt(e) ? await Be(e, r) : (await p(`git mv "${e}" "${r}"`), await p("git add .")), !0;
|
|
1733
|
+
} catch (n) {
|
|
1734
|
+
return l(`重命名文件夹失败: ${e} -> ${t}。${n}`), !1;
|
|
1679
1735
|
}
|
|
1680
1736
|
}
|
|
1681
|
-
async function
|
|
1682
|
-
const { exclude:
|
|
1683
|
-
async function
|
|
1737
|
+
async function Ia(e, t, i = {}) {
|
|
1738
|
+
const { exclude: a = Le } = i;
|
|
1739
|
+
async function n(s, o) {
|
|
1684
1740
|
if (!s || s.length === 0) return;
|
|
1685
|
-
const r = await
|
|
1741
|
+
const r = await ft(o, { exclude: a });
|
|
1686
1742
|
for (const c of s) {
|
|
1687
|
-
const u = String(c.value), d = G("module", c.label, u), f = r.find((
|
|
1688
|
-
let g = f?.path ||
|
|
1689
|
-
f ? f.displayName !== c.label && await
|
|
1743
|
+
const u = String(c.value), d = G("module", c.label, u), f = r.find((h) => h.id === u);
|
|
1744
|
+
let g = f?.path || m.join(o, d);
|
|
1745
|
+
f ? f.displayName !== c.label && await ge(f.path, c.label, "module", u) && (g = m.join(o, d)) : (await ce(g, { recursive: !0 }), await p(`git add "${g}"`)), c.children && c.children.length > 0 && await n(c.children, g);
|
|
1690
1746
|
}
|
|
1691
1747
|
}
|
|
1692
|
-
await
|
|
1748
|
+
await n(e, m.resolve(t));
|
|
1693
1749
|
}
|
|
1694
|
-
async function
|
|
1750
|
+
async function gt(e) {
|
|
1695
1751
|
const t = {
|
|
1696
1752
|
id: 0,
|
|
1697
1753
|
name: "",
|
|
1698
1754
|
path: ""
|
|
1699
1755
|
};
|
|
1700
1756
|
if (e)
|
|
1701
|
-
Number.isNaN(Number(e)) &&
|
|
1757
|
+
Number.isNaN(Number(e)) && l("请输入正确的产品ID"), t.id = Number(e);
|
|
1702
1758
|
else {
|
|
1703
|
-
const i = await
|
|
1704
|
-
t.id = await
|
|
1759
|
+
const i = await Di();
|
|
1760
|
+
t.id = await T({
|
|
1705
1761
|
message: "请选择产品",
|
|
1706
|
-
choices: i.map((
|
|
1707
|
-
name: `${
|
|
1708
|
-
value:
|
|
1762
|
+
choices: i.map((a) => ({
|
|
1763
|
+
name: `${a.label}[${a.value}]`,
|
|
1764
|
+
value: a.value
|
|
1709
1765
|
}))
|
|
1710
1766
|
});
|
|
1711
1767
|
}
|
|
1712
|
-
return t.name = await Pi(t.id), t.path =
|
|
1768
|
+
return t.name = await Pi(t.id), t.path = m.join(mt, G("module", t.name, String(t.id))), t;
|
|
1713
1769
|
}
|
|
1714
|
-
async function
|
|
1715
|
-
return (await
|
|
1770
|
+
async function De(e) {
|
|
1771
|
+
return (await ft(mt)).find((i) => Number(i.id) === e.id);
|
|
1716
1772
|
}
|
|
1717
|
-
async function
|
|
1773
|
+
async function ht(e, t) {
|
|
1718
1774
|
const i = {
|
|
1719
1775
|
precondition: e.precondition,
|
|
1720
1776
|
priority: e.pri,
|
|
1721
1777
|
steps: []
|
|
1722
1778
|
};
|
|
1723
|
-
i.steps = await Mi(e.id),
|
|
1779
|
+
i.steps = await Mi(e.id), E.writeJSONSync(t, i, {
|
|
1724
1780
|
spaces: 2
|
|
1725
1781
|
});
|
|
1726
1782
|
}
|
|
1727
|
-
async function
|
|
1728
|
-
await
|
|
1783
|
+
async function wt(e, t) {
|
|
1784
|
+
await ce(t, {
|
|
1729
1785
|
recursive: !0
|
|
1730
|
-
}), await
|
|
1731
|
-
|
|
1732
|
-
$(
|
|
1733
|
-
),
|
|
1734
|
-
|
|
1735
|
-
$(
|
|
1786
|
+
}), await ht(e, m.join(t, "config.json")), E.ensureFileSync(m.join(t, "data.yaml")), await _(
|
|
1787
|
+
m.join(t, "data.yaml"),
|
|
1788
|
+
$(m.resolve(V, "data.yaml")) ? await Ae(m.resolve(V, "data.yaml")) : ii
|
|
1789
|
+
), E.ensureFileSync(m.join(t, "main.py")), await _(
|
|
1790
|
+
m.join(t, "main.py"),
|
|
1791
|
+
$(m.resolve(V, "main.py")) ? await Ae(m.resolve(V, "main.py")) : ai
|
|
1736
1792
|
);
|
|
1737
1793
|
}
|
|
1738
|
-
function
|
|
1794
|
+
function Pe(e) {
|
|
1739
1795
|
if (e) {
|
|
1740
1796
|
const t = e.split(",").map((i) => i.trim()).filter((i) => {
|
|
1741
|
-
const
|
|
1742
|
-
return Number.isInteger(
|
|
1797
|
+
const a = Number(i);
|
|
1798
|
+
return Number.isInteger(a) && a > 0;
|
|
1743
1799
|
}).map((i) => Number(i));
|
|
1744
|
-
return t.length === 0 ? (
|
|
1800
|
+
return t.length === 0 ? (l('未找到有效的ID,请输入格式如 "1,2,3,4" 的正整数ID'), []) : t;
|
|
1745
1801
|
}
|
|
1746
1802
|
return [];
|
|
1747
1803
|
}
|
|
1748
|
-
async function
|
|
1749
|
-
|
|
1804
|
+
async function Ne(e, t) {
|
|
1805
|
+
ae(), Q(), await ue();
|
|
1750
1806
|
let i;
|
|
1751
|
-
t ? ([
|
|
1807
|
+
t ? ([k.MODULE, k.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${k.MODULE} 或者 ${k.CASE}。`), i = t) : i = await T({
|
|
1752
1808
|
message: `请选择要${e}的数据类型`,
|
|
1753
1809
|
choices: zt
|
|
1754
1810
|
});
|
|
1755
|
-
const
|
|
1811
|
+
const a = i === k.MODULE ? "模块" : k.CASE === i ? "用例" : "";
|
|
1756
1812
|
return {
|
|
1757
1813
|
type: i,
|
|
1758
|
-
typeStr:
|
|
1814
|
+
typeStr: a
|
|
1759
1815
|
};
|
|
1760
1816
|
}
|
|
1761
|
-
async function
|
|
1762
|
-
const t = await
|
|
1763
|
-
return i ||
|
|
1817
|
+
async function Se(e) {
|
|
1818
|
+
const t = await gt(e), i = await De(t);
|
|
1819
|
+
return i || l(`本地未找到产品【${t.name}[${t.id}]】`), {
|
|
1764
1820
|
product: t,
|
|
1765
1821
|
localProduct: i
|
|
1766
1822
|
};
|
|
1767
1823
|
}
|
|
1768
|
-
async function
|
|
1769
|
-
e.text = "查找本地产品目录...", await
|
|
1770
|
-
const
|
|
1824
|
+
async function xa(e, t, i) {
|
|
1825
|
+
e.text = "查找本地产品目录...", await De(t) || l(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
1826
|
+
const n = Pe(i);
|
|
1771
1827
|
let s = await K(t.path);
|
|
1772
1828
|
e.text = "获取远程用例列表...";
|
|
1773
|
-
const o = await Oi(t.id,
|
|
1829
|
+
const o = await Oi(t.id, n);
|
|
1774
1830
|
e.text = "本地用例同步中...";
|
|
1775
1831
|
for (const r of o) {
|
|
1776
1832
|
let c;
|
|
1777
|
-
if (r.module === 0 ? c =
|
|
1778
|
-
return
|
|
1833
|
+
if (r.module === 0 ? c = m.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", !c)
|
|
1834
|
+
return l(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
1779
1835
|
const u = s.find(({ id: d }) => r.id === Number(d));
|
|
1780
1836
|
if (u)
|
|
1781
|
-
u.displayName !== r.title && await
|
|
1837
|
+
u.displayName !== r.title && await ge(u.path, r.title, u.type, u.id) && B(`重命名成功: ${u.displayName} -> ${r.title}`), s = await K(t.path), r.module === 0 ? c = m.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await ht(
|
|
1782
1838
|
r,
|
|
1783
|
-
|
|
1839
|
+
m.join(c, G("case", r.title, String(r.id)), "config.json")
|
|
1784
1840
|
);
|
|
1785
1841
|
else {
|
|
1786
|
-
const d =
|
|
1787
|
-
await
|
|
1842
|
+
const d = m.join(c, G("case", r.title, String(r.id)));
|
|
1843
|
+
await wt(r, d);
|
|
1788
1844
|
}
|
|
1789
1845
|
}
|
|
1790
1846
|
}
|
|
1791
|
-
async function
|
|
1847
|
+
async function Ra(e, t) {
|
|
1792
1848
|
e.text = "本地产品目录查找中...";
|
|
1793
|
-
const i = await
|
|
1794
|
-
i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await
|
|
1795
|
-
const
|
|
1796
|
-
e.text = "本地同步模块中...", await
|
|
1797
|
-
}
|
|
1798
|
-
async function
|
|
1799
|
-
const { type: i, typeStr:
|
|
1800
|
-
if (
|
|
1801
|
-
const o =
|
|
1849
|
+
const i = await De(t);
|
|
1850
|
+
i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await ge(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await ce(t.path, { recursive: !0 }), await p("git add .")), e.text = "获取远程模块列表...";
|
|
1851
|
+
const a = await st(t.id);
|
|
1852
|
+
e.text = "本地同步模块中...", await Ia(a || [], t.path);
|
|
1853
|
+
}
|
|
1854
|
+
async function La(e, t) {
|
|
1855
|
+
const { type: i, typeStr: a } = await Ne("拉取", e), n = await gt(t.productId), s = w(`${a}同步中...`).start();
|
|
1856
|
+
if (k.MODULE === i && await Ra(s, n), k.CASE === i && await xa(s, n, t.caseIds), s.succeed(`${a}同步完成 🎉`), !t.disableAutoCommit && await p("git status -s")) {
|
|
1857
|
+
const o = w("代码提交中...").start();
|
|
1802
1858
|
try {
|
|
1803
|
-
await
|
|
1859
|
+
await p(`git add . && git commit -m "chore: 同步禅道${a}数据"`), o.succeed("代码已提交 ✅");
|
|
1804
1860
|
} catch (r) {
|
|
1805
1861
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
1806
1862
|
}
|
|
1807
1863
|
}
|
|
1808
1864
|
}
|
|
1809
|
-
|
|
1810
|
-
async function
|
|
1811
|
-
const
|
|
1865
|
+
x.command("qa-pull").alias("qp").description("将禅道中的模块或者用例同步到本地").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "type=case时,可传指定用例ID(可传N个,逗号隔开);不传则为产品下全部用例").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(La, ...e));
|
|
1866
|
+
async function Da(e, t, i) {
|
|
1867
|
+
const a = await F({
|
|
1812
1868
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
1813
|
-
}),
|
|
1814
|
-
|
|
1815
|
-
const s = await
|
|
1869
|
+
}), n = w(`用例【${i}】开始创建...`).start();
|
|
1870
|
+
n.text = "远程用例创建中...";
|
|
1871
|
+
const s = await _i({
|
|
1816
1872
|
product: Number(e.id),
|
|
1817
1873
|
// 如果父模块是产品根目录,parent=0
|
|
1818
|
-
module:
|
|
1874
|
+
module: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
1819
1875
|
title: i,
|
|
1820
1876
|
type: "interface",
|
|
1821
1877
|
openedBy: A("ldapAccount"),
|
|
1822
|
-
precondition:
|
|
1878
|
+
precondition: a || ""
|
|
1823
1879
|
});
|
|
1824
|
-
|
|
1880
|
+
n.text = "远程用例步骤创建中...", await Fi({
|
|
1825
1881
|
case: s,
|
|
1826
1882
|
type: "step",
|
|
1827
1883
|
desc: "按照预期执行",
|
|
1828
1884
|
expect: "正常执行,符合预期"
|
|
1829
|
-
}),
|
|
1830
|
-
const o =
|
|
1831
|
-
return $(o) ? B(`${o}已存在,请检查是否对应,本地不再创建。`) : (await
|
|
1885
|
+
}), n.text = "本地用例创建中...";
|
|
1886
|
+
const o = m.join(t.path, G("case", i, String(s)));
|
|
1887
|
+
return $(o) ? B(`${o}已存在,请检查是否对应,本地不再创建。`) : (await wt(
|
|
1832
1888
|
{
|
|
1833
1889
|
id: s,
|
|
1834
1890
|
pri: 3,
|
|
1835
|
-
precondition:
|
|
1891
|
+
precondition: a
|
|
1836
1892
|
},
|
|
1837
1893
|
o
|
|
1838
|
-
),
|
|
1894
|
+
), n.succeed(`用例【[${o}】创建完成 🎉`), o);
|
|
1839
1895
|
}
|
|
1840
|
-
async function
|
|
1841
|
-
const
|
|
1842
|
-
|
|
1843
|
-
const
|
|
1896
|
+
async function Pa(e, t, i) {
|
|
1897
|
+
const a = w(`模块【${i}】开始创建...`).start();
|
|
1898
|
+
a.text = "远程模块创建中...";
|
|
1899
|
+
const n = await zi({
|
|
1844
1900
|
root: Number(e.id),
|
|
1845
1901
|
name: i,
|
|
1846
1902
|
// 如果父模块是产品根目录,parent=0
|
|
1847
|
-
parent:
|
|
1903
|
+
parent: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
|
|
1848
1904
|
});
|
|
1849
|
-
|
|
1850
|
-
const s =
|
|
1905
|
+
a.text = "本地模块创建中...";
|
|
1906
|
+
const s = m.join(t.path, G("module", i, String(n)));
|
|
1851
1907
|
if ($(s))
|
|
1852
1908
|
return B(`${s}已存在,请检查是否对应,本地不再创建。`);
|
|
1853
|
-
await
|
|
1909
|
+
await ce(s, {
|
|
1854
1910
|
recursive: !0
|
|
1855
|
-
}),
|
|
1856
|
-
}
|
|
1857
|
-
function
|
|
1858
|
-
function t(
|
|
1859
|
-
if (!
|
|
1860
|
-
const
|
|
1861
|
-
|
|
1862
|
-
value:
|
|
1863
|
-
label:
|
|
1864
|
-
type:
|
|
1911
|
+
}), a.succeed(`模块【${s}】创建完成 🎉`);
|
|
1912
|
+
}
|
|
1913
|
+
function Oa(e) {
|
|
1914
|
+
function t(a) {
|
|
1915
|
+
if (!a.children || a.children.length === 0) return;
|
|
1916
|
+
const n = a.children[0];
|
|
1917
|
+
n && n.label === a.label && n.value === a.value && (!n.children || n.children.length === 0) || a.children.unshift({
|
|
1918
|
+
value: a.value,
|
|
1919
|
+
label: a.label,
|
|
1920
|
+
type: a.type,
|
|
1865
1921
|
children: void 0,
|
|
1866
1922
|
tempTitle: "当前层级"
|
|
1867
1923
|
});
|
|
1868
1924
|
}
|
|
1869
|
-
async function i(
|
|
1870
|
-
const s =
|
|
1925
|
+
async function i(a, n = []) {
|
|
1926
|
+
const s = n.length ? `请选择层级(当前:${n.join(" / ")})` : "请选择层级", o = await T({
|
|
1871
1927
|
message: s,
|
|
1872
|
-
choices:
|
|
1928
|
+
choices: a.map((r) => ({
|
|
1873
1929
|
name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
|
|
1874
1930
|
value: r
|
|
1875
1931
|
}))
|
|
1876
1932
|
});
|
|
1877
|
-
return o?.children?.length ? (t(o), i(o.children, [...
|
|
1933
|
+
return o?.children?.length ? (t(o), i(o.children, [...n, o.label])) : o;
|
|
1878
1934
|
}
|
|
1879
1935
|
return i(e);
|
|
1880
1936
|
}
|
|
1881
|
-
async function
|
|
1882
|
-
const { type: i, typeStr:
|
|
1937
|
+
async function Ma(e, t) {
|
|
1938
|
+
const { type: i, typeStr: a } = await Ne("创建", e), { product: n, localProduct: s } = await Se(t.productId), o = await st(n.id), r = await Oa(o), c = G("module", r.label, String(r.value)), d = (await K(n.path, { hasRoot: !0 })).find((h) => h.name === c);
|
|
1883
1939
|
if (!d?.path || !$(d.path))
|
|
1884
|
-
return
|
|
1940
|
+
return l(`本地不存在${c}模块`);
|
|
1885
1941
|
const f = await F({
|
|
1886
|
-
message: `请输入你要创建的${
|
|
1942
|
+
message: `请输入你要创建的${a}名称`,
|
|
1887
1943
|
required: !0,
|
|
1888
|
-
validate: (
|
|
1944
|
+
validate: (h) => h.length > 0 && h.length < 255
|
|
1889
1945
|
});
|
|
1890
1946
|
let g = "";
|
|
1891
|
-
if (
|
|
1892
|
-
const
|
|
1947
|
+
if (k.MODULE === i && await Pa(s, d, f), k.CASE === i && (g = await Da(s, d, f)), !t.disableAutoCommit && k.CASE === i) {
|
|
1948
|
+
const h = w("代码提交中...").start();
|
|
1893
1949
|
try {
|
|
1894
|
-
await
|
|
1895
|
-
} catch (
|
|
1896
|
-
|
|
1950
|
+
await p(`git add . && git commit -m "chore: 创建了用例${m.basename(g)}"`), h.succeed("代码已提交 ✅");
|
|
1951
|
+
} catch (j) {
|
|
1952
|
+
h.fail(`提交失败,${j}`), process.exit(1);
|
|
1897
1953
|
}
|
|
1898
1954
|
}
|
|
1899
1955
|
}
|
|
1900
|
-
|
|
1901
|
-
async function
|
|
1902
|
-
const
|
|
1903
|
-
let
|
|
1956
|
+
x.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(Ma, ...e));
|
|
1957
|
+
async function za(e, t) {
|
|
1958
|
+
const a = (await K(e.path)).filter((r) => r.type === "case");
|
|
1959
|
+
let n = [];
|
|
1904
1960
|
if (t.length)
|
|
1905
|
-
|
|
1961
|
+
n = a.filter((r) => t.includes(Number(r.id))).map((r) => ({
|
|
1906
1962
|
id: Number(r.id),
|
|
1907
1963
|
path: r.path
|
|
1908
|
-
})),
|
|
1964
|
+
})), n.length || l(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
|
|
1909
1965
|
else {
|
|
1910
|
-
const r =
|
|
1966
|
+
const r = a.map((c) => ({
|
|
1911
1967
|
value: {
|
|
1912
1968
|
id: Number(c.id),
|
|
1913
1969
|
path: c.path
|
|
1914
1970
|
},
|
|
1915
|
-
name: c.path.replace(
|
|
1971
|
+
name: c.path.replace(m.resolve(e.path), "")
|
|
1916
1972
|
}));
|
|
1917
|
-
|
|
1973
|
+
n = await ie({
|
|
1918
1974
|
message: "选择要删除的用例",
|
|
1919
1975
|
pageSize: 100,
|
|
1920
1976
|
loop: !1,
|
|
@@ -1924,32 +1980,32 @@ async function La(e, t) {
|
|
|
1924
1980
|
}
|
|
1925
1981
|
});
|
|
1926
1982
|
}
|
|
1927
|
-
const s =
|
|
1983
|
+
const s = w("远程用例删除中...").start(), o = n.map((r) => r.id);
|
|
1928
1984
|
await Ui({
|
|
1929
1985
|
product: Number(e.id),
|
|
1930
1986
|
caseIds: o
|
|
1931
1987
|
}), s.text = "本地用例删除中...";
|
|
1932
|
-
for (const r of
|
|
1988
|
+
for (const r of n)
|
|
1933
1989
|
$(r.path) && D.rm("-rf", r.path);
|
|
1934
1990
|
return s.succeed("用例删除完成"), o;
|
|
1935
1991
|
}
|
|
1936
|
-
async function
|
|
1937
|
-
const
|
|
1938
|
-
let
|
|
1992
|
+
async function _a(e, t) {
|
|
1993
|
+
const a = (await K(e.path)).filter((r) => r.type === "module");
|
|
1994
|
+
let n = [];
|
|
1939
1995
|
if (t.length)
|
|
1940
|
-
|
|
1996
|
+
n = a.filter((r) => t.includes(Number(r.id))).map((r) => ({
|
|
1941
1997
|
id: Number(r.id),
|
|
1942
1998
|
path: r.path
|
|
1943
|
-
})),
|
|
1999
|
+
})), n.length || l(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
|
|
1944
2000
|
else {
|
|
1945
|
-
const r =
|
|
2001
|
+
const r = a.map((c) => ({
|
|
1946
2002
|
value: {
|
|
1947
2003
|
id: Number(c.id),
|
|
1948
2004
|
path: c.path
|
|
1949
2005
|
},
|
|
1950
|
-
name: c.path.replace(
|
|
2006
|
+
name: c.path.replace(m.resolve(e.path), "")
|
|
1951
2007
|
}));
|
|
1952
|
-
|
|
2008
|
+
n = await ie({
|
|
1953
2009
|
message: "选择要删除的模块",
|
|
1954
2010
|
pageSize: 100,
|
|
1955
2011
|
loop: !1,
|
|
@@ -1959,75 +2015,75 @@ async function Pa(e, t) {
|
|
|
1959
2015
|
}
|
|
1960
2016
|
});
|
|
1961
2017
|
}
|
|
1962
|
-
|
|
1963
|
-
const s =
|
|
2018
|
+
n = n.sort((r, c) => r.path.localeCompare(c.path));
|
|
2019
|
+
const s = w("远程模块删除中...").start(), o = n.map((r) => r.id);
|
|
1964
2020
|
await Bi({
|
|
1965
2021
|
product: Number(e.id),
|
|
1966
2022
|
moduleIds: o
|
|
1967
2023
|
}), s.text = "本地模块删除中...";
|
|
1968
|
-
for (const r of
|
|
2024
|
+
for (const r of n)
|
|
1969
2025
|
$(r.path) && D.rm("-rf", r.path);
|
|
1970
2026
|
return s.succeed("模块删除完成"), o;
|
|
1971
2027
|
}
|
|
1972
|
-
async function
|
|
1973
|
-
const { type: i, typeStr:
|
|
2028
|
+
async function Fa(e, t) {
|
|
2029
|
+
const { type: i, typeStr: a } = await Ne("删除", e), { localProduct: n } = await Se(t.productId), s = Pe(t.targetIds);
|
|
1974
2030
|
let o = [];
|
|
1975
|
-
if (
|
|
1976
|
-
const r =
|
|
2031
|
+
if (k.MODULE === i ? o = await _a(n, s) : k.CASE === i && (o = await za(n, s)), !t.disableAutoCommit && await p("git status -s")) {
|
|
2032
|
+
const r = w("代码提交中...").start();
|
|
1977
2033
|
try {
|
|
1978
|
-
await
|
|
2034
|
+
await p(`git add . && git commit -m 'chore: 删除了一些${a}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
1979
2035
|
} catch (c) {
|
|
1980
2036
|
r.fail(`提交失败,${c}`), process.exit(1);
|
|
1981
2037
|
}
|
|
1982
2038
|
}
|
|
1983
2039
|
}
|
|
1984
|
-
|
|
1985
|
-
async function
|
|
1986
|
-
const
|
|
1987
|
-
let
|
|
2040
|
+
x.command("qa-remove").alias("qr").description("删除模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-ids <targetIds>", "可传指定目标(用例/模块)ID。可传N个,逗号隔开").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(Fa, ...e));
|
|
2041
|
+
async function Ba(e, t) {
|
|
2042
|
+
const a = (await K(e.path)).filter((g) => g.type === "case");
|
|
2043
|
+
let n;
|
|
1988
2044
|
if (t.targetId) {
|
|
1989
|
-
if (
|
|
1990
|
-
return
|
|
2045
|
+
if (n = a.find((g) => Number(g.id) === Number(t.targetId)), !n)
|
|
2046
|
+
return l(`未找到对应用例,请确认输入的用例ID(${t.targetId})是否正确`);
|
|
1991
2047
|
} else {
|
|
1992
|
-
const g =
|
|
2048
|
+
const g = a.map((h) => ({
|
|
1993
2049
|
value: {
|
|
1994
|
-
id: Number(
|
|
1995
|
-
path:
|
|
1996
|
-
displayName:
|
|
2050
|
+
id: Number(h.id),
|
|
2051
|
+
path: h.path,
|
|
2052
|
+
displayName: h.displayName
|
|
1997
2053
|
},
|
|
1998
|
-
name:
|
|
2054
|
+
name: h.path.replace(m.resolve(e.path), "")
|
|
1999
2055
|
}));
|
|
2000
|
-
[
|
|
2056
|
+
[n] = await ie({
|
|
2001
2057
|
message: "选择要更新的用例",
|
|
2002
2058
|
pageSize: 100,
|
|
2003
2059
|
loop: !1,
|
|
2004
2060
|
multiple: void 0,
|
|
2005
|
-
options: (
|
|
2006
|
-
validate(
|
|
2007
|
-
return
|
|
2061
|
+
options: (h) => h ? g.filter((j) => j.name.includes(h)) : g,
|
|
2062
|
+
validate(h) {
|
|
2063
|
+
return h.length > 1 ? "只能选一个" : h.length < 1 ? "请选一个" : !0;
|
|
2008
2064
|
}
|
|
2009
2065
|
});
|
|
2010
2066
|
}
|
|
2011
2067
|
const s = await F({
|
|
2012
2068
|
message: "修改用例名称",
|
|
2013
|
-
default:
|
|
2069
|
+
default: n.displayName,
|
|
2014
2070
|
required: !0,
|
|
2015
2071
|
validate: (g) => g.length > 0 && g.length < 255,
|
|
2016
2072
|
prefill: "editable"
|
|
2017
|
-
}), o =
|
|
2018
|
-
s !==
|
|
2019
|
-
id: Number(
|
|
2073
|
+
}), o = w("用例重命名中...").start();
|
|
2074
|
+
s !== n.displayName ? (await Gi({
|
|
2075
|
+
id: Number(n.id),
|
|
2020
2076
|
name: s
|
|
2021
|
-
}), await
|
|
2022
|
-
let r =
|
|
2023
|
-
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await
|
|
2077
|
+
}), await ge(n.path, s, "case", String(n.id)) && o.succeed(`用例重命名成功: ${n.displayName} -> ${s}`), n.displayName = s, n.path = m.join(m.dirname(n.path), G("case", s, String(n.id)))) : o.succeed("用例名称无变动");
|
|
2078
|
+
let r = E.readJsonSync(m.join(n.path, "config.json")), c;
|
|
2079
|
+
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await ze({
|
|
2024
2080
|
message: "修改用例优先级",
|
|
2025
2081
|
min: 1,
|
|
2026
2082
|
max: 5,
|
|
2027
2083
|
required: !0,
|
|
2028
2084
|
default: r.priority,
|
|
2029
2085
|
validate: (g) => g > 0 && g < 6
|
|
2030
|
-
}) : c = await
|
|
2086
|
+
}) : c = await ze({
|
|
2031
2087
|
message: "修改用例优先级",
|
|
2032
2088
|
min: 1,
|
|
2033
2089
|
max: 5,
|
|
@@ -2035,53 +2091,53 @@ async function Ma(e, t) {
|
|
|
2035
2091
|
default: r.priority,
|
|
2036
2092
|
validate: (g) => g > 0 && g < 6
|
|
2037
2093
|
});
|
|
2038
|
-
const u =
|
|
2094
|
+
const u = w("用例优先级设置中...").start();
|
|
2039
2095
|
c !== r.priority ? (await Wi({
|
|
2040
|
-
id: Number(
|
|
2096
|
+
id: Number(n.id),
|
|
2041
2097
|
priority: c
|
|
2042
|
-
}),
|
|
2043
|
-
|
|
2098
|
+
}), E.writeJSONSync(
|
|
2099
|
+
m.join(n.path, "config.json"),
|
|
2044
2100
|
{
|
|
2045
2101
|
...r,
|
|
2046
2102
|
priority: c
|
|
2047
2103
|
},
|
|
2048
2104
|
{ spaces: 2 }
|
|
2049
|
-
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r =
|
|
2105
|
+
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = E.readJsonSync(m.join(n.path, "config.json"));
|
|
2050
2106
|
let d;
|
|
2051
2107
|
t.casePrecondition ? d = t.casePrecondition : d = await F({
|
|
2052
2108
|
message: "修改用例前置条件",
|
|
2053
2109
|
default: r.precondition,
|
|
2054
2110
|
prefill: "editable"
|
|
2055
2111
|
});
|
|
2056
|
-
const f =
|
|
2112
|
+
const f = w("用例前置条件设置中...").start();
|
|
2057
2113
|
return d !== r.precondition ? (await qi({
|
|
2058
|
-
id: Number(
|
|
2114
|
+
id: Number(n.id),
|
|
2059
2115
|
precondition: d
|
|
2060
|
-
}),
|
|
2061
|
-
|
|
2116
|
+
}), E.writeJSONSync(
|
|
2117
|
+
m.join(n.path, "config.json"),
|
|
2062
2118
|
{
|
|
2063
2119
|
...r,
|
|
2064
2120
|
precondition: d
|
|
2065
2121
|
},
|
|
2066
2122
|
{ spaces: 2 }
|
|
2067
|
-
), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : f.succeed("用例前置条件无变动"),
|
|
2123
|
+
), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : f.succeed("用例前置条件无变动"), n.id;
|
|
2068
2124
|
}
|
|
2069
|
-
async function
|
|
2070
|
-
const
|
|
2071
|
-
let
|
|
2125
|
+
async function Ua(e, t) {
|
|
2126
|
+
const a = (await K(e.path)).filter((r) => r.type === "module");
|
|
2127
|
+
let n;
|
|
2072
2128
|
if (t.targetId) {
|
|
2073
|
-
if (
|
|
2074
|
-
return
|
|
2129
|
+
if (n = a.find((r) => Number(r.id) === Number(t.targetId)), !n)
|
|
2130
|
+
return l(`未找到对应模块,请确认输入的模块ID(${t.targetId})是否正确`);
|
|
2075
2131
|
} else {
|
|
2076
|
-
const r =
|
|
2132
|
+
const r = a.map((c) => ({
|
|
2077
2133
|
value: {
|
|
2078
2134
|
id: Number(c.id),
|
|
2079
2135
|
path: c.path,
|
|
2080
2136
|
displayName: c.displayName
|
|
2081
2137
|
},
|
|
2082
|
-
name: c.path.replace(
|
|
2138
|
+
name: c.path.replace(m.resolve(e.path), "")
|
|
2083
2139
|
}));
|
|
2084
|
-
[
|
|
2140
|
+
[n] = await ie({
|
|
2085
2141
|
message: "选择要更新的模块",
|
|
2086
2142
|
pageSize: 100,
|
|
2087
2143
|
loop: !1,
|
|
@@ -2094,38 +2150,38 @@ async function za(e, t) {
|
|
|
2094
2150
|
}
|
|
2095
2151
|
const s = await F({
|
|
2096
2152
|
message: "修改模块名称",
|
|
2097
|
-
default:
|
|
2153
|
+
default: n.displayName,
|
|
2098
2154
|
required: !0,
|
|
2099
2155
|
validate: (r) => r.length > 0 && r.length < 255,
|
|
2100
2156
|
prefill: "editable"
|
|
2101
|
-
}), o =
|
|
2102
|
-
return s !==
|
|
2103
|
-
id: Number(
|
|
2157
|
+
}), o = w("模块重命名中...").start();
|
|
2158
|
+
return s !== n.displayName ? (await Ji({
|
|
2159
|
+
id: Number(n.id),
|
|
2104
2160
|
name: s
|
|
2105
|
-
}), await
|
|
2161
|
+
}), await ge(n.path, s, "module", String(n.id)) && o.succeed(`模块重命名成功: ${n.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), n.id;
|
|
2106
2162
|
}
|
|
2107
|
-
async function
|
|
2108
|
-
const { type: i, typeStr:
|
|
2163
|
+
async function Ja(e, t) {
|
|
2164
|
+
const { type: i, typeStr: a } = await Ne("修改", e), { localProduct: n } = await Se(t.productId);
|
|
2109
2165
|
let s;
|
|
2110
|
-
if (
|
|
2111
|
-
const o =
|
|
2166
|
+
if (k.MODULE === i ? s = await Ua(n, t) : k.CASE === i && (s = await Ba(n, t)), !t.disableAutoCommit && await p("git status -s")) {
|
|
2167
|
+
const o = w("代码提交中...").start();
|
|
2112
2168
|
try {
|
|
2113
|
-
await
|
|
2169
|
+
await p(`git add . && git commit -m 'chore: 修改了一个${a}(${s})'`), o.succeed("代码已提交 ✅");
|
|
2114
2170
|
} catch (r) {
|
|
2115
2171
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
2116
2172
|
}
|
|
2117
2173
|
}
|
|
2118
2174
|
}
|
|
2119
|
-
|
|
2120
|
-
async function
|
|
2121
|
-
const e =
|
|
2175
|
+
x.command("qa-update").alias("qu").description("修改模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-id <targetId>", "可传指定目标(用例/模块)ID").option("--target-name <targetName>", "可传指定目标(用例/模块)修改后的名称").option("--case-priority <casePriority>", "如果是用例,指定修改后的优先级").option("--case-precondition <casePrecondition>", "如果是用例,指定修改后的前置条件").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(Ja, ...e));
|
|
2176
|
+
async function Ga() {
|
|
2177
|
+
const e = be();
|
|
2122
2178
|
if (!e?.interpreter?.path) {
|
|
2123
2179
|
Vt("$ 执行用例前,需要配置解释器路径");
|
|
2124
2180
|
const t = await F({
|
|
2125
2181
|
message: "请输入Python解释器在本机的路径",
|
|
2126
2182
|
required: !0
|
|
2127
2183
|
});
|
|
2128
|
-
return
|
|
2184
|
+
return tt({
|
|
2129
2185
|
...e,
|
|
2130
2186
|
interpreter: {
|
|
2131
2187
|
path: t
|
|
@@ -2134,41 +2190,41 @@ async function _a() {
|
|
|
2134
2190
|
}
|
|
2135
2191
|
return e?.interpreter?.path;
|
|
2136
2192
|
}
|
|
2137
|
-
async function
|
|
2193
|
+
async function Wa(e, t, i) {
|
|
2138
2194
|
if (!t.length)
|
|
2139
2195
|
return [];
|
|
2140
|
-
const
|
|
2141
|
-
(
|
|
2196
|
+
const a = It(20), n = t.map(
|
|
2197
|
+
(s) => a(async () => {
|
|
2142
2198
|
try {
|
|
2143
|
-
const
|
|
2199
|
+
const o = i.env || "production", r = await p(`${e} ${s.path}/main.py --env ${o}`);
|
|
2144
2200
|
try {
|
|
2145
|
-
|
|
2201
|
+
s.result = JSON.parse(r);
|
|
2146
2202
|
} catch {
|
|
2147
|
-
|
|
2203
|
+
l(`用例${s.displayName}[${s.id}]返回格式错误:${r}`);
|
|
2148
2204
|
}
|
|
2149
|
-
} catch (
|
|
2150
|
-
const
|
|
2151
|
-
|
|
2205
|
+
} catch (o) {
|
|
2206
|
+
const r = o instanceof Error ? o.message : String(o);
|
|
2207
|
+
l(`用例${s.displayName}[${s.id}]执行失败: ${r}`);
|
|
2152
2208
|
}
|
|
2153
2209
|
})
|
|
2154
2210
|
);
|
|
2155
2211
|
return await Promise.all(n), t;
|
|
2156
2212
|
}
|
|
2157
|
-
async function
|
|
2158
|
-
|
|
2159
|
-
const t = await
|
|
2160
|
-
let
|
|
2213
|
+
async function qa(e) {
|
|
2214
|
+
ae(), Q();
|
|
2215
|
+
const t = await Ga(), { localProduct: i } = await Se(e.productId);
|
|
2216
|
+
let a = [];
|
|
2161
2217
|
const s = (await K(i.path)).filter((u) => u.type === "case");
|
|
2162
2218
|
if (e.all)
|
|
2163
|
-
|
|
2219
|
+
a = s.map((u) => ({
|
|
2164
2220
|
id: Number(u.id),
|
|
2165
2221
|
path: u.path,
|
|
2166
2222
|
displayName: u.displayName
|
|
2167
2223
|
}));
|
|
2168
2224
|
else {
|
|
2169
|
-
const u =
|
|
2225
|
+
const u = Pe(e.caseIds);
|
|
2170
2226
|
if (u.length)
|
|
2171
|
-
|
|
2227
|
+
a = s.filter((d) => u.includes(Number(d.id))).map((d) => ({
|
|
2172
2228
|
id: Number(d.id),
|
|
2173
2229
|
path: d.path,
|
|
2174
2230
|
displayName: d.displayName
|
|
@@ -2180,9 +2236,9 @@ async function Ua(e) {
|
|
|
2180
2236
|
path: f.path,
|
|
2181
2237
|
displayName: f.displayName
|
|
2182
2238
|
},
|
|
2183
|
-
name: f.path.replace(
|
|
2239
|
+
name: f.path.replace(m.resolve(i.path), "")
|
|
2184
2240
|
}));
|
|
2185
|
-
|
|
2241
|
+
a = await ie({
|
|
2186
2242
|
message: "选择要执行的用例",
|
|
2187
2243
|
pageSize: 100,
|
|
2188
2244
|
loop: !1,
|
|
@@ -2193,54 +2249,95 @@ async function Ua(e) {
|
|
|
2193
2249
|
});
|
|
2194
2250
|
}
|
|
2195
2251
|
}
|
|
2196
|
-
const o =
|
|
2252
|
+
const o = w("用例执行中...").start(), c = (await Wa(t, a, e)).filter((u) => u.result.length);
|
|
2197
2253
|
if (c.length === 0)
|
|
2198
2254
|
o.succeed("所有用例执行通过 🎉");
|
|
2199
2255
|
else {
|
|
2200
2256
|
if (e.processStep === "1")
|
|
2201
2257
|
return B("执行报告如下:"), console.log(JSON.stringify(c, null, 2)), process.exit(0);
|
|
2202
|
-
o.
|
|
2258
|
+
o.warn(`【${c.length}】个用例执行出错`);
|
|
2259
|
+
let u = 0;
|
|
2260
|
+
if (e.zenExecutionId)
|
|
2261
|
+
Number.isNaN(Number(e.zenExecutionId)) && l(`zenExecutionId ${e.zenExecutionId}不是正整数`), u = Number(e.zenExecutionId);
|
|
2262
|
+
else {
|
|
2263
|
+
const f = await Zi(), g = await T({
|
|
2264
|
+
message: "请选择用例执行出错后,BUG所属的项目",
|
|
2265
|
+
choices: f.map(({ id: j, name: X }) => ({ name: X, value: j }))
|
|
2266
|
+
}), h = await Hi(g);
|
|
2267
|
+
u = await T({
|
|
2268
|
+
message: "请选择用例执行出错后,BUG所属的执行",
|
|
2269
|
+
choices: h.map(({ id: j, name: X }) => ({ name: X, value: j }))
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
let d;
|
|
2273
|
+
if (e.zenBuildId)
|
|
2274
|
+
d = e.zenBuildId;
|
|
2275
|
+
else {
|
|
2276
|
+
const f = await Ki(Number(u));
|
|
2277
|
+
if (f.length) {
|
|
2278
|
+
const g = await Te({
|
|
2279
|
+
message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
|
|
2280
|
+
required: !1,
|
|
2281
|
+
choices: f.map(({ id: h, name: j, date: X, builder: P }) => ({
|
|
2282
|
+
value: h,
|
|
2283
|
+
name: `${j} ${P} ${X}`
|
|
2284
|
+
}))
|
|
2285
|
+
});
|
|
2286
|
+
g.length ? d = g.join(",") : d = "";
|
|
2287
|
+
} else
|
|
2288
|
+
o.warn("当前执行下没有构建,使用默认【主干】"), d = "";
|
|
2289
|
+
}
|
|
2290
|
+
o.start("上传中...");
|
|
2291
|
+
for (const f of c)
|
|
2292
|
+
await Vi({
|
|
2293
|
+
caseId: f.id,
|
|
2294
|
+
caseResult: "fail",
|
|
2295
|
+
stepResults: f.result,
|
|
2296
|
+
runner: A("ldapAccount"),
|
|
2297
|
+
executionId: u,
|
|
2298
|
+
openedBuild: d
|
|
2299
|
+
});
|
|
2300
|
+
o.succeed(
|
|
2301
|
+
`用例执行完成。查看相关BUG(${Y("ZenTaoDomain")}/zentao/execution-bug-${u}.html}) `
|
|
2302
|
+
);
|
|
2203
2303
|
}
|
|
2204
2304
|
}
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
"不传默认3。 1. 仅在本地返回执行报告; 2. 仅将执行报告提交到禅道用例执行结果; 3. 执行报告提交到禅道用例并将执行出错的结果提交BUG。"
|
|
2208
|
-
).option("--zen-execution-id <zenExecutionId>", "提bug时,要关联的禅道执行ID").option("--zen-build-id <zenBuildId>", "提bug时,要关联的禅道执行构建ID。默认「主干」").option("--zen-bug-title <zenBugTitle>", "提bug时,bug标题。默认用例名称").option("--zen-bug-severity <zenBugServerity>", "提bug时,bug严重程度。默认3").action((...e) => P(Ua, ...e));
|
|
2209
|
-
function Ja() {
|
|
2305
|
+
x.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--zen-execution-id <zenExecutionId>", "提bug时,要关联的禅道执行ID").option("--zen-build-id <zenBuildId>", "提bug时,要关联的禅道执行构建ID。默认「主干」").action((...e) => M(qa, ...e));
|
|
2306
|
+
function Va() {
|
|
2210
2307
|
process.on("unhandledRejection", (e) => {
|
|
2211
2308
|
}), process.on("uncaughtException", (e) => {
|
|
2212
2309
|
}), D.config.fatal = !0, D.config.silent = !0, D.config.verbose = !1;
|
|
2213
2310
|
}
|
|
2214
|
-
async function
|
|
2215
|
-
const e =
|
|
2311
|
+
async function Za() {
|
|
2312
|
+
const e = de("latestCheckVersionTimestamp"), t = de("versionCheckDuring");
|
|
2216
2313
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
2217
|
-
const i = await
|
|
2218
|
-
|
|
2219
|
-
let
|
|
2314
|
+
const i = await at();
|
|
2315
|
+
Ie(i);
|
|
2316
|
+
let a;
|
|
2220
2317
|
try {
|
|
2221
|
-
const
|
|
2222
|
-
setTimeout(() => o(
|
|
2318
|
+
const n = "TIME_OUT", s = new Promise((o) => {
|
|
2319
|
+
setTimeout(() => o(n), 3e3);
|
|
2223
2320
|
});
|
|
2224
|
-
|
|
2321
|
+
a = await Promise.race([
|
|
2225
2322
|
s,
|
|
2226
|
-
|
|
2227
|
-
]),
|
|
2228
|
-
} catch (
|
|
2229
|
-
console.log("升级出错!请重试,或者手动升级"),
|
|
2323
|
+
p(`npm view ${te.name} version --registry https://registry.npmmirror.com/`)
|
|
2324
|
+
]), a !== n && a !== te.version && (console.log(`${S.blue(te.name)}本地版本为${te.version},低于线上版本${a},开始升级`), await pt(a)), oe("latestCheckVersionTimestamp", Date.now()), ne();
|
|
2325
|
+
} catch (n) {
|
|
2326
|
+
console.log("升级出错!请重试,或者手动升级"), l(n);
|
|
2230
2327
|
}
|
|
2231
2328
|
}
|
|
2232
2329
|
}
|
|
2233
|
-
async function
|
|
2234
|
-
const e =
|
|
2330
|
+
async function Ha() {
|
|
2331
|
+
const e = xt(process.argv.slice(2));
|
|
2235
2332
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2236
2333
|
if (He()) {
|
|
2237
|
-
const t =
|
|
2238
|
-
|
|
2334
|
+
const t = E.readJSONSync($e());
|
|
2335
|
+
O(t.profile), oe(t.main), Ie(t.constants), await Za();
|
|
2239
2336
|
} else
|
|
2240
|
-
|
|
2337
|
+
l(`请先初始化z-develop(执行 z i)。更多见${Ve}`);
|
|
2241
2338
|
}
|
|
2242
|
-
async function
|
|
2243
|
-
|
|
2339
|
+
async function Ka() {
|
|
2340
|
+
Va(), await Ha();
|
|
2244
2341
|
}
|
|
2245
|
-
|
|
2246
|
-
|
|
2342
|
+
x.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(Ve)}`).usage("<command> [options]").hook("preAction", Ka).version(te.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
2343
|
+
x.parse();
|