cli-z-develop 0.10.1 → 0.10.3
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 +75 -76
- 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,12 +6,12 @@ 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";
|
|
13
13
|
import w from "ora";
|
|
14
|
-
import
|
|
14
|
+
import S from "fs-extra";
|
|
15
15
|
import { select as re } from "inquirer-select-pro";
|
|
16
16
|
import Et from "lint-staged";
|
|
17
17
|
import Tt from "semver";
|
|
@@ -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: "产品",
|
|
@@ -67,7 +67,7 @@ const xt = {
|
|
|
67
67
|
}, me = "http://git.cxlqd.com", Lt = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
68
68
|
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 || {});
|
|
69
69
|
const Pt = "fe-biz7tvsd", We = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
70
|
-
var
|
|
70
|
+
var j = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(j || {});
|
|
71
71
|
const Ot = [
|
|
72
72
|
{
|
|
73
73
|
name: "模块",
|
|
@@ -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.3", 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,27 +372,27 @@ 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 = S.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
|
-
`当前目录(${
|
|
383
|
-
), U =
|
|
382
|
+
`当前目录(${x.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
383
|
+
), U = S.readJsonSync(e), U;
|
|
384
384
|
}
|
|
385
385
|
function li(e) {
|
|
386
386
|
U ? U = {
|
|
387
387
|
...U,
|
|
388
388
|
...e
|
|
389
|
-
} : U = e,
|
|
389
|
+
} : U = e, S.writeJSONSync(Ae(), U, { spaces: 2 });
|
|
390
390
|
}
|
|
391
391
|
function mi(e) {
|
|
392
392
|
B ? B = {
|
|
393
393
|
...B,
|
|
394
394
|
...e
|
|
395
|
-
} : B = e,
|
|
395
|
+
} : B = e, S.writeJSONSync(l.join("package.json"), B, { spaces: 2 });
|
|
396
396
|
}
|
|
397
397
|
const V = {
|
|
398
398
|
id: 0,
|
|
@@ -412,7 +412,7 @@ async function pi() {
|
|
|
412
412
|
return V.sourceBranch || (V.sourceBranch = await u("git branch --show-current")), V;
|
|
413
413
|
}
|
|
414
414
|
function te() {
|
|
415
|
-
|
|
415
|
+
S.writeJSONSync(
|
|
416
416
|
ye(),
|
|
417
417
|
{
|
|
418
418
|
main: pe(),
|
|
@@ -643,7 +643,7 @@ function Ti(e) {
|
|
|
643
643
|
}
|
|
644
644
|
function ki() {
|
|
645
645
|
const e = de("fe-groups.json");
|
|
646
|
-
return $(e) ?
|
|
646
|
+
return $(e) ? S.readJSONSync(e) : { groups: [] };
|
|
647
647
|
}
|
|
648
648
|
async function Ci() {
|
|
649
649
|
const e = await $i(), t = Lt.map((i) => {
|
|
@@ -654,7 +654,7 @@ async function Ci() {
|
|
|
654
654
|
description: n.description
|
|
655
655
|
} : !1;
|
|
656
656
|
}).filter((i) => !!i);
|
|
657
|
-
|
|
657
|
+
S.writeJSONSync(de("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
658
658
|
}
|
|
659
659
|
async function T(e) {
|
|
660
660
|
const t = `${ee("FEServerDomain")}/api`, { data: i } = await Z({
|
|
@@ -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,
|
|
@@ -1209,7 +1209,7 @@ async function ra() {
|
|
|
1209
1209
|
...o.scripts,
|
|
1210
1210
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1211
1211
|
}
|
|
1212
|
-
}), await
|
|
1212
|
+
}), await S.writeFile(l.resolve("README.md"), Ht(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Ce(e.tplLanguage, e.group?.name);
|
|
1213
1213
|
const r = w("依赖安装中").start();
|
|
1214
1214
|
await u("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1215
1215
|
const c = w("项目推送中").start();
|
|
@@ -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,12 +1438,12 @@ 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)) {
|
|
1446
|
-
const t =
|
|
1446
|
+
const t = S.readJsonSync(e);
|
|
1447
1447
|
if (t["lint-staged"])
|
|
1448
1448
|
return t["lint-staged"];
|
|
1449
1449
|
throw new Error("未找到lint配置");
|
|
@@ -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);
|
|
@@ -1716,17 +1716,17 @@ async function dt(e, t) {
|
|
|
1716
1716
|
priority: e.pri,
|
|
1717
1717
|
steps: []
|
|
1718
1718
|
};
|
|
1719
|
-
i.steps = await Li(e.id),
|
|
1719
|
+
i.steps = await Li(e.id), S.writeJSONSync(t, i, {
|
|
1720
1720
|
spaces: 2
|
|
1721
1721
|
});
|
|
1722
1722
|
}
|
|
1723
1723
|
async function ft(e, t) {
|
|
1724
1724
|
await se(t, {
|
|
1725
1725
|
recursive: !0
|
|
1726
|
-
}), await dt(e, l.join(t, "config.json")),
|
|
1726
|
+
}), await dt(e, l.join(t, "config.json")), S.ensureFileSync(l.join(t, "data.json")), await M(
|
|
1727
1727
|
l.join(t, "data.json"),
|
|
1728
1728
|
$(l.resolve(q, "data.json")) ? await Se(l.resolve(q, "data.json")) : Yt
|
|
1729
|
-
),
|
|
1729
|
+
), S.ensureFileSync(l.join(t, "main.py")), await M(
|
|
1730
1730
|
l.join(t, "main.py"),
|
|
1731
1731
|
$(l.resolve(q, "main.py")) ? await Se(l.resolve(q, "main.py")) : Xt
|
|
1732
1732
|
);
|
|
@@ -1744,17 +1744,17 @@ function gt(e) {
|
|
|
1744
1744
|
async function ve(e, t) {
|
|
1745
1745
|
oe(), X(), await ce();
|
|
1746
1746
|
let i;
|
|
1747
|
-
t ? ([
|
|
1747
|
+
t ? ([j.MODULE, j.CASE].includes(t) || m(`不支持的参数${t}。参数值应为 ${j.MODULE} 或者 ${j.CASE}。`), i = t) : i = await E({
|
|
1748
1748
|
message: `请选择要${e}的数据类型`,
|
|
1749
1749
|
choices: Ot
|
|
1750
1750
|
});
|
|
1751
|
-
const n = i ===
|
|
1751
|
+
const n = i === j.MODULE ? "模块" : j.CASE === i ? "用例" : "";
|
|
1752
1752
|
return {
|
|
1753
1753
|
type: i,
|
|
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;
|
|
@@ -1793,16 +1793,16 @@ async function Aa(e, t) {
|
|
|
1793
1793
|
}
|
|
1794
1794
|
async function Ea(e, t) {
|
|
1795
1795
|
const { type: i, typeStr: n } = await ve("拉取", e), a = await pt(t.productId), s = w(`${n}同步中...`).start();
|
|
1796
|
-
if (
|
|
1796
|
+
if (j.MODULE === i && await Aa(s, a), j.CASE === i && await ja(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await u("git status -s")) {
|
|
1797
1797
|
const o = w("代码提交中...").start();
|
|
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 _({
|
|
@@ -1884,16 +1884,16 @@ async function Ra(e, t) {
|
|
|
1884
1884
|
validate: (g) => g.length > 0 && g.length < 255
|
|
1885
1885
|
});
|
|
1886
1886
|
let f = "";
|
|
1887
|
-
if (
|
|
1887
|
+
if (j.MODULE === i && await ka(s, d, y), j.CASE === i && (f = await Ta(s, d, y)), !t.disableAutoCommit && j.CASE === i) {
|
|
1888
1888
|
const g = w("代码提交中...").start();
|
|
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 (
|
|
1971
|
+
if (j.MODULE === i ? o = await xa(a, s) : j.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;
|
|
@@ -2020,8 +2020,7 @@ async function La(e, t) {
|
|
|
2020
2020
|
a.displayName = s, a.path = l.join(l.dirname(a.path), G("case", s, String(a.id))), f && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`);
|
|
2021
2021
|
} else
|
|
2022
2022
|
o.succeed("用例名称无变动");
|
|
2023
|
-
|
|
2024
|
-
let c;
|
|
2023
|
+
let r = S.readJsonSync(l.join(a.path, "config.json")), c;
|
|
2025
2024
|
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await Oe({
|
|
2026
2025
|
message: "修改用例优先级",
|
|
2027
2026
|
min: 1,
|
|
@@ -2041,14 +2040,14 @@ async function La(e, t) {
|
|
|
2041
2040
|
c !== r.priority ? (await Ui({
|
|
2042
2041
|
id: Number(a.id),
|
|
2043
2042
|
priority: c
|
|
2044
|
-
}),
|
|
2043
|
+
}), S.writeJSONSync(
|
|
2045
2044
|
l.join(a.path, "config.json"),
|
|
2046
2045
|
{
|
|
2047
2046
|
...r,
|
|
2048
2047
|
priority: c
|
|
2049
2048
|
},
|
|
2050
2049
|
{ spaces: 2 }
|
|
2051
|
-
), p.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : p.succeed("用例优先级无变动");
|
|
2050
|
+
), p.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : p.succeed("用例优先级无变动"), r = S.readJsonSync(l.join(a.path, "config.json"));
|
|
2052
2051
|
let d;
|
|
2053
2052
|
t.casePrecondition ? d = t.casePrecondition : d = await _({
|
|
2054
2053
|
message: "修改用例前置条件",
|
|
@@ -2059,14 +2058,14 @@ async function La(e, t) {
|
|
|
2059
2058
|
return d !== r.precondition ? (await Ji({
|
|
2060
2059
|
id: Number(a.id),
|
|
2061
2060
|
precondition: d
|
|
2062
|
-
}),
|
|
2061
|
+
}), S.writeJSONSync(
|
|
2063
2062
|
l.join(a.path, "config.json"),
|
|
2064
2063
|
{
|
|
2065
2064
|
...r,
|
|
2066
2065
|
precondition: d
|
|
2067
2066
|
},
|
|
2068
2067
|
{ spaces: 2 }
|
|
2069
|
-
), y.succeed(`用例前置条件修改成功:${r.
|
|
2068
|
+
), y.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : y.succeed("用例前置条件无变动"), a.id;
|
|
2070
2069
|
}
|
|
2071
2070
|
async function Pa(e, t) {
|
|
2072
2071
|
const n = (await Y(e.path)).filter((r) => r.type === "module");
|
|
@@ -2107,22 +2106,22 @@ async function Pa(e, t) {
|
|
|
2107
2106
|
}), await fe(a.path, s, "module", String(a.id)) && o.succeed(`模块重命名成功: ${a.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), a.id;
|
|
2108
2107
|
}
|
|
2109
2108
|
async function Oa(e, t) {
|
|
2110
|
-
const { type: i, typeStr: n } = await ve("修改", e), { localProduct: a } = await
|
|
2109
|
+
const { type: i, typeStr: n } = await ve("修改", e), { localProduct: a } = await xe(t.productId);
|
|
2111
2110
|
let s;
|
|
2112
|
-
if (
|
|
2111
|
+
if (j.MODULE === i ? s = await Pa(a, t) : j.CASE === i && (s = await La(a, t)), !t.disableAutoCommit && await u("git status -s")) {
|
|
2113
2112
|
const o = w("代码提交中...").start();
|
|
2114
2113
|
try {
|
|
2115
2114
|
await u(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
|
|
2116
2115
|
} catch (r) {
|
|
2117
|
-
o.fail(`提交失败,${r}`);
|
|
2116
|
+
o.fail(`提交失败,${r}`), process.exit(1);
|
|
2118
2117
|
}
|
|
2119
2118
|
}
|
|
2120
2119
|
}
|
|
2121
|
-
|
|
2120
|
+
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
2121
|
function Ma() {
|
|
2123
2122
|
process.on("unhandledRejection", (e) => {
|
|
2124
2123
|
}), process.on("uncaughtException", (e) => {
|
|
2125
|
-
}),
|
|
2124
|
+
}), x.config.fatal = !0, x.config.silent = !0, x.config.verbose = !1;
|
|
2126
2125
|
}
|
|
2127
2126
|
async function za() {
|
|
2128
2127
|
const e = pe("latestCheckVersionTimestamp"), t = pe("versionCheckDuring");
|
|
@@ -2147,7 +2146,7 @@ async function Fa() {
|
|
|
2147
2146
|
const e = Ct(process.argv.slice(2));
|
|
2148
2147
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2149
2148
|
if (qe()) {
|
|
2150
|
-
const t =
|
|
2149
|
+
const t = S.readJSONSync(ye());
|
|
2151
2150
|
L(t.profile), ne(t.main), Te(t.constants), await za();
|
|
2152
2151
|
} else
|
|
2153
2152
|
m(`请先初始化z-develop(执行 z i)。更多见${We}`);
|
|
@@ -2155,5 +2154,5 @@ async function Fa() {
|
|
|
2155
2154
|
async function _a() {
|
|
2156
2155
|
Ma(), await Fa();
|
|
2157
2156
|
}
|
|
2158
|
-
|
|
2159
|
-
|
|
2157
|
+
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查看帮助。");
|
|
2158
|
+
D.parse();
|