cli-z-develop 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -51
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { program as
|
|
1
|
+
import { program as D } from "commander";
|
|
2
2
|
import yt from "node:child_process";
|
|
3
3
|
import { existsSync as $, readdirSync as $t, lstatSync as vt } from "node:fs";
|
|
4
4
|
import { readdir as je, mkdir as se, writeFile as M, rename as Fe, readFile as Se, stat as bt } from "node:fs/promises";
|
|
@@ -6,7 +6,7 @@ import l from "node:path";
|
|
|
6
6
|
import le, { AxiosError as Nt } from "axios";
|
|
7
7
|
import N from "chalk";
|
|
8
8
|
import St from "dayjs";
|
|
9
|
-
import
|
|
9
|
+
import x from "shelljs";
|
|
10
10
|
import jt from "node:os";
|
|
11
11
|
import Le from "child_process";
|
|
12
12
|
import { confirm as _e, select as E, input as _, password as At, checkbox as Pe, number as Oe } from "@inquirer/prompts";
|
|
@@ -36,7 +36,7 @@ const Ge = [
|
|
|
36
36
|
name: `正式环境 - ${v.PROD}`,
|
|
37
37
|
value: v.PROD
|
|
38
38
|
}
|
|
39
|
-
],
|
|
39
|
+
], xt = [
|
|
40
40
|
{
|
|
41
41
|
name: "网页 - h5",
|
|
42
42
|
value: "h5"
|
|
@@ -54,7 +54,7 @@ const Ge = [
|
|
|
54
54
|
}
|
|
55
55
|
];
|
|
56
56
|
var ue = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(ue || {}), ae = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(ae || {}), I = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e))(I || {});
|
|
57
|
-
const
|
|
57
|
+
const Dt = {
|
|
58
58
|
1: "研发",
|
|
59
59
|
2: "测试",
|
|
60
60
|
3: "产品",
|
|
@@ -141,7 +141,7 @@ async function u(e, t = {
|
|
|
141
141
|
}) {
|
|
142
142
|
let i = await new Promise((n, a) => {
|
|
143
143
|
try {
|
|
144
|
-
const s =
|
|
144
|
+
const s = x.exec(e, {
|
|
145
145
|
silent: t.silent
|
|
146
146
|
});
|
|
147
147
|
n(s);
|
|
@@ -314,7 +314,7 @@ dist/
|
|
|
314
314
|
"Method": "接口类型",
|
|
315
315
|
"Expected": "期望结果"
|
|
316
316
|
}
|
|
317
|
-
]`, Xt = "# from assets", ei = "cli-z-develop", ti = "0.10.
|
|
317
|
+
]`, Xt = "# from assets", ei = "cli-z-develop", ti = "0.10.2", ii = "技术团队开发流程管理工具", ai = "dist/index.js", ni = { z: "bin/z.js", "z-develop": "bin/z.js" }, si = { 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" }, ri = "module", oi = "z", ci = { "@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" }, ui = { "@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", semver: "^7.7.3", shelljs: "^0.10.0" }, Q = {
|
|
318
318
|
name: ei,
|
|
319
319
|
version: ti,
|
|
320
320
|
description: ii,
|
|
@@ -372,14 +372,14 @@ function $e() {
|
|
|
372
372
|
if (B)
|
|
373
373
|
return B;
|
|
374
374
|
const e = l.join("package.json");
|
|
375
|
-
return $(e) || m(`当前目录(${
|
|
375
|
+
return $(e) || m(`当前目录(${x.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), B = j.readJsonSync(e), B;
|
|
376
376
|
}
|
|
377
377
|
function Ee() {
|
|
378
378
|
if (U)
|
|
379
379
|
return U;
|
|
380
380
|
const e = Ae();
|
|
381
381
|
return $(e) || m(
|
|
382
|
-
`当前目录(${
|
|
382
|
+
`当前目录(${x.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
383
383
|
), U = j.readJsonSync(e), U;
|
|
384
384
|
}
|
|
385
385
|
function li(e) {
|
|
@@ -688,7 +688,7 @@ function it(e) {
|
|
|
688
688
|
}
|
|
689
689
|
});
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function xi(e) {
|
|
692
692
|
return T({
|
|
693
693
|
url: "/zen/testcase/product/name",
|
|
694
694
|
data: {
|
|
@@ -696,7 +696,7 @@ function Di(e) {
|
|
|
696
696
|
}
|
|
697
697
|
});
|
|
698
698
|
}
|
|
699
|
-
function
|
|
699
|
+
function Di(e, t) {
|
|
700
700
|
return T({
|
|
701
701
|
url: "/zen/testcase/product/auto-case/list",
|
|
702
702
|
data: {
|
|
@@ -785,7 +785,7 @@ function Gi(e, t) {
|
|
|
785
785
|
}
|
|
786
786
|
async function at() {
|
|
787
787
|
const t = (await Ri()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
788
|
-
name: `${s.nick} - ${
|
|
788
|
+
name: `${s.nick} - ${Dt[s.title]}`,
|
|
789
789
|
value: s.weWorkUserId
|
|
790
790
|
})), i = pe("weWorkListCache"), n = i.map((s) => s.value), a = [];
|
|
791
791
|
return t.forEach((s) => {
|
|
@@ -829,7 +829,7 @@ async function Vi() {
|
|
|
829
829
|
try {
|
|
830
830
|
qe() && (await _e({
|
|
831
831
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
832
|
-
}) ?
|
|
832
|
+
}) ? x.rm("-rf", ye()) : process.exit(0)), await se(de(), { recursive: !0 });
|
|
833
833
|
const t = await E({
|
|
834
834
|
message: "请选择岗位类型",
|
|
835
835
|
choices: [
|
|
@@ -1011,9 +1011,9 @@ async function Ki(e, t) {
|
|
|
1011
1011
|
});
|
|
1012
1012
|
}
|
|
1013
1013
|
async function Ce(e, t) {
|
|
1014
|
-
e ?
|
|
1014
|
+
e ? x.rm("-rf", q) : $(k()) && (await _e({
|
|
1015
1015
|
message: `当前项目中已存在配置文件夹${q},确认重新配置?`
|
|
1016
|
-
}) ?
|
|
1016
|
+
}) ? x.rm("-rf", q) : process.exit(0)), await se(k(), { recursive: !0 }), await Ki(e, t), await Zi(), J("项目初始化完成");
|
|
1017
1017
|
}
|
|
1018
1018
|
async function Qi() {
|
|
1019
1019
|
$(k()) && $(we()) ? Ve() : await Ce(), process.exit(0);
|
|
@@ -1021,7 +1021,7 @@ async function Qi() {
|
|
|
1021
1021
|
async function Yi(e, t) {
|
|
1022
1022
|
t.projectLanguage && !Object.values(I).includes(t.projectLanguage) && m("项目语言不支持"), e ? (X(), e === "." ? (await Ce(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await Qi() : m("参数错误。执行 z init -h 查看帮助。")) : await Vi();
|
|
1023
1023
|
}
|
|
1024
|
-
|
|
1024
|
+
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(I).join("/")} `).action((...e) => z(Yi, ...e));
|
|
1025
1025
|
async function Xi(e, t) {
|
|
1026
1026
|
if (!e)
|
|
1027
1027
|
return "不能为空";
|
|
@@ -1164,12 +1164,12 @@ async function ra() {
|
|
|
1164
1164
|
try {
|
|
1165
1165
|
const e = {}, t = async () => {
|
|
1166
1166
|
const F = Ke(), { projects: K } = await hi(), W = K.map((ie) => {
|
|
1167
|
-
const
|
|
1167
|
+
const De = {
|
|
1168
1168
|
name: `${ie.name} [${ie.desc}]`,
|
|
1169
1169
|
value: ie.name,
|
|
1170
1170
|
disabled: !1
|
|
1171
1171
|
};
|
|
1172
|
-
return F.includes(ie.name) && (
|
|
1172
|
+
return F.includes(ie.name) && (De.disabled = "目录下已存在同名文件夹"), De;
|
|
1173
1173
|
}), wt = await E({
|
|
1174
1174
|
message: "请选择一个项目模板",
|
|
1175
1175
|
choices: W
|
|
@@ -1199,7 +1199,7 @@ async function ra() {
|
|
|
1199
1199
|
};
|
|
1200
1200
|
await t(), await i(), await n();
|
|
1201
1201
|
const a = `${me}/${e.group?.name}/${e.projectName}.git`, s = w("模版初始化中").start();
|
|
1202
|
-
await u(`git clone --depth=1 ${e.tplUrl}`), await Fe(e.tplName, e.projectName),
|
|
1202
|
+
await u(`git clone --depth=1 ${e.tplUrl}`), await Fe(e.tplName, e.projectName), x.cd(e.projectName), x.rm("-rf", ".git"), await u(`git init --initial-branch=${h.MASTER}`), await u(`git remote add origin ${a}`), await u(`git config user.name ${A("gitName")}`), await u(`git config user.email ${A("gitEmail")}`);
|
|
1203
1203
|
const o = $e();
|
|
1204
1204
|
mi({
|
|
1205
1205
|
...o,
|
|
@@ -1275,7 +1275,7 @@ async function oa(e, t) {
|
|
|
1275
1275
|
]
|
|
1276
1276
|
}), i === "project" ? await ra() : (oe(), X(), i === "branch" ? (await ce(), await ia(t)) : i === "commit-msg" && await sa());
|
|
1277
1277
|
}
|
|
1278
|
-
|
|
1278
|
+
D.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(ue).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").action((...e) => z(oa, ...e));
|
|
1279
1279
|
function ca(e) {
|
|
1280
1280
|
return Xe({
|
|
1281
1281
|
url: `${ee("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${Pt}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
|
|
@@ -1320,7 +1320,7 @@ async function rt(e, t) {
|
|
|
1320
1320
|
let i = e, n = t.platform;
|
|
1321
1321
|
if (i && !Object.values(h).includes(i) && m("仅支持发布指定环境分支"), n && !Object.values(H).includes(n) && m("发布平台错误"), n || (n = await E({
|
|
1322
1322
|
message: "请选择平台",
|
|
1323
|
-
choices:
|
|
1323
|
+
choices: xt
|
|
1324
1324
|
})), n === H.NPM && (i = h.MASTER), !i) {
|
|
1325
1325
|
const c = await E({
|
|
1326
1326
|
message: "请选择部署环境",
|
|
@@ -1438,8 +1438,8 @@ async function pa(e, t) {
|
|
|
1438
1438
|
skipGroupNotification: t.skipGroupNotification
|
|
1439
1439
|
});
|
|
1440
1440
|
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1441
|
+
D.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(H).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => z(pa, ...e));
|
|
1442
|
+
D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(h).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(H).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => z(rt, ...e));
|
|
1443
1443
|
function da() {
|
|
1444
1444
|
const e = Ae();
|
|
1445
1445
|
if ($(e)) {
|
|
@@ -1458,7 +1458,7 @@ async function fa() {
|
|
|
1458
1458
|
config: da(),
|
|
1459
1459
|
quiet: !0,
|
|
1460
1460
|
relative: !0
|
|
1461
|
-
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : e.fail("代码风格检测未通过!");
|
|
1461
|
+
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
1462
1462
|
}
|
|
1463
1463
|
function ga(e) {
|
|
1464
1464
|
if (e.includes("Merge") && e.includes("# Conflicts:") || Tt.valid(e))
|
|
@@ -1471,7 +1471,7 @@ function ga(e) {
|
|
|
1471
1471
|
}
|
|
1472
1472
|
async function ha() {
|
|
1473
1473
|
const e = await Se(l.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = w("提交信息格式校验中...").start(), i = ga(e);
|
|
1474
|
-
i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : t.fail(`提交信息格式校验失败。${i}`);
|
|
1474
|
+
i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
|
|
1475
1475
|
}
|
|
1476
1476
|
async function wa() {
|
|
1477
1477
|
await ce();
|
|
@@ -1501,7 +1501,7 @@ async function ya(e) {
|
|
|
1501
1501
|
silent: !1
|
|
1502
1502
|
}), t.succeed("eslint执行成功"), process.exit(0);
|
|
1503
1503
|
} catch {
|
|
1504
|
-
t.fail("eslint校验出错");
|
|
1504
|
+
t.fail("eslint校验出错"), process.exit(1);
|
|
1505
1505
|
}
|
|
1506
1506
|
}
|
|
1507
1507
|
async function $a() {
|
|
@@ -1515,7 +1515,7 @@ async function $a() {
|
|
|
1515
1515
|
}
|
|
1516
1516
|
), e.succeed("prettier执行成功"), process.exit(0);
|
|
1517
1517
|
} catch {
|
|
1518
|
-
e.fail("prettier校验出错");
|
|
1518
|
+
e.fail("prettier校验出错"), process.exit(1);
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
1521
|
function va() {
|
|
@@ -1574,7 +1574,7 @@ async function ba(e, t) {
|
|
|
1574
1574
|
]
|
|
1575
1575
|
}), i === "commit-msg" ? await ha() : i === "commit-files" ? await fa() : i === "prettier" ? await $a() : i === "eslint" ? await ya(t) : i === "type-check" ? va() : i === "dependency-check" && await wa();
|
|
1576
1576
|
}
|
|
1577
|
-
|
|
1577
|
+
D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check 脚本。").argument(
|
|
1578
1578
|
"[type]",
|
|
1579
1579
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc。"
|
|
1580
1580
|
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(ba, ...e));
|
|
@@ -1582,7 +1582,7 @@ async function ct(e = "latest") {
|
|
|
1582
1582
|
const t = w("安装中...").start();
|
|
1583
1583
|
await u(`npm i -g ${Q.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", ne("latestCheckVersionTimestamp", Date.now()), ne("version", e), te(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1584
1584
|
}
|
|
1585
|
-
|
|
1585
|
+
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(ct, ...e));
|
|
1586
1586
|
async function Na(e) {
|
|
1587
1587
|
let t = e;
|
|
1588
1588
|
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) : m("参数输入有误") : t = await E({
|
|
@@ -1592,7 +1592,7 @@ async function Na(e) {
|
|
|
1592
1592
|
const i = $e(), n = `dev:${t}`;
|
|
1593
1593
|
i.scripts[n] ? Qe(`npm run ${n}`) : m(`项目中(package.json > scripts)不存在命令${n},请先添加!`);
|
|
1594
1594
|
}
|
|
1595
|
-
|
|
1595
|
+
D.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(Na, ...e));
|
|
1596
1596
|
const Re = /Thumbs\.db|\.git|DS_Store|idea/, ut = "testcase";
|
|
1597
1597
|
function lt(e) {
|
|
1598
1598
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
@@ -1705,7 +1705,7 @@ async function pt(e) {
|
|
|
1705
1705
|
}))
|
|
1706
1706
|
});
|
|
1707
1707
|
}
|
|
1708
|
-
return t.name = await
|
|
1708
|
+
return t.name = await xi(t.id), t.path = l.join(ut, G("module", t.name, String(t.id))), t;
|
|
1709
1709
|
}
|
|
1710
1710
|
async function Ie(e) {
|
|
1711
1711
|
return (await mt(ut)).find((i) => Number(i.id) === e.id);
|
|
@@ -1754,7 +1754,7 @@ async function ve(e, t) {
|
|
|
1754
1754
|
typeStr: n
|
|
1755
1755
|
};
|
|
1756
1756
|
}
|
|
1757
|
-
async function
|
|
1757
|
+
async function xe(e) {
|
|
1758
1758
|
const t = await pt(e), i = await Ie(t);
|
|
1759
1759
|
return i || m(`本地未找到产品【${t.name}[${t.id}]】`), {
|
|
1760
1760
|
product: t,
|
|
@@ -1766,7 +1766,7 @@ async function ja(e, t, i) {
|
|
|
1766
1766
|
const a = gt(i);
|
|
1767
1767
|
let s = await Y(t.path);
|
|
1768
1768
|
e.text = "获取远程用例列表...";
|
|
1769
|
-
const o = await
|
|
1769
|
+
const o = await Di(t.id, a);
|
|
1770
1770
|
e.text = "本地用例同步中...";
|
|
1771
1771
|
for (const r of o) {
|
|
1772
1772
|
let c;
|
|
@@ -1798,11 +1798,11 @@ async function Ea(e, t) {
|
|
|
1798
1798
|
try {
|
|
1799
1799
|
await u(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
|
|
1800
1800
|
} catch (r) {
|
|
1801
|
-
o.fail(`提交失败,${r}`);
|
|
1801
|
+
o.fail(`提交失败,${r}`), process.exit(1);
|
|
1802
1802
|
}
|
|
1803
1803
|
}
|
|
1804
1804
|
}
|
|
1805
|
-
|
|
1805
|
+
D.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) => z(Ea, ...e));
|
|
1806
1806
|
async function Ta(e, t, i) {
|
|
1807
1807
|
const n = await _({
|
|
1808
1808
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
@@ -1875,7 +1875,7 @@ function Ca(e) {
|
|
|
1875
1875
|
return i(e);
|
|
1876
1876
|
}
|
|
1877
1877
|
async function Ra(e, t) {
|
|
1878
|
-
const { type: i, typeStr: n } = await ve("创建", e), { product: a, localProduct: s } = await
|
|
1878
|
+
const { type: i, typeStr: n } = await ve("创建", e), { product: a, localProduct: s } = await xe(t.productId), o = await it(a.id), r = await Ca(o), c = G("module", r.label, String(r.value)), d = (await Y(a.path, { hasRoot: !0 })).find((g) => g.name === c);
|
|
1879
1879
|
if (!d?.path || !$(d.path))
|
|
1880
1880
|
return m(`本地不存在${c}模块`);
|
|
1881
1881
|
const y = await _({
|
|
@@ -1889,11 +1889,11 @@ async function Ra(e, t) {
|
|
|
1889
1889
|
try {
|
|
1890
1890
|
await u(`git add . && git commit -m "chore: 创建了用例${l.basename(f)}"`), g.succeed("代码已提交 ✅");
|
|
1891
1891
|
} catch (O) {
|
|
1892
|
-
g.fail(`提交失败,${O}`);
|
|
1892
|
+
g.fail(`提交失败,${O}`), process.exit(1);
|
|
1893
1893
|
}
|
|
1894
1894
|
}
|
|
1895
1895
|
}
|
|
1896
|
-
|
|
1896
|
+
D.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(Ra, ...e));
|
|
1897
1897
|
async function Ia(e, t) {
|
|
1898
1898
|
const n = (await Y(e.path)).filter((r) => r.type === "case");
|
|
1899
1899
|
let a = [];
|
|
@@ -1926,10 +1926,10 @@ async function Ia(e, t) {
|
|
|
1926
1926
|
caseIds: o
|
|
1927
1927
|
}), s.text = "本地用例删除中...";
|
|
1928
1928
|
for (const r of a)
|
|
1929
|
-
$(r.path) &&
|
|
1929
|
+
$(r.path) && x.rm("-rf", r.path);
|
|
1930
1930
|
return s.succeed("用例删除完成"), o;
|
|
1931
1931
|
}
|
|
1932
|
-
async function
|
|
1932
|
+
async function xa(e, t) {
|
|
1933
1933
|
const n = (await Y(e.path)).filter((r) => r.type === "module");
|
|
1934
1934
|
let a = [];
|
|
1935
1935
|
if (t.length)
|
|
@@ -1962,22 +1962,22 @@ async function Da(e, t) {
|
|
|
1962
1962
|
moduleIds: o
|
|
1963
1963
|
}), s.text = "本地模块删除中...";
|
|
1964
1964
|
for (const r of a)
|
|
1965
|
-
$(r.path) &&
|
|
1965
|
+
$(r.path) && x.rm("-rf", r.path);
|
|
1966
1966
|
return s.succeed("模块删除完成"), o;
|
|
1967
1967
|
}
|
|
1968
|
-
async function
|
|
1969
|
-
const { type: i, typeStr: n } = await ve("删除", e), { localProduct: a } = await
|
|
1968
|
+
async function Da(e, t) {
|
|
1969
|
+
const { type: i, typeStr: n } = await ve("删除", e), { localProduct: a } = await xe(t.productId), s = gt(t.targetIds);
|
|
1970
1970
|
let o = [];
|
|
1971
|
-
if (S.MODULE === i ? o = await
|
|
1971
|
+
if (S.MODULE === i ? o = await xa(a, s) : S.CASE === i && (o = await Ia(a, s)), !t.disableAutoCommit && await u("git status -s")) {
|
|
1972
1972
|
const r = w("代码提交中...").start();
|
|
1973
1973
|
try {
|
|
1974
1974
|
await u(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
1975
1975
|
} catch (c) {
|
|
1976
|
-
r.fail(`提交失败,${c}`);
|
|
1976
|
+
r.fail(`提交失败,${c}`), process.exit(1);
|
|
1977
1977
|
}
|
|
1978
1978
|
}
|
|
1979
1979
|
}
|
|
1980
|
-
|
|
1980
|
+
D.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) => z(Da, ...e));
|
|
1981
1981
|
async function La(e, t) {
|
|
1982
1982
|
const n = (await Y(e.path)).filter((f) => f.type === "case");
|
|
1983
1983
|
let a;
|
|
@@ -2107,22 +2107,22 @@ async function Pa(e, t) {
|
|
|
2107
2107
|
}), await fe(a.path, s, "module", String(a.id)) && o.succeed(`模块重命名成功: ${a.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), a.id;
|
|
2108
2108
|
}
|
|
2109
2109
|
async function Oa(e, t) {
|
|
2110
|
-
const { type: i, typeStr: n } = await ve("修改", e), { localProduct: a } = await
|
|
2110
|
+
const { type: i, typeStr: n } = await ve("修改", e), { localProduct: a } = await xe(t.productId);
|
|
2111
2111
|
let s;
|
|
2112
2112
|
if (S.MODULE === i ? s = await Pa(a, t) : S.CASE === i && (s = await La(a, t)), !t.disableAutoCommit && await u("git status -s")) {
|
|
2113
2113
|
const o = w("代码提交中...").start();
|
|
2114
2114
|
try {
|
|
2115
2115
|
await u(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
|
|
2116
2116
|
} catch (r) {
|
|
2117
|
-
o.fail(`提交失败,${r}`);
|
|
2117
|
+
o.fail(`提交失败,${r}`), process.exit(1);
|
|
2118
2118
|
}
|
|
2119
2119
|
}
|
|
2120
2120
|
}
|
|
2121
|
-
|
|
2121
|
+
D.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) => z(Oa, ...e));
|
|
2122
2122
|
function Ma() {
|
|
2123
2123
|
process.on("unhandledRejection", (e) => {
|
|
2124
2124
|
}), process.on("uncaughtException", (e) => {
|
|
2125
|
-
}),
|
|
2125
|
+
}), x.config.fatal = !0, x.config.silent = !0, x.config.verbose = !1;
|
|
2126
2126
|
}
|
|
2127
2127
|
async function za() {
|
|
2128
2128
|
const e = pe("latestCheckVersionTimestamp"), t = pe("versionCheckDuring");
|
|
@@ -2155,5 +2155,5 @@ async function Fa() {
|
|
|
2155
2155
|
async function _a() {
|
|
2156
2156
|
Ma(), await Fa();
|
|
2157
2157
|
}
|
|
2158
|
-
|
|
2159
|
-
|
|
2158
|
+
D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${N.blue(We)}`).usage("<command> [options]").hook("preAction", _a).version(Q.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
2159
|
+
D.parse();
|