cli-z-develop 0.10.6 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +59 -59
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
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 ke, mkdir as ce, writeFile as _, rename as Be, readFile as
|
|
4
|
+
import { readdir as ke, mkdir as ce, writeFile as _, rename as Be, readFile as Ee, stat as Nt } from "node:fs/promises";
|
|
5
5
|
import m from "node:path";
|
|
6
6
|
import pe, { AxiosError as St } from "axios";
|
|
7
7
|
import S from "chalk";
|
|
8
8
|
import jt from "dayjs";
|
|
9
9
|
import D from "shelljs";
|
|
10
|
-
import
|
|
10
|
+
import At from "node:os";
|
|
11
11
|
import Me from "child_process";
|
|
12
|
-
import { confirm as Ue, select as T, input as F, password as
|
|
12
|
+
import { confirm as Ue, select as T, input as F, password as Et, checkbox as Te, number as ze } from "@inquirer/prompts";
|
|
13
13
|
import w from "ora";
|
|
14
|
-
import
|
|
14
|
+
import A from "fs-extra";
|
|
15
15
|
import { select as ie } from "inquirer-select-pro";
|
|
16
16
|
import Tt from "lint-staged";
|
|
17
17
|
import kt from "semver";
|
|
@@ -94,7 +94,7 @@ function Ze() {
|
|
|
94
94
|
Me.spawnSync("git", ["config", "core.hooksPath", C()]), Me.spawnSync("git", ["config", "commit.template", ye()]);
|
|
95
95
|
}
|
|
96
96
|
function fe(e = "") {
|
|
97
|
-
return m.resolve(
|
|
97
|
+
return m.resolve(At.homedir(), _t, e);
|
|
98
98
|
}
|
|
99
99
|
function $e() {
|
|
100
100
|
return fe(Ft);
|
|
@@ -347,7 +347,7 @@ dist/
|
|
|
347
347
|
validate:
|
|
348
348
|
# 包含内容
|
|
349
349
|
- contains: {}
|
|
350
|
-
`, ai = "# from assets", ni = "cli-z-develop", si = "0.10.
|
|
350
|
+
`, ai = "# from assets", ni = "cli-z-develop", si = "0.10.7", 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 = {
|
|
351
351
|
name: ni,
|
|
352
352
|
version: si,
|
|
353
353
|
description: ri,
|
|
@@ -391,7 +391,7 @@ dist/
|
|
|
391
391
|
K8SWebDomain: ""
|
|
392
392
|
}
|
|
393
393
|
};
|
|
394
|
-
function
|
|
394
|
+
function E(e) {
|
|
395
395
|
return e ? I.profile[e] : I.profile;
|
|
396
396
|
}
|
|
397
397
|
function de(e) {
|
|
@@ -405,7 +405,7 @@ function ve() {
|
|
|
405
405
|
if (U)
|
|
406
406
|
return U;
|
|
407
407
|
const e = m.join("package.json");
|
|
408
|
-
return $(e) || l(`当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), U =
|
|
408
|
+
return $(e) || l(`当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), U = A.readJsonSync(e), U;
|
|
409
409
|
}
|
|
410
410
|
function be() {
|
|
411
411
|
if (J)
|
|
@@ -413,19 +413,19 @@ function be() {
|
|
|
413
413
|
const e = Ce();
|
|
414
414
|
return $(e) || l(
|
|
415
415
|
`当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
416
|
-
), J =
|
|
416
|
+
), J = A.readJsonSync(e), J;
|
|
417
417
|
}
|
|
418
418
|
function tt(e) {
|
|
419
419
|
J ? J = {
|
|
420
420
|
...J,
|
|
421
421
|
...e
|
|
422
|
-
} : J = e,
|
|
422
|
+
} : J = e, A.writeJSONSync(Ce(), J, { spaces: 2 });
|
|
423
423
|
}
|
|
424
424
|
function fi(e) {
|
|
425
425
|
U ? U = {
|
|
426
426
|
...U,
|
|
427
427
|
...e
|
|
428
|
-
} : U = e,
|
|
428
|
+
} : U = e, A.writeJSONSync(m.join("package.json"), U, { spaces: 2 });
|
|
429
429
|
}
|
|
430
430
|
const q = {
|
|
431
431
|
id: 0,
|
|
@@ -445,11 +445,11 @@ async function gi() {
|
|
|
445
445
|
return q.sourceBranch || (q.sourceBranch = await p("git branch --show-current")), q;
|
|
446
446
|
}
|
|
447
447
|
function ne() {
|
|
448
|
-
|
|
448
|
+
A.writeJSONSync(
|
|
449
449
|
$e(),
|
|
450
450
|
{
|
|
451
451
|
main: de(),
|
|
452
|
-
profile:
|
|
452
|
+
profile: E(),
|
|
453
453
|
constants: Y()
|
|
454
454
|
},
|
|
455
455
|
{
|
|
@@ -492,7 +492,7 @@ async function H(e) {
|
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
async function hi() {
|
|
495
|
-
const e =
|
|
495
|
+
const e = E("gitToken");
|
|
496
496
|
if (e)
|
|
497
497
|
return e;
|
|
498
498
|
{
|
|
@@ -501,8 +501,8 @@ async function hi() {
|
|
|
501
501
|
method: "post",
|
|
502
502
|
data: {
|
|
503
503
|
grant_type: "password",
|
|
504
|
-
username:
|
|
505
|
-
password:
|
|
504
|
+
username: E("ldapAccount"),
|
|
505
|
+
password: E("ldapPassword")
|
|
506
506
|
}
|
|
507
507
|
}), i = `Bearer ${t}`;
|
|
508
508
|
return O("gitToken", i), ne(), i;
|
|
@@ -517,7 +517,7 @@ async function R(e) {
|
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
519
|
async function wi() {
|
|
520
|
-
const e =
|
|
520
|
+
const e = E("zenTaoToken");
|
|
521
521
|
if (e)
|
|
522
522
|
return e;
|
|
523
523
|
{
|
|
@@ -525,8 +525,8 @@ async function wi() {
|
|
|
525
525
|
url: `${Y("ZenTaoDomain")}/api.php/v1/tokens`,
|
|
526
526
|
method: "post",
|
|
527
527
|
data: {
|
|
528
|
-
account:
|
|
529
|
-
password:
|
|
528
|
+
account: E("ldapAccount"),
|
|
529
|
+
password: E("ldapPassword")
|
|
530
530
|
}
|
|
531
531
|
});
|
|
532
532
|
return O("zenTaoToken", t), ne(), t;
|
|
@@ -560,7 +560,7 @@ async function we(e) {
|
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
562
|
async function yi() {
|
|
563
|
-
const e =
|
|
563
|
+
const e = E("k8sToken");
|
|
564
564
|
if (e)
|
|
565
565
|
return e;
|
|
566
566
|
{
|
|
@@ -571,8 +571,8 @@ async function yi() {
|
|
|
571
571
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
572
572
|
},
|
|
573
573
|
data: {
|
|
574
|
-
username:
|
|
575
|
-
password:
|
|
574
|
+
username: E("ldapAccount"),
|
|
575
|
+
password: E("ldapPassword")
|
|
576
576
|
}
|
|
577
577
|
}), i = `Bearer ${t}`;
|
|
578
578
|
return O("k8sToken", i), ne(), i;
|
|
@@ -636,14 +636,14 @@ function ji(e) {
|
|
|
636
636
|
}
|
|
637
637
|
});
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Ai(e) {
|
|
640
640
|
return R({
|
|
641
641
|
url: `${z()}/projects/${e.id}/merge_requests`,
|
|
642
642
|
method: "post",
|
|
643
643
|
data: e
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function Ei(e) {
|
|
647
647
|
return R({
|
|
648
648
|
url: `${z()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
649
649
|
method: "put"
|
|
@@ -676,7 +676,7 @@ function Ii(e) {
|
|
|
676
676
|
}
|
|
677
677
|
function xi() {
|
|
678
678
|
const e = fe("fe-groups.json");
|
|
679
|
-
return $(e) ?
|
|
679
|
+
return $(e) ? A.readJSONSync(e) : { groups: [] };
|
|
680
680
|
}
|
|
681
681
|
async function Ri() {
|
|
682
682
|
const e = await Ni(), t = Ot.map((i) => {
|
|
@@ -687,7 +687,7 @@ async function Ri() {
|
|
|
687
687
|
description: a.description
|
|
688
688
|
} : !1;
|
|
689
689
|
}).filter((i) => !!i);
|
|
690
|
-
|
|
690
|
+
A.writeJSONSync(fe("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
691
691
|
}
|
|
692
692
|
async function N(e) {
|
|
693
693
|
const t = `${Y("FEServerDomain")}/api`, { data: i } = await H({
|
|
@@ -908,7 +908,7 @@ async function Xi() {
|
|
|
908
908
|
]
|
|
909
909
|
}), i = await F({
|
|
910
910
|
message: "请输入LDAP账号:"
|
|
911
|
-
}), a = await
|
|
911
|
+
}), a = await Et({
|
|
912
912
|
message: "请输入LDAP密码:",
|
|
913
913
|
mask: !0
|
|
914
914
|
});
|
|
@@ -931,7 +931,7 @@ async function Xi() {
|
|
|
931
931
|
gitName: t.name,
|
|
932
932
|
gitEnglishName: t.username,
|
|
933
933
|
gitEmail: t.email
|
|
934
|
-
}), oe("latestCheckVersionTimestamp", Date.now()), ne(),
|
|
934
|
+
}), oe("latestCheckVersionTimestamp", Date.now()), ne(), E("jobType") === re.FRONT_END && await Ri(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
935
935
|
} catch (t) {
|
|
936
936
|
e.fail("配置信息初始化失败"), pe.isAxiosError(t) && l("请检查你的域名及令牌配置"), l(t);
|
|
937
937
|
}
|
|
@@ -1151,7 +1151,7 @@ async function pa() {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
})) : [];
|
|
1153
1153
|
}
|
|
1154
|
-
async function
|
|
1154
|
+
async function Ae(e, t) {
|
|
1155
1155
|
let i = "";
|
|
1156
1156
|
if ([b.FEAT, b.FIX, b.REFACTOR].includes(e)) {
|
|
1157
1157
|
const a = t.map((s) => s.value).join(","), n = t.map((s) => s.name).join(";");
|
|
@@ -1194,7 +1194,7 @@ async function ma() {
|
|
|
1194
1194
|
})),
|
|
1195
1195
|
pageSize: t.length
|
|
1196
1196
|
});
|
|
1197
|
-
await
|
|
1197
|
+
await Ae(b.FEAT, i);
|
|
1198
1198
|
}
|
|
1199
1199
|
if (e === b.FIX) {
|
|
1200
1200
|
const t = await pa();
|
|
@@ -1209,14 +1209,14 @@ async function ma() {
|
|
|
1209
1209
|
})),
|
|
1210
1210
|
pageSize: t.length
|
|
1211
1211
|
});
|
|
1212
|
-
await
|
|
1212
|
+
await Ae(b.FIX, i);
|
|
1213
1213
|
}
|
|
1214
1214
|
if (e === b.CHORE) {
|
|
1215
1215
|
const t = await F({
|
|
1216
1216
|
message: "请输入commit msg:",
|
|
1217
1217
|
validate: (i) => i.length === 0 ? "请输入commit msg" : !0
|
|
1218
1218
|
});
|
|
1219
|
-
await
|
|
1219
|
+
await Ae(b.CHORE, t);
|
|
1220
1220
|
}
|
|
1221
1221
|
process.exit(0);
|
|
1222
1222
|
}
|
|
@@ -1259,7 +1259,7 @@ async function da() {
|
|
|
1259
1259
|
};
|
|
1260
1260
|
await t(), await i(), await a();
|
|
1261
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 ${
|
|
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 ${E("gitName")}`), await p(`git config user.email ${E("gitEmail")}`);
|
|
1263
1263
|
const o = ve();
|
|
1264
1264
|
fi({
|
|
1265
1265
|
...o,
|
|
@@ -1269,7 +1269,7 @@ async function da() {
|
|
|
1269
1269
|
...o.scripts,
|
|
1270
1270
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1271
1271
|
}
|
|
1272
|
-
}), await
|
|
1272
|
+
}), await A.writeFile(m.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Re(e.tplLanguage, e.group?.name);
|
|
1273
1273
|
const r = w("依赖安装中").start();
|
|
1274
1274
|
await p("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1275
1275
|
const c = w("项目推送中").start();
|
|
@@ -1344,7 +1344,7 @@ function ga(e) {
|
|
|
1344
1344
|
});
|
|
1345
1345
|
}
|
|
1346
1346
|
async function ha(e) {
|
|
1347
|
-
const t = w("部署任务创建中").start(), { targetBranch: i, notify: a, projectName: n } = e, s = a ? [.../* @__PURE__ */ new Set([
|
|
1347
|
+
const t = w("部署任务创建中").start(), { targetBranch: i, notify: a, projectName: n } = e, s = a ? [.../* @__PURE__ */ new Set([E("weWorkUserId"), ...a])] : [E("weWorkUserId")];
|
|
1348
1348
|
try {
|
|
1349
1349
|
const { metadata: o, spec: r } = await ga({
|
|
1350
1350
|
projectName: n,
|
|
@@ -1406,7 +1406,7 @@ async function lt(e, t, i, a) {
|
|
|
1406
1406
|
const n = w(`分支合并中,${e} -> ${t}`).start();
|
|
1407
1407
|
let s = 0;
|
|
1408
1408
|
try {
|
|
1409
|
-
const { iid: r } = await
|
|
1409
|
+
const { iid: r } = await Ai({
|
|
1410
1410
|
title: `${e} -> ${t} by z-develop`,
|
|
1411
1411
|
id: i.id,
|
|
1412
1412
|
source_branch: e,
|
|
@@ -1422,7 +1422,7 @@ async function lt(e, t, i, a) {
|
|
|
1422
1422
|
try {
|
|
1423
1423
|
await new Promise((r) => {
|
|
1424
1424
|
setTimeout(r, 5e3);
|
|
1425
|
-
}), await
|
|
1425
|
+
}), await Ei({
|
|
1426
1426
|
id: i.id,
|
|
1427
1427
|
iid: s
|
|
1428
1428
|
}), n.succeed(`分支${e}已合并到分支${t}`);
|
|
@@ -1503,7 +1503,7 @@ x.command("deploy").alias("d").description("部署到指定环境").argument("[b
|
|
|
1503
1503
|
function va() {
|
|
1504
1504
|
const e = Ce();
|
|
1505
1505
|
if ($(e)) {
|
|
1506
|
-
const t =
|
|
1506
|
+
const t = A.readJsonSync(e);
|
|
1507
1507
|
if (t["lint-staged"])
|
|
1508
1508
|
return t["lint-staged"];
|
|
1509
1509
|
throw new Error("未找到lint配置");
|
|
@@ -1530,7 +1530,7 @@ function Na(e) {
|
|
|
1530
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 : "不存在的提交类型。";
|
|
1531
1531
|
}
|
|
1532
1532
|
async function Sa() {
|
|
1533
|
-
const e = await
|
|
1533
|
+
const e = await Ee(m.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = w("提交信息格式校验中...").start(), i = Na(e);
|
|
1534
1534
|
i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
|
|
1535
1535
|
}
|
|
1536
1536
|
async function ja() {
|
|
@@ -1552,7 +1552,7 @@ async function ja() {
|
|
|
1552
1552
|
}
|
|
1553
1553
|
process.exit(0);
|
|
1554
1554
|
}
|
|
1555
|
-
async function
|
|
1555
|
+
async function Aa(e) {
|
|
1556
1556
|
$(m.resolve("node_modules", ".bin", "eslint")) || l("该项目未安装eslint,请安装后重试");
|
|
1557
1557
|
const t = w("eslint执行中...").start();
|
|
1558
1558
|
try {
|
|
@@ -1564,7 +1564,7 @@ async function Ea(e) {
|
|
|
1564
1564
|
t.fail("eslint校验出错"), process.exit(1);
|
|
1565
1565
|
}
|
|
1566
1566
|
}
|
|
1567
|
-
async function
|
|
1567
|
+
async function Ea() {
|
|
1568
1568
|
$(m.resolve("node_modules", ".bin", "prettier")) || l("该项目未安装prettier,请安装后重试");
|
|
1569
1569
|
const e = w("prettier执行中...").start();
|
|
1570
1570
|
try {
|
|
@@ -1632,7 +1632,7 @@ async function ka(e, t) {
|
|
|
1632
1632
|
/* DependencyCheck */
|
|
1633
1633
|
}
|
|
1634
1634
|
]
|
|
1635
|
-
}), i === "commit-msg" ? await Sa() : i === "commit-files" ? await ba() : i === "prettier" ? await
|
|
1635
|
+
}), i === "commit-msg" ? await Sa() : i === "commit-files" ? await ba() : i === "prettier" ? await Ea() : i === "eslint" ? await Aa(t) : i === "type-check" ? Ta() : i === "dependency-check" && await ja();
|
|
1636
1636
|
}
|
|
1637
1637
|
x.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check 脚本。").argument(
|
|
1638
1638
|
"[type]",
|
|
@@ -1776,19 +1776,19 @@ async function ht(e, t) {
|
|
|
1776
1776
|
priority: e.pri,
|
|
1777
1777
|
steps: []
|
|
1778
1778
|
};
|
|
1779
|
-
i.steps = await Mi(e.id),
|
|
1779
|
+
i.steps = await Mi(e.id), A.writeJSONSync(t, i, {
|
|
1780
1780
|
spaces: 2
|
|
1781
1781
|
});
|
|
1782
1782
|
}
|
|
1783
1783
|
async function wt(e, t) {
|
|
1784
1784
|
await ce(t, {
|
|
1785
1785
|
recursive: !0
|
|
1786
|
-
}), await ht(e, m.join(t, "config.json")),
|
|
1786
|
+
}), await ht(e, m.join(t, "config.json")), A.ensureFileSync(m.join(t, "data.yaml")), await _(
|
|
1787
1787
|
m.join(t, "data.yaml"),
|
|
1788
|
-
$(m.resolve(V, "data.yaml")) ? await
|
|
1789
|
-
),
|
|
1788
|
+
$(m.resolve(V, "data.yaml")) ? await Ee(m.resolve(V, "data.yaml")) : ii
|
|
1789
|
+
), A.ensureFileSync(m.join(t, "main.py")), await _(
|
|
1790
1790
|
m.join(t, "main.py"),
|
|
1791
|
-
$(m.resolve(V, "main.py")) ? await
|
|
1791
|
+
$(m.resolve(V, "main.py")) ? await Ee(m.resolve(V, "main.py")) : ai
|
|
1792
1792
|
);
|
|
1793
1793
|
}
|
|
1794
1794
|
function Pe(e) {
|
|
@@ -1874,7 +1874,7 @@ async function Da(e, t, i) {
|
|
|
1874
1874
|
module: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
1875
1875
|
title: i,
|
|
1876
1876
|
type: "interface",
|
|
1877
|
-
openedBy:
|
|
1877
|
+
openedBy: E("ldapAccount"),
|
|
1878
1878
|
precondition: a || ""
|
|
1879
1879
|
});
|
|
1880
1880
|
n.text = "远程用例步骤创建中...", await Fi({
|
|
@@ -2075,7 +2075,7 @@ async function Ba(e, t) {
|
|
|
2075
2075
|
id: Number(n.id),
|
|
2076
2076
|
name: s
|
|
2077
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 =
|
|
2078
|
+
let r = A.readJsonSync(m.join(n.path, "config.json")), c;
|
|
2079
2079
|
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await ze({
|
|
2080
2080
|
message: "修改用例优先级",
|
|
2081
2081
|
min: 1,
|
|
@@ -2095,14 +2095,14 @@ async function Ba(e, t) {
|
|
|
2095
2095
|
c !== r.priority ? (await Wi({
|
|
2096
2096
|
id: Number(n.id),
|
|
2097
2097
|
priority: c
|
|
2098
|
-
}),
|
|
2098
|
+
}), A.writeJSONSync(
|
|
2099
2099
|
m.join(n.path, "config.json"),
|
|
2100
2100
|
{
|
|
2101
2101
|
...r,
|
|
2102
2102
|
priority: c
|
|
2103
2103
|
},
|
|
2104
2104
|
{ spaces: 2 }
|
|
2105
|
-
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r =
|
|
2105
|
+
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = A.readJsonSync(m.join(n.path, "config.json"));
|
|
2106
2106
|
let d;
|
|
2107
2107
|
t.casePrecondition ? d = t.casePrecondition : d = await F({
|
|
2108
2108
|
message: "修改用例前置条件",
|
|
@@ -2113,7 +2113,7 @@ async function Ba(e, t) {
|
|
|
2113
2113
|
return d !== r.precondition ? (await qi({
|
|
2114
2114
|
id: Number(n.id),
|
|
2115
2115
|
precondition: d
|
|
2116
|
-
}),
|
|
2116
|
+
}), A.writeJSONSync(
|
|
2117
2117
|
m.join(n.path, "config.json"),
|
|
2118
2118
|
{
|
|
2119
2119
|
...r,
|
|
@@ -2257,8 +2257,8 @@ async function qa(e) {
|
|
|
2257
2257
|
return B("执行报告如下:"), console.log(JSON.stringify(c, null, 2)), process.exit(0);
|
|
2258
2258
|
o.warn(`【${c.length}】个用例执行出错`);
|
|
2259
2259
|
let u = 0;
|
|
2260
|
-
if (e.
|
|
2261
|
-
Number.isNaN(Number(e.
|
|
2260
|
+
if (e.executionId)
|
|
2261
|
+
Number.isNaN(Number(e.executionId)) && l(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
|
|
2262
2262
|
else {
|
|
2263
2263
|
const f = await Zi(), g = await T({
|
|
2264
2264
|
message: "请选择用例执行出错后,BUG所属的项目",
|
|
@@ -2270,8 +2270,8 @@ async function qa(e) {
|
|
|
2270
2270
|
});
|
|
2271
2271
|
}
|
|
2272
2272
|
let d;
|
|
2273
|
-
if (e.
|
|
2274
|
-
d = e.
|
|
2273
|
+
if (e.buildId)
|
|
2274
|
+
d = e.buildId;
|
|
2275
2275
|
else {
|
|
2276
2276
|
const f = await Ki(Number(u));
|
|
2277
2277
|
if (f.length) {
|
|
@@ -2293,7 +2293,7 @@ async function qa(e) {
|
|
|
2293
2293
|
caseId: f.id,
|
|
2294
2294
|
caseResult: "fail",
|
|
2295
2295
|
stepResults: f.result,
|
|
2296
|
-
runner:
|
|
2296
|
+
runner: E("ldapAccount"),
|
|
2297
2297
|
executionId: u,
|
|
2298
2298
|
openedBuild: d
|
|
2299
2299
|
});
|
|
@@ -2302,7 +2302,7 @@ async function qa(e) {
|
|
|
2302
2302
|
);
|
|
2303
2303
|
}
|
|
2304
2304
|
}
|
|
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("--
|
|
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("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认「主干」").action((...e) => M(qa, ...e));
|
|
2306
2306
|
function Va() {
|
|
2307
2307
|
process.on("unhandledRejection", (e) => {
|
|
2308
2308
|
}), process.on("uncaughtException", (e) => {
|
|
@@ -2331,7 +2331,7 @@ async function Ha() {
|
|
|
2331
2331
|
const e = xt(process.argv.slice(2));
|
|
2332
2332
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2333
2333
|
if (He()) {
|
|
2334
|
-
const t =
|
|
2334
|
+
const t = A.readJSONSync($e());
|
|
2335
2335
|
O(t.profile), oe(t.main), Ie(t.constants), await Za();
|
|
2336
2336
|
} else
|
|
2337
2337
|
l(`请先初始化z-develop(执行 z i)。更多见${Ve}`);
|