cli-z-develop 0.12.3 → 0.13.1
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 +267 -227
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,19 +7,19 @@ import ce, { AxiosError as jt } from "axios";
|
|
|
7
7
|
import S from "chalk";
|
|
8
8
|
import St from "dayjs";
|
|
9
9
|
import O from "shelljs";
|
|
10
|
-
import
|
|
10
|
+
import kt from "node:os";
|
|
11
11
|
import Me from "child_process";
|
|
12
|
-
import { confirm as Ue, select as
|
|
12
|
+
import { confirm as Ue, select as k, input as J, password as Tt, checkbox as Ce, number as ze } from "@inquirer/prompts";
|
|
13
13
|
import y from "ora";
|
|
14
|
-
import
|
|
14
|
+
import x from "fs-extra";
|
|
15
15
|
import { select as ae } from "inquirer-select-pro";
|
|
16
16
|
import Et from "lint-staged";
|
|
17
17
|
import Ct from "semver";
|
|
18
18
|
import { run as Rt } from "npm-check-updates";
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
const Ge = "dev",
|
|
22
|
-
var b = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST =
|
|
19
|
+
import xt from "p-limit";
|
|
20
|
+
import It from "minimist";
|
|
21
|
+
const Ge = "dev", We = "test", Ve = "release", Dt = "production", Lt = "master";
|
|
22
|
+
var b = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = We] = "TEST", e[e.RELEASE = Ve] = "RELEASE", e[e.PROD = Dt] = "PROD", e))(b || {}), $ = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = We] = "TEST", e[e.RELEASE = Ve] = "RELEASE", e[e.MASTER = Lt] = "MASTER", e))($ || {}), G = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(G || {});
|
|
23
23
|
const qe = [
|
|
24
24
|
{
|
|
25
25
|
name: `开发环境 - ${b.DEV}`,
|
|
@@ -67,7 +67,7 @@ const Pt = {
|
|
|
67
67
|
9: "其他"
|
|
68
68
|
}, fe = "http://git.cxlqd.com", Mt = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
69
69
|
var j = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(j || {});
|
|
70
|
-
const zt = "fe-biz7tvsd",
|
|
70
|
+
const zt = "fe-biz7tvsd", Ke = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
71
71
|
var R = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(R || {});
|
|
72
72
|
const Bt = [
|
|
73
73
|
{
|
|
@@ -80,24 +80,24 @@ const Bt = [
|
|
|
80
80
|
value: "case"
|
|
81
81
|
/* CASE */
|
|
82
82
|
}
|
|
83
|
-
],
|
|
83
|
+
], Ft = ".z", Jt = "develop-config.json", Z = ".z", _t = ".commit-msg-tpl", Ut = "project.json";
|
|
84
84
|
function C(e = "") {
|
|
85
|
-
return p.join(
|
|
85
|
+
return p.join(Z, e);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function He() {
|
|
88
88
|
return C(Ut);
|
|
89
89
|
}
|
|
90
90
|
function Ne() {
|
|
91
91
|
return C(_t);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function Ze() {
|
|
94
94
|
Me.spawnSync("git", ["config", "core.hooksPath", C()]), Me.spawnSync("git", ["config", "commit.template", Ne()]);
|
|
95
95
|
}
|
|
96
96
|
function he(e = "") {
|
|
97
|
-
return p.resolve(
|
|
97
|
+
return p.resolve(kt.homedir(), Ft, e);
|
|
98
98
|
}
|
|
99
99
|
function be() {
|
|
100
|
-
return he(
|
|
100
|
+
return he(Jt);
|
|
101
101
|
}
|
|
102
102
|
function Gt() {
|
|
103
103
|
return v(he());
|
|
@@ -116,11 +116,11 @@ function $e(e) {
|
|
|
116
116
|
}
|
|
117
117
|
return encodeURIComponent(t.replace(/\.git$/, ""));
|
|
118
118
|
}
|
|
119
|
-
const { red: Be, green:
|
|
119
|
+
const { red: Be, green: Wt, blue: An, magenta: Vt, yellow: jn } = S;
|
|
120
120
|
function ye(...e) {
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
console.log(
|
|
122
|
+
function W(...e) {
|
|
123
|
+
console.log(Wt(...e));
|
|
124
124
|
}
|
|
125
125
|
function Xe(e) {
|
|
126
126
|
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));
|
|
@@ -128,13 +128,13 @@ function Xe(e) {
|
|
|
128
128
|
function l(e, t = !1) {
|
|
129
129
|
Xe(e);
|
|
130
130
|
let i = e;
|
|
131
|
-
e instanceof Error ? (i = e.message, ce.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(Be(i)), console.log(
|
|
131
|
+
e instanceof Error ? (i = e.message, ce.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(Be(i)), console.log(Vt(e.stack))) : console.log(Be(e)), t || process.exit(1);
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function Fe(e) {
|
|
134
134
|
return v(e) ? Nt(e).isDirectory() : !1;
|
|
135
135
|
}
|
|
136
136
|
function Qe(e = process.cwd()) {
|
|
137
|
-
return
|
|
137
|
+
return Fe(e) ? vt(e).filter((i) => Fe(p.resolve(e, i))) : [];
|
|
138
138
|
}
|
|
139
139
|
async function m(e, t = {
|
|
140
140
|
removeTailLinkBreak: !0,
|
|
@@ -175,10 +175,10 @@ function Q() {
|
|
|
175
175
|
async function me() {
|
|
176
176
|
await m("git status -s") !== "" && l("请先提交代码变动,再进行操作");
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function Kt(e) {
|
|
179
179
|
return e === $.MASTER ? b.PROD : e;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function Ht(e) {
|
|
182
182
|
return e === b.PROD ? $.MASTER : e;
|
|
183
183
|
}
|
|
184
184
|
async function z(e, ...t) {
|
|
@@ -188,7 +188,7 @@ async function z(e, ...t) {
|
|
|
188
188
|
throw Xe(i), i;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
async function
|
|
191
|
+
async function Zt(e) {
|
|
192
192
|
return (await Re(e)).length === 0;
|
|
193
193
|
}
|
|
194
194
|
function Yt(e = "项目中文名", t = "项目描述") {
|
|
@@ -262,11 +262,11 @@ const Xt = {
|
|
|
262
262
|
"**/*.{py}": "echo 'todo'"
|
|
263
263
|
},
|
|
264
264
|
[w.MARKDOWN]: {
|
|
265
|
-
"
|
|
265
|
+
"*": "prettier -wu",
|
|
266
266
|
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
267
|
-
"
|
|
267
|
+
"**/*.md": "markdownlint --fix"
|
|
268
268
|
}
|
|
269
|
-
}, Qt = "cli-z-develop", ei = "0.
|
|
269
|
+
}, Qt = "cli-z-develop", ei = "0.13.1", ti = "技术团队开发流程管理工具", ii = "dist/index.js", ai = { z: "bin/z.js", "z-develop": "bin/z.js" }, ni = { 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" }, si = "module", ri = "z", oi = { "@lonely9/eslint-config-team": "^1.3.8", "@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.58.2", "@typescript-eslint/parser": "^8.58.2", eslint: "^9.39.2", jiti: "^2.6.1", prettier: "^3.8.2", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.2.6" }, ci = { "@inquirer/prompts": "^8.4.1", axios: "^1.15.0", chalk: "^5.6.2", commander: "^14.0.3", dayjs: "^1.11.20", "fs-extra": "^11.3.4", "inquirer-select-pro": "^1.0.0-alpha.9", "lint-staged": "^16.4.0", minimist: "^1.2.8", "npm-check-updates": "^19.3.1", ora: "^9.3.0", "p-limit": "^7.3.0", semver: "^7.7.4", shelljs: "^0.10.0" }, ie = {
|
|
270
270
|
name: Qt,
|
|
271
271
|
version: ei,
|
|
272
272
|
description: ti,
|
|
@@ -277,7 +277,7 @@ const Xt = {
|
|
|
277
277
|
author: ri,
|
|
278
278
|
devDependencies: oi,
|
|
279
279
|
dependencies: ci
|
|
280
|
-
},
|
|
280
|
+
}, I = {
|
|
281
281
|
// 个人数据
|
|
282
282
|
profile: {
|
|
283
283
|
ldapAccount: "",
|
|
@@ -312,42 +312,42 @@ const Xt = {
|
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
314
|
function E(e) {
|
|
315
|
-
return e ?
|
|
315
|
+
return e ? I.profile[e] : I.profile;
|
|
316
316
|
}
|
|
317
317
|
function ge(e) {
|
|
318
|
-
return e ?
|
|
318
|
+
return e ? I.main[e] : I.main;
|
|
319
319
|
}
|
|
320
320
|
function q(e) {
|
|
321
|
-
return e ?
|
|
321
|
+
return e ? I.constants[e] : I.constants;
|
|
322
322
|
}
|
|
323
323
|
let _ = null, U = null;
|
|
324
324
|
function Ae() {
|
|
325
325
|
if (_)
|
|
326
326
|
return _;
|
|
327
327
|
const e = p.join("package.json");
|
|
328
|
-
return v(e) || l(`当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), _ =
|
|
328
|
+
return v(e) || l(`当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), _ = x.readJsonSync(e), _;
|
|
329
329
|
}
|
|
330
330
|
function pe() {
|
|
331
331
|
if (U)
|
|
332
332
|
return U;
|
|
333
|
-
const e =
|
|
333
|
+
const e = He();
|
|
334
334
|
return v(e) || l(
|
|
335
335
|
`当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
336
|
-
), U =
|
|
336
|
+
), U = x.readJsonSync(e), U;
|
|
337
337
|
}
|
|
338
338
|
function ui(e) {
|
|
339
339
|
U ? U = {
|
|
340
340
|
...U,
|
|
341
341
|
...e
|
|
342
|
-
} : U = e,
|
|
342
|
+
} : U = e, x.writeJSONSync(He(), U, { spaces: 2 });
|
|
343
343
|
}
|
|
344
344
|
function li(e) {
|
|
345
345
|
_ ? _ = {
|
|
346
346
|
..._,
|
|
347
347
|
...e
|
|
348
|
-
} : _ = e,
|
|
348
|
+
} : _ = e, x.writeJSONSync(p.join("package.json"), _, { spaces: 2 });
|
|
349
349
|
}
|
|
350
|
-
const
|
|
350
|
+
const H = {
|
|
351
351
|
id: 0,
|
|
352
352
|
path: "",
|
|
353
353
|
group: "",
|
|
@@ -355,17 +355,17 @@ const Z = {
|
|
|
355
355
|
mergeRequestUrl: ""
|
|
356
356
|
};
|
|
357
357
|
async function mi() {
|
|
358
|
-
if (!
|
|
358
|
+
if (!H.id)
|
|
359
359
|
try {
|
|
360
360
|
const e = pe(), t = $e(e.repository.url), i = await nt(t);
|
|
361
|
-
|
|
361
|
+
H.id = i.id, H.path = t, H.group = i.namespace.full_path, H.mergeRequestUrl = `${i.web_url}/merge_requests`;
|
|
362
362
|
} catch (e) {
|
|
363
363
|
l(e);
|
|
364
364
|
}
|
|
365
|
-
return
|
|
365
|
+
return H.sourceBranch || (H.sourceBranch = await m("git branch --show-current")), H;
|
|
366
366
|
}
|
|
367
367
|
function se() {
|
|
368
|
-
|
|
368
|
+
x.writeJSONSync(
|
|
369
369
|
be(),
|
|
370
370
|
{
|
|
371
371
|
main: ge(),
|
|
@@ -378,20 +378,20 @@ function se() {
|
|
|
378
378
|
);
|
|
379
379
|
}
|
|
380
380
|
function M(e, t) {
|
|
381
|
-
t !== void 0 ?
|
|
382
|
-
...
|
|
381
|
+
t !== void 0 ? I.profile[e] = t : I.profile = {
|
|
382
|
+
...I.profile,
|
|
383
383
|
...e
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
|
-
function
|
|
387
|
-
|
|
388
|
-
...
|
|
386
|
+
function xe(e, t) {
|
|
387
|
+
I.constants = {
|
|
388
|
+
...I.constants,
|
|
389
389
|
...e
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
392
|
function ue(e, t) {
|
|
393
|
-
t !== void 0 ?
|
|
394
|
-
...
|
|
393
|
+
t !== void 0 ? I.main[e] = t : I.main = {
|
|
394
|
+
...I.main,
|
|
395
395
|
...e
|
|
396
396
|
};
|
|
397
397
|
}
|
|
@@ -527,68 +527,68 @@ async function gi(e, t) {
|
|
|
527
527
|
throw console.error("下载失败:", i), i;
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
|
-
const B = () => `${fe}/api/v4`,
|
|
530
|
+
const B = () => `${fe}/api/v4`, F = (e) => `${B()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
|
|
531
531
|
function hi() {
|
|
532
532
|
return N({
|
|
533
|
-
url:
|
|
533
|
+
url: F("src/data/template-projects.json")
|
|
534
534
|
});
|
|
535
535
|
}
|
|
536
536
|
function wi() {
|
|
537
537
|
return N({
|
|
538
|
-
url:
|
|
538
|
+
url: F("src/data/java-project-module.json")
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
541
|
function at() {
|
|
542
542
|
return N({
|
|
543
|
-
url:
|
|
543
|
+
url: F("src/data/z-develop-config.json")
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
function yi() {
|
|
547
547
|
return N({
|
|
548
|
-
url:
|
|
548
|
+
url: F("src/assets/tsconfig.browser.json")
|
|
549
549
|
});
|
|
550
550
|
}
|
|
551
551
|
function $i() {
|
|
552
552
|
return N({
|
|
553
|
-
url:
|
|
553
|
+
url: F("src/assets/tsconfig.node.json")
|
|
554
554
|
});
|
|
555
555
|
}
|
|
556
556
|
function vi() {
|
|
557
557
|
return N({
|
|
558
|
-
url:
|
|
558
|
+
url: F("src/assets/.prettierignore")
|
|
559
559
|
});
|
|
560
560
|
}
|
|
561
561
|
function Ni() {
|
|
562
562
|
return N({
|
|
563
|
-
url:
|
|
563
|
+
url: F("src/assets/.prettierrc.json")
|
|
564
564
|
});
|
|
565
565
|
}
|
|
566
566
|
function bi() {
|
|
567
567
|
return N({
|
|
568
|
-
url:
|
|
568
|
+
url: F("src/assets/data.yaml")
|
|
569
569
|
});
|
|
570
570
|
}
|
|
571
571
|
function Ai() {
|
|
572
572
|
return N({
|
|
573
|
-
url:
|
|
573
|
+
url: F("src/assets/main.py")
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
576
|
function ji() {
|
|
577
577
|
return N({
|
|
578
|
-
url:
|
|
578
|
+
url: F("src/assets/checkstyle.xml")
|
|
579
579
|
});
|
|
580
580
|
}
|
|
581
581
|
function Si() {
|
|
582
582
|
return N({
|
|
583
|
-
url:
|
|
583
|
+
url: F("src/data/project-group-chats.json")
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
|
-
function
|
|
586
|
+
function ki() {
|
|
587
587
|
return N({
|
|
588
588
|
url: `${B()}/user`
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
|
-
function
|
|
591
|
+
function Ti() {
|
|
592
592
|
return N({
|
|
593
593
|
url: `${B()}/groups`
|
|
594
594
|
});
|
|
@@ -621,13 +621,13 @@ function Ri(e) {
|
|
|
621
621
|
data: e
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
|
-
function
|
|
624
|
+
function xi(e) {
|
|
625
625
|
return N({
|
|
626
626
|
url: `${B()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
627
627
|
method: "put"
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
|
-
function
|
|
630
|
+
function Ii(e) {
|
|
631
631
|
return N({
|
|
632
632
|
url: `${B()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
633
633
|
method: "put",
|
|
@@ -654,10 +654,10 @@ function Oi(e) {
|
|
|
654
654
|
}
|
|
655
655
|
function Pi() {
|
|
656
656
|
const e = he("fe-groups.json");
|
|
657
|
-
return v(e) ?
|
|
657
|
+
return v(e) ? x.readJSONSync(e) : { groups: [] };
|
|
658
658
|
}
|
|
659
659
|
async function Mi() {
|
|
660
|
-
const e = await
|
|
660
|
+
const e = await Ti(), t = Mt.map((i) => {
|
|
661
661
|
const n = e.find((a) => a.name === i);
|
|
662
662
|
return n ? {
|
|
663
663
|
name: n.name,
|
|
@@ -665,7 +665,7 @@ async function Mi() {
|
|
|
665
665
|
description: n.description
|
|
666
666
|
} : !1;
|
|
667
667
|
}).filter((i) => !!i);
|
|
668
|
-
|
|
668
|
+
x.writeJSONSync(he("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
669
669
|
}
|
|
670
670
|
async function A(e) {
|
|
671
671
|
const t = `${q("FEServerDomain")}/api`, { data: i } = await Y({
|
|
@@ -699,7 +699,7 @@ function st(e) {
|
|
|
699
699
|
}
|
|
700
700
|
});
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function Fi(e) {
|
|
703
703
|
return A({
|
|
704
704
|
url: "/zen/testcase/product/name",
|
|
705
705
|
data: {
|
|
@@ -707,7 +707,7 @@ function Ji(e) {
|
|
|
707
707
|
}
|
|
708
708
|
});
|
|
709
709
|
}
|
|
710
|
-
function
|
|
710
|
+
function Ji(e, t) {
|
|
711
711
|
return A({
|
|
712
712
|
url: "/zen/testcase/product/auto-case/list",
|
|
713
713
|
data: {
|
|
@@ -736,13 +736,13 @@ function Gi(e) {
|
|
|
736
736
|
data: e
|
|
737
737
|
});
|
|
738
738
|
}
|
|
739
|
-
function
|
|
739
|
+
function Wi(e) {
|
|
740
740
|
return A({
|
|
741
741
|
url: "/zen/testcase/step/create",
|
|
742
742
|
data: e
|
|
743
743
|
});
|
|
744
744
|
}
|
|
745
|
-
function
|
|
745
|
+
function Vi(e) {
|
|
746
746
|
return A({
|
|
747
747
|
url: "/zen/testcase/modules/remove",
|
|
748
748
|
data: e
|
|
@@ -754,19 +754,19 @@ function qi(e) {
|
|
|
754
754
|
data: e
|
|
755
755
|
});
|
|
756
756
|
}
|
|
757
|
-
function
|
|
757
|
+
function Ki(e) {
|
|
758
758
|
return A({
|
|
759
759
|
url: "/zen/testcase/module/update/name",
|
|
760
760
|
data: e
|
|
761
761
|
});
|
|
762
762
|
}
|
|
763
|
-
function
|
|
763
|
+
function Hi(e) {
|
|
764
764
|
return A({
|
|
765
765
|
url: "/zen/testcase/case/update/name",
|
|
766
766
|
data: e
|
|
767
767
|
});
|
|
768
768
|
}
|
|
769
|
-
function
|
|
769
|
+
function Zi(e) {
|
|
770
770
|
return A({
|
|
771
771
|
url: "/zen/testcase/case/update/priority",
|
|
772
772
|
data: e
|
|
@@ -874,7 +874,7 @@ async function sa() {
|
|
|
874
874
|
Ye() && (await Ue({
|
|
875
875
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
876
876
|
}) ? O.rm("-rf", be()) : process.exit(0)), await le(he(), { recursive: !0 });
|
|
877
|
-
const t = await
|
|
877
|
+
const t = await k({
|
|
878
878
|
message: "请选择岗位类型",
|
|
879
879
|
choices: [
|
|
880
880
|
{
|
|
@@ -891,17 +891,17 @@ async function sa() {
|
|
|
891
891
|
}
|
|
892
892
|
]
|
|
893
893
|
});
|
|
894
|
-
let i = await
|
|
894
|
+
let i = await J({
|
|
895
895
|
message: "请输入LDAP账号:"
|
|
896
896
|
});
|
|
897
897
|
i = i.trim();
|
|
898
|
-
let n = await
|
|
898
|
+
let n = await Tt({
|
|
899
899
|
message: "请输入LDAP密码:",
|
|
900
900
|
mask: !0
|
|
901
901
|
});
|
|
902
902
|
n = n.trim(), M("jobType", t), M("ldapAccount", i), M("ldapPassword", n);
|
|
903
903
|
const a = await at();
|
|
904
|
-
|
|
904
|
+
xe(a);
|
|
905
905
|
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]);
|
|
906
906
|
M({
|
|
907
907
|
weWorkName: r,
|
|
@@ -912,7 +912,7 @@ async function sa() {
|
|
|
912
912
|
}
|
|
913
913
|
const e = y("配置信息初始化中").start();
|
|
914
914
|
try {
|
|
915
|
-
const t = await
|
|
915
|
+
const t = await ki();
|
|
916
916
|
M({
|
|
917
917
|
gitUserId: t.id,
|
|
918
918
|
gitName: t.name,
|
|
@@ -943,13 +943,13 @@ z run commit-files`, { mode: 493 });
|
|
|
943
943
|
mode: 493
|
|
944
944
|
});
|
|
945
945
|
}
|
|
946
|
-
|
|
946
|
+
Ze();
|
|
947
947
|
}
|
|
948
948
|
async function oa(e, t) {
|
|
949
949
|
const i = await m("git remote get-url --push origin");
|
|
950
950
|
i || l("获取项目远程git地址失败,请配置后重试");
|
|
951
951
|
let n = e;
|
|
952
|
-
n || (n = await
|
|
952
|
+
n || (n = await k({
|
|
953
953
|
message: "请选择项目语言",
|
|
954
954
|
choices: [
|
|
955
955
|
{
|
|
@@ -986,18 +986,18 @@ async function oa(e, t) {
|
|
|
986
986
|
}
|
|
987
987
|
});
|
|
988
988
|
}
|
|
989
|
-
async function
|
|
990
|
-
e ? O.rm("-rf",
|
|
991
|
-
message: `当前项目中已存在配置文件夹${
|
|
992
|
-
}) ? O.rm("-rf",
|
|
989
|
+
async function Ie(e, t) {
|
|
990
|
+
e ? O.rm("-rf", Z) : v(C()) && (await Ue({
|
|
991
|
+
message: `当前项目中已存在配置文件夹${Z},确认重新配置?`
|
|
992
|
+
}) ? O.rm("-rf", Z) : process.exit(0)), await le(C(), { recursive: !0 }), await oa(e, t);
|
|
993
993
|
const i = y("项目初始化中...").start();
|
|
994
994
|
await ra(), i.succeed("项目初始化完成");
|
|
995
995
|
}
|
|
996
996
|
async function ca() {
|
|
997
|
-
v(C()) && v(Ne()) ?
|
|
997
|
+
v(C()) && v(Ne()) ? Ze() : await Ie(), process.exit(0);
|
|
998
998
|
}
|
|
999
999
|
async function ua(e, t) {
|
|
1000
|
-
t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && l("项目语言不支持"), e ? (Q(), e === "." ? (await
|
|
1000
|
+
t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && l("项目语言不支持"), e ? (Q(), e === "." ? (await Ie(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await ca() : l("参数错误。执行 z init -h 查看帮助。")) : await sa();
|
|
1001
1001
|
}
|
|
1002
1002
|
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => z(ua, ...e));
|
|
1003
1003
|
async function la(e, t) {
|
|
@@ -1019,7 +1019,7 @@ function pa(e) {
|
|
|
1019
1019
|
async function da(e) {
|
|
1020
1020
|
ne(), Q(), await me();
|
|
1021
1021
|
let t, i;
|
|
1022
|
-
e.branchType ? t = e.branchType : t = await
|
|
1022
|
+
e.branchType ? t = e.branchType : t = await k({
|
|
1023
1023
|
message: "请选择创建分支的类型",
|
|
1024
1024
|
choices: [
|
|
1025
1025
|
{
|
|
@@ -1035,7 +1035,7 @@ async function da(e) {
|
|
|
1035
1035
|
value: de.REFACTOR
|
|
1036
1036
|
}
|
|
1037
1037
|
]
|
|
1038
|
-
}), e.branchPurpose ? i = e.branchPurpose : (i = await
|
|
1038
|
+
}), e.branchPurpose ? i = e.branchPurpose : (i = await J({
|
|
1039
1039
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1040
1040
|
validate: pa
|
|
1041
1041
|
}), i = i.trim());
|
|
@@ -1069,7 +1069,7 @@ async function ga() {
|
|
|
1069
1069
|
}
|
|
1070
1070
|
})) : [];
|
|
1071
1071
|
}
|
|
1072
|
-
async function
|
|
1072
|
+
async function Je(e) {
|
|
1073
1073
|
const t = await m("git diff HEAD");
|
|
1074
1074
|
t || l("git暂存区没有内容,请先git add添加文件到暂存区");
|
|
1075
1075
|
const i = await ia({
|
|
@@ -1079,20 +1079,20 @@ async function Fe(e) {
|
|
|
1079
1079
|
});
|
|
1080
1080
|
return e + i;
|
|
1081
1081
|
}
|
|
1082
|
-
async function
|
|
1082
|
+
async function Te(e, t, i) {
|
|
1083
1083
|
const n = y("🤖 生成提交信息中...").start();
|
|
1084
1084
|
let a = "", s = !0;
|
|
1085
1085
|
if ([j.FEAT, j.FIX, j.REFACTOR].includes(e)) {
|
|
1086
1086
|
const o = t.map((r) => r.value).join(",");
|
|
1087
|
-
if (i || (a = await
|
|
1087
|
+
if (i || (a = await Je(`${e}(${o}): `)), !a) {
|
|
1088
1088
|
const r = t.map((c) => c.name).join(";");
|
|
1089
1089
|
a = `${e}(${o}): ${r}`, s = !1;
|
|
1090
1090
|
}
|
|
1091
1091
|
}
|
|
1092
|
-
e === j.CHORE && (t ? a = `${e}: ${t}` : a = await
|
|
1092
|
+
e === j.CHORE && (t ? a = `${e}: ${t}` : a = await Je(`${e}: `)), await L(Ne(), a, "utf-8"), s || i ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(S.yellow(a));
|
|
1093
1093
|
}
|
|
1094
1094
|
async function ha(e) {
|
|
1095
|
-
const t = await
|
|
1095
|
+
const t = await k({
|
|
1096
1096
|
message: "请选择你要创建的模板类型",
|
|
1097
1097
|
choices: [
|
|
1098
1098
|
{
|
|
@@ -1116,7 +1116,7 @@ async function ha(e) {
|
|
|
1116
1116
|
if ([j.FEAT, j.REFACTOR].includes(t)) {
|
|
1117
1117
|
const i = await fa();
|
|
1118
1118
|
if (!i.length)
|
|
1119
|
-
return
|
|
1119
|
+
return W("🤷 暂无开发任务");
|
|
1120
1120
|
const n = await Ce({
|
|
1121
1121
|
message: "请关联开发任务(可多选):",
|
|
1122
1122
|
validate: (a) => a.length === 0 ? "请选择项" : !0,
|
|
@@ -1126,12 +1126,12 @@ async function ha(e) {
|
|
|
1126
1126
|
})),
|
|
1127
1127
|
pageSize: i.length
|
|
1128
1128
|
});
|
|
1129
|
-
await
|
|
1129
|
+
await Te(j.FEAT, n, e);
|
|
1130
1130
|
}
|
|
1131
1131
|
if (t === j.FIX) {
|
|
1132
1132
|
const i = await ga();
|
|
1133
1133
|
if (!i.length)
|
|
1134
|
-
return
|
|
1134
|
+
return W("🤷 暂无BUG");
|
|
1135
1135
|
const n = await Ce({
|
|
1136
1136
|
message: "请关联Bug(可多选):",
|
|
1137
1137
|
validate: (a) => a.length === 0 ? "请选择项" : !0,
|
|
@@ -1141,50 +1141,50 @@ async function ha(e) {
|
|
|
1141
1141
|
})),
|
|
1142
1142
|
pageSize: i.length
|
|
1143
1143
|
});
|
|
1144
|
-
await
|
|
1144
|
+
await Te(j.FIX, n, e);
|
|
1145
1145
|
}
|
|
1146
1146
|
if (t === j.CHORE) {
|
|
1147
1147
|
let i = "";
|
|
1148
|
-
e && (i = await
|
|
1148
|
+
e && (i = await J({
|
|
1149
1149
|
message: "请输入commit msg:",
|
|
1150
1150
|
validate: (n) => n.length === 0 ? "请输入commit msg" : !0
|
|
1151
|
-
}), i = i.trim()), await
|
|
1151
|
+
}), i = i.trim()), await Te(j.CHORE, i);
|
|
1152
1152
|
}
|
|
1153
1153
|
process.exit(0);
|
|
1154
1154
|
}
|
|
1155
1155
|
async function wa() {
|
|
1156
1156
|
try {
|
|
1157
1157
|
const e = {}, t = async () => {
|
|
1158
|
-
const P = Qe(), { projects: te } = await hi(),
|
|
1158
|
+
const P = Qe(), { projects: te } = await hi(), K = te.map((re) => {
|
|
1159
1159
|
const Pe = {
|
|
1160
1160
|
name: `${re.name} [${re.desc}]`,
|
|
1161
1161
|
value: re.name,
|
|
1162
1162
|
disabled: !1
|
|
1163
1163
|
};
|
|
1164
1164
|
return P.includes(re.name) && (Pe.disabled = "目录下已存在同名文件夹"), Pe;
|
|
1165
|
-
}), yt = await
|
|
1165
|
+
}), yt = await k({
|
|
1166
1166
|
message: "请选择一个项目模板",
|
|
1167
|
-
choices:
|
|
1168
|
-
}),
|
|
1169
|
-
e.tplName =
|
|
1167
|
+
choices: K
|
|
1168
|
+
}), ke = te.find((re) => re.name === yt);
|
|
1169
|
+
e.tplName = ke.name, e.tplUrl = ke.url, e.tplLanguage = ke.language;
|
|
1170
1170
|
}, i = async () => {
|
|
1171
|
-
const { groups: P } = Pi(), te = await
|
|
1171
|
+
const { groups: P } = Pi(), te = await k({
|
|
1172
1172
|
message: "请选择一个分组",
|
|
1173
|
-
choices: P.map((
|
|
1174
|
-
name: `${
|
|
1175
|
-
value:
|
|
1176
|
-
short:
|
|
1173
|
+
choices: P.map((K) => ({
|
|
1174
|
+
name: `${K.name} [${K.description}]`,
|
|
1175
|
+
value: K.id,
|
|
1176
|
+
short: K.name
|
|
1177
1177
|
}))
|
|
1178
1178
|
});
|
|
1179
1179
|
e.group = {
|
|
1180
1180
|
id: te,
|
|
1181
|
-
name: P.find((
|
|
1181
|
+
name: P.find((K) => K.id === te)?.name
|
|
1182
1182
|
};
|
|
1183
1183
|
}, n = async () => {
|
|
1184
|
-
e.projectName = await
|
|
1184
|
+
e.projectName = await J({
|
|
1185
1185
|
message: "请输入项目名称",
|
|
1186
1186
|
validate: (P) => la(P, e.group?.name || "")
|
|
1187
|
-
}), e.projectName = e.projectName.trim(), e.projectDesc = await
|
|
1187
|
+
}), e.projectName = e.projectName.trim(), e.projectDesc = await J({
|
|
1188
1188
|
message: "请输入项目描述",
|
|
1189
1189
|
validate: ma
|
|
1190
1190
|
}), e.projectDesc = e.projectDesc.trim();
|
|
@@ -1201,7 +1201,7 @@ async function wa() {
|
|
|
1201
1201
|
...o.scripts,
|
|
1202
1202
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1203
1203
|
}
|
|
1204
|
-
}), await
|
|
1204
|
+
}), await x.writeFile(p.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Ie(e.tplLanguage, e.group?.name);
|
|
1205
1205
|
const r = y("依赖安装中").start();
|
|
1206
1206
|
await m("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1207
1207
|
const c = y("项目推送中").start();
|
|
@@ -1222,10 +1222,10 @@ async function wa() {
|
|
|
1222
1222
|
ref: $.MASTER
|
|
1223
1223
|
})
|
|
1224
1224
|
)
|
|
1225
|
-
),
|
|
1225
|
+
), T = [];
|
|
1226
1226
|
h.forEach(({ status: P }, te) => {
|
|
1227
|
-
P === "fulfilled" &&
|
|
1228
|
-
}), await m("git pull"),
|
|
1227
|
+
P === "fulfilled" && T.push(g[te]);
|
|
1228
|
+
}), await m("git pull"), T.includes(f) ? (await m(`git checkout -b ${f} origin/${f}`), d.succeed(`项目已切换到初始分支: ${S.blue(f)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
|
|
1229
1229
|
const ee = `cd ${e.projectName} && z start`;
|
|
1230
1230
|
console.log(`输入 ${S.green(ee)} 开始开发吧~`), process.exit(0);
|
|
1231
1231
|
} catch (e) {
|
|
@@ -1246,7 +1246,7 @@ async function ya(e, t) {
|
|
|
1246
1246
|
"commit-msg",
|
|
1247
1247
|
"cm"
|
|
1248
1248
|
/* CommitMsgAbbr */
|
|
1249
|
-
].includes(e) ? i = "commit-msg" : l("参数输入错误") : i = await
|
|
1249
|
+
].includes(e) ? i = "commit-msg" : l("参数输入错误") : i = await k({
|
|
1250
1250
|
message: "请选择你要创建的类型",
|
|
1251
1251
|
choices: [
|
|
1252
1252
|
{
|
|
@@ -1312,20 +1312,24 @@ async function ut(e, t) {
|
|
|
1312
1312
|
ne(), Q(), await me();
|
|
1313
1313
|
let i = e, n = t.platform;
|
|
1314
1314
|
const a = pe();
|
|
1315
|
-
if (a.language === w.JAVA && (n = G.SERVER), i && !Object.values($).includes(i) && l("仅支持发布指定环境分支"), n && !Object.values(G).includes(n) && l("发布平台错误"), n || (n = await
|
|
1315
|
+
if (a.language === w.JAVA && (n = G.SERVER), i && !Object.values($).includes(i) && l("仅支持发布指定环境分支"), n && !Object.values(G).includes(n) && l("发布平台错误"), n || (n = await k({
|
|
1316
1316
|
message: "请选择平台",
|
|
1317
1317
|
choices: Ot
|
|
1318
1318
|
})), n === G.NPM && (i = $.MASTER), !i) {
|
|
1319
|
-
const u = await
|
|
1319
|
+
const u = await k({
|
|
1320
1320
|
message: "请选择部署环境",
|
|
1321
1321
|
choices: qe
|
|
1322
1322
|
});
|
|
1323
|
-
i =
|
|
1323
|
+
i = Ht(u);
|
|
1324
1324
|
}
|
|
1325
1325
|
let s = "";
|
|
1326
1326
|
a.language === w.JAVASCRIPT && (s = zt);
|
|
1327
1327
|
let o = "";
|
|
1328
|
-
if (a.language === w.JAVASCRIPT
|
|
1328
|
+
if (a.language === w.JAVASCRIPT) {
|
|
1329
|
+
const u = Ae();
|
|
1330
|
+
u.name.startsWith("@") && u.name.includes("/") ? o = u.name.split("/").reverse()[0] : o = u.name;
|
|
1331
|
+
}
|
|
1332
|
+
if (a.language === w.JAVA) {
|
|
1329
1333
|
const { projects: u } = await wi(), d = u.find(
|
|
1330
1334
|
(f) => $e(f.url) === $e(a.repository.url)
|
|
1331
1335
|
);
|
|
@@ -1341,7 +1345,7 @@ async function ut(e, t) {
|
|
|
1341
1345
|
const g = f.find((h) => h.value === t.module);
|
|
1342
1346
|
g && (o = g.value);
|
|
1343
1347
|
}
|
|
1344
|
-
o = await
|
|
1348
|
+
o = await k({
|
|
1345
1349
|
message: "请选择部署模块",
|
|
1346
1350
|
choices: f
|
|
1347
1351
|
});
|
|
@@ -1351,7 +1355,7 @@ async function ut(e, t) {
|
|
|
1351
1355
|
t.skipSelectionNotification || (r = await ot("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1352
1356
|
let c = [];
|
|
1353
1357
|
if (t.skipGroupNotification || (c = await na("请选择部署成功要通知的群组:", () => !0, !0)), a.language === w.JAVASCRIPT) {
|
|
1354
|
-
const u =
|
|
1358
|
+
const u = Kt(i);
|
|
1355
1359
|
Na(u, n);
|
|
1356
1360
|
}
|
|
1357
1361
|
await va({
|
|
@@ -1382,7 +1386,7 @@ async function lt(e, t, i, n) {
|
|
|
1382
1386
|
try {
|
|
1383
1387
|
await new Promise((r) => {
|
|
1384
1388
|
setTimeout(r, 5e3);
|
|
1385
|
-
}), await
|
|
1389
|
+
}), await xi({
|
|
1386
1390
|
id: i.id,
|
|
1387
1391
|
iid: s
|
|
1388
1392
|
}), a.succeed(`分支${e}已合并到分支${t}`);
|
|
@@ -1391,7 +1395,7 @@ async function lt(e, t, i, n) {
|
|
|
1391
1395
|
const c = r?.response?.status;
|
|
1392
1396
|
if (c === 406)
|
|
1393
1397
|
return await o();
|
|
1394
|
-
if (await
|
|
1398
|
+
if (await Ii({
|
|
1395
1399
|
id: i.id,
|
|
1396
1400
|
iid: s,
|
|
1397
1401
|
state_event: "close"
|
|
@@ -1437,7 +1441,7 @@ async function Aa(e, t) {
|
|
|
1437
1441
|
};
|
|
1438
1442
|
});
|
|
1439
1443
|
let s;
|
|
1440
|
-
e && !a.filter((c) => c.value === e).length && l(`未找到目标分支${e}`), e ? s = e : s = await
|
|
1444
|
+
e && !a.filter((c) => c.value === e).length && l(`未找到目标分支${e}`), e ? s = e : s = await k({
|
|
1441
1445
|
message: "请选择要合并到的目标分支:",
|
|
1442
1446
|
choices: a
|
|
1443
1447
|
});
|
|
@@ -1450,7 +1454,7 @@ async function Aa(e, t) {
|
|
|
1450
1454
|
), process.exit(1));
|
|
1451
1455
|
} else
|
|
1452
1456
|
await m(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`);
|
|
1453
|
-
await ba(i, s), await lt(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster), $.MASTER === s && !t.keepBranchAfterMergeMaster && (await m(`git checkout ${$.MASTER}`), await m(`git pull origin ${$.MASTER}`), await m(`git branch -d ${i.sourceBranch}`),
|
|
1457
|
+
await ba(i, s), await lt(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster), $.MASTER === s && !t.keepBranchAfterMergeMaster && (await m(`git checkout ${$.MASTER}`), await m(`git pull origin ${$.MASTER}`), await m(`git branch -d ${i.sourceBranch}`), W(
|
|
1454
1458
|
`${i.sourceBranch}分支已移除,当前已切换到最新的${$.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1455
1459
|
)), Object.values($).includes(s) && await ut(s, {
|
|
1456
1460
|
platform: t.deployPlatform,
|
|
@@ -1464,12 +1468,23 @@ async function ja() {
|
|
|
1464
1468
|
try {
|
|
1465
1469
|
await m("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
|
|
1466
1470
|
silent: !1
|
|
1467
|
-
}),
|
|
1471
|
+
}), W("checkstyle执行完毕"), process.exit(0);
|
|
1468
1472
|
} catch {
|
|
1469
1473
|
l("checkstyle执行出错"), process.exit(1);
|
|
1470
1474
|
}
|
|
1471
1475
|
}
|
|
1472
|
-
function Sa() {
|
|
1476
|
+
async function Sa() {
|
|
1477
|
+
v(p.resolve("node_modules", ".bin", "markdownlint")) || l("该项目未安装markdownlint,请安装后重试");
|
|
1478
|
+
const e = y("markdownlint执行中...").start();
|
|
1479
|
+
try {
|
|
1480
|
+
await m('npx markdownlint "**/*.md" --fix', {
|
|
1481
|
+
silent: !1
|
|
1482
|
+
}), e.succeed("markdownlint执行成功"), process.exit(0);
|
|
1483
|
+
} catch {
|
|
1484
|
+
e.fail("markdownlint校验出错"), process.exit(1);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
function ka() {
|
|
1473
1488
|
const e = pe();
|
|
1474
1489
|
if (e["lint-staged"])
|
|
1475
1490
|
return e["lint-staged"];
|
|
@@ -1480,12 +1495,12 @@ async function Ta() {
|
|
|
1480
1495
|
await Et({
|
|
1481
1496
|
concurrent: 4,
|
|
1482
1497
|
debug: !1,
|
|
1483
|
-
config:
|
|
1498
|
+
config: ka(),
|
|
1484
1499
|
quiet: !0,
|
|
1485
1500
|
relative: !0
|
|
1486
1501
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
1487
1502
|
}
|
|
1488
|
-
function
|
|
1503
|
+
function Ea(e) {
|
|
1489
1504
|
if (e.includes("Merge") && e.includes("# Conflicts:") || Ct.valid(e))
|
|
1490
1505
|
return !0;
|
|
1491
1506
|
const t = e.split(": ");
|
|
@@ -1494,11 +1509,11 @@ function ka(e) {
|
|
|
1494
1509
|
const i = t[0];
|
|
1495
1510
|
return /^(feat|fix|refactor)/.test(i) ? /\(\d+(?:,\d+)*\)/.test(i) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(i) ? [j.CHORE, j.CI].includes(i) ? !0 : "chore/ci类型无需填写ID。" : j.Break === i ? !0 : "不存在的提交类型。";
|
|
1496
1511
|
}
|
|
1497
|
-
async function
|
|
1498
|
-
const e = await Ee(p.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), i =
|
|
1512
|
+
async function Ca() {
|
|
1513
|
+
const e = await Ee(p.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), i = Ea(e);
|
|
1499
1514
|
i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
|
|
1500
1515
|
}
|
|
1501
|
-
async function
|
|
1516
|
+
async function Ra() {
|
|
1502
1517
|
await me();
|
|
1503
1518
|
const e = await Rt({
|
|
1504
1519
|
// 分组,展示仓库链接
|
|
@@ -1511,13 +1526,13 @@ async function Ca() {
|
|
|
1511
1526
|
install: "always"
|
|
1512
1527
|
});
|
|
1513
1528
|
if (e && Object.keys(e).length) {
|
|
1514
|
-
|
|
1529
|
+
W("升级完成 🎉");
|
|
1515
1530
|
const t = Object.entries(e).map(([i, n]) => `${i}@${n}`).join("; ");
|
|
1516
1531
|
await m(`git add . && git commit -m "chore: 依赖升级。${t}"`);
|
|
1517
1532
|
}
|
|
1518
1533
|
process.exit(0);
|
|
1519
1534
|
}
|
|
1520
|
-
async function
|
|
1535
|
+
async function xa(e) {
|
|
1521
1536
|
v(p.resolve("node_modules", ".bin", "eslint")) || l("该项目未安装eslint,请安装后重试");
|
|
1522
1537
|
const t = y("eslint执行中...").start();
|
|
1523
1538
|
try {
|
|
@@ -1543,10 +1558,10 @@ async function Ia() {
|
|
|
1543
1558
|
e.fail("prettier校验出错"), process.exit(1);
|
|
1544
1559
|
}
|
|
1545
1560
|
}
|
|
1546
|
-
function
|
|
1561
|
+
function Da() {
|
|
1547
1562
|
v(p.resolve("./node_modules/.bin/vue-tsc")) || l("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), et("npx vue-tsc --build"), process.exit(0);
|
|
1548
1563
|
}
|
|
1549
|
-
async function
|
|
1564
|
+
async function La(e, t) {
|
|
1550
1565
|
ne(), Q();
|
|
1551
1566
|
const i = pe();
|
|
1552
1567
|
let n;
|
|
@@ -1579,7 +1594,11 @@ async function Da(e, t) {
|
|
|
1579
1594
|
"checkstyle",
|
|
1580
1595
|
"cs"
|
|
1581
1596
|
/* CheckStyleAbbr */
|
|
1582
|
-
].includes(e) ? n = "checkstyle" :
|
|
1597
|
+
].includes(e) ? n = "checkstyle" : [
|
|
1598
|
+
"markdown-lint",
|
|
1599
|
+
"ml"
|
|
1600
|
+
/* MarkdownLintAbbr */
|
|
1601
|
+
].includes(e) ? n = "markdown-lint" : l("参数输入错误");
|
|
1583
1602
|
else {
|
|
1584
1603
|
const a = [
|
|
1585
1604
|
{
|
|
@@ -1608,32 +1627,53 @@ async function Da(e, t) {
|
|
|
1608
1627
|
value: "dependency-check"
|
|
1609
1628
|
/* DependencyCheck */
|
|
1610
1629
|
}
|
|
1611
|
-
),
|
|
1630
|
+
), i.language === w.MARKDOWN && a.push(
|
|
1631
|
+
{
|
|
1632
|
+
name: "执行markdown-lint",
|
|
1633
|
+
value: "markdown-lint"
|
|
1634
|
+
/* MarkdownLint */
|
|
1635
|
+
},
|
|
1636
|
+
{
|
|
1637
|
+
name: "执行 eslint",
|
|
1638
|
+
value: "eslint"
|
|
1639
|
+
/* Eslint */
|
|
1640
|
+
},
|
|
1641
|
+
{
|
|
1642
|
+
name: "执行 type-check",
|
|
1643
|
+
value: "type-check"
|
|
1644
|
+
/* TypeCheck */
|
|
1645
|
+
},
|
|
1646
|
+
{
|
|
1647
|
+
name: "执行 dependency-check",
|
|
1648
|
+
value: "dependency-check"
|
|
1649
|
+
/* DependencyCheck */
|
|
1650
|
+
}
|
|
1651
|
+
), n = await k({
|
|
1612
1652
|
message: "请选择你要执行的操作",
|
|
1613
1653
|
choices: a
|
|
1614
1654
|
});
|
|
1615
1655
|
}
|
|
1616
|
-
n === "commit-msg" ? await
|
|
1656
|
+
n === "commit-msg" ? await Ca() : n === "commit-files" ? await Ta() : n === "prettier" ? await Ia() : n === "eslint" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? await xa(t) : n === "type-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? Da() : n === "dependency-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? await Ra() : n === "checkstyle" && i.language === w.JAVA ? await ja() : n === "markdown-lint" && i.language === w.MARKDOWN && await Sa();
|
|
1617
1657
|
}
|
|
1618
|
-
D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle。").argument(
|
|
1658
|
+
D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint。").argument(
|
|
1619
1659
|
"[type]",
|
|
1620
|
-
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs。"
|
|
1621
|
-
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(
|
|
1660
|
+
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs, markdown-lint|ml。"
|
|
1661
|
+
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(La, ...e));
|
|
1622
1662
|
async function mt(e = "latest") {
|
|
1623
1663
|
const t = y("安装中...").start();
|
|
1624
1664
|
await m(`npm i -g ${ie.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", ue("latestCheckVersionTimestamp", Date.now()), ue("version", e), se(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1625
1665
|
}
|
|
1626
1666
|
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(mt, ...e));
|
|
1627
|
-
async function
|
|
1667
|
+
async function Oa(e) {
|
|
1628
1668
|
let t = e;
|
|
1629
|
-
t ? [b.DEV, b.TEST, b.RELEASE, b.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = b.DEV : t === "t" ? t = b.TEST : t === "r" ? t = b.RELEASE : t === "p" && (t = b.PROD) : l("参数输入有误") : t = await
|
|
1669
|
+
t ? [b.DEV, b.TEST, b.RELEASE, b.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = b.DEV : t === "t" ? t = b.TEST : t === "r" ? t = b.RELEASE : t === "p" && (t = b.PROD) : l("参数输入有误") : t = await k({
|
|
1630
1670
|
message: "请选择环境",
|
|
1631
1671
|
choices: qe
|
|
1632
1672
|
});
|
|
1633
1673
|
const i = Ae(), n = `dev:${t}`;
|
|
1634
1674
|
i.scripts[n] ? et(`npm run ${n}`) : l(`项目中(package.json > scripts)不存在命令${n},请先添加!`);
|
|
1635
1675
|
}
|
|
1636
|
-
D.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(
|
|
1676
|
+
D.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(Oa, ...e));
|
|
1637
1677
|
const De = /Thumbs\.db|\.git|DS_Store|idea/, pt = "testcase";
|
|
1638
1678
|
function dt(e) {
|
|
1639
1679
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
@@ -1661,7 +1701,7 @@ async function X(e, t = {}) {
|
|
|
1661
1701
|
if ((await At(s)).isFile())
|
|
1662
1702
|
return null;
|
|
1663
1703
|
const c = await Re(s, { withFileTypes: !0 }), u = (await Promise.all(
|
|
1664
|
-
c.filter((
|
|
1704
|
+
c.filter((T) => T.isDirectory() && !i.test(T.name)).map((T) => a(p.join(s, T.name)))
|
|
1665
1705
|
)).filter(Boolean), { type: d, id: f, displayName: g } = dt(o), h = {
|
|
1666
1706
|
name: o,
|
|
1667
1707
|
id: f,
|
|
@@ -1694,7 +1734,7 @@ async function ft(e, t = {}) {
|
|
|
1694
1734
|
return l(`读取目录失败: ${e} : ${n}`), [];
|
|
1695
1735
|
}
|
|
1696
1736
|
}
|
|
1697
|
-
function
|
|
1737
|
+
function V(e, t, i) {
|
|
1698
1738
|
switch (e) {
|
|
1699
1739
|
case "module":
|
|
1700
1740
|
return i ? `${t}[${i}]` : t;
|
|
@@ -1706,22 +1746,22 @@ function W(e, t, i) {
|
|
|
1706
1746
|
}
|
|
1707
1747
|
async function we(e, t, i, n) {
|
|
1708
1748
|
try {
|
|
1709
|
-
const a = p.basename(e), s =
|
|
1749
|
+
const a = p.basename(e), s = V(i, t, n);
|
|
1710
1750
|
if (a === s)
|
|
1711
1751
|
return !0;
|
|
1712
1752
|
const o = p.dirname(e), r = p.join(o, s);
|
|
1713
|
-
return await
|
|
1753
|
+
return await Zt(e) ? await _e(e, r) : (await m(`git mv "${e}" "${r}"`), await m("git add .")), !0;
|
|
1714
1754
|
} catch (a) {
|
|
1715
1755
|
return l(`重命名文件夹失败: ${e} -> ${t}。${a}`), !1;
|
|
1716
1756
|
}
|
|
1717
1757
|
}
|
|
1718
|
-
async function
|
|
1758
|
+
async function Pa(e, t, i = {}) {
|
|
1719
1759
|
const { exclude: n = De } = i;
|
|
1720
1760
|
async function a(s, o) {
|
|
1721
1761
|
if (!s || s.length === 0) return;
|
|
1722
1762
|
const r = await ft(o, { exclude: n });
|
|
1723
1763
|
for (const c of s) {
|
|
1724
|
-
const u = String(c.value), d =
|
|
1764
|
+
const u = String(c.value), d = V("module", c.label, u), f = r.find((h) => h.id === u);
|
|
1725
1765
|
let g = f?.path || p.join(o, d);
|
|
1726
1766
|
f ? f.displayName !== c.label && await we(f.path, c.label, "module", u) && (g = p.join(o, d)) : (await le(g, { recursive: !0 }), await m(`git add "${g}"`)), c.children && c.children.length > 0 && await a(c.children, g);
|
|
1727
1767
|
}
|
|
@@ -1738,7 +1778,7 @@ async function gt(e) {
|
|
|
1738
1778
|
Number.isNaN(Number(e)) && l("请输入正确的产品ID"), t.id = Number(e);
|
|
1739
1779
|
else {
|
|
1740
1780
|
const i = await Bi();
|
|
1741
|
-
t.id = await
|
|
1781
|
+
t.id = await k({
|
|
1742
1782
|
message: "请选择产品",
|
|
1743
1783
|
choices: i.map((n) => ({
|
|
1744
1784
|
name: `${n.label}[${n.value}]`,
|
|
@@ -1746,7 +1786,7 @@ async function gt(e) {
|
|
|
1746
1786
|
}))
|
|
1747
1787
|
});
|
|
1748
1788
|
}
|
|
1749
|
-
return t.name = await
|
|
1789
|
+
return t.name = await Fi(t.id), t.path = p.join(pt, V("module", t.name, String(t.id))), t;
|
|
1750
1790
|
}
|
|
1751
1791
|
async function Le(e) {
|
|
1752
1792
|
return (await ft(pt)).find((i) => Number(i.id) === e.id);
|
|
@@ -1757,19 +1797,19 @@ async function ht(e, t) {
|
|
|
1757
1797
|
priority: e.pri,
|
|
1758
1798
|
steps: []
|
|
1759
1799
|
};
|
|
1760
|
-
i.steps = await _i(e.id),
|
|
1800
|
+
i.steps = await _i(e.id), x.writeJSONSync(t, i, {
|
|
1761
1801
|
spaces: 2
|
|
1762
1802
|
});
|
|
1763
1803
|
}
|
|
1764
1804
|
async function wt(e, t) {
|
|
1765
1805
|
await le(t, {
|
|
1766
1806
|
recursive: !0
|
|
1767
|
-
}), await ht(e, p.join(t, "config.json")),
|
|
1807
|
+
}), await ht(e, p.join(t, "config.json")), x.ensureFileSync(p.join(t, "data.yaml")), await L(
|
|
1768
1808
|
p.join(t, "data.yaml"),
|
|
1769
|
-
v(p.resolve(
|
|
1770
|
-
),
|
|
1809
|
+
v(p.resolve(Z, "data.yaml")) ? await Ee(p.resolve(Z, "data.yaml")) : await bi()
|
|
1810
|
+
), x.ensureFileSync(p.join(t, "main.py")), await L(
|
|
1771
1811
|
p.join(t, "main.py"),
|
|
1772
|
-
v(p.resolve(
|
|
1812
|
+
v(p.resolve(Z, "main.py")) ? await Ee(p.resolve(Z, "main.py")) : await Ai()
|
|
1773
1813
|
);
|
|
1774
1814
|
}
|
|
1775
1815
|
function Oe(e) {
|
|
@@ -1785,7 +1825,7 @@ function Oe(e) {
|
|
|
1785
1825
|
async function je(e, t) {
|
|
1786
1826
|
ne(), Q(), await me();
|
|
1787
1827
|
let i;
|
|
1788
|
-
t ? ([R.MODULE, R.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${R.MODULE} 或者 ${R.CASE}。`), i = t) : i = await
|
|
1828
|
+
t ? ([R.MODULE, R.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${R.MODULE} 或者 ${R.CASE}。`), i = t) : i = await k({
|
|
1789
1829
|
message: `请选择要${e}的数据类型`,
|
|
1790
1830
|
choices: Bt
|
|
1791
1831
|
});
|
|
@@ -1802,12 +1842,12 @@ async function Se(e) {
|
|
|
1802
1842
|
localProduct: i
|
|
1803
1843
|
};
|
|
1804
1844
|
}
|
|
1805
|
-
async function
|
|
1845
|
+
async function Ma(e, t, i) {
|
|
1806
1846
|
e.text = "查找本地产品目录...", await Le(t) || l(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
1807
1847
|
const a = Oe(i);
|
|
1808
1848
|
let s = await X(t.path);
|
|
1809
1849
|
e.text = "获取远程用例列表...";
|
|
1810
|
-
const o = await
|
|
1850
|
+
const o = await Ji(t.id, a);
|
|
1811
1851
|
e.text = "本地用例同步中...";
|
|
1812
1852
|
for (const r of o) {
|
|
1813
1853
|
let c;
|
|
@@ -1815,26 +1855,26 @@ async function Pa(e, t, i) {
|
|
|
1815
1855
|
return l(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
1816
1856
|
const u = s.find(({ id: d }) => r.id === Number(d));
|
|
1817
1857
|
if (u)
|
|
1818
|
-
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) &&
|
|
1858
|
+
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && W(`重命名成功: ${u.displayName} -> ${r.title}`), s = await X(t.path), r.module === 0 ? c = p.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await ht(
|
|
1819
1859
|
r,
|
|
1820
|
-
p.join(c,
|
|
1860
|
+
p.join(c, V("case", r.title, String(r.id)), "config.json")
|
|
1821
1861
|
);
|
|
1822
1862
|
else {
|
|
1823
|
-
const d = p.join(c,
|
|
1863
|
+
const d = p.join(c, V("case", r.title, String(r.id)));
|
|
1824
1864
|
await wt(r, d);
|
|
1825
1865
|
}
|
|
1826
1866
|
}
|
|
1827
1867
|
}
|
|
1828
|
-
async function
|
|
1868
|
+
async function za(e, t) {
|
|
1829
1869
|
e.text = "本地产品目录查找中...";
|
|
1830
1870
|
const i = await Le(t);
|
|
1831
1871
|
i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await we(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await le(t.path, { recursive: !0 }), await m("git add .")), e.text = "获取远程模块列表...";
|
|
1832
1872
|
const n = await st(t.id);
|
|
1833
|
-
e.text = "本地同步模块中...", await
|
|
1873
|
+
e.text = "本地同步模块中...", await Pa(n || [], t.path);
|
|
1834
1874
|
}
|
|
1835
|
-
async function
|
|
1875
|
+
async function Ba(e, t) {
|
|
1836
1876
|
const { type: i, typeStr: n } = await je("拉取", e), a = await gt(t.productId), s = y(`${n}同步中...`).start();
|
|
1837
|
-
if (R.MODULE === i && await
|
|
1877
|
+
if (R.MODULE === i && await za(s, a), R.CASE === i && await Ma(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await m("git status -s")) {
|
|
1838
1878
|
const o = y("代码提交中...").start();
|
|
1839
1879
|
try {
|
|
1840
1880
|
await m(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
|
|
@@ -1843,9 +1883,9 @@ async function za(e, t) {
|
|
|
1843
1883
|
}
|
|
1844
1884
|
}
|
|
1845
1885
|
}
|
|
1846
|
-
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(
|
|
1847
|
-
async function
|
|
1848
|
-
let n = await
|
|
1886
|
+
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(Ba, ...e));
|
|
1887
|
+
async function Fa(e, t, i) {
|
|
1888
|
+
let n = await J({
|
|
1849
1889
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
1850
1890
|
});
|
|
1851
1891
|
n = n.trim();
|
|
@@ -1860,14 +1900,14 @@ async function Ba(e, t, i) {
|
|
|
1860
1900
|
openedBy: E("ldapAccount"),
|
|
1861
1901
|
precondition: n || ""
|
|
1862
1902
|
});
|
|
1863
|
-
a.text = "远程用例步骤创建中...", await
|
|
1903
|
+
a.text = "远程用例步骤创建中...", await Wi({
|
|
1864
1904
|
case: s,
|
|
1865
1905
|
type: "step",
|
|
1866
1906
|
desc: "按照预期执行",
|
|
1867
1907
|
expect: "正常执行,符合预期"
|
|
1868
1908
|
}), a.text = "本地用例创建中...";
|
|
1869
|
-
const o = p.join(t.path,
|
|
1870
|
-
return v(o) ?
|
|
1909
|
+
const o = p.join(t.path, V("case", i, String(s)));
|
|
1910
|
+
return v(o) ? W(`${o}已存在,请检查是否对应,本地不再创建。`) : (await wt(
|
|
1871
1911
|
{
|
|
1872
1912
|
id: s,
|
|
1873
1913
|
pri: 3,
|
|
@@ -1886,14 +1926,14 @@ async function Ja(e, t, i) {
|
|
|
1886
1926
|
parent: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
|
|
1887
1927
|
});
|
|
1888
1928
|
n.text = "本地模块创建中...";
|
|
1889
|
-
const s = p.join(t.path,
|
|
1929
|
+
const s = p.join(t.path, V("module", i, String(a)));
|
|
1890
1930
|
if (v(s))
|
|
1891
|
-
return
|
|
1931
|
+
return W(`${s}已存在,请检查是否对应,本地不再创建。`);
|
|
1892
1932
|
await le(s, {
|
|
1893
1933
|
recursive: !0
|
|
1894
1934
|
}), n.succeed(`模块【${s}】创建完成 🎉`);
|
|
1895
1935
|
}
|
|
1896
|
-
function
|
|
1936
|
+
function _a(e) {
|
|
1897
1937
|
function t(n) {
|
|
1898
1938
|
if (!n.children || n.children.length === 0) return;
|
|
1899
1939
|
const a = n.children[0];
|
|
@@ -1906,7 +1946,7 @@ function Fa(e) {
|
|
|
1906
1946
|
});
|
|
1907
1947
|
}
|
|
1908
1948
|
async function i(n, a = []) {
|
|
1909
|
-
const s = a.length ? `请选择层级(当前:${a.join(" / ")})` : "请选择层级", o = await
|
|
1949
|
+
const s = a.length ? `请选择层级(当前:${a.join(" / ")})` : "请选择层级", o = await k({
|
|
1910
1950
|
message: s,
|
|
1911
1951
|
choices: n.map((r) => ({
|
|
1912
1952
|
name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
|
|
@@ -1917,28 +1957,28 @@ function Fa(e) {
|
|
|
1917
1957
|
}
|
|
1918
1958
|
return i(e);
|
|
1919
1959
|
}
|
|
1920
|
-
async function
|
|
1921
|
-
const { type: i, typeStr: n } = await je("创建", e), { product: a, localProduct: s } = await Se(t.productId), o = await st(a.id), r = await
|
|
1960
|
+
async function Ua(e, t) {
|
|
1961
|
+
const { type: i, typeStr: n } = await je("创建", e), { product: a, localProduct: s } = await Se(t.productId), o = await st(a.id), r = await _a(o), c = V("module", r.label, String(r.value)), d = (await X(a.path, { hasRoot: !0 })).find((h) => h.name === c);
|
|
1922
1962
|
if (!d?.path || !v(d.path))
|
|
1923
1963
|
return l(`本地不存在${c}模块`);
|
|
1924
|
-
let f = await
|
|
1964
|
+
let f = await J({
|
|
1925
1965
|
message: `请输入你要创建的${n}名称`,
|
|
1926
1966
|
required: !0,
|
|
1927
1967
|
validate: (h) => h.length > 0 && h.length < 255
|
|
1928
1968
|
});
|
|
1929
1969
|
f = f.trim();
|
|
1930
1970
|
let g = "";
|
|
1931
|
-
if (R.MODULE === i && await Ja(s, d, f), R.CASE === i && (g = await
|
|
1971
|
+
if (R.MODULE === i && await Ja(s, d, f), R.CASE === i && (g = await Fa(s, d, f)), !t.disableAutoCommit && R.CASE === i) {
|
|
1932
1972
|
const h = y("代码提交中...").start();
|
|
1933
1973
|
try {
|
|
1934
1974
|
await m(`git add . && git commit -m "chore: 创建了用例${p.basename(g)}"`), h.succeed("代码已提交 ✅");
|
|
1935
|
-
} catch (
|
|
1936
|
-
h.fail(`提交失败,${
|
|
1975
|
+
} catch (T) {
|
|
1976
|
+
h.fail(`提交失败,${T}`), process.exit(1);
|
|
1937
1977
|
}
|
|
1938
1978
|
}
|
|
1939
1979
|
}
|
|
1940
|
-
D.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(
|
|
1941
|
-
async function
|
|
1980
|
+
D.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(Ua, ...e));
|
|
1981
|
+
async function Ga(e, t) {
|
|
1942
1982
|
const n = (await X(e.path)).filter((r) => r.type === "case");
|
|
1943
1983
|
let a = [];
|
|
1944
1984
|
if (t.length)
|
|
@@ -1973,7 +2013,7 @@ async function Ua(e, t) {
|
|
|
1973
2013
|
v(r.path) && O.rm("-rf", r.path);
|
|
1974
2014
|
return s.succeed("用例删除完成"), o;
|
|
1975
2015
|
}
|
|
1976
|
-
async function
|
|
2016
|
+
async function Wa(e, t) {
|
|
1977
2017
|
const n = (await X(e.path)).filter((r) => r.type === "module");
|
|
1978
2018
|
let a = [];
|
|
1979
2019
|
if (t.length)
|
|
@@ -2001,7 +2041,7 @@ async function Ga(e, t) {
|
|
|
2001
2041
|
}
|
|
2002
2042
|
a = a.sort((r, c) => r.path.localeCompare(c.path));
|
|
2003
2043
|
const s = y("远程模块删除中...").start(), o = a.map((r) => r.id);
|
|
2004
|
-
await
|
|
2044
|
+
await Vi({
|
|
2005
2045
|
product: Number(e.id),
|
|
2006
2046
|
moduleIds: o
|
|
2007
2047
|
}), s.text = "本地模块删除中...";
|
|
@@ -2012,7 +2052,7 @@ async function Ga(e, t) {
|
|
|
2012
2052
|
async function Va(e, t) {
|
|
2013
2053
|
const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await Se(t.productId), s = Oe(t.targetIds);
|
|
2014
2054
|
let o = [];
|
|
2015
|
-
if (R.MODULE === i ? o = await
|
|
2055
|
+
if (R.MODULE === i ? o = await Wa(a, s) : R.CASE === i && (o = await Ga(a, s)), !t.disableAutoCommit && await m("git status -s")) {
|
|
2016
2056
|
const r = y("代码提交中...").start();
|
|
2017
2057
|
try {
|
|
2018
2058
|
await m(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
@@ -2022,7 +2062,7 @@ async function Va(e, t) {
|
|
|
2022
2062
|
}
|
|
2023
2063
|
}
|
|
2024
2064
|
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(Va, ...e));
|
|
2025
|
-
async function
|
|
2065
|
+
async function qa(e, t) {
|
|
2026
2066
|
const n = (await X(e.path)).filter((g) => g.type === "case");
|
|
2027
2067
|
let a;
|
|
2028
2068
|
if (t.targetId) {
|
|
@@ -2042,13 +2082,13 @@ async function Wa(e, t) {
|
|
|
2042
2082
|
pageSize: 100,
|
|
2043
2083
|
loop: !1,
|
|
2044
2084
|
multiple: void 0,
|
|
2045
|
-
options: (h) => h ? g.filter((
|
|
2085
|
+
options: (h) => h ? g.filter((T) => T.name.includes(h)) : g,
|
|
2046
2086
|
validate(h) {
|
|
2047
2087
|
return h.length > 1 ? "只能选一个" : h.length < 1 ? "请选一个" : !0;
|
|
2048
2088
|
}
|
|
2049
2089
|
});
|
|
2050
2090
|
}
|
|
2051
|
-
let s = await
|
|
2091
|
+
let s = await J({
|
|
2052
2092
|
message: "修改用例名称",
|
|
2053
2093
|
default: a.displayName,
|
|
2054
2094
|
required: !0,
|
|
@@ -2057,11 +2097,11 @@ async function Wa(e, t) {
|
|
|
2057
2097
|
});
|
|
2058
2098
|
s = s.trim();
|
|
2059
2099
|
const o = y("用例重命名中...").start();
|
|
2060
|
-
s !== a.displayName ? (await
|
|
2100
|
+
s !== a.displayName ? (await Hi({
|
|
2061
2101
|
id: Number(a.id),
|
|
2062
2102
|
name: s
|
|
2063
|
-
}), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path = p.join(p.dirname(a.path),
|
|
2064
|
-
let r =
|
|
2103
|
+
}), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path = p.join(p.dirname(a.path), V("case", s, String(a.id)))) : o.succeed("用例名称无变动");
|
|
2104
|
+
let r = x.readJsonSync(p.join(a.path, "config.json")), c;
|
|
2065
2105
|
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await ze({
|
|
2066
2106
|
message: "修改用例优先级",
|
|
2067
2107
|
min: 1,
|
|
@@ -2078,19 +2118,19 @@ async function Wa(e, t) {
|
|
|
2078
2118
|
validate: (g) => g > 0 && g < 6
|
|
2079
2119
|
});
|
|
2080
2120
|
const u = y("用例优先级设置中...").start();
|
|
2081
|
-
c !== r.priority ? (await
|
|
2121
|
+
c !== r.priority ? (await Zi({
|
|
2082
2122
|
id: Number(a.id),
|
|
2083
2123
|
priority: c
|
|
2084
|
-
}),
|
|
2124
|
+
}), x.writeJSONSync(
|
|
2085
2125
|
p.join(a.path, "config.json"),
|
|
2086
2126
|
{
|
|
2087
2127
|
...r,
|
|
2088
2128
|
priority: c
|
|
2089
2129
|
},
|
|
2090
2130
|
{ spaces: 2 }
|
|
2091
|
-
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r =
|
|
2131
|
+
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = x.readJsonSync(p.join(a.path, "config.json"));
|
|
2092
2132
|
let d;
|
|
2093
|
-
t.casePrecondition ? d = t.casePrecondition : (d = await
|
|
2133
|
+
t.casePrecondition ? d = t.casePrecondition : (d = await J({
|
|
2094
2134
|
message: "修改用例前置条件",
|
|
2095
2135
|
default: r.precondition,
|
|
2096
2136
|
prefill: "editable"
|
|
@@ -2099,7 +2139,7 @@ async function Wa(e, t) {
|
|
|
2099
2139
|
return d !== r.precondition ? (await Yi({
|
|
2100
2140
|
id: Number(a.id),
|
|
2101
2141
|
precondition: d
|
|
2102
|
-
}),
|
|
2142
|
+
}), x.writeJSONSync(
|
|
2103
2143
|
p.join(a.path, "config.json"),
|
|
2104
2144
|
{
|
|
2105
2145
|
...r,
|
|
@@ -2108,7 +2148,7 @@ async function Wa(e, t) {
|
|
|
2108
2148
|
{ spaces: 2 }
|
|
2109
2149
|
), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : f.succeed("用例前置条件无变动"), a.id;
|
|
2110
2150
|
}
|
|
2111
|
-
async function
|
|
2151
|
+
async function Ka(e, t) {
|
|
2112
2152
|
const n = (await X(e.path)).filter((r) => r.type === "module");
|
|
2113
2153
|
let a;
|
|
2114
2154
|
if (t.targetId) {
|
|
@@ -2134,7 +2174,7 @@ async function qa(e, t) {
|
|
|
2134
2174
|
}
|
|
2135
2175
|
});
|
|
2136
2176
|
}
|
|
2137
|
-
let s = await
|
|
2177
|
+
let s = await J({
|
|
2138
2178
|
message: "修改模块名称",
|
|
2139
2179
|
default: a.displayName,
|
|
2140
2180
|
required: !0,
|
|
@@ -2143,7 +2183,7 @@ async function qa(e, t) {
|
|
|
2143
2183
|
});
|
|
2144
2184
|
s = s.trim();
|
|
2145
2185
|
const o = y("模块重命名中...").start();
|
|
2146
|
-
return s !== a.displayName ? (await
|
|
2186
|
+
return s !== a.displayName ? (await Ki({
|
|
2147
2187
|
id: Number(a.id),
|
|
2148
2188
|
name: s
|
|
2149
2189
|
}), await we(a.path, s, "module", String(a.id)) && o.succeed(`模块重命名成功: ${a.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), a.id;
|
|
@@ -2151,7 +2191,7 @@ async function qa(e, t) {
|
|
|
2151
2191
|
async function Ha(e, t) {
|
|
2152
2192
|
const { type: i, typeStr: n } = await je("修改", e), { localProduct: a } = await Se(t.productId);
|
|
2153
2193
|
let s;
|
|
2154
|
-
if (R.MODULE === i ? s = await
|
|
2194
|
+
if (R.MODULE === i ? s = await Ka(a, t) : R.CASE === i && (s = await qa(a, t)), !t.disableAutoCommit && await m("git status -s")) {
|
|
2155
2195
|
const o = y("代码提交中...").start();
|
|
2156
2196
|
try {
|
|
2157
2197
|
await m(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
|
|
@@ -2164,7 +2204,7 @@ D.command("qa-update").alias("qu").description("修改模块或者用例").argum
|
|
|
2164
2204
|
async function Za(e, t) {
|
|
2165
2205
|
if (!e.length)
|
|
2166
2206
|
return [];
|
|
2167
|
-
const i =
|
|
2207
|
+
const i = xt(20), n = e.map(
|
|
2168
2208
|
(a) => i(async () => {
|
|
2169
2209
|
try {
|
|
2170
2210
|
const s = t.env || "production", o = await m(`python ${a.path}/main.py --env ${s}`);
|
|
@@ -2181,7 +2221,7 @@ async function Za(e, t) {
|
|
|
2181
2221
|
);
|
|
2182
2222
|
return await Promise.all(n), e;
|
|
2183
2223
|
}
|
|
2184
|
-
async function
|
|
2224
|
+
async function Ya(e) {
|
|
2185
2225
|
ne(), Q();
|
|
2186
2226
|
const { localProduct: t } = await Se(e.productId);
|
|
2187
2227
|
let i = [];
|
|
@@ -2225,20 +2265,20 @@ async function Ka(e) {
|
|
|
2225
2265
|
s.succeed("所有用例执行通过 🎉");
|
|
2226
2266
|
else {
|
|
2227
2267
|
if (e.processStep === "1")
|
|
2228
|
-
return
|
|
2268
|
+
return W("执行报告如下:"), console.log(JSON.stringify(r, null, 2)), process.exit(0);
|
|
2229
2269
|
const c = r.reduce((f, g) => f + g.result.length, 0);
|
|
2230
2270
|
s.warn(`【${r.length}】个用例执行出错,【${c}】个BUG将创建。`);
|
|
2231
2271
|
let u = 0;
|
|
2232
2272
|
if (e.executionId)
|
|
2233
2273
|
Number.isNaN(Number(e.executionId)) && l(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
|
|
2234
2274
|
else {
|
|
2235
|
-
const f = await Qi(), g = await
|
|
2275
|
+
const f = await Qi(), g = await k({
|
|
2236
2276
|
message: "请选择用例执行出错后,BUG所属的项目",
|
|
2237
|
-
choices: f.map(({ id:
|
|
2277
|
+
choices: f.map(({ id: T, name: ee }) => ({ name: ee, value: T }))
|
|
2238
2278
|
}), h = await ea(g);
|
|
2239
|
-
u = await
|
|
2279
|
+
u = await k({
|
|
2240
2280
|
message: "请选择用例执行出错后,BUG所属的执行",
|
|
2241
|
-
choices: h.map(({ id:
|
|
2281
|
+
choices: h.map(({ id: T, name: ee }) => ({ name: ee, value: T }))
|
|
2242
2282
|
});
|
|
2243
2283
|
}
|
|
2244
2284
|
let d;
|
|
@@ -2250,9 +2290,9 @@ async function Ka(e) {
|
|
|
2250
2290
|
const g = await Ce({
|
|
2251
2291
|
message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
|
|
2252
2292
|
required: !1,
|
|
2253
|
-
choices: f.map(({ id: h, name:
|
|
2293
|
+
choices: f.map(({ id: h, name: T, date: ee, builder: P }) => ({
|
|
2254
2294
|
value: h,
|
|
2255
|
-
name: `${
|
|
2295
|
+
name: `${T} ${P} ${ee}`
|
|
2256
2296
|
}))
|
|
2257
2297
|
});
|
|
2258
2298
|
g.length ? d = g.join(",") : d = "";
|
|
@@ -2274,17 +2314,17 @@ async function Ka(e) {
|
|
|
2274
2314
|
);
|
|
2275
2315
|
}
|
|
2276
2316
|
}
|
|
2277
|
-
D.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。默认主干(trunk)").action((...e) => z(
|
|
2278
|
-
function
|
|
2317
|
+
D.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。默认主干(trunk)").action((...e) => z(Ya, ...e));
|
|
2318
|
+
function Xa() {
|
|
2279
2319
|
process.on("unhandledRejection", (e) => {
|
|
2280
2320
|
}), process.on("uncaughtException", (e) => {
|
|
2281
2321
|
}), O.config.fatal = !0, O.config.silent = !0, O.config.verbose = !1;
|
|
2282
2322
|
}
|
|
2283
|
-
async function
|
|
2323
|
+
async function Qa() {
|
|
2284
2324
|
const e = ge("latestCheckVersionTimestamp"), t = ge("versionCheckDuring");
|
|
2285
2325
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
2286
2326
|
const i = await at();
|
|
2287
|
-
|
|
2327
|
+
xe(i);
|
|
2288
2328
|
let n;
|
|
2289
2329
|
try {
|
|
2290
2330
|
const a = "TIME_OUT", s = new Promise((o) => {
|
|
@@ -2299,17 +2339,17 @@ async function Xa() {
|
|
|
2299
2339
|
}
|
|
2300
2340
|
}
|
|
2301
2341
|
}
|
|
2302
|
-
async function
|
|
2303
|
-
const e =
|
|
2342
|
+
async function en() {
|
|
2343
|
+
const e = It(process.argv.slice(2));
|
|
2304
2344
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2305
2345
|
if (Ye()) {
|
|
2306
|
-
const t =
|
|
2307
|
-
M(t.profile), ue(t.main),
|
|
2346
|
+
const t = x.readJSONSync(be());
|
|
2347
|
+
M(t.profile), ue(t.main), xe(t.constants), await Qa();
|
|
2308
2348
|
} else
|
|
2309
|
-
l(`请先初始化z-develop(执行 z i)。更多见${
|
|
2349
|
+
l(`请先初始化z-develop(执行 z i)。更多见${Ke}`);
|
|
2310
2350
|
}
|
|
2311
|
-
async function
|
|
2312
|
-
|
|
2351
|
+
async function tn() {
|
|
2352
|
+
Xa(), await en();
|
|
2313
2353
|
}
|
|
2314
|
-
D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(
|
|
2354
|
+
D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(Ke)}`).usage("<command> [options]").hook("preAction", tn).version(ie.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
2315
2355
|
D.parse();
|