cli-z-develop 0.10.4 → 0.10.5
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 +330 -309
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { program as I } from "commander";
|
|
2
2
|
import $t from "node:child_process";
|
|
3
3
|
import { existsSync as $, readdirSync as vt, lstatSync as bt } from "node:fs";
|
|
4
|
-
import { readdir as Ee, mkdir as oe, writeFile as z, rename as
|
|
4
|
+
import { readdir as Ee, mkdir as oe, writeFile as z, rename as Fe, readFile as Ae, stat as Nt } from "node:fs/promises";
|
|
5
5
|
import p from "node:path";
|
|
6
6
|
import le, { AxiosError as St } from "axios";
|
|
7
7
|
import N from "chalk";
|
|
8
8
|
import jt from "dayjs";
|
|
9
9
|
import D from "shelljs";
|
|
10
10
|
import At from "node:os";
|
|
11
|
-
import
|
|
12
|
-
import { confirm as Be, select as E, input as
|
|
11
|
+
import Oe from "child_process";
|
|
12
|
+
import { confirm as Be, select as E, input as _, password as Et, checkbox as Pe, number as Me } from "@inquirer/prompts";
|
|
13
13
|
import h from "ora";
|
|
14
14
|
import S from "fs-extra";
|
|
15
15
|
import { select as ee } from "inquirer-select-pro";
|
|
@@ -55,7 +55,7 @@ const We = [
|
|
|
55
55
|
}
|
|
56
56
|
];
|
|
57
57
|
var ue = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(ue || {}), se = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(se || {}), x = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e))(x || {});
|
|
58
|
-
const
|
|
58
|
+
const Ot = {
|
|
59
59
|
1: "研发",
|
|
60
60
|
2: "测试",
|
|
61
61
|
3: "产品",
|
|
@@ -65,7 +65,7 @@ const Pt = {
|
|
|
65
65
|
7: "行政",
|
|
66
66
|
8: "财务",
|
|
67
67
|
9: "其他"
|
|
68
|
-
}, pe = "http://git.cxlqd.com",
|
|
68
|
+
}, pe = "http://git.cxlqd.com", Pt = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
69
69
|
var b = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(b || {});
|
|
70
70
|
const Mt = "fe-biz7tvsd", qe = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
71
71
|
var j = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(j || {});
|
|
@@ -80,7 +80,7 @@ const zt = [
|
|
|
80
80
|
value: "case"
|
|
81
81
|
/* CASE */
|
|
82
82
|
}
|
|
83
|
-
],
|
|
83
|
+
], _t = ".z", Ft = "develop-config.json", V = ".z", Bt = ".commit-msg-tpl", Ut = "project.json";
|
|
84
84
|
function k(e = "") {
|
|
85
85
|
return p.join(V, e);
|
|
86
86
|
}
|
|
@@ -91,13 +91,13 @@ function we() {
|
|
|
91
91
|
return k(Bt);
|
|
92
92
|
}
|
|
93
93
|
function Ve() {
|
|
94
|
-
|
|
94
|
+
Oe.spawnSync("git", ["config", "core.hooksPath", k()]), Oe.spawnSync("git", ["config", "commit.template", we()]);
|
|
95
95
|
}
|
|
96
96
|
function de(e = "") {
|
|
97
|
-
return p.resolve(At.homedir(),
|
|
97
|
+
return p.resolve(At.homedir(), _t, e);
|
|
98
98
|
}
|
|
99
99
|
function ye() {
|
|
100
|
-
return de(
|
|
100
|
+
return de(Ft);
|
|
101
101
|
}
|
|
102
102
|
function Jt() {
|
|
103
103
|
return $(de());
|
|
@@ -111,8 +111,8 @@ function Ze(e) {
|
|
|
111
111
|
if (i)
|
|
112
112
|
t = i[2];
|
|
113
113
|
else {
|
|
114
|
-
const
|
|
115
|
-
t = t.replace(/^https?:\/\//, ""), t.startsWith(`${
|
|
114
|
+
const a = pe.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
115
|
+
t = t.replace(/^https?:\/\//, ""), t.startsWith(`${a}/`) ? t = t.slice(a.length + 1) : t = t.replace(`${pe.replace(/\/$/, "")}/`, "");
|
|
116
116
|
}
|
|
117
117
|
return encodeURIComponent(t.replace(/\.git$/, ""));
|
|
118
118
|
}
|
|
@@ -133,24 +133,24 @@ function m(e, t = !1) {
|
|
|
133
133
|
let i = e;
|
|
134
134
|
e instanceof Error ? (i = e.message, le.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(ze(i)), console.log(Wt(e.stack))) : console.log(ze(e)), t || process.exit(1);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function _e(e) {
|
|
137
137
|
return $(e) ? bt(e).isDirectory() : !1;
|
|
138
138
|
}
|
|
139
139
|
function Qe(e = process.cwd()) {
|
|
140
|
-
return
|
|
140
|
+
return _e(e) ? vt(e).filter((i) => _e(p.resolve(e, i))) : [];
|
|
141
141
|
}
|
|
142
142
|
async function l(e, t = {
|
|
143
143
|
removeTailLinkBreak: !0,
|
|
144
144
|
silent: !0
|
|
145
145
|
}) {
|
|
146
|
-
let i = await new Promise((
|
|
146
|
+
let i = await new Promise((a, n) => {
|
|
147
147
|
try {
|
|
148
148
|
const s = D.exec(e, {
|
|
149
149
|
silent: t.silent
|
|
150
150
|
});
|
|
151
|
-
n(s);
|
|
152
|
-
} catch (s) {
|
|
153
151
|
a(s);
|
|
152
|
+
} catch (s) {
|
|
153
|
+
n(s);
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
return i = i.toString(), t.removeTailLinkBreak && (i = i.replace(/\n$/, "")), i;
|
|
@@ -184,7 +184,7 @@ function Zt(e) {
|
|
|
184
184
|
function Kt(e) {
|
|
185
185
|
return e === v.PROD ? y.MASTER : e;
|
|
186
186
|
}
|
|
187
|
-
async function
|
|
187
|
+
async function O(e, ...t) {
|
|
188
188
|
try {
|
|
189
189
|
await e(...t);
|
|
190
190
|
} catch (i) {
|
|
@@ -309,16 +309,37 @@ dist/
|
|
|
309
309
|
// "**/*.{py}": "python --fix",
|
|
310
310
|
"**/*.{py}": "echo 'todo'"
|
|
311
311
|
}
|
|
312
|
-
}, ii = `
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
312
|
+
}, ii = `
|
|
313
|
+
- case_id: 1
|
|
314
|
+
name: "用例描述"
|
|
315
|
+
# 请求相关
|
|
316
|
+
request:
|
|
317
|
+
method: POST
|
|
318
|
+
url: ""
|
|
319
|
+
# 请求参数
|
|
320
|
+
json: {}
|
|
321
|
+
# 返回结果校验
|
|
322
|
+
validate:
|
|
323
|
+
# 包含内容
|
|
324
|
+
- contains: {}
|
|
325
|
+
# 前置条件
|
|
326
|
+
precondition: ""
|
|
327
|
+
|
|
328
|
+
- case_id: 2
|
|
329
|
+
name: "用例描述"
|
|
330
|
+
# 请求相关
|
|
331
|
+
request:
|
|
332
|
+
method: POST
|
|
333
|
+
url: ""
|
|
334
|
+
# 请求参数
|
|
335
|
+
json: {}
|
|
336
|
+
# 返回结果校验
|
|
337
|
+
validate:
|
|
338
|
+
# 包含内容
|
|
339
|
+
- contains: {}
|
|
340
|
+
# 前置条件
|
|
341
|
+
precondition: ""
|
|
342
|
+
`, ai = "# from assets", ni = "cli-z-develop", si = "0.10.5", ri = "技术团队开发流程管理工具", oi = "dist/index.js", ci = { z: "bin/z.js", "z-develop": "bin/z.js" }, ui = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", eslint: "eslint '**/*.{ts,js}' --fix", prettier: "prettier -wu .", upload: "npm run build && npm publish --access public --registry https://registry.npmjs.org/", "upload:patch": "npm version patch && npm run upload", "upload:minor": "npm version minor && npm run upload", "upload:major": "npm version major && npm run upload" }, li = "module", pi = "z", mi = { "@lonely9/eslint-config-team": "^1.3.5", "@tsconfig/node22": "^22.0.5", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.9", "@types/minimist": "^1.2.5", "@types/node": "^22.15.29", "@types/semver": "^7.7.1", "@types/shelljs": "^0.10.0", "@typescript-eslint/eslint-plugin": "^8.53.0", "@typescript-eslint/parser": "^8.53.0", eslint: "^9.39.2", jiti: "^2.6.1", prettier: "^3.7.4", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.2.2" }, di = { "@inquirer/prompts": "^8.2.0", axios: "^1.13.6", chalk: "^5.6.2", commander: "^14.0.2", dayjs: "^1.11.19", "fs-extra": "^11.3.3", "inquirer-select-pro": "^1.0.0-alpha.9", "lint-staged": "^16.2.7", minimist: "^1.2.8", "npm-check-updates": "^19.3.1", ora: "^9.0.0", "p-limit": "^7.3.0", semver: "^7.7.3", shelljs: "^0.10.0" }, X = {
|
|
322
343
|
name: ni,
|
|
323
344
|
version: si,
|
|
324
345
|
description: ri,
|
|
@@ -447,15 +468,15 @@ function re(e, t) {
|
|
|
447
468
|
};
|
|
448
469
|
}
|
|
449
470
|
async function Z(e) {
|
|
450
|
-
const t = e.method || "get", i = e.headers || {},
|
|
471
|
+
const t = e.method || "get", i = e.headers || {}, a = e.data || {}, n = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
|
|
451
472
|
try {
|
|
452
473
|
const s = {
|
|
453
474
|
url: e.url,
|
|
454
475
|
method: t,
|
|
455
|
-
[
|
|
476
|
+
[n]: a,
|
|
456
477
|
headers: i
|
|
457
478
|
};
|
|
458
|
-
ge(N.magenta(s.method.toUpperCase()), N.yellow(s.url), JSON.stringify(s.headers)), ge(N.gray(JSON.stringify(s[
|
|
479
|
+
ge(N.magenta(s.method.toUpperCase()), N.yellow(s.url), JSON.stringify(s.headers)), ge(N.gray(JSON.stringify(s[n], null, 2)));
|
|
459
480
|
const o = await le(s);
|
|
460
481
|
return ge(N.green("Response"), N.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
|
|
461
482
|
} catch (s) {
|
|
@@ -520,12 +541,12 @@ async function he(e) {
|
|
|
520
541
|
...e
|
|
521
542
|
})) : t;
|
|
522
543
|
} else {
|
|
523
|
-
const { status: i, data:
|
|
544
|
+
const { status: i, data: a } = t;
|
|
524
545
|
if (i === "success") {
|
|
525
|
-
const
|
|
526
|
-
return
|
|
546
|
+
const n = JSON.parse(a);
|
|
547
|
+
return n.title === "用户登录" ? (L("zenTaoToken", ""), he({
|
|
527
548
|
...e
|
|
528
|
-
})) :
|
|
549
|
+
})) : n;
|
|
529
550
|
} else
|
|
530
551
|
return {};
|
|
531
552
|
}
|
|
@@ -560,7 +581,7 @@ async function tt(e) {
|
|
|
560
581
|
...e
|
|
561
582
|
})) : t;
|
|
562
583
|
}
|
|
563
|
-
const
|
|
584
|
+
const P = () => `${pe}/api/v4`, Ce = (e) => `${P()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
|
|
564
585
|
function $i() {
|
|
565
586
|
return R({
|
|
566
587
|
url: Ce("src/data/template-projects.json")
|
|
@@ -578,29 +599,29 @@ function vi() {
|
|
|
578
599
|
}
|
|
579
600
|
function bi() {
|
|
580
601
|
return R({
|
|
581
|
-
url: `${
|
|
602
|
+
url: `${P()}/user`
|
|
582
603
|
});
|
|
583
604
|
}
|
|
584
605
|
function Ni() {
|
|
585
606
|
return R({
|
|
586
|
-
url: `${
|
|
607
|
+
url: `${P()}/groups`
|
|
587
608
|
});
|
|
588
609
|
}
|
|
589
610
|
function Si(e) {
|
|
590
611
|
return R({
|
|
591
|
-
url: `${
|
|
612
|
+
url: `${P()}/projects`,
|
|
592
613
|
method: "post",
|
|
593
614
|
data: e
|
|
594
615
|
});
|
|
595
616
|
}
|
|
596
617
|
function at(e) {
|
|
597
618
|
return R({
|
|
598
|
-
url: `${
|
|
619
|
+
url: `${P()}/projects/${e}`
|
|
599
620
|
});
|
|
600
621
|
}
|
|
601
622
|
function ji(e) {
|
|
602
623
|
return R({
|
|
603
|
-
url: `${
|
|
624
|
+
url: `${P()}/projects`,
|
|
604
625
|
data: {
|
|
605
626
|
search: e,
|
|
606
627
|
search_namespaces: !0
|
|
@@ -609,40 +630,40 @@ function ji(e) {
|
|
|
609
630
|
}
|
|
610
631
|
function Ai(e) {
|
|
611
632
|
return R({
|
|
612
|
-
url: `${
|
|
633
|
+
url: `${P()}/projects/${e.id}/merge_requests`,
|
|
613
634
|
method: "post",
|
|
614
635
|
data: e
|
|
615
636
|
});
|
|
616
637
|
}
|
|
617
638
|
function Ei(e) {
|
|
618
639
|
return R({
|
|
619
|
-
url: `${
|
|
640
|
+
url: `${P()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
620
641
|
method: "put"
|
|
621
642
|
});
|
|
622
643
|
}
|
|
623
644
|
function Ti(e) {
|
|
624
645
|
return R({
|
|
625
|
-
url: `${
|
|
646
|
+
url: `${P()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
626
647
|
method: "put",
|
|
627
648
|
data: e
|
|
628
649
|
});
|
|
629
650
|
}
|
|
630
651
|
function ki(e) {
|
|
631
652
|
return R({
|
|
632
|
-
url: `${
|
|
653
|
+
url: `${P()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
633
654
|
method: "get"
|
|
634
655
|
});
|
|
635
656
|
}
|
|
636
657
|
function Ci(e) {
|
|
637
658
|
return R({
|
|
638
|
-
url: `${
|
|
659
|
+
url: `${P()}/projects/${e.id}/repository/branches`,
|
|
639
660
|
method: "post",
|
|
640
661
|
data: e
|
|
641
662
|
});
|
|
642
663
|
}
|
|
643
664
|
function Ii(e) {
|
|
644
665
|
return R({
|
|
645
|
-
url: `${
|
|
666
|
+
url: `${P()}/projects/${e}/repository/branches`
|
|
646
667
|
});
|
|
647
668
|
}
|
|
648
669
|
function Ri() {
|
|
@@ -650,12 +671,12 @@ function Ri() {
|
|
|
650
671
|
return $(e) ? S.readJSONSync(e) : { groups: [] };
|
|
651
672
|
}
|
|
652
673
|
async function xi() {
|
|
653
|
-
const e = await Ni(), t =
|
|
654
|
-
const
|
|
655
|
-
return
|
|
656
|
-
name:
|
|
657
|
-
id:
|
|
658
|
-
description:
|
|
674
|
+
const e = await Ni(), t = Pt.map((i) => {
|
|
675
|
+
const a = e.find((n) => n.name === i);
|
|
676
|
+
return a ? {
|
|
677
|
+
name: a.name,
|
|
678
|
+
id: a.id,
|
|
679
|
+
description: a.description
|
|
659
680
|
} : !1;
|
|
660
681
|
}).filter((i) => !!i);
|
|
661
682
|
S.writeJSONSync(de("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
@@ -664,7 +685,7 @@ async function T(e) {
|
|
|
664
685
|
const t = `${ie("FEServerDomain")}/api`, { data: i } = await Z({
|
|
665
686
|
url: `${t}/auth/z-develop/login`,
|
|
666
687
|
method: "post"
|
|
667
|
-
}),
|
|
688
|
+
}), a = await Z({
|
|
668
689
|
url: t + e.url,
|
|
669
690
|
headers: {
|
|
670
691
|
Authorization: `Bearer ${i}`
|
|
@@ -672,7 +693,7 @@ async function T(e) {
|
|
|
672
693
|
data: e.data,
|
|
673
694
|
method: e.method || "post"
|
|
674
695
|
});
|
|
675
|
-
return
|
|
696
|
+
return a.code !== 0 && m(`${a.code}: ${a.message}`), a.data;
|
|
676
697
|
}
|
|
677
698
|
function Di() {
|
|
678
699
|
return T({
|
|
@@ -692,7 +713,7 @@ function nt(e) {
|
|
|
692
713
|
}
|
|
693
714
|
});
|
|
694
715
|
}
|
|
695
|
-
function
|
|
716
|
+
function Oi(e) {
|
|
696
717
|
return T({
|
|
697
718
|
url: "/zen/testcase/product/name",
|
|
698
719
|
data: {
|
|
@@ -700,7 +721,7 @@ function Pi(e) {
|
|
|
700
721
|
}
|
|
701
722
|
});
|
|
702
723
|
}
|
|
703
|
-
function
|
|
724
|
+
function Pi(e, t) {
|
|
704
725
|
return T({
|
|
705
726
|
url: "/zen/testcase/product/auto-case/list",
|
|
706
727
|
data: {
|
|
@@ -723,13 +744,13 @@ function zi(e) {
|
|
|
723
744
|
data: e
|
|
724
745
|
});
|
|
725
746
|
}
|
|
726
|
-
function
|
|
747
|
+
function _i(e) {
|
|
727
748
|
return T({
|
|
728
749
|
url: "/zen/testcase/create",
|
|
729
750
|
data: e
|
|
730
751
|
});
|
|
731
752
|
}
|
|
732
|
-
function
|
|
753
|
+
function Fi(e) {
|
|
733
754
|
return T({
|
|
734
755
|
url: "/zen/testcase/step/create",
|
|
735
756
|
data: e
|
|
@@ -776,55 +797,55 @@ function Vi(e, t) {
|
|
|
776
797
|
t.forEach((s) => {
|
|
777
798
|
e.includes(s.value) && i.push(s);
|
|
778
799
|
});
|
|
779
|
-
const
|
|
800
|
+
const a = me("weWorkListCache"), n = a.map((s) => s.value);
|
|
780
801
|
i.forEach((s) => {
|
|
781
|
-
const o =
|
|
782
|
-
o > -1 ?
|
|
802
|
+
const o = n.indexOf(s.value);
|
|
803
|
+
o > -1 ? a[o].usageCount += 1 : a.push({
|
|
783
804
|
...s,
|
|
784
805
|
usageCount: 1
|
|
785
806
|
});
|
|
786
807
|
}), re({
|
|
787
|
-
weWorkListCache:
|
|
808
|
+
weWorkListCache: a.sort((s, o) => o.usageCount - s.usageCount)
|
|
788
809
|
}), ae();
|
|
789
810
|
}
|
|
790
811
|
async function st() {
|
|
791
812
|
const t = (await Di()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
792
|
-
name: `${s.nick} - ${
|
|
813
|
+
name: `${s.nick} - ${Ot[s.title]}`,
|
|
793
814
|
value: s.weWorkUserId
|
|
794
|
-
})), i = me("weWorkListCache"),
|
|
815
|
+
})), i = me("weWorkListCache"), a = i.map((s) => s.value), n = [];
|
|
795
816
|
return t.forEach((s) => {
|
|
796
|
-
const o =
|
|
797
|
-
|
|
817
|
+
const o = a.indexOf(s.value);
|
|
818
|
+
n.push({
|
|
798
819
|
...s,
|
|
799
820
|
usageCount: o > -1 ? i[o].usageCount : 0
|
|
800
821
|
});
|
|
801
|
-
}),
|
|
822
|
+
}), n.sort((s, o) => o.usageCount - s.usageCount);
|
|
802
823
|
}
|
|
803
824
|
async function rt(e, t, i) {
|
|
804
|
-
const
|
|
805
|
-
let
|
|
825
|
+
const a = await st();
|
|
826
|
+
let n = await ee({
|
|
806
827
|
message: e,
|
|
807
828
|
loop: !0,
|
|
808
|
-
pageSize:
|
|
829
|
+
pageSize: a.length || 5,
|
|
809
830
|
clearInputWhenSelected: !0,
|
|
810
831
|
multiple: i,
|
|
811
|
-
options: (s) => s ?
|
|
832
|
+
options: (s) => s ? a.filter((o) => o.name.includes(s)) : a,
|
|
812
833
|
validate: t
|
|
813
834
|
});
|
|
814
|
-
return
|
|
835
|
+
return n = Array.isArray(n) ? n : [n], Vi(n, a), n;
|
|
815
836
|
}
|
|
816
837
|
async function Hi(e, t, i) {
|
|
817
|
-
const { groups:
|
|
838
|
+
const { groups: a } = await vi(), n = a.map((o) => ({
|
|
818
839
|
name: o.name,
|
|
819
840
|
value: o.url
|
|
820
841
|
}));
|
|
821
842
|
let s = await ee({
|
|
822
843
|
message: e,
|
|
823
844
|
loop: !0,
|
|
824
|
-
pageSize:
|
|
845
|
+
pageSize: n.length || 5,
|
|
825
846
|
clearInputWhenSelected: !0,
|
|
826
847
|
multiple: i,
|
|
827
|
-
options: (o) => o ?
|
|
848
|
+
options: (o) => o ? n.filter((r) => r.name.includes(o)) : n,
|
|
828
849
|
validate: t
|
|
829
850
|
});
|
|
830
851
|
return s = Array.isArray(s) ? s : [s], s;
|
|
@@ -850,15 +871,15 @@ async function Zi() {
|
|
|
850
871
|
value: se.QUALITY_ASSURANCE
|
|
851
872
|
}
|
|
852
873
|
]
|
|
853
|
-
}), i = await
|
|
874
|
+
}), i = await _({
|
|
854
875
|
message: "请输入LDAP账号:"
|
|
855
|
-
}),
|
|
876
|
+
}), a = await Et({
|
|
856
877
|
message: "请输入LDAP密码:",
|
|
857
878
|
mask: !0
|
|
858
879
|
});
|
|
859
|
-
L("jobType", t), L("ldapAccount", i), L("ldapPassword",
|
|
860
|
-
const
|
|
861
|
-
ke(
|
|
880
|
+
L("jobType", t), L("ldapAccount", i), L("ldapPassword", a);
|
|
881
|
+
const n = await it();
|
|
882
|
+
ke(n);
|
|
862
883
|
const s = await st(), o = await rt("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((u) => u.value === o[0]);
|
|
863
884
|
L({
|
|
864
885
|
weWorkName: r,
|
|
@@ -980,8 +1001,8 @@ z run commit-files`, { mode: 493 });
|
|
|
980
1001
|
async function Xi(e, t) {
|
|
981
1002
|
const i = await l("git remote get-url --push origin");
|
|
982
1003
|
i || m("获取项目远程git地址失败,请配置后重试");
|
|
983
|
-
let
|
|
984
|
-
|
|
1004
|
+
let a = e;
|
|
1005
|
+
a || (a = await E({
|
|
985
1006
|
message: "请选择项目语言",
|
|
986
1007
|
choices: [
|
|
987
1008
|
{
|
|
@@ -998,19 +1019,19 @@ async function Xi(e, t) {
|
|
|
998
1019
|
}
|
|
999
1020
|
]
|
|
1000
1021
|
}));
|
|
1001
|
-
let
|
|
1002
|
-
if (!
|
|
1022
|
+
let n = t;
|
|
1023
|
+
if (!n) {
|
|
1003
1024
|
const s = Ze(i), o = await at(s);
|
|
1004
1025
|
if (!o)
|
|
1005
1026
|
return m(`未找到项目,请确认项目${i}是否存在,或者当前账号权限`);
|
|
1006
|
-
|
|
1027
|
+
n = o.namespace.full_path;
|
|
1007
1028
|
}
|
|
1008
1029
|
et({
|
|
1009
|
-
language:
|
|
1010
|
-
"lint-staged": ti[
|
|
1030
|
+
language: a,
|
|
1031
|
+
"lint-staged": ti[a],
|
|
1011
1032
|
repository: {
|
|
1012
1033
|
url: i,
|
|
1013
|
-
group:
|
|
1034
|
+
group: n
|
|
1014
1035
|
}
|
|
1015
1036
|
});
|
|
1016
1037
|
}
|
|
@@ -1025,7 +1046,7 @@ async function ea() {
|
|
|
1025
1046
|
async function ta(e, t) {
|
|
1026
1047
|
t.projectLanguage && !Object.values(x).includes(t.projectLanguage) && m("项目语言不支持"), e ? (Q(), e === "." ? (await Ie(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await ea() : m("参数错误。执行 z init -h 查看帮助。")) : await Zi();
|
|
1027
1048
|
}
|
|
1028
|
-
I.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(x).join("/")} `).action((...e) =>
|
|
1049
|
+
I.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(x).join("/")} `).action((...e) => O(ta, ...e));
|
|
1029
1050
|
async function ia(e, t) {
|
|
1030
1051
|
if (!e)
|
|
1031
1052
|
return "不能为空";
|
|
@@ -1033,8 +1054,8 @@ async function ia(e, t) {
|
|
|
1033
1054
|
return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
|
|
1034
1055
|
if (Qe().includes(e))
|
|
1035
1056
|
return "当前目录下已存在同名文件夹,请先处理。";
|
|
1036
|
-
const
|
|
1037
|
-
return
|
|
1057
|
+
const n = (await ji(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
|
|
1058
|
+
return n ? `远程仓库中已存在同名项目(${n.http_url_to_repo}),请更名后重试` : !0;
|
|
1038
1059
|
}
|
|
1039
1060
|
function aa(e) {
|
|
1040
1061
|
return e ? !0 : "不能为空";
|
|
@@ -1061,12 +1082,12 @@ async function sa(e) {
|
|
|
1061
1082
|
value: ue.REFACTOR
|
|
1062
1083
|
}
|
|
1063
1084
|
]
|
|
1064
|
-
}), e.branchPurpose ? i = e.branchPurpose : i = await
|
|
1085
|
+
}), e.branchPurpose ? i = e.branchPurpose : i = await _({
|
|
1065
1086
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1066
1087
|
validate: na
|
|
1067
1088
|
});
|
|
1068
|
-
const
|
|
1069
|
-
await l(`git fetch origin ${y.MASTER}`), await l(`git checkout -b ${
|
|
1089
|
+
const a = `${t}_${i}_${Xe()}`;
|
|
1090
|
+
await l(`git fetch origin ${y.MASTER}`), await l(`git checkout -b ${a} origin/${y.MASTER}`), await l(`git push -u origin ${a}`), process.exit(0);
|
|
1070
1091
|
}
|
|
1071
1092
|
const ot = (e) => `${ie("ZenTaoDomain")}${e}`;
|
|
1072
1093
|
async function ra() {
|
|
@@ -1098,8 +1119,8 @@ async function oa() {
|
|
|
1098
1119
|
async function je(e, t) {
|
|
1099
1120
|
let i = "";
|
|
1100
1121
|
if ([b.FEAT, b.FIX, b.REFACTOR].includes(e)) {
|
|
1101
|
-
const
|
|
1102
|
-
i = `${e}(${
|
|
1122
|
+
const a = t.map((s) => s.value).join(","), n = t.map((s) => s.name).join(";");
|
|
1123
|
+
i = `${e}(${a}): ${n}`;
|
|
1103
1124
|
}
|
|
1104
1125
|
e === b.CHORE && (i = `${e}: ${t}`), await z(we(), i, "utf-8"), console.log(N.yellow(i)), B("commit msg模板写入成功,可以进行提交了");
|
|
1105
1126
|
}
|
|
@@ -1129,12 +1150,12 @@ async function ca() {
|
|
|
1129
1150
|
const t = await ra();
|
|
1130
1151
|
if (!t.length)
|
|
1131
1152
|
return B("🤷 暂无开发任务");
|
|
1132
|
-
const i = await
|
|
1153
|
+
const i = await Pe({
|
|
1133
1154
|
message: "请关联开发任务(可多选):",
|
|
1134
|
-
validate: (
|
|
1135
|
-
choices: t.map((
|
|
1136
|
-
...
|
|
1137
|
-
name: `[${
|
|
1155
|
+
validate: (a) => a.length === 0 ? "请选择项" : !0,
|
|
1156
|
+
choices: t.map((a) => ({
|
|
1157
|
+
...a,
|
|
1158
|
+
name: `[${a.value.value}]: ${a.name}`
|
|
1138
1159
|
})),
|
|
1139
1160
|
pageSize: t.length
|
|
1140
1161
|
});
|
|
@@ -1144,19 +1165,19 @@ async function ca() {
|
|
|
1144
1165
|
const t = await oa();
|
|
1145
1166
|
if (!t.length)
|
|
1146
1167
|
return B("🤷 暂无BUG");
|
|
1147
|
-
const i = await
|
|
1168
|
+
const i = await Pe({
|
|
1148
1169
|
message: "请关联Bug(可多选):",
|
|
1149
|
-
validate: (
|
|
1150
|
-
choices: t.map((
|
|
1151
|
-
...
|
|
1152
|
-
name: `[${
|
|
1170
|
+
validate: (a) => a.length === 0 ? "请选择项" : !0,
|
|
1171
|
+
choices: t.map((a) => ({
|
|
1172
|
+
...a,
|
|
1173
|
+
name: `[${a.value.value}]: ${a.name}`
|
|
1153
1174
|
})),
|
|
1154
1175
|
pageSize: t.length
|
|
1155
1176
|
});
|
|
1156
1177
|
await je(b.FIX, i);
|
|
1157
1178
|
}
|
|
1158
1179
|
if (e === b.CHORE) {
|
|
1159
|
-
const t = await
|
|
1180
|
+
const t = await _({
|
|
1160
1181
|
message: "请输入commit msg:",
|
|
1161
1182
|
validate: (i) => i.length === 0 ? "请输入commit msg" : !0
|
|
1162
1183
|
});
|
|
@@ -1167,22 +1188,22 @@ async function ca() {
|
|
|
1167
1188
|
async function ua() {
|
|
1168
1189
|
try {
|
|
1169
1190
|
const e = {}, t = async () => {
|
|
1170
|
-
const
|
|
1191
|
+
const F = Qe(), { projects: Y } = await $i(), W = Y.map((ne) => {
|
|
1171
1192
|
const Le = {
|
|
1172
1193
|
name: `${ne.name} [${ne.desc}]`,
|
|
1173
1194
|
value: ne.name,
|
|
1174
1195
|
disabled: !1
|
|
1175
1196
|
};
|
|
1176
|
-
return
|
|
1197
|
+
return F.includes(ne.name) && (Le.disabled = "目录下已存在同名文件夹"), Le;
|
|
1177
1198
|
}), yt = await E({
|
|
1178
1199
|
message: "请选择一个项目模板",
|
|
1179
1200
|
choices: W
|
|
1180
1201
|
}), Se = Y.find((ne) => ne.name === yt);
|
|
1181
1202
|
e.tplName = Se.name, e.tplUrl = Se.url, e.tplLanguage = Se.language;
|
|
1182
1203
|
}, i = async () => {
|
|
1183
|
-
const { groups:
|
|
1204
|
+
const { groups: F } = Ri(), Y = await E({
|
|
1184
1205
|
message: "请选择一个分组",
|
|
1185
|
-
choices:
|
|
1206
|
+
choices: F.map((W) => ({
|
|
1186
1207
|
name: `${W.name} [${W.description}]`,
|
|
1187
1208
|
value: W.id,
|
|
1188
1209
|
short: W.name
|
|
@@ -1190,20 +1211,20 @@ async function ua() {
|
|
|
1190
1211
|
});
|
|
1191
1212
|
e.group = {
|
|
1192
1213
|
id: Y,
|
|
1193
|
-
name:
|
|
1214
|
+
name: F.find((W) => W.id === Y)?.name
|
|
1194
1215
|
};
|
|
1195
|
-
},
|
|
1196
|
-
e.projectName = await
|
|
1216
|
+
}, a = async () => {
|
|
1217
|
+
e.projectName = await _({
|
|
1197
1218
|
message: "请输入项目名称",
|
|
1198
|
-
validate: (
|
|
1199
|
-
}), e.projectDesc = await
|
|
1219
|
+
validate: (F) => ia(F, e.group?.name || "")
|
|
1220
|
+
}), e.projectDesc = await _({
|
|
1200
1221
|
message: "请输入项目描述",
|
|
1201
1222
|
validate: aa
|
|
1202
1223
|
});
|
|
1203
1224
|
};
|
|
1204
|
-
await t(), await i(), await
|
|
1205
|
-
const
|
|
1206
|
-
await l(`git clone --depth=1 ${e.tplUrl}`), await
|
|
1225
|
+
await t(), await i(), await a();
|
|
1226
|
+
const n = `${pe}/${e.group?.name}/${e.projectName}.git`, s = h("模版初始化中").start();
|
|
1227
|
+
await l(`git clone --depth=1 ${e.tplUrl}`), await Fe(e.tplName, e.projectName), D.cd(e.projectName), D.rm("-rf", ".git"), await l(`git init --initial-branch=${y.MASTER}`), await l(`git remote add origin ${n}`), await l(`git config user.name ${A("gitName")}`), await l(`git config user.email ${A("gitEmail")}`);
|
|
1207
1228
|
const o = $e();
|
|
1208
1229
|
fi({
|
|
1209
1230
|
...o,
|
|
@@ -1225,18 +1246,18 @@ async function ua() {
|
|
|
1225
1246
|
visibility: "private",
|
|
1226
1247
|
namespace_id: e.group?.id
|
|
1227
1248
|
});
|
|
1228
|
-
await l(`git push -u origin ${y.MASTER}`), await l(`git push origin HEAD:${y.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${N.blue(
|
|
1249
|
+
await l(`git push -u origin ${y.MASTER}`), await l(`git push origin HEAD:${y.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${N.blue(n)}`);
|
|
1229
1250
|
const d = h("初始化分支中").start(), f = `feat_init_${Xe()}`, g = [y.DEV, y.TEST, y.RELEASE, f], w = await Promise.allSettled(
|
|
1230
1251
|
g.map(
|
|
1231
|
-
(
|
|
1252
|
+
(F) => Ci({
|
|
1232
1253
|
id: u.id,
|
|
1233
|
-
branch:
|
|
1254
|
+
branch: F,
|
|
1234
1255
|
ref: y.MASTER
|
|
1235
1256
|
})
|
|
1236
1257
|
)
|
|
1237
1258
|
), M = [];
|
|
1238
|
-
w.forEach(({ status:
|
|
1239
|
-
|
|
1259
|
+
w.forEach(({ status: F }, Y) => {
|
|
1260
|
+
F === "fulfilled" && M.push(g[Y]);
|
|
1240
1261
|
}), await l("git pull"), M.includes(f) ? (await l(`git checkout -b ${f} origin/${f}`), d.succeed(`项目已切换到初始分支: ${N.blue(f)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
|
|
1241
1262
|
const wt = `cd ${e.projectName} && z start`;
|
|
1242
1263
|
console.log(`输入 ${N.green(wt)} 开始开发吧~`), process.exit(0);
|
|
@@ -1279,7 +1300,7 @@ async function la(e, t) {
|
|
|
1279
1300
|
]
|
|
1280
1301
|
}), i === "project" ? await ua() : (te(), Q(), i === "branch" ? (await ce(), await sa(t)) : i === "commit-msg" && await ca());
|
|
1281
1302
|
}
|
|
1282
|
-
I.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) =>
|
|
1303
|
+
I.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) => O(la, ...e));
|
|
1283
1304
|
function pa(e) {
|
|
1284
1305
|
return tt({
|
|
1285
1306
|
url: `${ie("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${Mt}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
|
|
@@ -1288,10 +1309,10 @@ function pa(e) {
|
|
|
1288
1309
|
});
|
|
1289
1310
|
}
|
|
1290
1311
|
async function ma(e) {
|
|
1291
|
-
const t = h("部署任务创建中").start(), { targetBranch: i, notify:
|
|
1312
|
+
const t = h("部署任务创建中").start(), { targetBranch: i, notify: a, projectName: n } = e, s = a ? [.../* @__PURE__ */ new Set([A("weWorkUserId"), ...a])] : [A("weWorkUserId")];
|
|
1292
1313
|
try {
|
|
1293
1314
|
const { metadata: o, spec: r } = await pa({
|
|
1294
|
-
projectName:
|
|
1315
|
+
projectName: n,
|
|
1295
1316
|
branchName: i,
|
|
1296
1317
|
params: {
|
|
1297
1318
|
parameters: [
|
|
@@ -1314,40 +1335,40 @@ async function ma(e) {
|
|
|
1314
1335
|
function da(e, t) {
|
|
1315
1336
|
const i = $e();
|
|
1316
1337
|
if (ve()?.repository?.url || m(".z/project.json中缺少repository.url"), t === H.H5) {
|
|
1317
|
-
const
|
|
1318
|
-
i?.scripts[
|
|
1338
|
+
const n = `build:${e}`;
|
|
1339
|
+
i?.scripts[n] || m(`项目package.json文件scripts不存在命令${n}。`);
|
|
1319
1340
|
}
|
|
1320
1341
|
t === H.NPM && (i?.scripts.build || m("项目package.json文件scripts不存在命令build。")), t === H.SERVER && (i?.scripts.build || m("项目package.json文件scripts不存在命令build。"));
|
|
1321
1342
|
}
|
|
1322
1343
|
async function ct(e, t) {
|
|
1323
1344
|
te(), Q(), await ce();
|
|
1324
|
-
let i = e,
|
|
1325
|
-
if (i && !Object.values(y).includes(i) && m("仅支持发布指定环境分支"),
|
|
1345
|
+
let i = e, a = t.platform;
|
|
1346
|
+
if (i && !Object.values(y).includes(i) && m("仅支持发布指定环境分支"), a && !Object.values(H).includes(a) && m("发布平台错误"), a || (a = await E({
|
|
1326
1347
|
message: "请选择平台",
|
|
1327
1348
|
choices: Lt
|
|
1328
|
-
})),
|
|
1349
|
+
})), a === H.NPM && (i = y.MASTER), !i) {
|
|
1329
1350
|
const c = await E({
|
|
1330
1351
|
message: "请选择部署环境",
|
|
1331
1352
|
choices: We
|
|
1332
1353
|
});
|
|
1333
1354
|
i = Kt(c);
|
|
1334
1355
|
}
|
|
1335
|
-
let
|
|
1336
|
-
t.skipSelectionNotification || (
|
|
1356
|
+
let n = [];
|
|
1357
|
+
t.skipSelectionNotification || (n = await rt("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1337
1358
|
let s = [];
|
|
1338
1359
|
t.skipGroupNotification || (s = await Hi("请选择部署成功要通知的群组:", () => !0, !0));
|
|
1339
1360
|
const o = Zt(i);
|
|
1340
|
-
da(o,
|
|
1361
|
+
da(o, a);
|
|
1341
1362
|
const r = $e();
|
|
1342
1363
|
await ma({
|
|
1343
1364
|
projectName: r.name,
|
|
1344
1365
|
targetBranch: i,
|
|
1345
|
-
notify:
|
|
1366
|
+
notify: n,
|
|
1346
1367
|
notifyGroup: s
|
|
1347
1368
|
});
|
|
1348
1369
|
}
|
|
1349
|
-
async function ut(e, t, i,
|
|
1350
|
-
const
|
|
1370
|
+
async function ut(e, t, i, a) {
|
|
1371
|
+
const n = h(`分支合并中,${e} -> ${t}`).start();
|
|
1351
1372
|
let s = 0;
|
|
1352
1373
|
try {
|
|
1353
1374
|
const { iid: r } = await Ai({
|
|
@@ -1356,7 +1377,7 @@ async function ut(e, t, i, n) {
|
|
|
1356
1377
|
source_branch: e,
|
|
1357
1378
|
target_branch: t,
|
|
1358
1379
|
// 合到主分支上的分支需要在合并完成后被移除
|
|
1359
|
-
remove_source_branch:
|
|
1380
|
+
remove_source_branch: a ? !1 : y.MASTER === t
|
|
1360
1381
|
});
|
|
1361
1382
|
s = r;
|
|
1362
1383
|
} catch (r) {
|
|
@@ -1369,7 +1390,7 @@ async function ut(e, t, i, n) {
|
|
|
1369
1390
|
}), await Ei({
|
|
1370
1391
|
id: i.id,
|
|
1371
1392
|
iid: s
|
|
1372
|
-
}),
|
|
1393
|
+
}), n.succeed(`分支${e}已合并到分支${t}`);
|
|
1373
1394
|
} catch (r) {
|
|
1374
1395
|
le.isAxiosError(r) || m(r);
|
|
1375
1396
|
const c = r?.response?.status;
|
|
@@ -1385,25 +1406,25 @@ async function ut(e, t, i, n) {
|
|
|
1385
1406
|
iid: s
|
|
1386
1407
|
});
|
|
1387
1408
|
if (u.merge_status === "cannot_be_merged" && u.diff_refs.base_sha === u.diff_refs.head_sha) {
|
|
1388
|
-
|
|
1409
|
+
n.warn("MR已关闭。判定为空的合并请求(没有新内容),可继续进行部署");
|
|
1389
1410
|
return;
|
|
1390
1411
|
}
|
|
1391
1412
|
}
|
|
1392
|
-
|
|
1413
|
+
n.fail("合并过程中出现冲突,MR已关闭。建议在本地完成合并。"), process.exit(1);
|
|
1393
1414
|
}
|
|
1394
1415
|
};
|
|
1395
1416
|
await o();
|
|
1396
1417
|
}
|
|
1397
1418
|
async function fa(e, t) {
|
|
1398
|
-
const i = `origin/${e.sourceBranch}`,
|
|
1399
|
-
`git log ${
|
|
1419
|
+
const i = `origin/${e.sourceBranch}`, a = await l(`git log -b origin/${y.MASTER} -1 --format=%H`), n = await l(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await l(
|
|
1420
|
+
`git log ${a}...${n} -b ${i}`
|
|
1400
1421
|
);
|
|
1401
1422
|
if (s || m(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await l(
|
|
1402
|
-
`git branch --contains ${
|
|
1423
|
+
`git branch --contains ${a} -r ${i}`
|
|
1403
1424
|
) || (console.log(N.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await ut(y.MASTER, e.sourceBranch, e)), t === y.MASTER) {
|
|
1404
1425
|
const r = s.split(`
|
|
1405
1426
|
`).filter((f) => f), c = await l(`git log -b origin/${v.TEST} -1 --format=%H`), d = (await l(
|
|
1406
|
-
`git log ${
|
|
1427
|
+
`git log ${a}...${c} -b origin/${v.TEST}`
|
|
1407
1428
|
)).split(`
|
|
1408
1429
|
`).filter((f) => f);
|
|
1409
1430
|
Ht(d, r) || m("请先在测试环境发布要部署的代码");
|
|
@@ -1413,7 +1434,7 @@ async function ga(e, t) {
|
|
|
1413
1434
|
te(), Q(), await ce();
|
|
1414
1435
|
const i = await gi();
|
|
1415
1436
|
Object.values(y).includes(i.sourceBranch) && m(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1416
|
-
const
|
|
1437
|
+
const n = (await Ii(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
|
|
1417
1438
|
let u = c.name;
|
|
1418
1439
|
return Object.values(y).includes(u) && (u = N.bold.blue(u)), {
|
|
1419
1440
|
name: u,
|
|
@@ -1421,9 +1442,9 @@ async function ga(e, t) {
|
|
|
1421
1442
|
};
|
|
1422
1443
|
});
|
|
1423
1444
|
let s;
|
|
1424
|
-
e && !
|
|
1445
|
+
e && !n.filter((c) => c.value === e).length && m(`未找到目标分支${e}`), e ? s = e : s = await E({
|
|
1425
1446
|
message: "请选择要合并到的目标分支:",
|
|
1426
|
-
choices:
|
|
1447
|
+
choices: n
|
|
1427
1448
|
});
|
|
1428
1449
|
const o = h(`本地分支${i.sourceBranch}检测中`).start();
|
|
1429
1450
|
if (await l(`git ls-remote --heads origin ${i.sourceBranch}`)) {
|
|
@@ -1442,8 +1463,8 @@ async function ga(e, t) {
|
|
|
1442
1463
|
skipGroupNotification: t.skipGroupNotification
|
|
1443
1464
|
});
|
|
1444
1465
|
}
|
|
1445
|
-
I.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) =>
|
|
1446
|
-
I.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(y).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(H).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) =>
|
|
1466
|
+
I.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) => O(ga, ...e));
|
|
1467
|
+
I.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(y).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(H).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => O(ct, ...e));
|
|
1447
1468
|
function ha() {
|
|
1448
1469
|
const e = Te();
|
|
1449
1470
|
if ($(e)) {
|
|
@@ -1491,7 +1512,7 @@ async function va() {
|
|
|
1491
1512
|
});
|
|
1492
1513
|
if (e && Object.keys(e).length) {
|
|
1493
1514
|
B("升级完成 🎉");
|
|
1494
|
-
const t = Object.entries(e).map(([i,
|
|
1515
|
+
const t = Object.entries(e).map(([i, a]) => `${i}@${a}`).join("; ");
|
|
1495
1516
|
await l(`git add . && git commit -m "chore: 依赖升级。${t}"`);
|
|
1496
1517
|
}
|
|
1497
1518
|
process.exit(0);
|
|
@@ -1581,22 +1602,22 @@ async function ja(e, t) {
|
|
|
1581
1602
|
I.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check 脚本。").argument(
|
|
1582
1603
|
"[type]",
|
|
1583
1604
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc。"
|
|
1584
|
-
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) =>
|
|
1605
|
+
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => O(ja, ...e));
|
|
1585
1606
|
async function lt(e = "latest") {
|
|
1586
1607
|
const t = h("安装中...").start();
|
|
1587
1608
|
await l(`npm i -g ${X.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", re("latestCheckVersionTimestamp", Date.now()), re("version", e), ae(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1588
1609
|
}
|
|
1589
|
-
I.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) =>
|
|
1610
|
+
I.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => O(lt, ...e));
|
|
1590
1611
|
async function Aa(e) {
|
|
1591
1612
|
let t = e;
|
|
1592
1613
|
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({
|
|
1593
1614
|
message: "请选择环境",
|
|
1594
1615
|
choices: We
|
|
1595
1616
|
});
|
|
1596
|
-
const i = $e(),
|
|
1597
|
-
i.scripts[
|
|
1617
|
+
const i = $e(), a = `dev:${t}`;
|
|
1618
|
+
i.scripts[a] ? Ye(`npm run ${a}`) : m(`项目中(package.json > scripts)不存在命令${a},请先添加!`);
|
|
1598
1619
|
}
|
|
1599
|
-
I.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) =>
|
|
1620
|
+
I.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => O(Aa, ...e));
|
|
1600
1621
|
const Re = /Thumbs\.db|\.git|DS_Store|idea/, pt = "testcase";
|
|
1601
1622
|
function mt(e) {
|
|
1602
1623
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
@@ -1618,13 +1639,13 @@ function mt(e) {
|
|
|
1618
1639
|
};
|
|
1619
1640
|
}
|
|
1620
1641
|
async function K(e, t = {}) {
|
|
1621
|
-
const { exclude: i = Re } = t,
|
|
1622
|
-
async function
|
|
1642
|
+
const { exclude: i = Re } = t, a = [];
|
|
1643
|
+
async function n(s) {
|
|
1623
1644
|
const o = p.basename(s);
|
|
1624
1645
|
if ((await Nt(s)).isFile())
|
|
1625
1646
|
return null;
|
|
1626
1647
|
const c = await Ee(s, { withFileTypes: !0 }), u = (await Promise.all(
|
|
1627
|
-
c.filter((M) => M.isDirectory() && !i.test(M.name)).map((M) =>
|
|
1648
|
+
c.filter((M) => M.isDirectory() && !i.test(M.name)).map((M) => n(p.join(s, M.name)))
|
|
1628
1649
|
)).filter(Boolean), { type: d, id: f, displayName: g } = mt(o), w = {
|
|
1629
1650
|
name: o,
|
|
1630
1651
|
id: f,
|
|
@@ -1633,19 +1654,19 @@ async function K(e, t = {}) {
|
|
|
1633
1654
|
type: d,
|
|
1634
1655
|
children: u
|
|
1635
1656
|
};
|
|
1636
|
-
return (t.hasRoot || p.resolve(e) !== s) &&
|
|
1657
|
+
return (t.hasRoot || p.resolve(e) !== s) && a.push(w), w;
|
|
1637
1658
|
}
|
|
1638
|
-
return await
|
|
1659
|
+
return await n(p.resolve(e)), a;
|
|
1639
1660
|
}
|
|
1640
1661
|
async function dt(e, t = {}) {
|
|
1641
1662
|
const { exclude: i = Re } = t;
|
|
1642
1663
|
try {
|
|
1643
|
-
const
|
|
1664
|
+
const a = await Ee(p.resolve(e), { withFileTypes: !0 });
|
|
1644
1665
|
return await Promise.all(
|
|
1645
|
-
|
|
1646
|
-
const s = p.join(e,
|
|
1666
|
+
a.filter((n) => n.isDirectory() && !i.test(n.name)).map((n) => {
|
|
1667
|
+
const s = p.join(e, n.name), { type: o, id: r, displayName: c } = mt(n.name);
|
|
1647
1668
|
return {
|
|
1648
|
-
name:
|
|
1669
|
+
name: n.name,
|
|
1649
1670
|
id: r,
|
|
1650
1671
|
displayName: c,
|
|
1651
1672
|
path: s,
|
|
@@ -1653,8 +1674,8 @@ async function dt(e, t = {}) {
|
|
|
1653
1674
|
};
|
|
1654
1675
|
})
|
|
1655
1676
|
);
|
|
1656
|
-
} catch (
|
|
1657
|
-
return m(`读取目录失败: ${e} : ${
|
|
1677
|
+
} catch (a) {
|
|
1678
|
+
return m(`读取目录失败: ${e} : ${a}`), [];
|
|
1658
1679
|
}
|
|
1659
1680
|
}
|
|
1660
1681
|
function G(e, t, i) {
|
|
@@ -1667,29 +1688,29 @@ function G(e, t, i) {
|
|
|
1667
1688
|
return t;
|
|
1668
1689
|
}
|
|
1669
1690
|
}
|
|
1670
|
-
async function fe(e, t, i,
|
|
1691
|
+
async function fe(e, t, i, a) {
|
|
1671
1692
|
try {
|
|
1672
|
-
const
|
|
1673
|
-
if (
|
|
1693
|
+
const n = p.basename(e), s = G(i, t, a);
|
|
1694
|
+
if (n === s)
|
|
1674
1695
|
return !0;
|
|
1675
1696
|
const o = p.dirname(e), r = p.join(o, s);
|
|
1676
|
-
return await Qt(e) ? await
|
|
1677
|
-
} catch (
|
|
1678
|
-
return m(`重命名文件夹失败: ${e} -> ${t}。${
|
|
1697
|
+
return await Qt(e) ? await Fe(e, r) : (await l(`git mv "${e}" "${r}"`), await l("git add .")), !0;
|
|
1698
|
+
} catch (n) {
|
|
1699
|
+
return m(`重命名文件夹失败: ${e} -> ${t}。${n}`), !1;
|
|
1679
1700
|
}
|
|
1680
1701
|
}
|
|
1681
1702
|
async function Ea(e, t, i = {}) {
|
|
1682
|
-
const { exclude:
|
|
1683
|
-
async function
|
|
1703
|
+
const { exclude: a = Re } = i;
|
|
1704
|
+
async function n(s, o) {
|
|
1684
1705
|
if (!s || s.length === 0) return;
|
|
1685
|
-
const r = await dt(o, { exclude:
|
|
1706
|
+
const r = await dt(o, { exclude: a });
|
|
1686
1707
|
for (const c of s) {
|
|
1687
1708
|
const u = String(c.value), d = G("module", c.label, u), f = r.find((w) => w.id === u);
|
|
1688
1709
|
let g = f?.path || p.join(o, d);
|
|
1689
|
-
f ? f.displayName !== c.label && await fe(f.path, c.label, "module", u) && (g = p.join(o, d)) : (await oe(g, { recursive: !0 }), await l(`git add "${g}"`)), c.children && c.children.length > 0 && await
|
|
1710
|
+
f ? f.displayName !== c.label && await fe(f.path, c.label, "module", u) && (g = p.join(o, d)) : (await oe(g, { recursive: !0 }), await l(`git add "${g}"`)), c.children && c.children.length > 0 && await n(c.children, g);
|
|
1690
1711
|
}
|
|
1691
1712
|
}
|
|
1692
|
-
await
|
|
1713
|
+
await n(e, p.resolve(t));
|
|
1693
1714
|
}
|
|
1694
1715
|
async function ft(e) {
|
|
1695
1716
|
const t = {
|
|
@@ -1703,13 +1724,13 @@ async function ft(e) {
|
|
|
1703
1724
|
const i = await Li();
|
|
1704
1725
|
t.id = await E({
|
|
1705
1726
|
message: "请选择产品",
|
|
1706
|
-
choices: i.map((
|
|
1707
|
-
name: `${
|
|
1708
|
-
value:
|
|
1727
|
+
choices: i.map((a) => ({
|
|
1728
|
+
name: `${a.label}[${a.value}]`,
|
|
1729
|
+
value: a.value
|
|
1709
1730
|
}))
|
|
1710
1731
|
});
|
|
1711
1732
|
}
|
|
1712
|
-
return t.name = await
|
|
1733
|
+
return t.name = await Oi(t.id), t.path = p.join(pt, G("module", t.name, String(t.id))), t;
|
|
1713
1734
|
}
|
|
1714
1735
|
async function xe(e) {
|
|
1715
1736
|
return (await dt(pt)).find((i) => Number(i.id) === e.id);
|
|
@@ -1727,9 +1748,9 @@ async function gt(e, t) {
|
|
|
1727
1748
|
async function ht(e, t) {
|
|
1728
1749
|
await oe(t, {
|
|
1729
1750
|
recursive: !0
|
|
1730
|
-
}), await gt(e, p.join(t, "config.json")), S.ensureFileSync(p.join(t, "data.
|
|
1731
|
-
p.join(t, "data.
|
|
1732
|
-
$(p.resolve(V, "data.
|
|
1751
|
+
}), await gt(e, p.join(t, "config.json")), S.ensureFileSync(p.join(t, "data.yaml")), await z(
|
|
1752
|
+
p.join(t, "data.yaml"),
|
|
1753
|
+
$(p.resolve(V, "data.yaml")) ? await Ae(p.resolve(V, "data.yaml")) : ii
|
|
1733
1754
|
), S.ensureFileSync(p.join(t, "main.py")), await z(
|
|
1734
1755
|
p.join(t, "main.py"),
|
|
1735
1756
|
$(p.resolve(V, "main.py")) ? await Ae(p.resolve(V, "main.py")) : ai
|
|
@@ -1738,8 +1759,8 @@ async function ht(e, t) {
|
|
|
1738
1759
|
function De(e) {
|
|
1739
1760
|
if (e) {
|
|
1740
1761
|
const t = e.split(",").map((i) => i.trim()).filter((i) => {
|
|
1741
|
-
const
|
|
1742
|
-
return Number.isInteger(
|
|
1762
|
+
const a = Number(i);
|
|
1763
|
+
return Number.isInteger(a) && a > 0;
|
|
1743
1764
|
}).map((i) => Number(i));
|
|
1744
1765
|
return t.length === 0 ? (m('未找到有效的ID,请输入格式如 "1,2,3,4" 的正整数ID'), []) : t;
|
|
1745
1766
|
}
|
|
@@ -1752,10 +1773,10 @@ async function be(e, t) {
|
|
|
1752
1773
|
message: `请选择要${e}的数据类型`,
|
|
1753
1774
|
choices: zt
|
|
1754
1775
|
});
|
|
1755
|
-
const
|
|
1776
|
+
const a = i === j.MODULE ? "模块" : j.CASE === i ? "用例" : "";
|
|
1756
1777
|
return {
|
|
1757
1778
|
type: i,
|
|
1758
|
-
typeStr:
|
|
1779
|
+
typeStr: a
|
|
1759
1780
|
};
|
|
1760
1781
|
}
|
|
1761
1782
|
async function Ne(e) {
|
|
@@ -1767,10 +1788,10 @@ async function Ne(e) {
|
|
|
1767
1788
|
}
|
|
1768
1789
|
async function Ta(e, t, i) {
|
|
1769
1790
|
e.text = "查找本地产品目录...", await xe(t) || m(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
1770
|
-
const
|
|
1791
|
+
const n = De(i);
|
|
1771
1792
|
let s = await K(t.path);
|
|
1772
1793
|
e.text = "获取远程用例列表...";
|
|
1773
|
-
const o = await
|
|
1794
|
+
const o = await Pi(t.id, n);
|
|
1774
1795
|
e.text = "本地用例同步中...";
|
|
1775
1796
|
for (const r of o) {
|
|
1776
1797
|
let c;
|
|
@@ -1792,98 +1813,98 @@ async function ka(e, t) {
|
|
|
1792
1813
|
e.text = "本地产品目录查找中...";
|
|
1793
1814
|
const i = await xe(t);
|
|
1794
1815
|
i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await fe(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await oe(t.path, { recursive: !0 }), await l("git add .")), e.text = "获取远程模块列表...";
|
|
1795
|
-
const
|
|
1796
|
-
e.text = "本地同步模块中...", await Ea(
|
|
1816
|
+
const a = await nt(t.id);
|
|
1817
|
+
e.text = "本地同步模块中...", await Ea(a || [], t.path);
|
|
1797
1818
|
}
|
|
1798
1819
|
async function Ca(e, t) {
|
|
1799
|
-
const { type: i, typeStr:
|
|
1800
|
-
if (j.MODULE === i && await ka(s,
|
|
1820
|
+
const { type: i, typeStr: a } = await be("拉取", e), n = await ft(t.productId), s = h(`${a}同步中...`).start();
|
|
1821
|
+
if (j.MODULE === i && await ka(s, n), j.CASE === i && await Ta(s, n, t.caseIds), s.succeed(`${a}同步完成 🎉`), !t.disableAutoCommit && await l("git status -s")) {
|
|
1801
1822
|
const o = h("代码提交中...").start();
|
|
1802
1823
|
try {
|
|
1803
|
-
await l(`git add . && git commit -m "chore: 同步禅道${
|
|
1824
|
+
await l(`git add . && git commit -m "chore: 同步禅道${a}数据"`), o.succeed("代码已提交 ✅");
|
|
1804
1825
|
} catch (r) {
|
|
1805
1826
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
1806
1827
|
}
|
|
1807
1828
|
}
|
|
1808
1829
|
}
|
|
1809
|
-
I.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) =>
|
|
1830
|
+
I.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) => O(Ca, ...e));
|
|
1810
1831
|
async function Ia(e, t, i) {
|
|
1811
|
-
const
|
|
1832
|
+
const a = await _({
|
|
1812
1833
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
1813
|
-
}),
|
|
1814
|
-
|
|
1815
|
-
const s = await
|
|
1834
|
+
}), n = h(`用例【${i}】开始创建...`).start();
|
|
1835
|
+
n.text = "远程用例创建中...";
|
|
1836
|
+
const s = await _i({
|
|
1816
1837
|
product: Number(e.id),
|
|
1817
1838
|
// 如果父模块是产品根目录,parent=0
|
|
1818
1839
|
module: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
1819
1840
|
title: i,
|
|
1820
1841
|
type: "interface",
|
|
1821
1842
|
openedBy: A("ldapAccount"),
|
|
1822
|
-
precondition:
|
|
1843
|
+
precondition: a || ""
|
|
1823
1844
|
});
|
|
1824
|
-
|
|
1845
|
+
n.text = "远程用例步骤创建中...", await Fi({
|
|
1825
1846
|
case: s,
|
|
1826
1847
|
type: "step",
|
|
1827
1848
|
desc: "按照预期执行",
|
|
1828
1849
|
expect: "正常执行,符合预期"
|
|
1829
|
-
}),
|
|
1850
|
+
}), n.text = "本地用例创建中...";
|
|
1830
1851
|
const o = p.join(t.path, G("case", i, String(s)));
|
|
1831
1852
|
return $(o) ? B(`${o}已存在,请检查是否对应,本地不再创建。`) : (await ht(
|
|
1832
1853
|
{
|
|
1833
1854
|
id: s,
|
|
1834
1855
|
pri: 3,
|
|
1835
|
-
precondition:
|
|
1856
|
+
precondition: a
|
|
1836
1857
|
},
|
|
1837
1858
|
o
|
|
1838
|
-
),
|
|
1859
|
+
), n.succeed(`用例【[${o}】创建完成 🎉`), o);
|
|
1839
1860
|
}
|
|
1840
1861
|
async function Ra(e, t, i) {
|
|
1841
|
-
const
|
|
1842
|
-
|
|
1843
|
-
const
|
|
1862
|
+
const a = h(`模块【${i}】开始创建...`).start();
|
|
1863
|
+
a.text = "远程模块创建中...";
|
|
1864
|
+
const n = await zi({
|
|
1844
1865
|
root: Number(e.id),
|
|
1845
1866
|
name: i,
|
|
1846
1867
|
// 如果父模块是产品根目录,parent=0
|
|
1847
1868
|
parent: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
|
|
1848
1869
|
});
|
|
1849
|
-
|
|
1850
|
-
const s = p.join(t.path, G("module", i, String(
|
|
1870
|
+
a.text = "本地模块创建中...";
|
|
1871
|
+
const s = p.join(t.path, G("module", i, String(n)));
|
|
1851
1872
|
if ($(s))
|
|
1852
1873
|
return B(`${s}已存在,请检查是否对应,本地不再创建。`);
|
|
1853
1874
|
await oe(s, {
|
|
1854
1875
|
recursive: !0
|
|
1855
|
-
}),
|
|
1876
|
+
}), a.succeed(`模块【${s}】创建完成 🎉`);
|
|
1856
1877
|
}
|
|
1857
1878
|
function xa(e) {
|
|
1858
|
-
function t(
|
|
1859
|
-
if (!
|
|
1860
|
-
const
|
|
1861
|
-
|
|
1862
|
-
value:
|
|
1863
|
-
label:
|
|
1864
|
-
type:
|
|
1879
|
+
function t(a) {
|
|
1880
|
+
if (!a.children || a.children.length === 0) return;
|
|
1881
|
+
const n = a.children[0];
|
|
1882
|
+
n && n.label === a.label && n.value === a.value && (!n.children || n.children.length === 0) || a.children.unshift({
|
|
1883
|
+
value: a.value,
|
|
1884
|
+
label: a.label,
|
|
1885
|
+
type: a.type,
|
|
1865
1886
|
children: void 0,
|
|
1866
1887
|
tempTitle: "当前层级"
|
|
1867
1888
|
});
|
|
1868
1889
|
}
|
|
1869
|
-
async function i(
|
|
1870
|
-
const s =
|
|
1890
|
+
async function i(a, n = []) {
|
|
1891
|
+
const s = n.length ? `请选择层级(当前:${n.join(" / ")})` : "请选择层级", o = await E({
|
|
1871
1892
|
message: s,
|
|
1872
|
-
choices:
|
|
1893
|
+
choices: a.map((r) => ({
|
|
1873
1894
|
name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
|
|
1874
1895
|
value: r
|
|
1875
1896
|
}))
|
|
1876
1897
|
});
|
|
1877
|
-
return o?.children?.length ? (t(o), i(o.children, [...
|
|
1898
|
+
return o?.children?.length ? (t(o), i(o.children, [...n, o.label])) : o;
|
|
1878
1899
|
}
|
|
1879
1900
|
return i(e);
|
|
1880
1901
|
}
|
|
1881
1902
|
async function Da(e, t) {
|
|
1882
|
-
const { type: i, typeStr:
|
|
1903
|
+
const { type: i, typeStr: a } = await be("创建", e), { product: n, localProduct: s } = await Ne(t.productId), o = await nt(n.id), r = await xa(o), c = G("module", r.label, String(r.value)), d = (await K(n.path, { hasRoot: !0 })).find((w) => w.name === c);
|
|
1883
1904
|
if (!d?.path || !$(d.path))
|
|
1884
1905
|
return m(`本地不存在${c}模块`);
|
|
1885
|
-
const f = await
|
|
1886
|
-
message: `请输入你要创建的${
|
|
1906
|
+
const f = await _({
|
|
1907
|
+
message: `请输入你要创建的${a}名称`,
|
|
1887
1908
|
required: !0,
|
|
1888
1909
|
validate: (w) => w.length > 0 && w.length < 255
|
|
1889
1910
|
});
|
|
@@ -1897,24 +1918,24 @@ async function Da(e, t) {
|
|
|
1897
1918
|
}
|
|
1898
1919
|
}
|
|
1899
1920
|
}
|
|
1900
|
-
I.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) =>
|
|
1921
|
+
I.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => O(Da, ...e));
|
|
1901
1922
|
async function La(e, t) {
|
|
1902
|
-
const
|
|
1903
|
-
let
|
|
1923
|
+
const a = (await K(e.path)).filter((r) => r.type === "case");
|
|
1924
|
+
let n = [];
|
|
1904
1925
|
if (t.length)
|
|
1905
|
-
|
|
1926
|
+
n = a.filter((r) => t.includes(Number(r.id))).map((r) => ({
|
|
1906
1927
|
id: Number(r.id),
|
|
1907
1928
|
path: r.path
|
|
1908
|
-
})),
|
|
1929
|
+
})), n.length || m(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
|
|
1909
1930
|
else {
|
|
1910
|
-
const r =
|
|
1931
|
+
const r = a.map((c) => ({
|
|
1911
1932
|
value: {
|
|
1912
1933
|
id: Number(c.id),
|
|
1913
1934
|
path: c.path
|
|
1914
1935
|
},
|
|
1915
1936
|
name: c.path.replace(p.resolve(e.path), "")
|
|
1916
1937
|
}));
|
|
1917
|
-
|
|
1938
|
+
n = await ee({
|
|
1918
1939
|
message: "选择要删除的用例",
|
|
1919
1940
|
pageSize: 100,
|
|
1920
1941
|
loop: !1,
|
|
@@ -1924,32 +1945,32 @@ async function La(e, t) {
|
|
|
1924
1945
|
}
|
|
1925
1946
|
});
|
|
1926
1947
|
}
|
|
1927
|
-
const s = h("远程用例删除中...").start(), o =
|
|
1948
|
+
const s = h("远程用例删除中...").start(), o = n.map((r) => r.id);
|
|
1928
1949
|
await Ui({
|
|
1929
1950
|
product: Number(e.id),
|
|
1930
1951
|
caseIds: o
|
|
1931
1952
|
}), s.text = "本地用例删除中...";
|
|
1932
|
-
for (const r of
|
|
1953
|
+
for (const r of n)
|
|
1933
1954
|
$(r.path) && D.rm("-rf", r.path);
|
|
1934
1955
|
return s.succeed("用例删除完成"), o;
|
|
1935
1956
|
}
|
|
1936
|
-
async function
|
|
1937
|
-
const
|
|
1938
|
-
let
|
|
1957
|
+
async function Oa(e, t) {
|
|
1958
|
+
const a = (await K(e.path)).filter((r) => r.type === "module");
|
|
1959
|
+
let n = [];
|
|
1939
1960
|
if (t.length)
|
|
1940
|
-
|
|
1961
|
+
n = a.filter((r) => t.includes(Number(r.id))).map((r) => ({
|
|
1941
1962
|
id: Number(r.id),
|
|
1942
1963
|
path: r.path
|
|
1943
|
-
})),
|
|
1964
|
+
})), n.length || m(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
|
|
1944
1965
|
else {
|
|
1945
|
-
const r =
|
|
1966
|
+
const r = a.map((c) => ({
|
|
1946
1967
|
value: {
|
|
1947
1968
|
id: Number(c.id),
|
|
1948
1969
|
path: c.path
|
|
1949
1970
|
},
|
|
1950
1971
|
name: c.path.replace(p.resolve(e.path), "")
|
|
1951
1972
|
}));
|
|
1952
|
-
|
|
1973
|
+
n = await ee({
|
|
1953
1974
|
message: "选择要删除的模块",
|
|
1954
1975
|
pageSize: 100,
|
|
1955
1976
|
loop: !1,
|
|
@@ -1959,37 +1980,37 @@ async function Pa(e, t) {
|
|
|
1959
1980
|
}
|
|
1960
1981
|
});
|
|
1961
1982
|
}
|
|
1962
|
-
|
|
1963
|
-
const s = h("远程模块删除中...").start(), o =
|
|
1983
|
+
n = n.sort((r, c) => r.path.localeCompare(c.path));
|
|
1984
|
+
const s = h("远程模块删除中...").start(), o = n.map((r) => r.id);
|
|
1964
1985
|
await Bi({
|
|
1965
1986
|
product: Number(e.id),
|
|
1966
1987
|
moduleIds: o
|
|
1967
1988
|
}), s.text = "本地模块删除中...";
|
|
1968
|
-
for (const r of
|
|
1989
|
+
for (const r of n)
|
|
1969
1990
|
$(r.path) && D.rm("-rf", r.path);
|
|
1970
1991
|
return s.succeed("模块删除完成"), o;
|
|
1971
1992
|
}
|
|
1972
|
-
async function
|
|
1973
|
-
const { type: i, typeStr:
|
|
1993
|
+
async function Pa(e, t) {
|
|
1994
|
+
const { type: i, typeStr: a } = await be("删除", e), { localProduct: n } = await Ne(t.productId), s = De(t.targetIds);
|
|
1974
1995
|
let o = [];
|
|
1975
|
-
if (j.MODULE === i ? o = await
|
|
1996
|
+
if (j.MODULE === i ? o = await Oa(n, s) : j.CASE === i && (o = await La(n, s)), !t.disableAutoCommit && await l("git status -s")) {
|
|
1976
1997
|
const r = h("代码提交中...").start();
|
|
1977
1998
|
try {
|
|
1978
|
-
await l(`git add . && git commit -m 'chore: 删除了一些${
|
|
1999
|
+
await l(`git add . && git commit -m 'chore: 删除了一些${a}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
1979
2000
|
} catch (c) {
|
|
1980
2001
|
r.fail(`提交失败,${c}`), process.exit(1);
|
|
1981
2002
|
}
|
|
1982
2003
|
}
|
|
1983
2004
|
}
|
|
1984
|
-
I.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) =>
|
|
2005
|
+
I.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) => O(Pa, ...e));
|
|
1985
2006
|
async function Ma(e, t) {
|
|
1986
|
-
const
|
|
1987
|
-
let
|
|
2007
|
+
const a = (await K(e.path)).filter((g) => g.type === "case");
|
|
2008
|
+
let n;
|
|
1988
2009
|
if (t.targetId) {
|
|
1989
|
-
if (
|
|
2010
|
+
if (n = a.find((g) => Number(g.id) === Number(t.targetId)), !n)
|
|
1990
2011
|
return m(`未找到对应用例,请确认输入的用例ID(${t.targetId})是否正确`);
|
|
1991
2012
|
} else {
|
|
1992
|
-
const g =
|
|
2013
|
+
const g = a.map((w) => ({
|
|
1993
2014
|
value: {
|
|
1994
2015
|
id: Number(w.id),
|
|
1995
2016
|
path: w.path,
|
|
@@ -1997,7 +2018,7 @@ async function Ma(e, t) {
|
|
|
1997
2018
|
},
|
|
1998
2019
|
name: w.path.replace(p.resolve(e.path), "")
|
|
1999
2020
|
}));
|
|
2000
|
-
[
|
|
2021
|
+
[n] = await ee({
|
|
2001
2022
|
message: "选择要更新的用例",
|
|
2002
2023
|
pageSize: 100,
|
|
2003
2024
|
loop: !1,
|
|
@@ -2008,18 +2029,18 @@ async function Ma(e, t) {
|
|
|
2008
2029
|
}
|
|
2009
2030
|
});
|
|
2010
2031
|
}
|
|
2011
|
-
const s = await
|
|
2032
|
+
const s = await _({
|
|
2012
2033
|
message: "修改用例名称",
|
|
2013
|
-
default:
|
|
2034
|
+
default: n.displayName,
|
|
2014
2035
|
required: !0,
|
|
2015
2036
|
validate: (g) => g.length > 0 && g.length < 255,
|
|
2016
2037
|
prefill: "editable"
|
|
2017
2038
|
}), o = h("用例重命名中...").start();
|
|
2018
|
-
s !==
|
|
2019
|
-
id: Number(
|
|
2039
|
+
s !== n.displayName ? (await Gi({
|
|
2040
|
+
id: Number(n.id),
|
|
2020
2041
|
name: s
|
|
2021
|
-
}), await fe(
|
|
2022
|
-
let r = S.readJsonSync(p.join(
|
|
2042
|
+
}), await fe(n.path, s, "case", String(n.id)) && o.succeed(`用例重命名成功: ${n.displayName} -> ${s}`), n.displayName = s, n.path = p.join(p.dirname(n.path), G("case", s, String(n.id)))) : o.succeed("用例名称无变动");
|
|
2043
|
+
let r = S.readJsonSync(p.join(n.path, "config.json")), c;
|
|
2023
2044
|
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await Me({
|
|
2024
2045
|
message: "修改用例优先级",
|
|
2025
2046
|
min: 1,
|
|
@@ -2037,43 +2058,43 @@ async function Ma(e, t) {
|
|
|
2037
2058
|
});
|
|
2038
2059
|
const u = h("用例优先级设置中...").start();
|
|
2039
2060
|
c !== r.priority ? (await Wi({
|
|
2040
|
-
id: Number(
|
|
2061
|
+
id: Number(n.id),
|
|
2041
2062
|
priority: c
|
|
2042
2063
|
}), S.writeJSONSync(
|
|
2043
|
-
p.join(
|
|
2064
|
+
p.join(n.path, "config.json"),
|
|
2044
2065
|
{
|
|
2045
2066
|
...r,
|
|
2046
2067
|
priority: c
|
|
2047
2068
|
},
|
|
2048
2069
|
{ spaces: 2 }
|
|
2049
|
-
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = S.readJsonSync(p.join(
|
|
2070
|
+
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = S.readJsonSync(p.join(n.path, "config.json"));
|
|
2050
2071
|
let d;
|
|
2051
|
-
t.casePrecondition ? d = t.casePrecondition : d = await
|
|
2072
|
+
t.casePrecondition ? d = t.casePrecondition : d = await _({
|
|
2052
2073
|
message: "修改用例前置条件",
|
|
2053
2074
|
default: r.precondition,
|
|
2054
2075
|
prefill: "editable"
|
|
2055
2076
|
});
|
|
2056
2077
|
const f = h("用例前置条件设置中...").start();
|
|
2057
2078
|
return d !== r.precondition ? (await qi({
|
|
2058
|
-
id: Number(
|
|
2079
|
+
id: Number(n.id),
|
|
2059
2080
|
precondition: d
|
|
2060
2081
|
}), S.writeJSONSync(
|
|
2061
|
-
p.join(
|
|
2082
|
+
p.join(n.path, "config.json"),
|
|
2062
2083
|
{
|
|
2063
2084
|
...r,
|
|
2064
2085
|
precondition: d
|
|
2065
2086
|
},
|
|
2066
2087
|
{ spaces: 2 }
|
|
2067
|
-
), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : f.succeed("用例前置条件无变动"),
|
|
2088
|
+
), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : f.succeed("用例前置条件无变动"), n.id;
|
|
2068
2089
|
}
|
|
2069
2090
|
async function za(e, t) {
|
|
2070
|
-
const
|
|
2071
|
-
let
|
|
2091
|
+
const a = (await K(e.path)).filter((r) => r.type === "module");
|
|
2092
|
+
let n;
|
|
2072
2093
|
if (t.targetId) {
|
|
2073
|
-
if (
|
|
2094
|
+
if (n = a.find((r) => Number(r.id) === Number(t.targetId)), !n)
|
|
2074
2095
|
return m(`未找到对应模块,请确认输入的模块ID(${t.targetId})是否正确`);
|
|
2075
2096
|
} else {
|
|
2076
|
-
const r =
|
|
2097
|
+
const r = a.map((c) => ({
|
|
2077
2098
|
value: {
|
|
2078
2099
|
id: Number(c.id),
|
|
2079
2100
|
path: c.path,
|
|
@@ -2081,7 +2102,7 @@ async function za(e, t) {
|
|
|
2081
2102
|
},
|
|
2082
2103
|
name: c.path.replace(p.resolve(e.path), "")
|
|
2083
2104
|
}));
|
|
2084
|
-
[
|
|
2105
|
+
[n] = await ee({
|
|
2085
2106
|
message: "选择要更新的模块",
|
|
2086
2107
|
pageSize: 100,
|
|
2087
2108
|
loop: !1,
|
|
@@ -2092,36 +2113,36 @@ async function za(e, t) {
|
|
|
2092
2113
|
}
|
|
2093
2114
|
});
|
|
2094
2115
|
}
|
|
2095
|
-
const s = await
|
|
2116
|
+
const s = await _({
|
|
2096
2117
|
message: "修改模块名称",
|
|
2097
|
-
default:
|
|
2118
|
+
default: n.displayName,
|
|
2098
2119
|
required: !0,
|
|
2099
2120
|
validate: (r) => r.length > 0 && r.length < 255,
|
|
2100
2121
|
prefill: "editable"
|
|
2101
2122
|
}), o = h("模块重命名中...").start();
|
|
2102
|
-
return s !==
|
|
2103
|
-
id: Number(
|
|
2123
|
+
return s !== n.displayName ? (await Ji({
|
|
2124
|
+
id: Number(n.id),
|
|
2104
2125
|
name: s
|
|
2105
|
-
}), await fe(
|
|
2126
|
+
}), await fe(n.path, s, "module", String(n.id)) && o.succeed(`模块重命名成功: ${n.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), n.id;
|
|
2106
2127
|
}
|
|
2107
|
-
async function
|
|
2108
|
-
const { type: i, typeStr:
|
|
2128
|
+
async function _a(e, t) {
|
|
2129
|
+
const { type: i, typeStr: a } = await be("修改", e), { localProduct: n } = await Ne(t.productId);
|
|
2109
2130
|
let s;
|
|
2110
|
-
if (j.MODULE === i ? s = await za(
|
|
2131
|
+
if (j.MODULE === i ? s = await za(n, t) : j.CASE === i && (s = await Ma(n, t)), !t.disableAutoCommit && await l("git status -s")) {
|
|
2111
2132
|
const o = h("代码提交中...").start();
|
|
2112
2133
|
try {
|
|
2113
|
-
await l(`git add . && git commit -m 'chore: 修改了一个${
|
|
2134
|
+
await l(`git add . && git commit -m 'chore: 修改了一个${a}(${s})'`), o.succeed("代码已提交 ✅");
|
|
2114
2135
|
} catch (r) {
|
|
2115
2136
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
2116
2137
|
}
|
|
2117
2138
|
}
|
|
2118
2139
|
}
|
|
2119
|
-
I.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) =>
|
|
2120
|
-
async function
|
|
2140
|
+
I.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) => O(_a, ...e));
|
|
2141
|
+
async function Fa() {
|
|
2121
2142
|
const e = ve();
|
|
2122
2143
|
if (!e?.interpreter?.path) {
|
|
2123
2144
|
Vt("$ 执行用例前,需要配置解释器路径");
|
|
2124
|
-
const t = await
|
|
2145
|
+
const t = await _({
|
|
2125
2146
|
message: "请输入Python解释器在本机的路径",
|
|
2126
2147
|
required: !0
|
|
2127
2148
|
});
|
|
@@ -2134,21 +2155,21 @@ async function _a() {
|
|
|
2134
2155
|
}
|
|
2135
2156
|
return e?.interpreter?.path;
|
|
2136
2157
|
}
|
|
2137
|
-
async function Ba(e, t) {
|
|
2158
|
+
async function Ba(e, t, i) {
|
|
2138
2159
|
if (!t.length)
|
|
2139
2160
|
return [];
|
|
2140
|
-
const
|
|
2141
|
-
(
|
|
2161
|
+
const a = It(20), n = t.map(
|
|
2162
|
+
(s) => a(async () => {
|
|
2142
2163
|
try {
|
|
2143
|
-
const
|
|
2164
|
+
const o = i.env || "production", r = await l(`${e} ${s.path}/main.py --env ${o}`);
|
|
2144
2165
|
try {
|
|
2145
|
-
|
|
2166
|
+
s.result = JSON.parse(r);
|
|
2146
2167
|
} catch {
|
|
2147
|
-
m(`用例${
|
|
2168
|
+
m(`用例${s.displayName}[${s.id}]返回格式错误:${r}`);
|
|
2148
2169
|
}
|
|
2149
|
-
} catch (
|
|
2150
|
-
const
|
|
2151
|
-
m(`用例${
|
|
2170
|
+
} catch (o) {
|
|
2171
|
+
const r = o instanceof Error ? o.message : String(o);
|
|
2172
|
+
m(`用例${s.displayName}[${s.id}]执行失败: ${r}`);
|
|
2152
2173
|
}
|
|
2153
2174
|
})
|
|
2154
2175
|
);
|
|
@@ -2156,11 +2177,11 @@ async function Ba(e, t) {
|
|
|
2156
2177
|
}
|
|
2157
2178
|
async function Ua(e) {
|
|
2158
2179
|
te(), Q();
|
|
2159
|
-
const t = await
|
|
2160
|
-
let
|
|
2180
|
+
const t = await Fa(), { localProduct: i } = await Ne(e.productId);
|
|
2181
|
+
let a = [];
|
|
2161
2182
|
const s = (await K(i.path)).filter((u) => u.type === "case");
|
|
2162
2183
|
if (e.all)
|
|
2163
|
-
|
|
2184
|
+
a = s.map((u) => ({
|
|
2164
2185
|
id: Number(u.id),
|
|
2165
2186
|
path: u.path,
|
|
2166
2187
|
displayName: u.displayName
|
|
@@ -2168,7 +2189,7 @@ async function Ua(e) {
|
|
|
2168
2189
|
else {
|
|
2169
2190
|
const u = De(e.caseIds);
|
|
2170
2191
|
if (u.length)
|
|
2171
|
-
|
|
2192
|
+
a = s.filter((d) => u.includes(Number(d.id))).map((d) => ({
|
|
2172
2193
|
id: Number(d.id),
|
|
2173
2194
|
path: d.path,
|
|
2174
2195
|
displayName: d.displayName
|
|
@@ -2182,7 +2203,7 @@ async function Ua(e) {
|
|
|
2182
2203
|
},
|
|
2183
2204
|
name: f.path.replace(p.resolve(i.path), "")
|
|
2184
2205
|
}));
|
|
2185
|
-
|
|
2206
|
+
a = await ee({
|
|
2186
2207
|
message: "选择要执行的用例",
|
|
2187
2208
|
pageSize: 100,
|
|
2188
2209
|
loop: !1,
|
|
@@ -2193,7 +2214,7 @@ async function Ua(e) {
|
|
|
2193
2214
|
});
|
|
2194
2215
|
}
|
|
2195
2216
|
}
|
|
2196
|
-
const o = h("用例执行中...").start(), c = (await Ba(t,
|
|
2217
|
+
const o = h("用例执行中...").start(), c = (await Ba(t, a, e)).filter((u) => u.result.length);
|
|
2197
2218
|
if (c.length === 0)
|
|
2198
2219
|
o.succeed("所有用例执行通过 🎉");
|
|
2199
2220
|
else {
|
|
@@ -2205,7 +2226,7 @@ async function Ua(e) {
|
|
|
2205
2226
|
I.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有ID").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option(
|
|
2206
2227
|
"--process-step <step>",
|
|
2207
2228
|
"不传默认3。 1. 仅在本地返回执行报告; 2. 仅将执行报告提交到禅道用例执行结果; 3. 执行报告提交到禅道用例并将执行出错的结果提交BUG。"
|
|
2208
|
-
).option("--zen-execution-id <zenExecutionId>", "提bug时,要关联的禅道执行ID").option("--zen-build-id <zenBuildId>", "提bug时,要关联的禅道执行构建ID。默认「主干」").option("--zen-bug-title <zenBugTitle>", "提bug时,bug标题。默认用例名称").option("--zen-bug-severity <zenBugServerity>", "提bug时,bug严重程度。默认3").action((...e) =>
|
|
2229
|
+
).option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--zen-execution-id <zenExecutionId>", "提bug时,要关联的禅道执行ID").option("--zen-build-id <zenBuildId>", "提bug时,要关联的禅道执行构建ID。默认「主干」").option("--zen-bug-title <zenBugTitle>", "提bug时,bug标题。默认用例名称").option("--zen-bug-severity <zenBugServerity>", "提bug时,bug严重程度。默认3").action((...e) => O(Ua, ...e));
|
|
2209
2230
|
function Ja() {
|
|
2210
2231
|
process.on("unhandledRejection", (e) => {
|
|
2211
2232
|
}), process.on("uncaughtException", (e) => {
|
|
@@ -2216,17 +2237,17 @@ async function Ga() {
|
|
|
2216
2237
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
2217
2238
|
const i = await it();
|
|
2218
2239
|
ke(i);
|
|
2219
|
-
let
|
|
2240
|
+
let a;
|
|
2220
2241
|
try {
|
|
2221
|
-
const
|
|
2222
|
-
setTimeout(() => o(
|
|
2242
|
+
const n = "TIME_OUT", s = new Promise((o) => {
|
|
2243
|
+
setTimeout(() => o(n), 3e3);
|
|
2223
2244
|
});
|
|
2224
|
-
|
|
2245
|
+
a = await Promise.race([
|
|
2225
2246
|
s,
|
|
2226
2247
|
l(`npm view ${X.name} version --registry https://registry.npmmirror.com/`)
|
|
2227
|
-
]),
|
|
2228
|
-
} catch (
|
|
2229
|
-
console.log("升级出错!请重试,或者手动升级"), m(
|
|
2248
|
+
]), a !== n && a !== X.version && (console.log(`${N.blue(X.name)}本地版本为${X.version},低于线上版本${a},开始升级`), await lt(a)), re("latestCheckVersionTimestamp", Date.now()), ae();
|
|
2249
|
+
} catch (n) {
|
|
2250
|
+
console.log("升级出错!请重试,或者手动升级"), m(n);
|
|
2230
2251
|
}
|
|
2231
2252
|
}
|
|
2232
2253
|
}
|