cli-z-develop 0.12.1 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +258 -247
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { program as D } from "commander";
|
|
2
2
|
import $t from "node:child_process";
|
|
3
3
|
import { existsSync as v, readdirSync as vt, lstatSync as Nt, createWriteStream as bt } from "node:fs";
|
|
4
|
-
import { readdir as Re, mkdir as le, writeFile as L, rename as _e, readFile as
|
|
5
|
-
import
|
|
4
|
+
import { readdir as Re, mkdir as le, writeFile as L, rename as _e, readFile as Ee, stat as At } from "node:fs/promises";
|
|
5
|
+
import p from "node:path";
|
|
6
6
|
import ce, { AxiosError as jt } from "axios";
|
|
7
7
|
import S from "chalk";
|
|
8
8
|
import St from "dayjs";
|
|
9
|
-
import
|
|
9
|
+
import O from "shelljs";
|
|
10
10
|
import Tt from "node:os";
|
|
11
11
|
import Me from "child_process";
|
|
12
|
-
import { confirm as Ue, select as T, input as F, password as
|
|
13
|
-
import
|
|
12
|
+
import { confirm as Ue, select as T, input as F, password as kt, checkbox as Ce, number as ze } from "@inquirer/prompts";
|
|
13
|
+
import y from "ora";
|
|
14
14
|
import I from "fs-extra";
|
|
15
15
|
import { select as ae } from "inquirer-select-pro";
|
|
16
|
-
import
|
|
16
|
+
import Et from "lint-staged";
|
|
17
17
|
import Ct from "semver";
|
|
18
18
|
import { run as Rt } from "npm-check-updates";
|
|
19
19
|
import It from "p-limit";
|
|
20
20
|
import xt from "minimist";
|
|
21
21
|
const Ge = "dev", Ve = "test", We = "release", Dt = "production", Lt = "master";
|
|
22
|
-
var b = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = Ve] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.PROD = Dt] = "PROD", e))(b || {}),
|
|
22
|
+
var b = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = Ve] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.PROD = Dt] = "PROD", e))(b || {}), $ = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = Ve] = "TEST", e[e.RELEASE = We] = "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}`,
|
|
@@ -37,7 +37,7 @@ const qe = [
|
|
|
37
37
|
name: `正式环境 - ${b.PROD}`,
|
|
38
38
|
value: b.PROD
|
|
39
39
|
}
|
|
40
|
-
],
|
|
40
|
+
], Ot = [
|
|
41
41
|
{
|
|
42
42
|
name: "网页 - h5",
|
|
43
43
|
value: "h5"
|
|
@@ -54,8 +54,8 @@ const qe = [
|
|
|
54
54
|
/* SERVER */
|
|
55
55
|
}
|
|
56
56
|
];
|
|
57
|
-
var de = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(de || {}), oe = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(oe || {}),
|
|
58
|
-
const
|
|
57
|
+
var de = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(de || {}), oe = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(oe || {}), w = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e.MARKDOWN = "Markdown", e))(w || {});
|
|
58
|
+
const Pt = {
|
|
59
59
|
1: "研发",
|
|
60
60
|
2: "测试",
|
|
61
61
|
3: "产品",
|
|
@@ -82,7 +82,7 @@ const Bt = [
|
|
|
82
82
|
}
|
|
83
83
|
], Jt = ".z", Ft = "develop-config.json", K = ".z", _t = ".commit-msg-tpl", Ut = "project.json";
|
|
84
84
|
function C(e = "") {
|
|
85
|
-
return
|
|
85
|
+
return p.join(K, e);
|
|
86
86
|
}
|
|
87
87
|
function Ze() {
|
|
88
88
|
return C(Ut);
|
|
@@ -94,7 +94,7 @@ function Ke() {
|
|
|
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
|
|
97
|
+
return p.resolve(Tt.homedir(), Jt, e);
|
|
98
98
|
}
|
|
99
99
|
function be() {
|
|
100
100
|
return he(Ft);
|
|
@@ -134,15 +134,15 @@ function Je(e) {
|
|
|
134
134
|
return v(e) ? Nt(e).isDirectory() : !1;
|
|
135
135
|
}
|
|
136
136
|
function Qe(e = process.cwd()) {
|
|
137
|
-
return Je(e) ? vt(e).filter((i) => Je(
|
|
137
|
+
return Je(e) ? vt(e).filter((i) => Je(p.resolve(e, i))) : [];
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
139
|
+
async function m(e, t = {
|
|
140
140
|
removeTailLinkBreak: !0,
|
|
141
141
|
silent: !0
|
|
142
142
|
}) {
|
|
143
143
|
let i = await new Promise((n, a) => {
|
|
144
144
|
try {
|
|
145
|
-
const s =
|
|
145
|
+
const s = O.exec(e, {
|
|
146
146
|
silent: t.silent
|
|
147
147
|
});
|
|
148
148
|
n(s);
|
|
@@ -170,16 +170,16 @@ function ne() {
|
|
|
170
170
|
v(C()) || l("当前不在项目根目录。请切换到项目根目录");
|
|
171
171
|
}
|
|
172
172
|
function Q() {
|
|
173
|
-
v(
|
|
173
|
+
v(p.resolve(".git")) || l("当前不是git项目根目录,请先执行git init,或切换到根目录");
|
|
174
174
|
}
|
|
175
|
-
async function
|
|
176
|
-
await
|
|
175
|
+
async function me() {
|
|
176
|
+
await m("git status -s") !== "" && l("请先提交代码变动,再进行操作");
|
|
177
177
|
}
|
|
178
178
|
function Ht(e) {
|
|
179
|
-
return e ===
|
|
179
|
+
return e === $.MASTER ? b.PROD : e;
|
|
180
180
|
}
|
|
181
181
|
function Zt(e) {
|
|
182
|
-
return e === b.PROD ?
|
|
182
|
+
return e === b.PROD ? $.MASTER : e;
|
|
183
183
|
}
|
|
184
184
|
async function z(e, ...t) {
|
|
185
185
|
try {
|
|
@@ -249,19 +249,24 @@ ${t}
|
|
|
249
249
|
`;
|
|
250
250
|
}
|
|
251
251
|
const Xt = {
|
|
252
|
-
[
|
|
252
|
+
[w.JAVA]: {
|
|
253
253
|
"**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml"
|
|
254
254
|
},
|
|
255
|
-
[
|
|
255
|
+
[w.JAVASCRIPT]: {
|
|
256
256
|
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
257
257
|
"*": "prettier -wu"
|
|
258
258
|
},
|
|
259
|
-
[
|
|
259
|
+
[w.PYTHON]: {
|
|
260
260
|
// TODO: 需要优化
|
|
261
261
|
// "**/*.{py}": "python --fix",
|
|
262
262
|
"**/*.{py}": "echo 'todo'"
|
|
263
|
+
},
|
|
264
|
+
[w.MARKDOWN]: {
|
|
265
|
+
"**/*.md": "markdownlint --fix",
|
|
266
|
+
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
267
|
+
"*": "prettier -wu"
|
|
263
268
|
}
|
|
264
|
-
}, Qt = "cli-z-develop", ei = "0.12.
|
|
269
|
+
}, Qt = "cli-z-develop", ei = "0.12.3", 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 = {
|
|
265
270
|
name: Qt,
|
|
266
271
|
version: ei,
|
|
267
272
|
description: ti,
|
|
@@ -306,7 +311,7 @@ const Xt = {
|
|
|
306
311
|
FECDNDomain: ""
|
|
307
312
|
}
|
|
308
313
|
};
|
|
309
|
-
function
|
|
314
|
+
function E(e) {
|
|
310
315
|
return e ? x.profile[e] : x.profile;
|
|
311
316
|
}
|
|
312
317
|
function ge(e) {
|
|
@@ -319,15 +324,15 @@ let _ = null, U = null;
|
|
|
319
324
|
function Ae() {
|
|
320
325
|
if (_)
|
|
321
326
|
return _;
|
|
322
|
-
const e =
|
|
323
|
-
return v(e) || l(`当前目录(${
|
|
327
|
+
const e = p.join("package.json");
|
|
328
|
+
return v(e) || l(`当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), _ = I.readJsonSync(e), _;
|
|
324
329
|
}
|
|
325
|
-
function
|
|
330
|
+
function pe() {
|
|
326
331
|
if (U)
|
|
327
332
|
return U;
|
|
328
333
|
const e = Ze();
|
|
329
334
|
return v(e) || l(
|
|
330
|
-
`当前目录(${
|
|
335
|
+
`当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
331
336
|
), U = I.readJsonSync(e), U;
|
|
332
337
|
}
|
|
333
338
|
function ui(e) {
|
|
@@ -340,7 +345,7 @@ function li(e) {
|
|
|
340
345
|
_ ? _ = {
|
|
341
346
|
..._,
|
|
342
347
|
...e
|
|
343
|
-
} : _ = e, I.writeJSONSync(
|
|
348
|
+
} : _ = e, I.writeJSONSync(p.join("package.json"), _, { spaces: 2 });
|
|
344
349
|
}
|
|
345
350
|
const Z = {
|
|
346
351
|
id: 0,
|
|
@@ -349,22 +354,22 @@ const Z = {
|
|
|
349
354
|
sourceBranch: "",
|
|
350
355
|
mergeRequestUrl: ""
|
|
351
356
|
};
|
|
352
|
-
async function
|
|
357
|
+
async function mi() {
|
|
353
358
|
if (!Z.id)
|
|
354
359
|
try {
|
|
355
|
-
const e =
|
|
360
|
+
const e = pe(), t = $e(e.repository.url), i = await nt(t);
|
|
356
361
|
Z.id = i.id, Z.path = t, Z.group = i.namespace.full_path, Z.mergeRequestUrl = `${i.web_url}/merge_requests`;
|
|
357
362
|
} catch (e) {
|
|
358
363
|
l(e);
|
|
359
364
|
}
|
|
360
|
-
return Z.sourceBranch || (Z.sourceBranch = await
|
|
365
|
+
return Z.sourceBranch || (Z.sourceBranch = await m("git branch --show-current")), Z;
|
|
361
366
|
}
|
|
362
367
|
function se() {
|
|
363
368
|
I.writeJSONSync(
|
|
364
369
|
be(),
|
|
365
370
|
{
|
|
366
371
|
main: ge(),
|
|
367
|
-
profile:
|
|
372
|
+
profile: E(),
|
|
368
373
|
constants: q()
|
|
369
374
|
},
|
|
370
375
|
{
|
|
@@ -407,8 +412,8 @@ async function Y(e) {
|
|
|
407
412
|
return s instanceof jt && ye(S.red("Error"), S.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
|
|
408
413
|
}
|
|
409
414
|
}
|
|
410
|
-
async function
|
|
411
|
-
const e =
|
|
415
|
+
async function pi() {
|
|
416
|
+
const e = E("gitToken");
|
|
412
417
|
if (e)
|
|
413
418
|
return e;
|
|
414
419
|
{
|
|
@@ -417,8 +422,8 @@ async function mi() {
|
|
|
417
422
|
method: "post",
|
|
418
423
|
data: {
|
|
419
424
|
grant_type: "password",
|
|
420
|
-
username:
|
|
421
|
-
password:
|
|
425
|
+
username: E("ldapAccount"),
|
|
426
|
+
password: E("ldapPassword")
|
|
422
427
|
}
|
|
423
428
|
}), i = `Bearer ${t}`;
|
|
424
429
|
return M("gitToken", i), se(), i;
|
|
@@ -428,12 +433,12 @@ async function N(e) {
|
|
|
428
433
|
return Y({
|
|
429
434
|
...e,
|
|
430
435
|
headers: {
|
|
431
|
-
Authorization: await
|
|
436
|
+
Authorization: await pi()
|
|
432
437
|
}
|
|
433
438
|
});
|
|
434
439
|
}
|
|
435
440
|
async function di() {
|
|
436
|
-
const e =
|
|
441
|
+
const e = E("zenTaoToken");
|
|
437
442
|
if (e)
|
|
438
443
|
return e;
|
|
439
444
|
{
|
|
@@ -441,8 +446,8 @@ async function di() {
|
|
|
441
446
|
url: `${q("ZenTaoDomain")}/api.php/v1/tokens`,
|
|
442
447
|
method: "post",
|
|
443
448
|
data: {
|
|
444
|
-
account:
|
|
445
|
-
password:
|
|
449
|
+
account: E("ldapAccount"),
|
|
450
|
+
password: E("ldapPassword")
|
|
446
451
|
}
|
|
447
452
|
});
|
|
448
453
|
return M("zenTaoToken", t), se(), t;
|
|
@@ -476,7 +481,7 @@ async function ve(e) {
|
|
|
476
481
|
}
|
|
477
482
|
}
|
|
478
483
|
async function fi() {
|
|
479
|
-
const e =
|
|
484
|
+
const e = E("k8sToken");
|
|
480
485
|
if (e)
|
|
481
486
|
return e;
|
|
482
487
|
{
|
|
@@ -487,8 +492,8 @@ async function fi() {
|
|
|
487
492
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
488
493
|
},
|
|
489
494
|
data: {
|
|
490
|
-
username:
|
|
491
|
-
password:
|
|
495
|
+
username: E("ldapAccount"),
|
|
496
|
+
password: E("ldapPassword")
|
|
492
497
|
}
|
|
493
498
|
}), i = `Bearer ${t}`;
|
|
494
499
|
return M("k8sToken", i), se(), i;
|
|
@@ -583,12 +588,12 @@ function Ti() {
|
|
|
583
588
|
url: `${B()}/user`
|
|
584
589
|
});
|
|
585
590
|
}
|
|
586
|
-
function
|
|
591
|
+
function ki() {
|
|
587
592
|
return N({
|
|
588
593
|
url: `${B()}/groups`
|
|
589
594
|
});
|
|
590
595
|
}
|
|
591
|
-
function
|
|
596
|
+
function Ei(e) {
|
|
592
597
|
return N({
|
|
593
598
|
url: `${B()}/projects`,
|
|
594
599
|
method: "post",
|
|
@@ -642,17 +647,17 @@ function Li(e) {
|
|
|
642
647
|
data: e
|
|
643
648
|
});
|
|
644
649
|
}
|
|
645
|
-
function
|
|
650
|
+
function Oi(e) {
|
|
646
651
|
return N({
|
|
647
652
|
url: `${B()}/projects/${e}/repository/branches`
|
|
648
653
|
});
|
|
649
654
|
}
|
|
650
|
-
function
|
|
655
|
+
function Pi() {
|
|
651
656
|
const e = he("fe-groups.json");
|
|
652
657
|
return v(e) ? I.readJSONSync(e) : { groups: [] };
|
|
653
658
|
}
|
|
654
659
|
async function Mi() {
|
|
655
|
-
const e = await
|
|
660
|
+
const e = await ki(), t = Mt.map((i) => {
|
|
656
661
|
const n = e.find((a) => a.name === i);
|
|
657
662
|
return n ? {
|
|
658
663
|
name: n.name,
|
|
@@ -824,7 +829,7 @@ function aa(e, t) {
|
|
|
824
829
|
}
|
|
825
830
|
async function rt() {
|
|
826
831
|
const t = (await zi()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
827
|
-
name: `${s.nick} - ${
|
|
832
|
+
name: `${s.nick} - ${Pt[s.title]}`,
|
|
828
833
|
value: s.weWorkUserId
|
|
829
834
|
})), i = ge("weWorkListCache"), n = i.map((s) => s.value), a = [];
|
|
830
835
|
return t.forEach((s) => {
|
|
@@ -868,7 +873,7 @@ async function sa() {
|
|
|
868
873
|
try {
|
|
869
874
|
Ye() && (await Ue({
|
|
870
875
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
871
|
-
}) ?
|
|
876
|
+
}) ? O.rm("-rf", be()) : process.exit(0)), await le(he(), { recursive: !0 });
|
|
872
877
|
const t = await T({
|
|
873
878
|
message: "请选择岗位类型",
|
|
874
879
|
choices: [
|
|
@@ -890,7 +895,7 @@ async function sa() {
|
|
|
890
895
|
message: "请输入LDAP账号:"
|
|
891
896
|
});
|
|
892
897
|
i = i.trim();
|
|
893
|
-
let n = await
|
|
898
|
+
let n = await kt({
|
|
894
899
|
message: "请输入LDAP密码:",
|
|
895
900
|
mask: !0
|
|
896
901
|
});
|
|
@@ -905,7 +910,7 @@ async function sa() {
|
|
|
905
910
|
} catch (t) {
|
|
906
911
|
l(t);
|
|
907
912
|
}
|
|
908
|
-
const e =
|
|
913
|
+
const e = y("配置信息初始化中").start();
|
|
909
914
|
try {
|
|
910
915
|
const t = await Ti();
|
|
911
916
|
M({
|
|
@@ -913,7 +918,7 @@ async function sa() {
|
|
|
913
918
|
gitName: t.name,
|
|
914
919
|
gitEnglishName: t.username,
|
|
915
920
|
gitEmail: t.email
|
|
916
|
-
}), ue("latestCheckVersionTimestamp", Date.now()), se(),
|
|
921
|
+
}), ue("latestCheckVersionTimestamp", Date.now()), se(), E("jobType") === oe.FRONT_END && await Mi(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
917
922
|
} catch (t) {
|
|
918
923
|
e.fail("配置信息初始化失败"), ce.isAxiosError(t) && l("请检查你的域名及令牌配置"), l(t);
|
|
919
924
|
}
|
|
@@ -923,17 +928,17 @@ async function ra() {
|
|
|
923
928
|
`, { mode: 493 }), await L(C("commit-msg"), `#!/usr/bin/env sh
|
|
924
929
|
z run commit-msg`, { mode: 493 }), await L(C("pre-commit"), `#!/usr/bin/env sh
|
|
925
930
|
z run commit-files`, { mode: 493 });
|
|
926
|
-
const { language: e } =
|
|
927
|
-
if (e
|
|
931
|
+
const { language: e } = pe();
|
|
932
|
+
if ([w.JAVASCRIPT, w.MARKDOWN].includes(e) && (await L(
|
|
928
933
|
C(".prettierrc.json"),
|
|
929
934
|
`${JSON.stringify(await Ni(), null, 2)}
|
|
930
935
|
`,
|
|
931
936
|
{
|
|
932
937
|
mode: 493
|
|
933
938
|
}
|
|
934
|
-
), await L(C(".prettierignore"), await vi(), { mode: 493 }), await L(C("tsconfig.node.json"), await $i(), { mode: 493 }), await L(C("tsconfig.browser.json"), await yi(), { mode: 493 })), e ===
|
|
939
|
+
), await L(C(".prettierignore"), await vi(), { mode: 493 }), await L(C("tsconfig.node.json"), await $i(), { mode: 493 }), await L(C("tsconfig.browser.json"), await yi(), { mode: 493 })), e === w.JAVA) {
|
|
935
940
|
await gi(`${q("FECDNDomain")}/file/vgnlfbfHRF.jar`, C("checkstyle.jar")), await L(C("checkstyle.xml"), await ji(), { mode: 493 });
|
|
936
|
-
const t =
|
|
941
|
+
const t = p.join("package.json");
|
|
937
942
|
v(t) || await L(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
|
|
938
943
|
mode: 493
|
|
939
944
|
});
|
|
@@ -941,23 +946,27 @@ z run commit-files`, { mode: 493 });
|
|
|
941
946
|
Ke();
|
|
942
947
|
}
|
|
943
948
|
async function oa(e, t) {
|
|
944
|
-
const i = await
|
|
949
|
+
const i = await m("git remote get-url --push origin");
|
|
945
950
|
i || l("获取项目远程git地址失败,请配置后重试");
|
|
946
951
|
let n = e;
|
|
947
952
|
n || (n = await T({
|
|
948
953
|
message: "请选择项目语言",
|
|
949
954
|
choices: [
|
|
950
955
|
{
|
|
951
|
-
name:
|
|
952
|
-
value:
|
|
956
|
+
name: w.JAVASCRIPT,
|
|
957
|
+
value: w.JAVASCRIPT
|
|
953
958
|
},
|
|
954
959
|
{
|
|
955
|
-
name:
|
|
956
|
-
value:
|
|
960
|
+
name: w.JAVA,
|
|
961
|
+
value: w.JAVA
|
|
957
962
|
},
|
|
958
963
|
{
|
|
959
|
-
name:
|
|
960
|
-
value:
|
|
964
|
+
name: w.PYTHON,
|
|
965
|
+
value: w.PYTHON
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
name: w.MARKDOWN,
|
|
969
|
+
value: w.MARKDOWN
|
|
961
970
|
}
|
|
962
971
|
]
|
|
963
972
|
}));
|
|
@@ -978,19 +987,19 @@ async function oa(e, t) {
|
|
|
978
987
|
});
|
|
979
988
|
}
|
|
980
989
|
async function xe(e, t) {
|
|
981
|
-
e ?
|
|
990
|
+
e ? O.rm("-rf", K) : v(C()) && (await Ue({
|
|
982
991
|
message: `当前项目中已存在配置文件夹${K},确认重新配置?`
|
|
983
|
-
}) ?
|
|
984
|
-
const i =
|
|
992
|
+
}) ? O.rm("-rf", K) : process.exit(0)), await le(C(), { recursive: !0 }), await oa(e, t);
|
|
993
|
+
const i = y("项目初始化中...").start();
|
|
985
994
|
await ra(), i.succeed("项目初始化完成");
|
|
986
995
|
}
|
|
987
996
|
async function ca() {
|
|
988
997
|
v(C()) && v(Ne()) ? Ke() : await xe(), process.exit(0);
|
|
989
998
|
}
|
|
990
999
|
async function ua(e, t) {
|
|
991
|
-
t.projectLanguage && !Object.values(
|
|
1000
|
+
t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && l("项目语言不支持"), e ? (Q(), e === "." ? (await xe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await ca() : l("参数错误。执行 z init -h 查看帮助。")) : await sa();
|
|
992
1001
|
}
|
|
993
|
-
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(
|
|
1002
|
+
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => z(ua, ...e));
|
|
994
1003
|
async function la(e, t) {
|
|
995
1004
|
if (!e)
|
|
996
1005
|
return "不能为空";
|
|
@@ -1001,14 +1010,14 @@ async function la(e, t) {
|
|
|
1001
1010
|
const a = (await Ci(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
|
|
1002
1011
|
return a ? `远程仓库中已存在同名项目(${a.http_url_to_repo}),请更名后重试` : !0;
|
|
1003
1012
|
}
|
|
1004
|
-
function
|
|
1013
|
+
function ma(e) {
|
|
1005
1014
|
return e ? !0 : "不能为空";
|
|
1006
1015
|
}
|
|
1007
|
-
function
|
|
1016
|
+
function pa(e) {
|
|
1008
1017
|
return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
|
|
1009
1018
|
}
|
|
1010
1019
|
async function da(e) {
|
|
1011
|
-
ne(), Q(), await
|
|
1020
|
+
ne(), Q(), await me();
|
|
1012
1021
|
let t, i;
|
|
1013
1022
|
e.branchType ? t = e.branchType : t = await T({
|
|
1014
1023
|
message: "请选择创建分支的类型",
|
|
@@ -1028,10 +1037,10 @@ async function da(e) {
|
|
|
1028
1037
|
]
|
|
1029
1038
|
}), e.branchPurpose ? i = e.branchPurpose : (i = await F({
|
|
1030
1039
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1031
|
-
validate:
|
|
1040
|
+
validate: pa
|
|
1032
1041
|
}), i = i.trim());
|
|
1033
1042
|
const n = `${t}_${i}_${tt()}`;
|
|
1034
|
-
await
|
|
1043
|
+
await m(`git fetch origin ${$.MASTER}`), await m(`git checkout -b ${n} origin/${$.MASTER}`), await m(`git push -u origin ${n}`), process.exit(0);
|
|
1035
1044
|
}
|
|
1036
1045
|
const ct = (e) => `${q("ZenTaoDomain")}${e}`;
|
|
1037
1046
|
async function fa() {
|
|
@@ -1061,15 +1070,17 @@ async function ga() {
|
|
|
1061
1070
|
})) : [];
|
|
1062
1071
|
}
|
|
1063
1072
|
async function Fe(e) {
|
|
1064
|
-
const t = await
|
|
1073
|
+
const t = await m("git diff HEAD");
|
|
1074
|
+
t || l("git暂存区没有内容,请先git add添加文件到暂存区");
|
|
1075
|
+
const i = await ia({
|
|
1065
1076
|
type: "commit-message-v2",
|
|
1066
1077
|
input: t
|
|
1067
1078
|
// modelName: "qwen-turbo",
|
|
1068
1079
|
});
|
|
1069
1080
|
return e + i;
|
|
1070
1081
|
}
|
|
1071
|
-
async function
|
|
1072
|
-
const n =
|
|
1082
|
+
async function ke(e, t, i) {
|
|
1083
|
+
const n = y("🤖 生成提交信息中...").start();
|
|
1073
1084
|
let a = "", s = !0;
|
|
1074
1085
|
if ([j.FEAT, j.FIX, j.REFACTOR].includes(e)) {
|
|
1075
1086
|
const o = t.map((r) => r.value).join(",");
|
|
@@ -1115,7 +1126,7 @@ async function ha(e) {
|
|
|
1115
1126
|
})),
|
|
1116
1127
|
pageSize: i.length
|
|
1117
1128
|
});
|
|
1118
|
-
await
|
|
1129
|
+
await ke(j.FEAT, n, e);
|
|
1119
1130
|
}
|
|
1120
1131
|
if (t === j.FIX) {
|
|
1121
1132
|
const i = await ga();
|
|
@@ -1130,36 +1141,36 @@ async function ha(e) {
|
|
|
1130
1141
|
})),
|
|
1131
1142
|
pageSize: i.length
|
|
1132
1143
|
});
|
|
1133
|
-
await
|
|
1144
|
+
await ke(j.FIX, n, e);
|
|
1134
1145
|
}
|
|
1135
1146
|
if (t === j.CHORE) {
|
|
1136
1147
|
let i = "";
|
|
1137
1148
|
e && (i = await F({
|
|
1138
1149
|
message: "请输入commit msg:",
|
|
1139
1150
|
validate: (n) => n.length === 0 ? "请输入commit msg" : !0
|
|
1140
|
-
}), i = i.trim()), await
|
|
1151
|
+
}), i = i.trim()), await ke(j.CHORE, i);
|
|
1141
1152
|
}
|
|
1142
1153
|
process.exit(0);
|
|
1143
1154
|
}
|
|
1144
1155
|
async function wa() {
|
|
1145
1156
|
try {
|
|
1146
1157
|
const e = {}, t = async () => {
|
|
1147
|
-
const
|
|
1148
|
-
const
|
|
1158
|
+
const P = Qe(), { projects: te } = await hi(), H = te.map((re) => {
|
|
1159
|
+
const Pe = {
|
|
1149
1160
|
name: `${re.name} [${re.desc}]`,
|
|
1150
1161
|
value: re.name,
|
|
1151
1162
|
disabled: !1
|
|
1152
1163
|
};
|
|
1153
|
-
return
|
|
1164
|
+
return P.includes(re.name) && (Pe.disabled = "目录下已存在同名文件夹"), Pe;
|
|
1154
1165
|
}), yt = await T({
|
|
1155
1166
|
message: "请选择一个项目模板",
|
|
1156
1167
|
choices: H
|
|
1157
1168
|
}), Te = te.find((re) => re.name === yt);
|
|
1158
1169
|
e.tplName = Te.name, e.tplUrl = Te.url, e.tplLanguage = Te.language;
|
|
1159
1170
|
}, i = async () => {
|
|
1160
|
-
const { groups:
|
|
1171
|
+
const { groups: P } = Pi(), te = await T({
|
|
1161
1172
|
message: "请选择一个分组",
|
|
1162
|
-
choices:
|
|
1173
|
+
choices: P.map((H) => ({
|
|
1163
1174
|
name: `${H.name} [${H.description}]`,
|
|
1164
1175
|
value: H.id,
|
|
1165
1176
|
short: H.name
|
|
@@ -1167,20 +1178,20 @@ async function wa() {
|
|
|
1167
1178
|
});
|
|
1168
1179
|
e.group = {
|
|
1169
1180
|
id: te,
|
|
1170
|
-
name:
|
|
1181
|
+
name: P.find((H) => H.id === te)?.name
|
|
1171
1182
|
};
|
|
1172
1183
|
}, n = async () => {
|
|
1173
1184
|
e.projectName = await F({
|
|
1174
1185
|
message: "请输入项目名称",
|
|
1175
|
-
validate: (
|
|
1186
|
+
validate: (P) => la(P, e.group?.name || "")
|
|
1176
1187
|
}), e.projectName = e.projectName.trim(), e.projectDesc = await F({
|
|
1177
1188
|
message: "请输入项目描述",
|
|
1178
|
-
validate:
|
|
1189
|
+
validate: ma
|
|
1179
1190
|
}), e.projectDesc = e.projectDesc.trim();
|
|
1180
1191
|
};
|
|
1181
1192
|
await t(), await i(), await n();
|
|
1182
|
-
const a = `${fe}/${e.group?.name}/${e.projectName}.git`, s =
|
|
1183
|
-
await
|
|
1193
|
+
const a = `${fe}/${e.group?.name}/${e.projectName}.git`, s = y("模版初始化中").start();
|
|
1194
|
+
await m(`git clone --depth=1 ${e.tplUrl}`), await _e(e.tplName, e.projectName), O.cd(e.projectName), O.rm("-rf", ".git"), await m(`git init --initial-branch=${$.MASTER}`), await m(`git remote add origin ${a}`), await m(`git config user.name ${E("gitName")}`), await m(`git config user.email ${E("gitEmail")}`);
|
|
1184
1195
|
const o = Ae();
|
|
1185
1196
|
li({
|
|
1186
1197
|
...o,
|
|
@@ -1190,31 +1201,31 @@ async function wa() {
|
|
|
1190
1201
|
...o.scripts,
|
|
1191
1202
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1192
1203
|
}
|
|
1193
|
-
}), await I.writeFile(
|
|
1194
|
-
const r =
|
|
1195
|
-
await
|
|
1196
|
-
const c =
|
|
1197
|
-
await
|
|
1198
|
-
const u = await
|
|
1204
|
+
}), await I.writeFile(p.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await xe(e.tplLanguage, e.group?.name);
|
|
1205
|
+
const r = y("依赖安装中").start();
|
|
1206
|
+
await m("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1207
|
+
const c = y("项目推送中").start();
|
|
1208
|
+
await m('git add . && git commit -m "chore: 项目初始化"'), await m("git tag v0.0.1");
|
|
1209
|
+
const u = await Ei({
|
|
1199
1210
|
name: e.projectName,
|
|
1200
1211
|
description: e.projectDesc,
|
|
1201
1212
|
path: e.projectName,
|
|
1202
1213
|
visibility: "private",
|
|
1203
1214
|
namespace_id: e.group?.id
|
|
1204
1215
|
});
|
|
1205
|
-
await
|
|
1206
|
-
const d =
|
|
1216
|
+
await m(`git push -u origin ${$.MASTER}`), await m(`git push origin HEAD:${$.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${S.blue(a)}`);
|
|
1217
|
+
const d = y("初始化分支中").start(), f = `feat_init_${tt()}`, g = [$.DEV, $.TEST, $.RELEASE, f], h = await Promise.allSettled(
|
|
1207
1218
|
g.map(
|
|
1208
|
-
(
|
|
1219
|
+
(P) => Li({
|
|
1209
1220
|
id: u.id,
|
|
1210
|
-
branch:
|
|
1211
|
-
ref:
|
|
1221
|
+
branch: P,
|
|
1222
|
+
ref: $.MASTER
|
|
1212
1223
|
})
|
|
1213
1224
|
)
|
|
1214
|
-
),
|
|
1215
|
-
h.forEach(({ status:
|
|
1216
|
-
|
|
1217
|
-
}), await
|
|
1225
|
+
), k = [];
|
|
1226
|
+
h.forEach(({ status: P }, te) => {
|
|
1227
|
+
P === "fulfilled" && k.push(g[te]);
|
|
1228
|
+
}), await m("git pull"), k.includes(f) ? (await m(`git checkout -b ${f} origin/${f}`), d.succeed(`项目已切换到初始分支: ${S.blue(f)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
|
|
1218
1229
|
const ee = `cd ${e.projectName} && z start`;
|
|
1219
1230
|
console.log(`输入 ${S.green(ee)} 开始开发吧~`), process.exit(0);
|
|
1220
1231
|
} catch (e) {
|
|
@@ -1254,7 +1265,7 @@ async function ya(e, t) {
|
|
|
1254
1265
|
/* Project */
|
|
1255
1266
|
}
|
|
1256
1267
|
]
|
|
1257
|
-
}), i === "project" ? await wa() : (ne(), Q(), i === "branch" ? (await
|
|
1268
|
+
}), i === "project" ? await wa() : (ne(), Q(), i === "branch" ? (await me(), await da(t)) : i === "commit-msg" && (await m("git status -s") ? await ha(t.commitMessageCloseAi) : l("没有要变动的文件,无法生成提交信息")));
|
|
1258
1269
|
}
|
|
1259
1270
|
D.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(de).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").action((...e) => z(ya, ...e));
|
|
1260
1271
|
function $a(e) {
|
|
@@ -1265,7 +1276,7 @@ function $a(e) {
|
|
|
1265
1276
|
});
|
|
1266
1277
|
}
|
|
1267
1278
|
async function va(e) {
|
|
1268
|
-
const t =
|
|
1279
|
+
const t = y("部署任务创建中").start(), { targetBranch: i, notify: n, projectName: a } = e, s = n ? [.../* @__PURE__ */ new Set([E("weWorkUserId"), ...n])] : [E("weWorkUserId")];
|
|
1269
1280
|
try {
|
|
1270
1281
|
const { metadata: o, spec: r } = await $a({
|
|
1271
1282
|
projectName: a,
|
|
@@ -1291,20 +1302,20 @@ async function va(e) {
|
|
|
1291
1302
|
}
|
|
1292
1303
|
function Na(e, t) {
|
|
1293
1304
|
const i = Ae();
|
|
1294
|
-
if (
|
|
1305
|
+
if (pe()?.repository?.url || l(".z/project.json中缺少repository.url"), t === G.H5) {
|
|
1295
1306
|
const a = `build:${e}`;
|
|
1296
1307
|
i?.scripts[a] || l(`项目package.json文件scripts不存在命令${a}。`);
|
|
1297
1308
|
}
|
|
1298
1309
|
t === G.NPM && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。")), t === G.SERVER && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。"));
|
|
1299
1310
|
}
|
|
1300
1311
|
async function ut(e, t) {
|
|
1301
|
-
ne(), Q(), await
|
|
1312
|
+
ne(), Q(), await me();
|
|
1302
1313
|
let i = e, n = t.platform;
|
|
1303
|
-
const a =
|
|
1304
|
-
if (a.language ===
|
|
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 T({
|
|
1305
1316
|
message: "请选择平台",
|
|
1306
|
-
choices:
|
|
1307
|
-
})), n === G.NPM && (i =
|
|
1317
|
+
choices: Ot
|
|
1318
|
+
})), n === G.NPM && (i = $.MASTER), !i) {
|
|
1308
1319
|
const u = await T({
|
|
1309
1320
|
message: "请选择部署环境",
|
|
1310
1321
|
choices: qe
|
|
@@ -1312,9 +1323,9 @@ async function ut(e, t) {
|
|
|
1312
1323
|
i = Zt(u);
|
|
1313
1324
|
}
|
|
1314
1325
|
let s = "";
|
|
1315
|
-
a.language ===
|
|
1326
|
+
a.language === w.JAVASCRIPT && (s = zt);
|
|
1316
1327
|
let o = "";
|
|
1317
|
-
if (a.language ===
|
|
1328
|
+
if (a.language === w.JAVASCRIPT && (o = Ae().name), a.language === w.JAVA) {
|
|
1318
1329
|
const { projects: u } = await wi(), d = u.find(
|
|
1319
1330
|
(f) => $e(f.url) === $e(a.repository.url)
|
|
1320
1331
|
);
|
|
@@ -1339,7 +1350,7 @@ async function ut(e, t) {
|
|
|
1339
1350
|
let r = [];
|
|
1340
1351
|
t.skipSelectionNotification || (r = await ot("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1341
1352
|
let c = [];
|
|
1342
|
-
if (t.skipGroupNotification || (c = await na("请选择部署成功要通知的群组:", () => !0, !0)), a.language ===
|
|
1353
|
+
if (t.skipGroupNotification || (c = await na("请选择部署成功要通知的群组:", () => !0, !0)), a.language === w.JAVASCRIPT) {
|
|
1343
1354
|
const u = Ht(i);
|
|
1344
1355
|
Na(u, n);
|
|
1345
1356
|
}
|
|
@@ -1352,7 +1363,7 @@ async function ut(e, t) {
|
|
|
1352
1363
|
});
|
|
1353
1364
|
}
|
|
1354
1365
|
async function lt(e, t, i, n) {
|
|
1355
|
-
const a =
|
|
1366
|
+
const a = y(`分支合并中,${e} -> ${t}`).start();
|
|
1356
1367
|
let s = 0;
|
|
1357
1368
|
try {
|
|
1358
1369
|
const { iid: r } = await Ri({
|
|
@@ -1361,7 +1372,7 @@ async function lt(e, t, i, n) {
|
|
|
1361
1372
|
source_branch: e,
|
|
1362
1373
|
target_branch: t,
|
|
1363
1374
|
// 合到主分支上的分支需要在合并完成后被移除
|
|
1364
|
-
remove_source_branch: n ? !1 :
|
|
1375
|
+
remove_source_branch: n ? !1 : $.MASTER === t
|
|
1365
1376
|
});
|
|
1366
1377
|
s = r;
|
|
1367
1378
|
} catch (r) {
|
|
@@ -1400,14 +1411,14 @@ async function lt(e, t, i, n) {
|
|
|
1400
1411
|
await o();
|
|
1401
1412
|
}
|
|
1402
1413
|
async function ba(e, t) {
|
|
1403
|
-
const i = `origin/${e.sourceBranch}`, n = await
|
|
1414
|
+
const i = `origin/${e.sourceBranch}`, n = await m(`git log -b origin/${$.MASTER} -1 --format=%H`), a = await m(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await m(
|
|
1404
1415
|
`git log ${n}...${a} -b ${i}`
|
|
1405
1416
|
);
|
|
1406
|
-
if (s || l(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await
|
|
1417
|
+
if (s || l(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await m(
|
|
1407
1418
|
`git branch --contains ${n} -r ${i}`
|
|
1408
|
-
) || (console.log(S.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt(
|
|
1419
|
+
) || (console.log(S.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt($.MASTER, e.sourceBranch, e)), t === $.MASTER) {
|
|
1409
1420
|
const r = s.split(`
|
|
1410
|
-
`).filter((f) => f), c = await
|
|
1421
|
+
`).filter((f) => f), c = await m(`git log -b origin/${b.TEST} -1 --format=%H`), d = (await m(
|
|
1411
1422
|
`git log ${n}...${c} -b origin/${b.TEST}`
|
|
1412
1423
|
)).split(`
|
|
1413
1424
|
`).filter((f) => f);
|
|
@@ -1415,12 +1426,12 @@ async function ba(e, t) {
|
|
|
1415
1426
|
}
|
|
1416
1427
|
}
|
|
1417
1428
|
async function Aa(e, t) {
|
|
1418
|
-
ne(), Q(), await
|
|
1419
|
-
const i = await
|
|
1420
|
-
Object.values(
|
|
1421
|
-
const a = (await
|
|
1429
|
+
ne(), Q(), await me();
|
|
1430
|
+
const i = await mi();
|
|
1431
|
+
Object.values($).includes(i.sourceBranch) && l(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1432
|
+
const a = (await Oi(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
|
|
1422
1433
|
let u = c.name;
|
|
1423
|
-
return Object.values(
|
|
1434
|
+
return Object.values($).includes(u) && (u = S.bold.blue(u)), {
|
|
1424
1435
|
name: u,
|
|
1425
1436
|
value: c.name
|
|
1426
1437
|
};
|
|
@@ -1430,28 +1441,28 @@ async function Aa(e, t) {
|
|
|
1430
1441
|
message: "请选择要合并到的目标分支:",
|
|
1431
1442
|
choices: a
|
|
1432
1443
|
});
|
|
1433
|
-
const o =
|
|
1434
|
-
if (await
|
|
1435
|
-
o.text = `存在远程分支origin/${i.sourceBranch}`, await
|
|
1436
|
-
const c = await
|
|
1437
|
-
await
|
|
1444
|
+
const o = y(`本地分支${i.sourceBranch}检测中`).start();
|
|
1445
|
+
if (await m(`git ls-remote --heads origin ${i.sourceBranch}`)) {
|
|
1446
|
+
o.text = `存在远程分支origin/${i.sourceBranch}`, await m("git fetch");
|
|
1447
|
+
const c = await m(`git rev-parse ${i.sourceBranch}`), u = await m(`git rev-parse origin/${i.sourceBranch}`);
|
|
1448
|
+
await m(`git merge-base ${u} HEAD`) === u ? (await m(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`)) : await m(`git merge-base ${c} ${u}`) === c ? (await m("git pull"), o.succeed(`本地分支${i.sourceBranch}已更新`)) : (o.fail(
|
|
1438
1449
|
`远程分支origin/${i.sourceBranch}和本地分支${i.sourceBranch}都有新的提交,请手动合并后再试。`
|
|
1439
1450
|
), process.exit(1));
|
|
1440
1451
|
} else
|
|
1441
|
-
await
|
|
1442
|
-
await ba(i, s), await lt(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster),
|
|
1443
|
-
`${i.sourceBranch}分支已移除,当前已切换到最新的${
|
|
1444
|
-
)), Object.values(
|
|
1452
|
+
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}`), V(
|
|
1454
|
+
`${i.sourceBranch}分支已移除,当前已切换到最新的${$.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1455
|
+
)), Object.values($).includes(s) && await ut(s, {
|
|
1445
1456
|
platform: t.deployPlatform,
|
|
1446
1457
|
skipSelectionNotification: t.deploySkipSelectionNotification,
|
|
1447
1458
|
skipGroupNotification: t.skipGroupNotification
|
|
1448
1459
|
});
|
|
1449
1460
|
}
|
|
1450
1461
|
D.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(G).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => z(Aa, ...e));
|
|
1451
|
-
D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(
|
|
1462
|
+
D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values($).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(G).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => z(ut, ...e));
|
|
1452
1463
|
async function ja() {
|
|
1453
1464
|
try {
|
|
1454
|
-
await
|
|
1465
|
+
await m("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
|
|
1455
1466
|
silent: !1
|
|
1456
1467
|
}), V("checkstyle执行完毕"), process.exit(0);
|
|
1457
1468
|
} catch {
|
|
@@ -1459,14 +1470,14 @@ async function ja() {
|
|
|
1459
1470
|
}
|
|
1460
1471
|
}
|
|
1461
1472
|
function Sa() {
|
|
1462
|
-
const e =
|
|
1473
|
+
const e = pe();
|
|
1463
1474
|
if (e["lint-staged"])
|
|
1464
1475
|
return e["lint-staged"];
|
|
1465
1476
|
throw new Error("未找到lint配置");
|
|
1466
1477
|
}
|
|
1467
1478
|
async function Ta() {
|
|
1468
|
-
const e =
|
|
1469
|
-
await
|
|
1479
|
+
const e = y("代码风格检测中...").start();
|
|
1480
|
+
await Et({
|
|
1470
1481
|
concurrent: 4,
|
|
1471
1482
|
debug: !1,
|
|
1472
1483
|
config: Sa(),
|
|
@@ -1474,7 +1485,7 @@ async function Ta() {
|
|
|
1474
1485
|
relative: !0
|
|
1475
1486
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
1476
1487
|
}
|
|
1477
|
-
function
|
|
1488
|
+
function ka(e) {
|
|
1478
1489
|
if (e.includes("Merge") && e.includes("# Conflicts:") || Ct.valid(e))
|
|
1479
1490
|
return !0;
|
|
1480
1491
|
const t = e.split(": ");
|
|
@@ -1483,12 +1494,12 @@ function Ea(e) {
|
|
|
1483
1494
|
const i = t[0];
|
|
1484
1495
|
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 : "不存在的提交类型。";
|
|
1485
1496
|
}
|
|
1486
|
-
async function
|
|
1487
|
-
const e = await
|
|
1497
|
+
async function Ea() {
|
|
1498
|
+
const e = await Ee(p.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), i = ka(e);
|
|
1488
1499
|
i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
|
|
1489
1500
|
}
|
|
1490
1501
|
async function Ca() {
|
|
1491
|
-
await
|
|
1502
|
+
await me();
|
|
1492
1503
|
const e = await Rt({
|
|
1493
1504
|
// 分组,展示仓库链接
|
|
1494
1505
|
format: ["group", "repo"],
|
|
@@ -1502,16 +1513,16 @@ async function Ca() {
|
|
|
1502
1513
|
if (e && Object.keys(e).length) {
|
|
1503
1514
|
V("升级完成 🎉");
|
|
1504
1515
|
const t = Object.entries(e).map(([i, n]) => `${i}@${n}`).join("; ");
|
|
1505
|
-
await
|
|
1516
|
+
await m(`git add . && git commit -m "chore: 依赖升级。${t}"`);
|
|
1506
1517
|
}
|
|
1507
1518
|
process.exit(0);
|
|
1508
1519
|
}
|
|
1509
1520
|
async function Ra(e) {
|
|
1510
|
-
v(
|
|
1511
|
-
const t =
|
|
1521
|
+
v(p.resolve("node_modules", ".bin", "eslint")) || l("该项目未安装eslint,请安装后重试");
|
|
1522
|
+
const t = y("eslint执行中...").start();
|
|
1512
1523
|
try {
|
|
1513
1524
|
let i = "npx eslint '**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}' --fix";
|
|
1514
|
-
process.platform === "win32" && (i = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (i += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? i += ` --max-warnings ${Number(e.maxWarnings)}` : i += " --max-warnings 100", await
|
|
1525
|
+
process.platform === "win32" && (i = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (i += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? i += ` --max-warnings ${Number(e.maxWarnings)}` : i += " --max-warnings 100", await m(i, {
|
|
1515
1526
|
silent: !1
|
|
1516
1527
|
}), t.succeed("eslint执行成功"), process.exit(0);
|
|
1517
1528
|
} catch {
|
|
@@ -1519,10 +1530,10 @@ async function Ra(e) {
|
|
|
1519
1530
|
}
|
|
1520
1531
|
}
|
|
1521
1532
|
async function Ia() {
|
|
1522
|
-
v(
|
|
1523
|
-
const e =
|
|
1533
|
+
v(p.resolve("node_modules", ".bin", "prettier")) || l("该项目未安装prettier,请安装后重试");
|
|
1534
|
+
const e = y("prettier执行中...").start();
|
|
1524
1535
|
try {
|
|
1525
|
-
await
|
|
1536
|
+
await m(
|
|
1526
1537
|
"npx prettier --write . --config .z/.prettierrc.json --ignore-path .z/.prettierignore --ignore-unknown --no-error-on-unmatched-pattern",
|
|
1527
1538
|
{
|
|
1528
1539
|
silent: !1
|
|
@@ -1533,11 +1544,11 @@ async function Ia() {
|
|
|
1533
1544
|
}
|
|
1534
1545
|
}
|
|
1535
1546
|
function xa() {
|
|
1536
|
-
v(
|
|
1547
|
+
v(p.resolve("./node_modules/.bin/vue-tsc")) || l("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), et("npx vue-tsc --build"), process.exit(0);
|
|
1537
1548
|
}
|
|
1538
1549
|
async function Da(e, t) {
|
|
1539
1550
|
ne(), Q();
|
|
1540
|
-
const i =
|
|
1551
|
+
const i = pe();
|
|
1541
1552
|
let n;
|
|
1542
1553
|
if (e)
|
|
1543
1554
|
[
|
|
@@ -1577,11 +1588,11 @@ async function Da(e, t) {
|
|
|
1577
1588
|
/* Prettier */
|
|
1578
1589
|
}
|
|
1579
1590
|
];
|
|
1580
|
-
i.language ===
|
|
1591
|
+
i.language === w.JAVA && a.push({
|
|
1581
1592
|
name: "执行 check-style",
|
|
1582
1593
|
value: "checkstyle"
|
|
1583
1594
|
/* CheckStyle */
|
|
1584
|
-
}), i.language ===
|
|
1595
|
+
}), i.language === w.JAVASCRIPT && a.push(
|
|
1585
1596
|
{
|
|
1586
1597
|
name: "执行 eslint",
|
|
1587
1598
|
value: "eslint"
|
|
@@ -1602,17 +1613,17 @@ async function Da(e, t) {
|
|
|
1602
1613
|
choices: a
|
|
1603
1614
|
});
|
|
1604
1615
|
}
|
|
1605
|
-
n === "commit-msg" ? await
|
|
1616
|
+
n === "commit-msg" ? await Ea() : n === "commit-files" ? await Ta() : n === "prettier" ? await Ia() : n === "eslint" && i.language === w.JAVASCRIPT ? await Ra(t) : n === "type-check" && i.language === w.JAVASCRIPT ? xa() : n === "dependency-check" && i.language === w.JAVASCRIPT ? await Ca() : n === "checkstyle" && i.language === w.JAVA && await ja();
|
|
1606
1617
|
}
|
|
1607
1618
|
D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle。").argument(
|
|
1608
1619
|
"[type]",
|
|
1609
1620
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs。"
|
|
1610
1621
|
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(Da, ...e));
|
|
1611
|
-
async function
|
|
1612
|
-
const t =
|
|
1613
|
-
await
|
|
1622
|
+
async function mt(e = "latest") {
|
|
1623
|
+
const t = y("安装中...").start();
|
|
1624
|
+
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);
|
|
1614
1625
|
}
|
|
1615
|
-
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(
|
|
1626
|
+
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(mt, ...e));
|
|
1616
1627
|
async function La(e) {
|
|
1617
1628
|
let t = e;
|
|
1618
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 T({
|
|
@@ -1623,7 +1634,7 @@ async function La(e) {
|
|
|
1623
1634
|
i.scripts[n] ? et(`npm run ${n}`) : l(`项目中(package.json > scripts)不存在命令${n},请先添加!`);
|
|
1624
1635
|
}
|
|
1625
1636
|
D.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(La, ...e));
|
|
1626
|
-
const De = /Thumbs\.db|\.git|DS_Store|idea/,
|
|
1637
|
+
const De = /Thumbs\.db|\.git|DS_Store|idea/, pt = "testcase";
|
|
1627
1638
|
function dt(e) {
|
|
1628
1639
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
1629
1640
|
if (t && !e.startsWith("["))
|
|
@@ -1646,11 +1657,11 @@ function dt(e) {
|
|
|
1646
1657
|
async function X(e, t = {}) {
|
|
1647
1658
|
const { exclude: i = De } = t, n = [];
|
|
1648
1659
|
async function a(s) {
|
|
1649
|
-
const o =
|
|
1660
|
+
const o = p.basename(s);
|
|
1650
1661
|
if ((await At(s)).isFile())
|
|
1651
1662
|
return null;
|
|
1652
1663
|
const c = await Re(s, { withFileTypes: !0 }), u = (await Promise.all(
|
|
1653
|
-
c.filter((
|
|
1664
|
+
c.filter((k) => k.isDirectory() && !i.test(k.name)).map((k) => a(p.join(s, k.name)))
|
|
1654
1665
|
)).filter(Boolean), { type: d, id: f, displayName: g } = dt(o), h = {
|
|
1655
1666
|
name: o,
|
|
1656
1667
|
id: f,
|
|
@@ -1659,17 +1670,17 @@ async function X(e, t = {}) {
|
|
|
1659
1670
|
type: d,
|
|
1660
1671
|
children: u
|
|
1661
1672
|
};
|
|
1662
|
-
return (t.hasRoot ||
|
|
1673
|
+
return (t.hasRoot || p.resolve(e) !== s) && n.push(h), h;
|
|
1663
1674
|
}
|
|
1664
|
-
return await a(
|
|
1675
|
+
return await a(p.resolve(e)), n;
|
|
1665
1676
|
}
|
|
1666
1677
|
async function ft(e, t = {}) {
|
|
1667
1678
|
const { exclude: i = De } = t;
|
|
1668
1679
|
try {
|
|
1669
|
-
const n = await Re(
|
|
1680
|
+
const n = await Re(p.resolve(e), { withFileTypes: !0 });
|
|
1670
1681
|
return await Promise.all(
|
|
1671
1682
|
n.filter((a) => a.isDirectory() && !i.test(a.name)).map((a) => {
|
|
1672
|
-
const s =
|
|
1683
|
+
const s = p.join(e, a.name), { type: o, id: r, displayName: c } = dt(a.name);
|
|
1673
1684
|
return {
|
|
1674
1685
|
name: a.name,
|
|
1675
1686
|
id: r,
|
|
@@ -1695,27 +1706,27 @@ function W(e, t, i) {
|
|
|
1695
1706
|
}
|
|
1696
1707
|
async function we(e, t, i, n) {
|
|
1697
1708
|
try {
|
|
1698
|
-
const a =
|
|
1709
|
+
const a = p.basename(e), s = W(i, t, n);
|
|
1699
1710
|
if (a === s)
|
|
1700
1711
|
return !0;
|
|
1701
|
-
const o =
|
|
1702
|
-
return await Kt(e) ? await _e(e, r) : (await
|
|
1712
|
+
const o = p.dirname(e), r = p.join(o, s);
|
|
1713
|
+
return await Kt(e) ? await _e(e, r) : (await m(`git mv "${e}" "${r}"`), await m("git add .")), !0;
|
|
1703
1714
|
} catch (a) {
|
|
1704
1715
|
return l(`重命名文件夹失败: ${e} -> ${t}。${a}`), !1;
|
|
1705
1716
|
}
|
|
1706
1717
|
}
|
|
1707
|
-
async function
|
|
1718
|
+
async function Oa(e, t, i = {}) {
|
|
1708
1719
|
const { exclude: n = De } = i;
|
|
1709
1720
|
async function a(s, o) {
|
|
1710
1721
|
if (!s || s.length === 0) return;
|
|
1711
1722
|
const r = await ft(o, { exclude: n });
|
|
1712
1723
|
for (const c of s) {
|
|
1713
1724
|
const u = String(c.value), d = W("module", c.label, u), f = r.find((h) => h.id === u);
|
|
1714
|
-
let g = f?.path ||
|
|
1715
|
-
f ? f.displayName !== c.label && await we(f.path, c.label, "module", u) && (g =
|
|
1725
|
+
let g = f?.path || p.join(o, d);
|
|
1726
|
+
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);
|
|
1716
1727
|
}
|
|
1717
1728
|
}
|
|
1718
|
-
await a(e,
|
|
1729
|
+
await a(e, p.resolve(t));
|
|
1719
1730
|
}
|
|
1720
1731
|
async function gt(e) {
|
|
1721
1732
|
const t = {
|
|
@@ -1735,10 +1746,10 @@ async function gt(e) {
|
|
|
1735
1746
|
}))
|
|
1736
1747
|
});
|
|
1737
1748
|
}
|
|
1738
|
-
return t.name = await Ji(t.id), t.path =
|
|
1749
|
+
return t.name = await Ji(t.id), t.path = p.join(pt, W("module", t.name, String(t.id))), t;
|
|
1739
1750
|
}
|
|
1740
1751
|
async function Le(e) {
|
|
1741
|
-
return (await ft(
|
|
1752
|
+
return (await ft(pt)).find((i) => Number(i.id) === e.id);
|
|
1742
1753
|
}
|
|
1743
1754
|
async function ht(e, t) {
|
|
1744
1755
|
const i = {
|
|
@@ -1753,15 +1764,15 @@ async function ht(e, t) {
|
|
|
1753
1764
|
async function wt(e, t) {
|
|
1754
1765
|
await le(t, {
|
|
1755
1766
|
recursive: !0
|
|
1756
|
-
}), await ht(e,
|
|
1757
|
-
|
|
1758
|
-
v(
|
|
1759
|
-
), I.ensureFileSync(
|
|
1760
|
-
|
|
1761
|
-
v(
|
|
1767
|
+
}), await ht(e, p.join(t, "config.json")), I.ensureFileSync(p.join(t, "data.yaml")), await L(
|
|
1768
|
+
p.join(t, "data.yaml"),
|
|
1769
|
+
v(p.resolve(K, "data.yaml")) ? await Ee(p.resolve(K, "data.yaml")) : await bi()
|
|
1770
|
+
), I.ensureFileSync(p.join(t, "main.py")), await L(
|
|
1771
|
+
p.join(t, "main.py"),
|
|
1772
|
+
v(p.resolve(K, "main.py")) ? await Ee(p.resolve(K, "main.py")) : await Ai()
|
|
1762
1773
|
);
|
|
1763
1774
|
}
|
|
1764
|
-
function
|
|
1775
|
+
function Oe(e) {
|
|
1765
1776
|
if (e) {
|
|
1766
1777
|
const t = e.split(",").map((i) => i.trim()).filter((i) => {
|
|
1767
1778
|
const n = Number(i);
|
|
@@ -1772,7 +1783,7 @@ function Pe(e) {
|
|
|
1772
1783
|
return [];
|
|
1773
1784
|
}
|
|
1774
1785
|
async function je(e, t) {
|
|
1775
|
-
ne(), Q(), await
|
|
1786
|
+
ne(), Q(), await me();
|
|
1776
1787
|
let i;
|
|
1777
1788
|
t ? ([R.MODULE, R.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${R.MODULE} 或者 ${R.CASE}。`), i = t) : i = await T({
|
|
1778
1789
|
message: `请选择要${e}的数据类型`,
|
|
@@ -1791,25 +1802,25 @@ async function Se(e) {
|
|
|
1791
1802
|
localProduct: i
|
|
1792
1803
|
};
|
|
1793
1804
|
}
|
|
1794
|
-
async function
|
|
1805
|
+
async function Pa(e, t, i) {
|
|
1795
1806
|
e.text = "查找本地产品目录...", await Le(t) || l(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
1796
|
-
const a =
|
|
1807
|
+
const a = Oe(i);
|
|
1797
1808
|
let s = await X(t.path);
|
|
1798
1809
|
e.text = "获取远程用例列表...";
|
|
1799
1810
|
const o = await Fi(t.id, a);
|
|
1800
1811
|
e.text = "本地用例同步中...";
|
|
1801
1812
|
for (const r of o) {
|
|
1802
1813
|
let c;
|
|
1803
|
-
if (r.module === 0 ? c =
|
|
1814
|
+
if (r.module === 0 ? c = p.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", !c)
|
|
1804
1815
|
return l(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
1805
1816
|
const u = s.find(({ id: d }) => r.id === Number(d));
|
|
1806
1817
|
if (u)
|
|
1807
|
-
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && V(`重命名成功: ${u.displayName} -> ${r.title}`), s = await X(t.path), r.module === 0 ? c =
|
|
1818
|
+
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && V(`重命名成功: ${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(
|
|
1808
1819
|
r,
|
|
1809
|
-
|
|
1820
|
+
p.join(c, W("case", r.title, String(r.id)), "config.json")
|
|
1810
1821
|
);
|
|
1811
1822
|
else {
|
|
1812
|
-
const d =
|
|
1823
|
+
const d = p.join(c, W("case", r.title, String(r.id)));
|
|
1813
1824
|
await wt(r, d);
|
|
1814
1825
|
}
|
|
1815
1826
|
}
|
|
@@ -1817,16 +1828,16 @@ async function Oa(e, t, i) {
|
|
|
1817
1828
|
async function Ma(e, t) {
|
|
1818
1829
|
e.text = "本地产品目录查找中...";
|
|
1819
1830
|
const i = await Le(t);
|
|
1820
|
-
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
|
|
1831
|
+
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 = "获取远程模块列表...";
|
|
1821
1832
|
const n = await st(t.id);
|
|
1822
|
-
e.text = "本地同步模块中...", await
|
|
1833
|
+
e.text = "本地同步模块中...", await Oa(n || [], t.path);
|
|
1823
1834
|
}
|
|
1824
1835
|
async function za(e, t) {
|
|
1825
|
-
const { type: i, typeStr: n } = await je("拉取", e), a = await gt(t.productId), s =
|
|
1826
|
-
if (R.MODULE === i && await Ma(s, a), R.CASE === i && await
|
|
1827
|
-
const o =
|
|
1836
|
+
const { type: i, typeStr: n } = await je("拉取", e), a = await gt(t.productId), s = y(`${n}同步中...`).start();
|
|
1837
|
+
if (R.MODULE === i && await Ma(s, a), R.CASE === i && await Pa(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await m("git status -s")) {
|
|
1838
|
+
const o = y("代码提交中...").start();
|
|
1828
1839
|
try {
|
|
1829
|
-
await
|
|
1840
|
+
await m(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
|
|
1830
1841
|
} catch (r) {
|
|
1831
1842
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
1832
1843
|
}
|
|
@@ -1838,15 +1849,15 @@ async function Ba(e, t, i) {
|
|
|
1838
1849
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
1839
1850
|
});
|
|
1840
1851
|
n = n.trim();
|
|
1841
|
-
const a =
|
|
1852
|
+
const a = y(`用例【${i}】开始创建...`).start();
|
|
1842
1853
|
a.text = "远程用例创建中...";
|
|
1843
1854
|
const s = await Gi({
|
|
1844
1855
|
product: Number(e.id),
|
|
1845
1856
|
// 如果父模块是产品根目录,parent=0
|
|
1846
|
-
module:
|
|
1857
|
+
module: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
1847
1858
|
title: i,
|
|
1848
1859
|
type: "interface",
|
|
1849
|
-
openedBy:
|
|
1860
|
+
openedBy: E("ldapAccount"),
|
|
1850
1861
|
precondition: n || ""
|
|
1851
1862
|
});
|
|
1852
1863
|
a.text = "远程用例步骤创建中...", await Vi({
|
|
@@ -1855,7 +1866,7 @@ async function Ba(e, t, i) {
|
|
|
1855
1866
|
desc: "按照预期执行",
|
|
1856
1867
|
expect: "正常执行,符合预期"
|
|
1857
1868
|
}), a.text = "本地用例创建中...";
|
|
1858
|
-
const o =
|
|
1869
|
+
const o = p.join(t.path, W("case", i, String(s)));
|
|
1859
1870
|
return v(o) ? V(`${o}已存在,请检查是否对应,本地不再创建。`) : (await wt(
|
|
1860
1871
|
{
|
|
1861
1872
|
id: s,
|
|
@@ -1866,16 +1877,16 @@ async function Ba(e, t, i) {
|
|
|
1866
1877
|
), a.succeed(`用例【[${o}】创建完成 🎉`), o);
|
|
1867
1878
|
}
|
|
1868
1879
|
async function Ja(e, t, i) {
|
|
1869
|
-
const n =
|
|
1880
|
+
const n = y(`模块【${i}】开始创建...`).start();
|
|
1870
1881
|
n.text = "远程模块创建中...";
|
|
1871
1882
|
const a = await Ui({
|
|
1872
1883
|
root: Number(e.id),
|
|
1873
1884
|
name: i,
|
|
1874
1885
|
// 如果父模块是产品根目录,parent=0
|
|
1875
|
-
parent:
|
|
1886
|
+
parent: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
|
|
1876
1887
|
});
|
|
1877
1888
|
n.text = "本地模块创建中...";
|
|
1878
|
-
const s =
|
|
1889
|
+
const s = p.join(t.path, W("module", i, String(a)));
|
|
1879
1890
|
if (v(s))
|
|
1880
1891
|
return V(`${s}已存在,请检查是否对应,本地不再创建。`);
|
|
1881
1892
|
await le(s, {
|
|
@@ -1918,11 +1929,11 @@ async function _a(e, t) {
|
|
|
1918
1929
|
f = f.trim();
|
|
1919
1930
|
let g = "";
|
|
1920
1931
|
if (R.MODULE === i && await Ja(s, d, f), R.CASE === i && (g = await Ba(s, d, f)), !t.disableAutoCommit && R.CASE === i) {
|
|
1921
|
-
const h =
|
|
1932
|
+
const h = y("代码提交中...").start();
|
|
1922
1933
|
try {
|
|
1923
|
-
await
|
|
1924
|
-
} catch (
|
|
1925
|
-
h.fail(`提交失败,${
|
|
1934
|
+
await m(`git add . && git commit -m "chore: 创建了用例${p.basename(g)}"`), h.succeed("代码已提交 ✅");
|
|
1935
|
+
} catch (k) {
|
|
1936
|
+
h.fail(`提交失败,${k}`), process.exit(1);
|
|
1926
1937
|
}
|
|
1927
1938
|
}
|
|
1928
1939
|
}
|
|
@@ -1941,7 +1952,7 @@ async function Ua(e, t) {
|
|
|
1941
1952
|
id: Number(c.id),
|
|
1942
1953
|
path: c.path
|
|
1943
1954
|
},
|
|
1944
|
-
name: c.path.replace(
|
|
1955
|
+
name: c.path.replace(p.resolve(e.path), "")
|
|
1945
1956
|
}));
|
|
1946
1957
|
a = await ae({
|
|
1947
1958
|
message: "选择要删除的用例",
|
|
@@ -1953,13 +1964,13 @@ async function Ua(e, t) {
|
|
|
1953
1964
|
}
|
|
1954
1965
|
});
|
|
1955
1966
|
}
|
|
1956
|
-
const s =
|
|
1967
|
+
const s = y("远程用例删除中...").start(), o = a.map((r) => r.id);
|
|
1957
1968
|
await qi({
|
|
1958
1969
|
product: Number(e.id),
|
|
1959
1970
|
caseIds: o
|
|
1960
1971
|
}), s.text = "本地用例删除中...";
|
|
1961
1972
|
for (const r of a)
|
|
1962
|
-
v(r.path) &&
|
|
1973
|
+
v(r.path) && O.rm("-rf", r.path);
|
|
1963
1974
|
return s.succeed("用例删除完成"), o;
|
|
1964
1975
|
}
|
|
1965
1976
|
async function Ga(e, t) {
|
|
@@ -1976,7 +1987,7 @@ async function Ga(e, t) {
|
|
|
1976
1987
|
id: Number(c.id),
|
|
1977
1988
|
path: c.path
|
|
1978
1989
|
},
|
|
1979
|
-
name: c.path.replace(
|
|
1990
|
+
name: c.path.replace(p.resolve(e.path), "")
|
|
1980
1991
|
}));
|
|
1981
1992
|
a = await ae({
|
|
1982
1993
|
message: "选择要删除的模块",
|
|
@@ -1989,22 +2000,22 @@ async function Ga(e, t) {
|
|
|
1989
2000
|
});
|
|
1990
2001
|
}
|
|
1991
2002
|
a = a.sort((r, c) => r.path.localeCompare(c.path));
|
|
1992
|
-
const s =
|
|
2003
|
+
const s = y("远程模块删除中...").start(), o = a.map((r) => r.id);
|
|
1993
2004
|
await Wi({
|
|
1994
2005
|
product: Number(e.id),
|
|
1995
2006
|
moduleIds: o
|
|
1996
2007
|
}), s.text = "本地模块删除中...";
|
|
1997
2008
|
for (const r of a)
|
|
1998
|
-
v(r.path) &&
|
|
2009
|
+
v(r.path) && O.rm("-rf", r.path);
|
|
1999
2010
|
return s.succeed("模块删除完成"), o;
|
|
2000
2011
|
}
|
|
2001
2012
|
async function Va(e, t) {
|
|
2002
|
-
const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await Se(t.productId), s =
|
|
2013
|
+
const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await Se(t.productId), s = Oe(t.targetIds);
|
|
2003
2014
|
let o = [];
|
|
2004
|
-
if (R.MODULE === i ? o = await Ga(a, s) : R.CASE === i && (o = await Ua(a, s)), !t.disableAutoCommit && await
|
|
2005
|
-
const r =
|
|
2015
|
+
if (R.MODULE === i ? o = await Ga(a, s) : R.CASE === i && (o = await Ua(a, s)), !t.disableAutoCommit && await m("git status -s")) {
|
|
2016
|
+
const r = y("代码提交中...").start();
|
|
2006
2017
|
try {
|
|
2007
|
-
await
|
|
2018
|
+
await m(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
2008
2019
|
} catch (c) {
|
|
2009
2020
|
r.fail(`提交失败,${c}`), process.exit(1);
|
|
2010
2021
|
}
|
|
@@ -2024,14 +2035,14 @@ async function Wa(e, t) {
|
|
|
2024
2035
|
path: h.path,
|
|
2025
2036
|
displayName: h.displayName
|
|
2026
2037
|
},
|
|
2027
|
-
name: h.path.replace(
|
|
2038
|
+
name: h.path.replace(p.resolve(e.path), "")
|
|
2028
2039
|
}));
|
|
2029
2040
|
[a] = await ae({
|
|
2030
2041
|
message: "选择要更新的用例",
|
|
2031
2042
|
pageSize: 100,
|
|
2032
2043
|
loop: !1,
|
|
2033
2044
|
multiple: void 0,
|
|
2034
|
-
options: (h) => h ? g.filter((
|
|
2045
|
+
options: (h) => h ? g.filter((k) => k.name.includes(h)) : g,
|
|
2035
2046
|
validate(h) {
|
|
2036
2047
|
return h.length > 1 ? "只能选一个" : h.length < 1 ? "请选一个" : !0;
|
|
2037
2048
|
}
|
|
@@ -2045,12 +2056,12 @@ async function Wa(e, t) {
|
|
|
2045
2056
|
prefill: "editable"
|
|
2046
2057
|
});
|
|
2047
2058
|
s = s.trim();
|
|
2048
|
-
const o =
|
|
2059
|
+
const o = y("用例重命名中...").start();
|
|
2049
2060
|
s !== a.displayName ? (await Zi({
|
|
2050
2061
|
id: Number(a.id),
|
|
2051
2062
|
name: s
|
|
2052
|
-
}), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path =
|
|
2053
|
-
let r = I.readJsonSync(
|
|
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), W("case", s, String(a.id)))) : o.succeed("用例名称无变动");
|
|
2064
|
+
let r = I.readJsonSync(p.join(a.path, "config.json")), c;
|
|
2054
2065
|
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await ze({
|
|
2055
2066
|
message: "修改用例优先级",
|
|
2056
2067
|
min: 1,
|
|
@@ -2066,30 +2077,30 @@ async function Wa(e, t) {
|
|
|
2066
2077
|
default: r.priority,
|
|
2067
2078
|
validate: (g) => g > 0 && g < 6
|
|
2068
2079
|
});
|
|
2069
|
-
const u =
|
|
2080
|
+
const u = y("用例优先级设置中...").start();
|
|
2070
2081
|
c !== r.priority ? (await Ki({
|
|
2071
2082
|
id: Number(a.id),
|
|
2072
2083
|
priority: c
|
|
2073
2084
|
}), I.writeJSONSync(
|
|
2074
|
-
|
|
2085
|
+
p.join(a.path, "config.json"),
|
|
2075
2086
|
{
|
|
2076
2087
|
...r,
|
|
2077
2088
|
priority: c
|
|
2078
2089
|
},
|
|
2079
2090
|
{ spaces: 2 }
|
|
2080
|
-
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = I.readJsonSync(
|
|
2091
|
+
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = I.readJsonSync(p.join(a.path, "config.json"));
|
|
2081
2092
|
let d;
|
|
2082
2093
|
t.casePrecondition ? d = t.casePrecondition : (d = await F({
|
|
2083
2094
|
message: "修改用例前置条件",
|
|
2084
2095
|
default: r.precondition,
|
|
2085
2096
|
prefill: "editable"
|
|
2086
2097
|
}), d = d.trim());
|
|
2087
|
-
const f =
|
|
2098
|
+
const f = y("用例前置条件设置中...").start();
|
|
2088
2099
|
return d !== r.precondition ? (await Yi({
|
|
2089
2100
|
id: Number(a.id),
|
|
2090
2101
|
precondition: d
|
|
2091
2102
|
}), I.writeJSONSync(
|
|
2092
|
-
|
|
2103
|
+
p.join(a.path, "config.json"),
|
|
2093
2104
|
{
|
|
2094
2105
|
...r,
|
|
2095
2106
|
precondition: d
|
|
@@ -2110,7 +2121,7 @@ async function qa(e, t) {
|
|
|
2110
2121
|
path: c.path,
|
|
2111
2122
|
displayName: c.displayName
|
|
2112
2123
|
},
|
|
2113
|
-
name: c.path.replace(
|
|
2124
|
+
name: c.path.replace(p.resolve(e.path), "")
|
|
2114
2125
|
}));
|
|
2115
2126
|
[a] = await ae({
|
|
2116
2127
|
message: "选择要更新的模块",
|
|
@@ -2131,7 +2142,7 @@ async function qa(e, t) {
|
|
|
2131
2142
|
prefill: "editable"
|
|
2132
2143
|
});
|
|
2133
2144
|
s = s.trim();
|
|
2134
|
-
const o =
|
|
2145
|
+
const o = y("模块重命名中...").start();
|
|
2135
2146
|
return s !== a.displayName ? (await Hi({
|
|
2136
2147
|
id: Number(a.id),
|
|
2137
2148
|
name: s
|
|
@@ -2140,10 +2151,10 @@ async function qa(e, t) {
|
|
|
2140
2151
|
async function Ha(e, t) {
|
|
2141
2152
|
const { type: i, typeStr: n } = await je("修改", e), { localProduct: a } = await Se(t.productId);
|
|
2142
2153
|
let s;
|
|
2143
|
-
if (R.MODULE === i ? s = await qa(a, t) : R.CASE === i && (s = await Wa(a, t)), !t.disableAutoCommit && await
|
|
2144
|
-
const o =
|
|
2154
|
+
if (R.MODULE === i ? s = await qa(a, t) : R.CASE === i && (s = await Wa(a, t)), !t.disableAutoCommit && await m("git status -s")) {
|
|
2155
|
+
const o = y("代码提交中...").start();
|
|
2145
2156
|
try {
|
|
2146
|
-
await
|
|
2157
|
+
await m(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
|
|
2147
2158
|
} catch (r) {
|
|
2148
2159
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
2149
2160
|
}
|
|
@@ -2156,7 +2167,7 @@ async function Za(e, t) {
|
|
|
2156
2167
|
const i = It(20), n = e.map(
|
|
2157
2168
|
(a) => i(async () => {
|
|
2158
2169
|
try {
|
|
2159
|
-
const s = t.env || "production", o = await
|
|
2170
|
+
const s = t.env || "production", o = await m(`python ${a.path}/main.py --env ${s}`);
|
|
2160
2171
|
try {
|
|
2161
2172
|
a.result = JSON.parse(o);
|
|
2162
2173
|
} catch {
|
|
@@ -2182,7 +2193,7 @@ async function Ka(e) {
|
|
|
2182
2193
|
displayName: c.displayName
|
|
2183
2194
|
}));
|
|
2184
2195
|
else {
|
|
2185
|
-
const c =
|
|
2196
|
+
const c = Oe(e.caseIds);
|
|
2186
2197
|
if (c.length)
|
|
2187
2198
|
i = a.filter((u) => c.includes(Number(u.id))).map((u) => ({
|
|
2188
2199
|
id: Number(u.id),
|
|
@@ -2196,7 +2207,7 @@ async function Ka(e) {
|
|
|
2196
2207
|
path: d.path,
|
|
2197
2208
|
displayName: d.displayName
|
|
2198
2209
|
},
|
|
2199
|
-
name: d.path.replace(
|
|
2210
|
+
name: d.path.replace(p.resolve(t.path), "")
|
|
2200
2211
|
}));
|
|
2201
2212
|
i = await ae({
|
|
2202
2213
|
message: "选择要执行的用例",
|
|
@@ -2209,7 +2220,7 @@ async function Ka(e) {
|
|
|
2209
2220
|
});
|
|
2210
2221
|
}
|
|
2211
2222
|
}
|
|
2212
|
-
const s =
|
|
2223
|
+
const s = y("用例执行中...").start(), r = (await Za(i, e)).filter((c) => c.result.length);
|
|
2213
2224
|
if (r.length === 0)
|
|
2214
2225
|
s.succeed("所有用例执行通过 🎉");
|
|
2215
2226
|
else {
|
|
@@ -2223,11 +2234,11 @@ async function Ka(e) {
|
|
|
2223
2234
|
else {
|
|
2224
2235
|
const f = await Qi(), g = await T({
|
|
2225
2236
|
message: "请选择用例执行出错后,BUG所属的项目",
|
|
2226
|
-
choices: f.map(({ id:
|
|
2237
|
+
choices: f.map(({ id: k, name: ee }) => ({ name: ee, value: k }))
|
|
2227
2238
|
}), h = await ea(g);
|
|
2228
2239
|
u = await T({
|
|
2229
2240
|
message: "请选择用例执行出错后,BUG所属的执行",
|
|
2230
|
-
choices: h.map(({ id:
|
|
2241
|
+
choices: h.map(({ id: k, name: ee }) => ({ name: ee, value: k }))
|
|
2231
2242
|
});
|
|
2232
2243
|
}
|
|
2233
2244
|
let d;
|
|
@@ -2239,9 +2250,9 @@ async function Ka(e) {
|
|
|
2239
2250
|
const g = await Ce({
|
|
2240
2251
|
message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
|
|
2241
2252
|
required: !1,
|
|
2242
|
-
choices: f.map(({ id: h, name:
|
|
2253
|
+
choices: f.map(({ id: h, name: k, date: ee, builder: P }) => ({
|
|
2243
2254
|
value: h,
|
|
2244
|
-
name: `${
|
|
2255
|
+
name: `${k} ${P} ${ee}`
|
|
2245
2256
|
}))
|
|
2246
2257
|
});
|
|
2247
2258
|
g.length ? d = g.join(",") : d = "";
|
|
@@ -2254,7 +2265,7 @@ async function Ka(e) {
|
|
|
2254
2265
|
caseId: f.id,
|
|
2255
2266
|
caseResult: "fail",
|
|
2256
2267
|
stepResults: f.result,
|
|
2257
|
-
runner:
|
|
2268
|
+
runner: E("ldapAccount"),
|
|
2258
2269
|
executionId: u,
|
|
2259
2270
|
openedBuild: d
|
|
2260
2271
|
});
|
|
@@ -2267,7 +2278,7 @@ D.command("qa-exec").alias("qe").description("执行用例").option("--product-i
|
|
|
2267
2278
|
function Ya() {
|
|
2268
2279
|
process.on("unhandledRejection", (e) => {
|
|
2269
2280
|
}), process.on("uncaughtException", (e) => {
|
|
2270
|
-
}),
|
|
2281
|
+
}), O.config.fatal = !0, O.config.silent = !0, O.config.verbose = !1;
|
|
2271
2282
|
}
|
|
2272
2283
|
async function Xa() {
|
|
2273
2284
|
const e = ge("latestCheckVersionTimestamp"), t = ge("versionCheckDuring");
|
|
@@ -2281,8 +2292,8 @@ async function Xa() {
|
|
|
2281
2292
|
});
|
|
2282
2293
|
n = await Promise.race([
|
|
2283
2294
|
s,
|
|
2284
|
-
|
|
2285
|
-
]), n !== a && n !== ie.version && (console.log(`${S.blue(ie.name)}本地版本为${ie.version},低于线上版本${n},开始升级`), await
|
|
2295
|
+
m(`npm view ${ie.name} version --registry https://registry.npmmirror.com/`)
|
|
2296
|
+
]), n !== a && n !== ie.version && (console.log(`${S.blue(ie.name)}本地版本为${ie.version},低于线上版本${n},开始升级`), await mt(n)), ue("latestCheckVersionTimestamp", Date.now()), se();
|
|
2286
2297
|
} catch (a) {
|
|
2287
2298
|
console.log("升级出错!请重试,或者手动升级"), l(a);
|
|
2288
2299
|
}
|