cli-z-develop 0.10.7 → 0.10.8

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.
Files changed (2) hide show
  1. package/dist/index.js +265 -264
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { program as x } from "commander";
1
+ import { program as R } 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
4
  import { readdir as ke, mkdir as ce, writeFile as _, rename as Be, readFile as Ee, stat as Nt } from "node:fs/promises";
@@ -6,20 +6,20 @@ import m from "node:path";
6
6
  import pe, { AxiosError as St } from "axios";
7
7
  import S from "chalk";
8
8
  import jt from "dayjs";
9
- import D from "shelljs";
9
+ import P from "shelljs";
10
10
  import At from "node:os";
11
11
  import Me from "child_process";
12
- import { confirm as Ue, select as T, input as F, password as Et, checkbox as Te, number as ze } from "@inquirer/prompts";
12
+ import { confirm as Ue, select as E, input as F, password as Et, checkbox as Te, number as ze } from "@inquirer/prompts";
13
13
  import w from "ora";
14
- import A from "fs-extra";
14
+ import j from "fs-extra";
15
15
  import { select as ie } from "inquirer-select-pro";
16
16
  import Tt from "lint-staged";
17
17
  import kt from "semver";
18
18
  import { run as Ct } from "npm-check-updates";
19
19
  import It from "p-limit";
20
20
  import xt from "minimist";
21
- const Je = "dev", Ge = "test", We = "release", Rt = "production", Lt = "master";
22
- var v = /* @__PURE__ */ ((e) => (e[e.DEV = Je] = "DEV", e[e.TEST = Ge] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.PROD = Rt] = "PROD", e))(v || {}), y = /* @__PURE__ */ ((e) => (e[e.DEV = Je] = "DEV", e[e.TEST = Ge] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.MASTER = Lt] = "MASTER", e))(y || {}), Z = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(Z || {});
21
+ const Ge = "dev", Je = "test", We = "release", Rt = "production", Lt = "master";
22
+ var v = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = Je] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.PROD = Rt] = "PROD", e))(v || {}), y = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = Je] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.MASTER = Lt] = "MASTER", e))(y || {}), H = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(H || {});
23
23
  const qe = [
24
24
  {
25
25
  name: `开发环境 - ${v.DEV}`,
@@ -54,7 +54,7 @@ const qe = [
54
54
  /* SERVER */
55
55
  }
56
56
  ];
57
- var le = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(le || {}), re = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(re || {}), L = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e))(L || {});
57
+ var le = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(le || {}), re = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(re || {}), D = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e))(D || {});
58
58
  const Pt = {
59
59
  1: "研发",
60
60
  2: "测试",
@@ -80,18 +80,18 @@ const zt = [
80
80
  value: "case"
81
81
  /* CASE */
82
82
  }
83
- ], _t = ".z", Ft = "develop-config.json", V = ".z", Bt = ".commit-msg-tpl", Ut = "project.json";
84
- function C(e = "") {
85
- return m.join(V, e);
83
+ ], _t = ".z", Ft = "develop-config.json", Z = ".z", Bt = ".commit-msg-tpl", Ut = "project.json";
84
+ function I(e = "") {
85
+ return m.join(Z, e);
86
86
  }
87
87
  function Ce() {
88
- return C(Ut);
88
+ return I(Ut);
89
89
  }
90
90
  function ye() {
91
- return C(Bt);
91
+ return I(Bt);
92
92
  }
93
93
  function Ze() {
94
- Me.spawnSync("git", ["config", "core.hooksPath", C()]), Me.spawnSync("git", ["config", "commit.template", ye()]);
94
+ Me.spawnSync("git", ["config", "core.hooksPath", I()]), Me.spawnSync("git", ["config", "commit.template", ye()]);
95
95
  }
96
96
  function fe(e = "") {
97
97
  return m.resolve(At.homedir(), _t, e);
@@ -99,11 +99,11 @@ function fe(e = "") {
99
99
  function $e() {
100
100
  return fe(Ft);
101
101
  }
102
- function Jt() {
102
+ function Gt() {
103
103
  return $(fe());
104
104
  }
105
105
  function He() {
106
- return Jt() && $($e());
106
+ return Gt() && $($e());
107
107
  }
108
108
  function Ke(e) {
109
109
  let t = e.trim();
@@ -116,14 +116,14 @@ function Ke(e) {
116
116
  }
117
117
  return encodeURIComponent(t.replace(/\.git$/, ""));
118
118
  }
119
- const { red: _e, green: Gt, blue: yn, magenta: Wt, yellow: qt } = S;
119
+ const { red: _e, green: Jt, blue: yn, magenta: Wt, yellow: qt } = S;
120
120
  function he(...e) {
121
121
  }
122
122
  function Vt(...e) {
123
123
  console.log(qt(...e));
124
124
  }
125
125
  function B(...e) {
126
- console.log(Gt(...e));
126
+ console.log(Jt(...e));
127
127
  }
128
128
  function Qe(e) {
129
129
  e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(S.cyan(" 👋 下次见~")), console.log(), process.exit(1));
@@ -145,7 +145,7 @@ async function p(e, t = {
145
145
  }) {
146
146
  let i = await new Promise((a, n) => {
147
147
  try {
148
- const s = D.exec(e, {
148
+ const s = P.exec(e, {
149
149
  silent: t.silent
150
150
  });
151
151
  a(s);
@@ -170,9 +170,9 @@ function Zt(e, t) {
170
170
  return !0;
171
171
  }
172
172
  function ae() {
173
- $(C()) || l("当前不在项目根目录。请切换到项目根目录");
173
+ $(I()) || l("当前不在项目根目录。请切换到项目根目录");
174
174
  }
175
- function Q() {
175
+ function Y() {
176
176
  $(m.resolve(".git")) || l("当前不是git项目根目录,请先执行git init,或切换到根目录");
177
177
  }
178
178
  async function ue() {
@@ -295,16 +295,16 @@ dist/
295
295
  # 垃圾文件
296
296
  .Trashes
297
297
  `, ti = {
298
- [L.JAVA]: {
298
+ [D.JAVA]: {
299
299
  // TODO: 需要优化
300
300
  // "**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml",
301
301
  "**/*.{java}": "echo 'todo'"
302
302
  },
303
- [L.JAVASCRIPT]: {
303
+ [D.JAVASCRIPT]: {
304
304
  "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
305
305
  "*": "prettier -wu"
306
306
  },
307
- [L.PYTHON]: {
307
+ [D.PYTHON]: {
308
308
  // TODO: 需要优化
309
309
  // "**/*.{py}": "python --fix",
310
310
  "**/*.{py}": "echo 'todo'"
@@ -347,7 +347,7 @@ dist/
347
347
  validate:
348
348
  # 包含内容
349
349
  - contains: {}
350
- `, ai = "# from assets", ni = "cli-z-develop", si = "0.10.7", 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" }, te = {
350
+ `, ai = "# from assets", ni = "cli-z-develop", si = "0.10.8", 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" }, te = {
351
351
  name: ni,
352
352
  version: si,
353
353
  description: ri,
@@ -358,7 +358,7 @@ dist/
358
358
  author: pi,
359
359
  devDependencies: mi,
360
360
  dependencies: di
361
- }, I = {
361
+ }, x = {
362
362
  // 个人数据
363
363
  profile: {
364
364
  ldapAccount: "",
@@ -391,43 +391,43 @@ dist/
391
391
  K8SWebDomain: ""
392
392
  }
393
393
  };
394
- function E(e) {
395
- return e ? I.profile[e] : I.profile;
394
+ function A(e) {
395
+ return e ? x.profile[e] : x.profile;
396
396
  }
397
397
  function de(e) {
398
- return e ? I.main[e] : I.main;
398
+ return e ? x.main[e] : x.main;
399
399
  }
400
- function Y(e) {
401
- return e ? I.constants[e] : I.constants;
400
+ function X(e) {
401
+ return e ? x.constants[e] : x.constants;
402
402
  }
403
- let U = null, J = null;
403
+ let G = null, J = null;
404
404
  function ve() {
405
- if (U)
406
- return U;
405
+ if (G)
406
+ return G;
407
407
  const e = m.join("package.json");
408
- return $(e) || l(`当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), U = A.readJsonSync(e), U;
408
+ return $(e) || l(`当前目录(${P.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), G = j.readJsonSync(e), G;
409
409
  }
410
410
  function be() {
411
411
  if (J)
412
412
  return J;
413
413
  const e = Ce();
414
414
  return $(e) || l(
415
- `当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
416
- ), J = A.readJsonSync(e), J;
415
+ `当前目录(${P.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
416
+ ), J = j.readJsonSync(e), J;
417
417
  }
418
418
  function tt(e) {
419
419
  J ? J = {
420
420
  ...J,
421
421
  ...e
422
- } : J = e, A.writeJSONSync(Ce(), J, { spaces: 2 });
422
+ } : J = e, j.writeJSONSync(Ce(), J, { spaces: 2 });
423
423
  }
424
424
  function fi(e) {
425
- U ? U = {
426
- ...U,
425
+ G ? G = {
426
+ ...G,
427
427
  ...e
428
- } : U = e, A.writeJSONSync(m.join("package.json"), U, { spaces: 2 });
428
+ } : G = e, j.writeJSONSync(m.join("package.json"), G, { spaces: 2 });
429
429
  }
430
- const q = {
430
+ const V = {
431
431
  id: 0,
432
432
  path: "",
433
433
  group: "",
@@ -435,22 +435,22 @@ const q = {
435
435
  mergeRequestUrl: ""
436
436
  };
437
437
  async function gi() {
438
- if (!q.id)
438
+ if (!V.id)
439
439
  try {
440
440
  const e = be(), t = Ke(e.repository.url), i = await nt(t);
441
- q.id = i.id, q.path = t, q.group = i.namespace.full_path, q.mergeRequestUrl = `${i.web_url}/merge_requests`;
441
+ V.id = i.id, V.path = t, V.group = i.namespace.full_path, V.mergeRequestUrl = `${i.web_url}/merge_requests`;
442
442
  } catch (e) {
443
443
  l(e);
444
444
  }
445
- return q.sourceBranch || (q.sourceBranch = await p("git branch --show-current")), q;
445
+ return V.sourceBranch || (V.sourceBranch = await p("git branch --show-current")), V;
446
446
  }
447
447
  function ne() {
448
- A.writeJSONSync(
448
+ j.writeJSONSync(
449
449
  $e(),
450
450
  {
451
451
  main: de(),
452
- profile: E(),
453
- constants: Y()
452
+ profile: A(),
453
+ constants: X()
454
454
  },
455
455
  {
456
456
  spaces: 2
@@ -458,24 +458,24 @@ function ne() {
458
458
  );
459
459
  }
460
460
  function O(e, t) {
461
- t !== void 0 ? I.profile[e] = t : I.profile = {
462
- ...I.profile,
461
+ t !== void 0 ? x.profile[e] = t : x.profile = {
462
+ ...x.profile,
463
463
  ...e
464
464
  };
465
465
  }
466
466
  function Ie(e, t) {
467
- I.constants = {
468
- ...I.constants,
467
+ x.constants = {
468
+ ...x.constants,
469
469
  ...e
470
470
  };
471
471
  }
472
472
  function oe(e, t) {
473
- t !== void 0 ? I.main[e] = t : I.main = {
474
- ...I.main,
473
+ t !== void 0 ? x.main[e] = t : x.main = {
474
+ ...x.main,
475
475
  ...e
476
476
  };
477
477
  }
478
- async function H(e) {
478
+ async function K(e) {
479
479
  const t = e.method || "get", i = e.headers || {}, a = e.data || {}, n = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
480
480
  try {
481
481
  const s = {
@@ -492,24 +492,24 @@ async function H(e) {
492
492
  }
493
493
  }
494
494
  async function hi() {
495
- const e = E("gitToken");
495
+ const e = A("gitToken");
496
496
  if (e)
497
497
  return e;
498
498
  {
499
- const { access_token: t } = await H({
499
+ const { access_token: t } = await K({
500
500
  url: `${me}/oauth/token`,
501
501
  method: "post",
502
502
  data: {
503
503
  grant_type: "password",
504
- username: E("ldapAccount"),
505
- password: E("ldapPassword")
504
+ username: A("ldapAccount"),
505
+ password: A("ldapPassword")
506
506
  }
507
507
  }), i = `Bearer ${t}`;
508
508
  return O("gitToken", i), ne(), i;
509
509
  }
510
510
  }
511
- async function R(e) {
512
- return H({
511
+ async function L(e) {
512
+ return K({
513
513
  ...e,
514
514
  headers: {
515
515
  Authorization: await hi()
@@ -517,23 +517,23 @@ async function R(e) {
517
517
  });
518
518
  }
519
519
  async function wi() {
520
- const e = E("zenTaoToken");
520
+ const e = A("zenTaoToken");
521
521
  if (e)
522
522
  return e;
523
523
  {
524
- const { token: t } = await H({
525
- url: `${Y("ZenTaoDomain")}/api.php/v1/tokens`,
524
+ const { token: t } = await K({
525
+ url: `${X("ZenTaoDomain")}/api.php/v1/tokens`,
526
526
  method: "post",
527
527
  data: {
528
- account: E("ldapAccount"),
529
- password: E("ldapPassword")
528
+ account: A("ldapAccount"),
529
+ password: A("ldapPassword")
530
530
  }
531
531
  });
532
532
  return O("zenTaoToken", t), ne(), t;
533
533
  }
534
534
  }
535
535
  async function we(e) {
536
- const t = await H({
536
+ const t = await K({
537
537
  ...e,
538
538
  headers: {
539
539
  Token: await wi()
@@ -560,26 +560,26 @@ async function we(e) {
560
560
  }
561
561
  }
562
562
  async function yi() {
563
- const e = E("k8sToken");
563
+ const e = A("k8sToken");
564
564
  if (e)
565
565
  return e;
566
566
  {
567
- const { access_token: t } = await H({
568
- url: `${Y("K8sDomain")}/oauth/login/LDAP`,
567
+ const { access_token: t } = await K({
568
+ url: `${X("K8sDomain")}/oauth/login/LDAP`,
569
569
  method: "post",
570
570
  headers: {
571
571
  "Content-Type": "application/x-www-form-urlencoded"
572
572
  },
573
573
  data: {
574
- username: E("ldapAccount"),
575
- password: E("ldapPassword")
574
+ username: A("ldapAccount"),
575
+ password: A("ldapPassword")
576
576
  }
577
577
  }), i = `Bearer ${t}`;
578
578
  return O("k8sToken", i), ne(), i;
579
579
  }
580
580
  }
581
581
  async function it(e) {
582
- const t = await H({
582
+ const t = await K({
583
583
  ...e,
584
584
  headers: {
585
585
  Authorization: await yi()
@@ -591,44 +591,44 @@ async function it(e) {
591
591
  }
592
592
  const z = () => `${me}/api/v4`, xe = (e) => `${z()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
593
593
  function $i() {
594
- return R({
594
+ return L({
595
595
  url: xe("src/data/template-projects.json")
596
596
  });
597
597
  }
598
598
  function at() {
599
- return R({
599
+ return L({
600
600
  url: xe("src/data/z-develop-config.json")
601
601
  });
602
602
  }
603
603
  function vi() {
604
- return R({
604
+ return L({
605
605
  url: xe("src/data/project-group-chats.json")
606
606
  });
607
607
  }
608
608
  function bi() {
609
- return R({
609
+ return L({
610
610
  url: `${z()}/user`
611
611
  });
612
612
  }
613
613
  function Ni() {
614
- return R({
614
+ return L({
615
615
  url: `${z()}/groups`
616
616
  });
617
617
  }
618
618
  function Si(e) {
619
- return R({
619
+ return L({
620
620
  url: `${z()}/projects`,
621
621
  method: "post",
622
622
  data: e
623
623
  });
624
624
  }
625
625
  function nt(e) {
626
- return R({
626
+ return L({
627
627
  url: `${z()}/projects/${e}`
628
628
  });
629
629
  }
630
630
  function ji(e) {
631
- return R({
631
+ return L({
632
632
  url: `${z()}/projects`,
633
633
  data: {
634
634
  search: e,
@@ -637,46 +637,46 @@ function ji(e) {
637
637
  });
638
638
  }
639
639
  function Ai(e) {
640
- return R({
640
+ return L({
641
641
  url: `${z()}/projects/${e.id}/merge_requests`,
642
642
  method: "post",
643
643
  data: e
644
644
  });
645
645
  }
646
646
  function Ei(e) {
647
- return R({
647
+ return L({
648
648
  url: `${z()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
649
649
  method: "put"
650
650
  });
651
651
  }
652
652
  function Ti(e) {
653
- return R({
653
+ return L({
654
654
  url: `${z()}/projects/${e.id}/merge_requests/${e.iid}`,
655
655
  method: "put",
656
656
  data: e
657
657
  });
658
658
  }
659
659
  function ki(e) {
660
- return R({
660
+ return L({
661
661
  url: `${z()}/projects/${e.id}/merge_requests/${e.iid}`,
662
662
  method: "get"
663
663
  });
664
664
  }
665
665
  function Ci(e) {
666
- return R({
666
+ return L({
667
667
  url: `${z()}/projects/${e.id}/repository/branches`,
668
668
  method: "post",
669
669
  data: e
670
670
  });
671
671
  }
672
672
  function Ii(e) {
673
- return R({
673
+ return L({
674
674
  url: `${z()}/projects/${e}/repository/branches`
675
675
  });
676
676
  }
677
677
  function xi() {
678
678
  const e = fe("fe-groups.json");
679
- return $(e) ? A.readJSONSync(e) : { groups: [] };
679
+ return $(e) ? j.readJSONSync(e) : { groups: [] };
680
680
  }
681
681
  async function Ri() {
682
682
  const e = await Ni(), t = Ot.map((i) => {
@@ -687,13 +687,13 @@ async function Ri() {
687
687
  description: a.description
688
688
  } : !1;
689
689
  }).filter((i) => !!i);
690
- A.writeJSONSync(fe("fe-groups.json"), { groups: t }, { spaces: 2 });
690
+ j.writeJSONSync(fe("fe-groups.json"), { groups: t }, { spaces: 2 });
691
691
  }
692
692
  async function N(e) {
693
- const t = `${Y("FEServerDomain")}/api`, { data: i } = await H({
693
+ const t = `${X("FEServerDomain")}/api`, { data: i } = await K({
694
694
  url: `${t}/auth/z-develop/login`,
695
695
  method: "post"
696
- }), a = await H({
696
+ }), a = await K({
697
697
  url: t + e.url,
698
698
  headers: {
699
699
  Authorization: `Bearer ${i}`
@@ -776,13 +776,13 @@ function Ui(e) {
776
776
  data: e
777
777
  });
778
778
  }
779
- function Ji(e) {
779
+ function Gi(e) {
780
780
  return N({
781
781
  url: "/zen/testcase/module/update/name",
782
782
  data: e
783
783
  });
784
784
  }
785
- function Gi(e) {
785
+ function Ji(e) {
786
786
  return N({
787
787
  url: "/zen/testcase/case/update/name",
788
788
  data: e
@@ -889,8 +889,8 @@ async function Xi() {
889
889
  try {
890
890
  He() && (await Ue({
891
891
  message: "系统中已存在z的配置文件,确认重新配置?"
892
- }) ? D.rm("-rf", $e()) : process.exit(0)), await ce(fe(), { recursive: !0 });
893
- const t = await T({
892
+ }) ? P.rm("-rf", $e()) : process.exit(0)), await ce(fe(), { recursive: !0 });
893
+ const t = await E({
894
894
  message: "请选择岗位类型",
895
895
  choices: [
896
896
  {
@@ -931,7 +931,7 @@ async function Xi() {
931
931
  gitName: t.name,
932
932
  gitEnglishName: t.username,
933
933
  gitEmail: t.email
934
- }), oe("latestCheckVersionTimestamp", Date.now()), ne(), E("jobType") === re.FRONT_END && await Ri(), e.succeed("配置信息初始化完成"), process.exit(0);
934
+ }), oe("latestCheckVersionTimestamp", Date.now()), ne(), A("jobType") === re.FRONT_END && await Ri(), e.succeed("配置信息初始化完成"), process.exit(0);
935
935
  } catch (t) {
936
936
  e.fail("配置信息初始化失败"), pe.isAxiosError(t) && l("请检查你的域名及令牌配置"), l(t);
937
937
  }
@@ -1024,12 +1024,12 @@ const ea = `{
1024
1024
  }
1025
1025
  `;
1026
1026
  async function ia() {
1027
- await _(ye(), "", { mode: 493 }), await _(C(".gitignore"), `.commit-msg-tpl
1028
- `, { mode: 493 }), await _(C("commit-msg"), `#!/usr/bin/env sh
1029
- z run commit-msg`, { mode: 493 }), await _(C("pre-commit"), `#!/usr/bin/env sh
1027
+ await _(ye(), "", { mode: 493 }), await _(I(".gitignore"), `.commit-msg-tpl
1028
+ `, { mode: 493 }), await _(I("commit-msg"), `#!/usr/bin/env sh
1029
+ z run commit-msg`, { mode: 493 }), await _(I("pre-commit"), `#!/usr/bin/env sh
1030
1030
  z run commit-files`, { mode: 493 });
1031
1031
  const { language: e } = be();
1032
- e === L.JAVASCRIPT && (await _(C(".prettierrc.json"), Xt, { mode: 493 }), await _(C(".prettierignore"), ei, { mode: 493 }), await _(C("tsconfig.node.json"), ta, { mode: 493 }), await _(C("tsconfig.browser.json"), ea, {
1032
+ e === D.JAVASCRIPT && (await _(I(".prettierrc.json"), Xt, { mode: 493 }), await _(I(".prettierignore"), ei, { mode: 493 }), await _(I("tsconfig.node.json"), ta, { mode: 493 }), await _(I("tsconfig.browser.json"), ea, {
1033
1033
  mode: 493
1034
1034
  })), Ze();
1035
1035
  }
@@ -1037,20 +1037,20 @@ async function aa(e, t) {
1037
1037
  const i = await p("git remote get-url --push origin");
1038
1038
  i || l("获取项目远程git地址失败,请配置后重试");
1039
1039
  let a = e;
1040
- a || (a = await T({
1040
+ a || (a = await E({
1041
1041
  message: "请选择项目语言",
1042
1042
  choices: [
1043
1043
  {
1044
- name: L.JAVASCRIPT,
1045
- value: L.JAVASCRIPT
1044
+ name: D.JAVASCRIPT,
1045
+ value: D.JAVASCRIPT
1046
1046
  },
1047
1047
  {
1048
- name: L.JAVA,
1049
- value: L.JAVA
1048
+ name: D.JAVA,
1049
+ value: D.JAVA
1050
1050
  },
1051
1051
  {
1052
- name: L.PYTHON,
1053
- value: L.PYTHON
1052
+ name: D.PYTHON,
1053
+ value: D.PYTHON
1054
1054
  }
1055
1055
  ]
1056
1056
  }));
@@ -1071,17 +1071,17 @@ async function aa(e, t) {
1071
1071
  });
1072
1072
  }
1073
1073
  async function Re(e, t) {
1074
- e ? D.rm("-rf", V) : $(C()) && (await Ue({
1075
- message: `当前项目中已存在配置文件夹${V},确认重新配置?`
1076
- }) ? D.rm("-rf", V) : process.exit(0)), await ce(C(), { recursive: !0 }), await aa(e, t), await ia(), B("项目初始化完成");
1074
+ e ? P.rm("-rf", Z) : $(I()) && (await Ue({
1075
+ message: `当前项目中已存在配置文件夹${Z},确认重新配置?`
1076
+ }) ? P.rm("-rf", Z) : process.exit(0)), await ce(I(), { recursive: !0 }), await aa(e, t), await ia(), B("项目初始化完成");
1077
1077
  }
1078
1078
  async function na() {
1079
- $(C()) && $(ye()) ? Ze() : await Re(), process.exit(0);
1079
+ $(I()) && $(ye()) ? Ze() : await Re(), process.exit(0);
1080
1080
  }
1081
1081
  async function sa(e, t) {
1082
- t.projectLanguage && !Object.values(L).includes(t.projectLanguage) && l("项目语言不支持"), e ? (Q(), e === "." ? (await Re(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await na() : l("参数错误。执行 z init -h 查看帮助。")) : await Xi();
1082
+ t.projectLanguage && !Object.values(D).includes(t.projectLanguage) && l("项目语言不支持"), e ? (Y(), e === "." ? (await Re(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await na() : l("参数错误。执行 z init -h 查看帮助。")) : await Xi();
1083
1083
  }
1084
- x.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(L).join("/")} `).action((...e) => M(sa, ...e));
1084
+ R.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(D).join("/")} `).action((...e) => M(sa, ...e));
1085
1085
  async function ra(e, t) {
1086
1086
  if (!e)
1087
1087
  return "不能为空";
@@ -1099,9 +1099,9 @@ function ca(e) {
1099
1099
  return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
1100
1100
  }
1101
1101
  async function ua(e) {
1102
- ae(), Q(), await ue();
1102
+ ae(), Y(), await ue();
1103
1103
  let t, i;
1104
- e.branchType ? t = e.branchType : t = await T({
1104
+ e.branchType ? t = e.branchType : t = await E({
1105
1105
  message: "请选择创建分支的类型",
1106
1106
  choices: [
1107
1107
  {
@@ -1124,7 +1124,7 @@ async function ua(e) {
1124
1124
  const a = `${t}_${i}_${et()}`;
1125
1125
  await p(`git fetch origin ${y.MASTER}`), await p(`git checkout -b ${a} origin/${y.MASTER}`), await p(`git push -u origin ${a}`), process.exit(0);
1126
1126
  }
1127
- const ct = (e) => `${Y("ZenTaoDomain")}${e}`;
1127
+ const ct = (e) => `${X("ZenTaoDomain")}${e}`;
1128
1128
  async function la() {
1129
1129
  const e = await we({
1130
1130
  url: ct("/my-work-task.json?tid=mrrferp8"),
@@ -1160,7 +1160,7 @@ async function Ae(e, t) {
1160
1160
  e === b.CHORE && (i = `${e}: ${t}`), await _(ye(), i, "utf-8"), console.log(S.yellow(i)), B("commit msg模板写入成功,可以进行提交了");
1161
1161
  }
1162
1162
  async function ma() {
1163
- const e = await T({
1163
+ const e = await E({
1164
1164
  message: "请选择你要创建的模板类型",
1165
1165
  choices: [
1166
1166
  {
@@ -1223,35 +1223,35 @@ async function ma() {
1223
1223
  async function da() {
1224
1224
  try {
1225
1225
  const e = {}, t = async () => {
1226
- const P = Ye(), { projects: ee } = await $i(), W = ee.map((se) => {
1226
+ const T = Ye(), { projects: U } = await $i(), q = U.map((se) => {
1227
1227
  const Oe = {
1228
1228
  name: `${se.name} [${se.desc}]`,
1229
1229
  value: se.name,
1230
1230
  disabled: !1
1231
1231
  };
1232
- return P.includes(se.name) && (Oe.disabled = "目录下已存在同名文件夹"), Oe;
1233
- }), yt = await T({
1232
+ return T.includes(se.name) && (Oe.disabled = "目录下已存在同名文件夹"), Oe;
1233
+ }), yt = await E({
1234
1234
  message: "请选择一个项目模板",
1235
- choices: W
1236
- }), je = ee.find((se) => se.name === yt);
1235
+ choices: q
1236
+ }), je = U.find((se) => se.name === yt);
1237
1237
  e.tplName = je.name, e.tplUrl = je.url, e.tplLanguage = je.language;
1238
1238
  }, i = async () => {
1239
- const { groups: P } = xi(), ee = await T({
1239
+ const { groups: T } = xi(), U = await E({
1240
1240
  message: "请选择一个分组",
1241
- choices: P.map((W) => ({
1242
- name: `${W.name} [${W.description}]`,
1243
- value: W.id,
1244
- short: W.name
1241
+ choices: T.map((q) => ({
1242
+ name: `${q.name} [${q.description}]`,
1243
+ value: q.id,
1244
+ short: q.name
1245
1245
  }))
1246
1246
  });
1247
1247
  e.group = {
1248
- id: ee,
1249
- name: P.find((W) => W.id === ee)?.name
1248
+ id: U,
1249
+ name: T.find((q) => q.id === U)?.name
1250
1250
  };
1251
1251
  }, a = async () => {
1252
1252
  e.projectName = await F({
1253
1253
  message: "请输入项目名称",
1254
- validate: (P) => ra(P, e.group?.name || "")
1254
+ validate: (T) => ra(T, e.group?.name || "")
1255
1255
  }), e.projectDesc = await F({
1256
1256
  message: "请输入项目描述",
1257
1257
  validate: oa
@@ -1259,7 +1259,7 @@ async function da() {
1259
1259
  };
1260
1260
  await t(), await i(), await a();
1261
1261
  const n = `${me}/${e.group?.name}/${e.projectName}.git`, s = w("模版初始化中").start();
1262
- await p(`git clone --depth=1 ${e.tplUrl}`), await Be(e.tplName, e.projectName), D.cd(e.projectName), D.rm("-rf", ".git"), await p(`git init --initial-branch=${y.MASTER}`), await p(`git remote add origin ${n}`), await p(`git config user.name ${E("gitName")}`), await p(`git config user.email ${E("gitEmail")}`);
1262
+ await p(`git clone --depth=1 ${e.tplUrl}`), await Be(e.tplName, e.projectName), P.cd(e.projectName), P.rm("-rf", ".git"), await p(`git init --initial-branch=${y.MASTER}`), await p(`git remote add origin ${n}`), await p(`git config user.name ${A("gitName")}`), await p(`git config user.email ${A("gitEmail")}`);
1263
1263
  const o = ve();
1264
1264
  fi({
1265
1265
  ...o,
@@ -1269,7 +1269,7 @@ async function da() {
1269
1269
  ...o.scripts,
1270
1270
  prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
1271
1271
  }
1272
- }), await A.writeFile(m.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Re(e.tplLanguage, e.group?.name);
1272
+ }), await j.writeFile(m.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Re(e.tplLanguage, e.group?.name);
1273
1273
  const r = w("依赖安装中").start();
1274
1274
  await p("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
1275
1275
  const c = w("项目推送中").start();
@@ -1282,20 +1282,20 @@ async function da() {
1282
1282
  namespace_id: e.group?.id
1283
1283
  });
1284
1284
  await p(`git push -u origin ${y.MASTER}`), await p(`git push origin HEAD:${y.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${S.blue(n)}`);
1285
- const d = w("初始化分支中").start(), f = `feat_init_${et()}`, g = [y.DEV, y.TEST, y.RELEASE, f], h = await Promise.allSettled(
1286
- g.map(
1287
- (P) => Ci({
1285
+ const d = w("初始化分支中").start(), g = `feat_init_${et()}`, f = [y.DEV, y.TEST, y.RELEASE, g], h = await Promise.allSettled(
1286
+ f.map(
1287
+ (T) => Ci({
1288
1288
  id: u.id,
1289
- branch: P,
1289
+ branch: T,
1290
1290
  ref: y.MASTER
1291
1291
  })
1292
1292
  )
1293
- ), j = [];
1294
- h.forEach(({ status: P }, ee) => {
1295
- P === "fulfilled" && j.push(g[ee]);
1296
- }), await p("git pull"), j.includes(f) ? (await p(`git checkout -b ${f} origin/${f}`), d.succeed(`项目已切换到初始分支: ${S.blue(f)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
1297
- const X = `cd ${e.projectName} && z start`;
1298
- console.log(`输入 ${S.green(X)} 开始开发吧~`), process.exit(0);
1293
+ ), C = [];
1294
+ h.forEach(({ status: T }, U) => {
1295
+ T === "fulfilled" && C.push(f[U]);
1296
+ }), await p("git pull"), C.includes(g) ? (await p(`git checkout -b ${g} origin/${g}`), d.succeed(`项目已切换到初始分支: ${S.blue(g)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
1297
+ const ee = `cd ${e.projectName} && z start`;
1298
+ console.log(`输入 ${S.green(ee)} 开始开发吧~`), process.exit(0);
1299
1299
  } catch (e) {
1300
1300
  l(e);
1301
1301
  }
@@ -1314,7 +1314,7 @@ async function fa(e, t) {
1314
1314
  "commit-msg",
1315
1315
  "cm"
1316
1316
  /* CommitMsgAbbr */
1317
- ].includes(e) ? i = "commit-msg" : l("参数输入错误") : i = await T({
1317
+ ].includes(e) ? i = "commit-msg" : l("参数输入错误") : i = await E({
1318
1318
  message: "请选择你要创建的类型",
1319
1319
  choices: [
1320
1320
  {
@@ -1333,18 +1333,18 @@ async function fa(e, t) {
1333
1333
  /* Project */
1334
1334
  }
1335
1335
  ]
1336
- }), i === "project" ? await da() : (ae(), Q(), i === "branch" ? (await ue(), await ua(t)) : i === "commit-msg" && await ma());
1336
+ }), i === "project" ? await da() : (ae(), Y(), i === "branch" ? (await ue(), await ua(t)) : i === "commit-msg" && await ma());
1337
1337
  }
1338
- x.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(le).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").action((...e) => M(fa, ...e));
1338
+ R.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(le).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").action((...e) => M(fa, ...e));
1339
1339
  function ga(e) {
1340
1340
  return it({
1341
- url: `${Y("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${Mt}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
1341
+ url: `${X("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${Mt}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
1342
1342
  method: "post",
1343
1343
  data: e.params
1344
1344
  });
1345
1345
  }
1346
1346
  async function ha(e) {
1347
- const t = w("部署任务创建中").start(), { targetBranch: i, notify: a, projectName: n } = e, s = a ? [.../* @__PURE__ */ new Set([E("weWorkUserId"), ...a])] : [E("weWorkUserId")];
1347
+ const t = w("部署任务创建中").start(), { targetBranch: i, notify: a, projectName: n } = e, s = a ? [.../* @__PURE__ */ new Set([A("weWorkUserId"), ...a])] : [A("weWorkUserId")];
1348
1348
  try {
1349
1349
  const { metadata: o, spec: r } = await ga({
1350
1350
  projectName: n,
@@ -1361,7 +1361,7 @@ async function ha(e) {
1361
1361
  }
1362
1362
  ]
1363
1363
  }
1364
- }), c = `${Y("K8SWebDomain")}/youshou-local/clusters/youshou-local/devops/${o.namespace}/pipelines/${r.pipelineRef.name}/branch/${r.scm.refName}/run/${o.name}/task-status`;
1364
+ }), c = `${X("K8SWebDomain")}/youshou-local/clusters/youshou-local/devops/${o.namespace}/pipelines/${r.pipelineRef.name}/branch/${r.scm.refName}/run/${o.name}/task-status`;
1365
1365
  t.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${S.blue(c)}`), process.exit(0);
1366
1366
  } catch (o) {
1367
1367
  t.fail("部署任务创建失败"), l(o);
@@ -1369,20 +1369,20 @@ async function ha(e) {
1369
1369
  }
1370
1370
  function wa(e, t) {
1371
1371
  const i = ve();
1372
- if (be()?.repository?.url || l(".z/project.json中缺少repository.url"), t === Z.H5) {
1372
+ if (be()?.repository?.url || l(".z/project.json中缺少repository.url"), t === H.H5) {
1373
1373
  const n = `build:${e}`;
1374
1374
  i?.scripts[n] || l(`项目package.json文件scripts不存在命令${n}。`);
1375
1375
  }
1376
- t === Z.NPM && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。")), t === Z.SERVER && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。"));
1376
+ t === H.NPM && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。")), t === H.SERVER && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。"));
1377
1377
  }
1378
1378
  async function ut(e, t) {
1379
- ae(), Q(), await ue();
1379
+ ae(), Y(), await ue();
1380
1380
  let i = e, a = t.platform;
1381
- if (i && !Object.values(y).includes(i) && l("仅支持发布指定环境分支"), a && !Object.values(Z).includes(a) && l("发布平台错误"), a || (a = await T({
1381
+ if (i && !Object.values(y).includes(i) && l("仅支持发布指定环境分支"), a && !Object.values(H).includes(a) && l("发布平台错误"), a || (a = await E({
1382
1382
  message: "请选择平台",
1383
1383
  choices: Dt
1384
- })), a === Z.NPM && (i = y.MASTER), !i) {
1385
- const c = await T({
1384
+ })), a === H.NPM && (i = y.MASTER), !i) {
1385
+ const c = await E({
1386
1386
  message: "请选择部署环境",
1387
1387
  choices: qe
1388
1388
  });
@@ -1458,15 +1458,15 @@ async function ya(e, t) {
1458
1458
  `git branch --contains ${a} -r ${i}`
1459
1459
  ) || (console.log(S.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt(y.MASTER, e.sourceBranch, e)), t === y.MASTER) {
1460
1460
  const r = s.split(`
1461
- `).filter((f) => f), c = await p(`git log -b origin/${v.TEST} -1 --format=%H`), d = (await p(
1461
+ `).filter((g) => g), c = await p(`git log -b origin/${v.TEST} -1 --format=%H`), d = (await p(
1462
1462
  `git log ${a}...${c} -b origin/${v.TEST}`
1463
1463
  )).split(`
1464
- `).filter((f) => f);
1464
+ `).filter((g) => g);
1465
1465
  Zt(d, r) || l("请先在测试环境发布要部署的代码");
1466
1466
  }
1467
1467
  }
1468
1468
  async function $a(e, t) {
1469
- ae(), Q(), await ue();
1469
+ ae(), Y(), await ue();
1470
1470
  const i = await gi();
1471
1471
  Object.values(y).includes(i.sourceBranch) && l(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
1472
1472
  const n = (await Ii(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
@@ -1477,7 +1477,7 @@ async function $a(e, t) {
1477
1477
  };
1478
1478
  });
1479
1479
  let s;
1480
- e && !n.filter((c) => c.value === e).length && l(`未找到目标分支${e}`), e ? s = e : s = await T({
1480
+ e && !n.filter((c) => c.value === e).length && l(`未找到目标分支${e}`), e ? s = e : s = await E({
1481
1481
  message: "请选择要合并到的目标分支:",
1482
1482
  choices: n
1483
1483
  });
@@ -1498,12 +1498,12 @@ async function $a(e, t) {
1498
1498
  skipGroupNotification: t.skipGroupNotification
1499
1499
  });
1500
1500
  }
1501
- x.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(Z).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => M($a, ...e));
1502
- x.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(y).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(Z).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => M(ut, ...e));
1501
+ R.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) => M($a, ...e));
1502
+ R.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) => M(ut, ...e));
1503
1503
  function va() {
1504
1504
  const e = Ce();
1505
1505
  if ($(e)) {
1506
- const t = A.readJsonSync(e);
1506
+ const t = j.readJsonSync(e);
1507
1507
  if (t["lint-staged"])
1508
1508
  return t["lint-staged"];
1509
1509
  throw new Error("未找到lint配置");
@@ -1582,7 +1582,7 @@ function Ta() {
1582
1582
  $(m.resolve("./node_modules/.bin/vue-tsc")) || l("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), Xe("npx vue-tsc --build"), process.exit(0);
1583
1583
  }
1584
1584
  async function ka(e, t) {
1585
- ae(), Q();
1585
+ ae(), Y();
1586
1586
  let i;
1587
1587
  e ? [
1588
1588
  "commit-msg",
@@ -1608,7 +1608,7 @@ async function ka(e, t) {
1608
1608
  "dependency-check",
1609
1609
  "dc"
1610
1610
  /* DependencyCheckAbbr */
1611
- ].includes(e) ? i = "dependency-check" : l("参数输入错误") : i = await T({
1611
+ ].includes(e) ? i = "dependency-check" : l("参数输入错误") : i = await E({
1612
1612
  message: "请选择你要执行的操作",
1613
1613
  choices: [
1614
1614
  {
@@ -1634,7 +1634,7 @@ async function ka(e, t) {
1634
1634
  ]
1635
1635
  }), i === "commit-msg" ? await Sa() : i === "commit-files" ? await ba() : i === "prettier" ? await Ea() : i === "eslint" ? await Aa(t) : i === "type-check" ? Ta() : i === "dependency-check" && await ja();
1636
1636
  }
1637
- x.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check 脚本。").argument(
1637
+ R.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check 脚本。").argument(
1638
1638
  "[type]",
1639
1639
  "非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc。"
1640
1640
  ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => M(ka, ...e));
@@ -1642,17 +1642,17 @@ async function pt(e = "latest") {
1642
1642
  const t = w("安装中...").start();
1643
1643
  await p(`npm i -g ${te.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", oe("latestCheckVersionTimestamp", Date.now()), oe("version", e), ne(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
1644
1644
  }
1645
- x.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => M(pt, ...e));
1645
+ R.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => M(pt, ...e));
1646
1646
  async function Ca(e) {
1647
1647
  let t = e;
1648
- 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) : l("参数输入有误") : t = await T({
1648
+ 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) : l("参数输入有误") : t = await E({
1649
1649
  message: "请选择环境",
1650
1650
  choices: qe
1651
1651
  });
1652
1652
  const i = ve(), a = `dev:${t}`;
1653
1653
  i.scripts[a] ? Xe(`npm run ${a}`) : l(`项目中(package.json > scripts)不存在命令${a},请先添加!`);
1654
1654
  }
1655
- x.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => M(Ca, ...e));
1655
+ R.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => M(Ca, ...e));
1656
1656
  const Le = /Thumbs\.db|\.git|DS_Store|idea/, mt = "testcase";
1657
1657
  function dt(e) {
1658
1658
  const t = e.match(/^(.*[^[])?\[(\d+)]$/);
@@ -1673,18 +1673,18 @@ function dt(e) {
1673
1673
  displayName: e
1674
1674
  };
1675
1675
  }
1676
- async function K(e, t = {}) {
1676
+ async function Q(e, t = {}) {
1677
1677
  const { exclude: i = Le } = t, a = [];
1678
1678
  async function n(s) {
1679
1679
  const o = m.basename(s);
1680
1680
  if ((await Nt(s)).isFile())
1681
1681
  return null;
1682
1682
  const c = await ke(s, { withFileTypes: !0 }), u = (await Promise.all(
1683
- c.filter((j) => j.isDirectory() && !i.test(j.name)).map((j) => n(m.join(s, j.name)))
1684
- )).filter(Boolean), { type: d, id: f, displayName: g } = dt(o), h = {
1683
+ c.filter((C) => C.isDirectory() && !i.test(C.name)).map((C) => n(m.join(s, C.name)))
1684
+ )).filter(Boolean), { type: d, id: g, displayName: f } = dt(o), h = {
1685
1685
  name: o,
1686
- id: f,
1687
- displayName: g,
1686
+ id: g,
1687
+ displayName: f,
1688
1688
  path: s,
1689
1689
  type: d,
1690
1690
  children: u
@@ -1713,7 +1713,7 @@ async function ft(e, t = {}) {
1713
1713
  return l(`读取目录失败: ${e} : ${a}`), [];
1714
1714
  }
1715
1715
  }
1716
- function G(e, t, i) {
1716
+ function W(e, t, i) {
1717
1717
  switch (e) {
1718
1718
  case "module":
1719
1719
  return i ? `${t}[${i}]` : t;
@@ -1725,7 +1725,7 @@ function G(e, t, i) {
1725
1725
  }
1726
1726
  async function ge(e, t, i, a) {
1727
1727
  try {
1728
- const n = m.basename(e), s = G(i, t, a);
1728
+ const n = m.basename(e), s = W(i, t, a);
1729
1729
  if (n === s)
1730
1730
  return !0;
1731
1731
  const o = m.dirname(e), r = m.join(o, s);
@@ -1740,9 +1740,9 @@ async function Ia(e, t, i = {}) {
1740
1740
  if (!s || s.length === 0) return;
1741
1741
  const r = await ft(o, { exclude: a });
1742
1742
  for (const c of s) {
1743
- const u = String(c.value), d = G("module", c.label, u), f = r.find((h) => h.id === u);
1744
- let g = f?.path || m.join(o, d);
1745
- f ? f.displayName !== c.label && await ge(f.path, c.label, "module", u) && (g = m.join(o, d)) : (await ce(g, { recursive: !0 }), await p(`git add "${g}"`)), c.children && c.children.length > 0 && await n(c.children, g);
1743
+ const u = String(c.value), d = W("module", c.label, u), g = r.find((h) => h.id === u);
1744
+ let f = g?.path || m.join(o, d);
1745
+ g ? g.displayName !== c.label && await ge(g.path, c.label, "module", u) && (f = m.join(o, d)) : (await ce(f, { recursive: !0 }), await p(`git add "${f}"`)), c.children && c.children.length > 0 && await n(c.children, f);
1746
1746
  }
1747
1747
  }
1748
1748
  await n(e, m.resolve(t));
@@ -1757,7 +1757,7 @@ async function gt(e) {
1757
1757
  Number.isNaN(Number(e)) && l("请输入正确的产品ID"), t.id = Number(e);
1758
1758
  else {
1759
1759
  const i = await Di();
1760
- t.id = await T({
1760
+ t.id = await E({
1761
1761
  message: "请选择产品",
1762
1762
  choices: i.map((a) => ({
1763
1763
  name: `${a.label}[${a.value}]`,
@@ -1765,7 +1765,7 @@ async function gt(e) {
1765
1765
  }))
1766
1766
  });
1767
1767
  }
1768
- return t.name = await Pi(t.id), t.path = m.join(mt, G("module", t.name, String(t.id))), t;
1768
+ return t.name = await Pi(t.id), t.path = m.join(mt, W("module", t.name, String(t.id))), t;
1769
1769
  }
1770
1770
  async function De(e) {
1771
1771
  return (await ft(mt)).find((i) => Number(i.id) === e.id);
@@ -1776,19 +1776,19 @@ async function ht(e, t) {
1776
1776
  priority: e.pri,
1777
1777
  steps: []
1778
1778
  };
1779
- i.steps = await Mi(e.id), A.writeJSONSync(t, i, {
1779
+ i.steps = await Mi(e.id), j.writeJSONSync(t, i, {
1780
1780
  spaces: 2
1781
1781
  });
1782
1782
  }
1783
1783
  async function wt(e, t) {
1784
1784
  await ce(t, {
1785
1785
  recursive: !0
1786
- }), await ht(e, m.join(t, "config.json")), A.ensureFileSync(m.join(t, "data.yaml")), await _(
1786
+ }), await ht(e, m.join(t, "config.json")), j.ensureFileSync(m.join(t, "data.yaml")), await _(
1787
1787
  m.join(t, "data.yaml"),
1788
- $(m.resolve(V, "data.yaml")) ? await Ee(m.resolve(V, "data.yaml")) : ii
1789
- ), A.ensureFileSync(m.join(t, "main.py")), await _(
1788
+ $(m.resolve(Z, "data.yaml")) ? await Ee(m.resolve(Z, "data.yaml")) : ii
1789
+ ), j.ensureFileSync(m.join(t, "main.py")), await _(
1790
1790
  m.join(t, "main.py"),
1791
- $(m.resolve(V, "main.py")) ? await Ee(m.resolve(V, "main.py")) : ai
1791
+ $(m.resolve(Z, "main.py")) ? await Ee(m.resolve(Z, "main.py")) : ai
1792
1792
  );
1793
1793
  }
1794
1794
  function Pe(e) {
@@ -1802,9 +1802,9 @@ function Pe(e) {
1802
1802
  return [];
1803
1803
  }
1804
1804
  async function Ne(e, t) {
1805
- ae(), Q(), await ue();
1805
+ ae(), Y(), await ue();
1806
1806
  let i;
1807
- t ? ([k.MODULE, k.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${k.MODULE} 或者 ${k.CASE}。`), i = t) : i = await T({
1807
+ t ? ([k.MODULE, k.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${k.MODULE} 或者 ${k.CASE}。`), i = t) : i = await E({
1808
1808
  message: `请选择要${e}的数据类型`,
1809
1809
  choices: zt
1810
1810
  });
@@ -1824,7 +1824,7 @@ async function Se(e) {
1824
1824
  async function xa(e, t, i) {
1825
1825
  e.text = "查找本地产品目录...", await De(t) || l(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
1826
1826
  const n = Pe(i);
1827
- let s = await K(t.path);
1827
+ let s = await Q(t.path);
1828
1828
  e.text = "获取远程用例列表...";
1829
1829
  const o = await Oi(t.id, n);
1830
1830
  e.text = "本地用例同步中...";
@@ -1834,12 +1834,12 @@ async function xa(e, t, i) {
1834
1834
  return l(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
1835
1835
  const u = s.find(({ id: d }) => r.id === Number(d));
1836
1836
  if (u)
1837
- u.displayName !== r.title && await ge(u.path, r.title, u.type, u.id) && B(`重命名成功: ${u.displayName} -> ${r.title}`), s = await K(t.path), r.module === 0 ? c = m.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await ht(
1837
+ u.displayName !== r.title && await ge(u.path, r.title, u.type, u.id) && B(`重命名成功: ${u.displayName} -> ${r.title}`), s = await Q(t.path), r.module === 0 ? c = m.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await ht(
1838
1838
  r,
1839
- m.join(c, G("case", r.title, String(r.id)), "config.json")
1839
+ m.join(c, W("case", r.title, String(r.id)), "config.json")
1840
1840
  );
1841
1841
  else {
1842
- const d = m.join(c, G("case", r.title, String(r.id)));
1842
+ const d = m.join(c, W("case", r.title, String(r.id)));
1843
1843
  await wt(r, d);
1844
1844
  }
1845
1845
  }
@@ -1862,7 +1862,7 @@ async function La(e, t) {
1862
1862
  }
1863
1863
  }
1864
1864
  }
1865
- x.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) => M(La, ...e));
1865
+ R.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) => M(La, ...e));
1866
1866
  async function Da(e, t, i) {
1867
1867
  const a = await F({
1868
1868
  message: "请输入你要创建的用例的前置条件(可不填)"
@@ -1874,7 +1874,7 @@ async function Da(e, t, i) {
1874
1874
  module: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
1875
1875
  title: i,
1876
1876
  type: "interface",
1877
- openedBy: E("ldapAccount"),
1877
+ openedBy: A("ldapAccount"),
1878
1878
  precondition: a || ""
1879
1879
  });
1880
1880
  n.text = "远程用例步骤创建中...", await Fi({
@@ -1883,7 +1883,7 @@ async function Da(e, t, i) {
1883
1883
  desc: "按照预期执行",
1884
1884
  expect: "正常执行,符合预期"
1885
1885
  }), n.text = "本地用例创建中...";
1886
- const o = m.join(t.path, G("case", i, String(s)));
1886
+ const o = m.join(t.path, W("case", i, String(s)));
1887
1887
  return $(o) ? B(`${o}已存在,请检查是否对应,本地不再创建。`) : (await wt(
1888
1888
  {
1889
1889
  id: s,
@@ -1903,7 +1903,7 @@ async function Pa(e, t, i) {
1903
1903
  parent: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
1904
1904
  });
1905
1905
  a.text = "本地模块创建中...";
1906
- const s = m.join(t.path, G("module", i, String(n)));
1906
+ const s = m.join(t.path, W("module", i, String(n)));
1907
1907
  if ($(s))
1908
1908
  return B(`${s}已存在,请检查是否对应,本地不再创建。`);
1909
1909
  await ce(s, {
@@ -1923,7 +1923,7 @@ function Oa(e) {
1923
1923
  });
1924
1924
  }
1925
1925
  async function i(a, n = []) {
1926
- const s = n.length ? `请选择层级(当前:${n.join(" / ")})` : "请选择层级", o = await T({
1926
+ const s = n.length ? `请选择层级(当前:${n.join(" / ")})` : "请选择层级", o = await E({
1927
1927
  message: s,
1928
1928
  choices: a.map((r) => ({
1929
1929
  name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
@@ -1935,27 +1935,27 @@ function Oa(e) {
1935
1935
  return i(e);
1936
1936
  }
1937
1937
  async function Ma(e, t) {
1938
- const { type: i, typeStr: a } = await Ne("创建", e), { product: n, localProduct: s } = await Se(t.productId), o = await st(n.id), r = await Oa(o), c = G("module", r.label, String(r.value)), d = (await K(n.path, { hasRoot: !0 })).find((h) => h.name === c);
1938
+ const { type: i, typeStr: a } = await Ne("创建", e), { product: n, localProduct: s } = await Se(t.productId), o = await st(n.id), r = await Oa(o), c = W("module", r.label, String(r.value)), d = (await Q(n.path, { hasRoot: !0 })).find((h) => h.name === c);
1939
1939
  if (!d?.path || !$(d.path))
1940
1940
  return l(`本地不存在${c}模块`);
1941
- const f = await F({
1941
+ const g = await F({
1942
1942
  message: `请输入你要创建的${a}名称`,
1943
1943
  required: !0,
1944
1944
  validate: (h) => h.length > 0 && h.length < 255
1945
1945
  });
1946
- let g = "";
1947
- if (k.MODULE === i && await Pa(s, d, f), k.CASE === i && (g = await Da(s, d, f)), !t.disableAutoCommit && k.CASE === i) {
1946
+ let f = "";
1947
+ if (k.MODULE === i && await Pa(s, d, g), k.CASE === i && (f = await Da(s, d, g)), !t.disableAutoCommit && k.CASE === i) {
1948
1948
  const h = w("代码提交中...").start();
1949
1949
  try {
1950
- await p(`git add . && git commit -m "chore: 创建了用例${m.basename(g)}"`), h.succeed("代码已提交 ✅");
1951
- } catch (j) {
1952
- h.fail(`提交失败,${j}`), process.exit(1);
1950
+ await p(`git add . && git commit -m "chore: 创建了用例${m.basename(f)}"`), h.succeed("代码已提交 ✅");
1951
+ } catch (C) {
1952
+ h.fail(`提交失败,${C}`), process.exit(1);
1953
1953
  }
1954
1954
  }
1955
1955
  }
1956
- x.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(Ma, ...e));
1956
+ R.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(Ma, ...e));
1957
1957
  async function za(e, t) {
1958
- const a = (await K(e.path)).filter((r) => r.type === "case");
1958
+ const a = (await Q(e.path)).filter((r) => r.type === "case");
1959
1959
  let n = [];
1960
1960
  if (t.length)
1961
1961
  n = a.filter((r) => t.includes(Number(r.id))).map((r) => ({
@@ -1986,11 +1986,11 @@ async function za(e, t) {
1986
1986
  caseIds: o
1987
1987
  }), s.text = "本地用例删除中...";
1988
1988
  for (const r of n)
1989
- $(r.path) && D.rm("-rf", r.path);
1989
+ $(r.path) && P.rm("-rf", r.path);
1990
1990
  return s.succeed("用例删除完成"), o;
1991
1991
  }
1992
1992
  async function _a(e, t) {
1993
- const a = (await K(e.path)).filter((r) => r.type === "module");
1993
+ const a = (await Q(e.path)).filter((r) => r.type === "module");
1994
1994
  let n = [];
1995
1995
  if (t.length)
1996
1996
  n = a.filter((r) => t.includes(Number(r.id))).map((r) => ({
@@ -2022,7 +2022,7 @@ async function _a(e, t) {
2022
2022
  moduleIds: o
2023
2023
  }), s.text = "本地模块删除中...";
2024
2024
  for (const r of n)
2025
- $(r.path) && D.rm("-rf", r.path);
2025
+ $(r.path) && P.rm("-rf", r.path);
2026
2026
  return s.succeed("模块删除完成"), o;
2027
2027
  }
2028
2028
  async function Fa(e, t) {
@@ -2037,15 +2037,15 @@ async function Fa(e, t) {
2037
2037
  }
2038
2038
  }
2039
2039
  }
2040
- x.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) => M(Fa, ...e));
2040
+ R.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) => M(Fa, ...e));
2041
2041
  async function Ba(e, t) {
2042
- const a = (await K(e.path)).filter((g) => g.type === "case");
2042
+ const a = (await Q(e.path)).filter((f) => f.type === "case");
2043
2043
  let n;
2044
2044
  if (t.targetId) {
2045
- if (n = a.find((g) => Number(g.id) === Number(t.targetId)), !n)
2045
+ if (n = a.find((f) => Number(f.id) === Number(t.targetId)), !n)
2046
2046
  return l(`未找到对应用例,请确认输入的用例ID(${t.targetId})是否正确`);
2047
2047
  } else {
2048
- const g = a.map((h) => ({
2048
+ const f = a.map((h) => ({
2049
2049
  value: {
2050
2050
  id: Number(h.id),
2051
2051
  path: h.path,
@@ -2058,7 +2058,7 @@ async function Ba(e, t) {
2058
2058
  pageSize: 100,
2059
2059
  loop: !1,
2060
2060
  multiple: void 0,
2061
- options: (h) => h ? g.filter((j) => j.name.includes(h)) : g,
2061
+ options: (h) => h ? f.filter((C) => C.name.includes(h)) : f,
2062
2062
  validate(h) {
2063
2063
  return h.length > 1 ? "只能选一个" : h.length < 1 ? "请选一个" : !0;
2064
2064
  }
@@ -2068,62 +2068,62 @@ async function Ba(e, t) {
2068
2068
  message: "修改用例名称",
2069
2069
  default: n.displayName,
2070
2070
  required: !0,
2071
- validate: (g) => g.length > 0 && g.length < 255,
2071
+ validate: (f) => f.length > 0 && f.length < 255,
2072
2072
  prefill: "editable"
2073
2073
  }), o = w("用例重命名中...").start();
2074
- s !== n.displayName ? (await Gi({
2074
+ s !== n.displayName ? (await Ji({
2075
2075
  id: Number(n.id),
2076
2076
  name: s
2077
- }), await ge(n.path, s, "case", String(n.id)) && o.succeed(`用例重命名成功: ${n.displayName} -> ${s}`), n.displayName = s, n.path = m.join(m.dirname(n.path), G("case", s, String(n.id)))) : o.succeed("用例名称无变动");
2078
- let r = A.readJsonSync(m.join(n.path, "config.json")), c;
2077
+ }), await ge(n.path, s, "case", String(n.id)) && o.succeed(`用例重命名成功: ${n.displayName} -> ${s}`), n.displayName = s, n.path = m.join(m.dirname(n.path), W("case", s, String(n.id)))) : o.succeed("用例名称无变动");
2078
+ let r = j.readJsonSync(m.join(n.path, "config.json")), c;
2079
2079
  t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await ze({
2080
2080
  message: "修改用例优先级",
2081
2081
  min: 1,
2082
2082
  max: 5,
2083
2083
  required: !0,
2084
2084
  default: r.priority,
2085
- validate: (g) => g > 0 && g < 6
2085
+ validate: (f) => f > 0 && f < 6
2086
2086
  }) : c = await ze({
2087
2087
  message: "修改用例优先级",
2088
2088
  min: 1,
2089
2089
  max: 5,
2090
2090
  required: !0,
2091
2091
  default: r.priority,
2092
- validate: (g) => g > 0 && g < 6
2092
+ validate: (f) => f > 0 && f < 6
2093
2093
  });
2094
2094
  const u = w("用例优先级设置中...").start();
2095
2095
  c !== r.priority ? (await Wi({
2096
2096
  id: Number(n.id),
2097
2097
  priority: c
2098
- }), A.writeJSONSync(
2098
+ }), j.writeJSONSync(
2099
2099
  m.join(n.path, "config.json"),
2100
2100
  {
2101
2101
  ...r,
2102
2102
  priority: c
2103
2103
  },
2104
2104
  { spaces: 2 }
2105
- ), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = A.readJsonSync(m.join(n.path, "config.json"));
2105
+ ), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = j.readJsonSync(m.join(n.path, "config.json"));
2106
2106
  let d;
2107
2107
  t.casePrecondition ? d = t.casePrecondition : d = await F({
2108
2108
  message: "修改用例前置条件",
2109
2109
  default: r.precondition,
2110
2110
  prefill: "editable"
2111
2111
  });
2112
- const f = w("用例前置条件设置中...").start();
2112
+ const g = w("用例前置条件设置中...").start();
2113
2113
  return d !== r.precondition ? (await qi({
2114
2114
  id: Number(n.id),
2115
2115
  precondition: d
2116
- }), A.writeJSONSync(
2116
+ }), j.writeJSONSync(
2117
2117
  m.join(n.path, "config.json"),
2118
2118
  {
2119
2119
  ...r,
2120
2120
  precondition: d
2121
2121
  },
2122
2122
  { spaces: 2 }
2123
- ), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : f.succeed("用例前置条件无变动"), n.id;
2123
+ ), g.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : g.succeed("用例前置条件无变动"), n.id;
2124
2124
  }
2125
2125
  async function Ua(e, t) {
2126
- const a = (await K(e.path)).filter((r) => r.type === "module");
2126
+ const a = (await Q(e.path)).filter((r) => r.type === "module");
2127
2127
  let n;
2128
2128
  if (t.targetId) {
2129
2129
  if (n = a.find((r) => Number(r.id) === Number(t.targetId)), !n)
@@ -2155,12 +2155,12 @@ async function Ua(e, t) {
2155
2155
  validate: (r) => r.length > 0 && r.length < 255,
2156
2156
  prefill: "editable"
2157
2157
  }), o = w("模块重命名中...").start();
2158
- return s !== n.displayName ? (await Ji({
2158
+ return s !== n.displayName ? (await Gi({
2159
2159
  id: Number(n.id),
2160
2160
  name: s
2161
2161
  }), await ge(n.path, s, "module", String(n.id)) && o.succeed(`模块重命名成功: ${n.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), n.id;
2162
2162
  }
2163
- async function Ja(e, t) {
2163
+ async function Ga(e, t) {
2164
2164
  const { type: i, typeStr: a } = await Ne("修改", e), { localProduct: n } = await Se(t.productId);
2165
2165
  let s;
2166
2166
  if (k.MODULE === i ? s = await Ua(n, t) : k.CASE === i && (s = await Ba(n, t)), !t.disableAutoCommit && await p("git status -s")) {
@@ -2172,8 +2172,8 @@ async function Ja(e, t) {
2172
2172
  }
2173
2173
  }
2174
2174
  }
2175
- x.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) => M(Ja, ...e));
2176
- async function Ga() {
2175
+ R.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) => M(Ga, ...e));
2176
+ async function Ja() {
2177
2177
  const e = be();
2178
2178
  if (!e?.interpreter?.path) {
2179
2179
  Vt("$ 执行用例前,需要配置解释器路径");
@@ -2211,10 +2211,10 @@ async function Wa(e, t, i) {
2211
2211
  return await Promise.all(n), t;
2212
2212
  }
2213
2213
  async function qa(e) {
2214
- ae(), Q();
2215
- const t = await Ga(), { localProduct: i } = await Se(e.productId);
2214
+ ae(), Y();
2215
+ const t = await Ja(), { localProduct: i } = await Se(e.productId);
2216
2216
  let a = [];
2217
- const s = (await K(i.path)).filter((u) => u.type === "case");
2217
+ const s = (await Q(i.path)).filter((u) => u.type === "case");
2218
2218
  if (e.all)
2219
2219
  a = s.map((u) => ({
2220
2220
  id: Number(u.id),
@@ -2230,21 +2230,21 @@ async function qa(e) {
2230
2230
  displayName: d.displayName
2231
2231
  }));
2232
2232
  else {
2233
- const d = s.map((f) => ({
2233
+ const d = s.map((g) => ({
2234
2234
  value: {
2235
- id: Number(f.id),
2236
- path: f.path,
2237
- displayName: f.displayName
2235
+ id: Number(g.id),
2236
+ path: g.path,
2237
+ displayName: g.displayName
2238
2238
  },
2239
- name: f.path.replace(m.resolve(i.path), "")
2239
+ name: g.path.replace(m.resolve(i.path), "")
2240
2240
  }));
2241
2241
  a = await ie({
2242
2242
  message: "选择要执行的用例",
2243
2243
  pageSize: 100,
2244
2244
  loop: !1,
2245
- options: (f) => f ? d.filter((g) => g.name.includes(f)) : d,
2246
- validate(f) {
2247
- return f.length === 0 ? "至少选择一项" : !0;
2245
+ options: (g) => g ? d.filter((f) => f.name.includes(g)) : d,
2246
+ validate(g) {
2247
+ return g.length === 0 ? "至少选择一项" : !0;
2248
2248
  }
2249
2249
  });
2250
2250
  }
@@ -2255,37 +2255,38 @@ async function qa(e) {
2255
2255
  else {
2256
2256
  if (e.processStep === "1")
2257
2257
  return B("执行报告如下:"), console.log(JSON.stringify(c, null, 2)), process.exit(0);
2258
- o.warn(`【${c.length}】个用例执行出错`);
2259
- let u = 0;
2258
+ const u = c.reduce((f, h) => f + h.result.length, 0);
2259
+ o.warn(`【${c.length}】个用例执行出错,【${u}】个BUG将创建。`);
2260
+ let d = 0;
2260
2261
  if (e.executionId)
2261
- Number.isNaN(Number(e.executionId)) && l(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
2262
+ Number.isNaN(Number(e.executionId)) && l(`executionId ${e.executionId}不是正整数`), d = Number(e.executionId);
2262
2263
  else {
2263
- const f = await Zi(), g = await T({
2264
+ const f = await Zi(), h = await E({
2264
2265
  message: "请选择用例执行出错后,BUG所属的项目",
2265
- choices: f.map(({ id: j, name: X }) => ({ name: X, value: j }))
2266
- }), h = await Hi(g);
2267
- u = await T({
2266
+ choices: f.map(({ id: ee, name: T }) => ({ name: T, value: ee }))
2267
+ }), C = await Hi(h);
2268
+ d = await E({
2268
2269
  message: "请选择用例执行出错后,BUG所属的执行",
2269
- choices: h.map(({ id: j, name: X }) => ({ name: X, value: j }))
2270
+ choices: C.map(({ id: ee, name: T }) => ({ name: T, value: ee }))
2270
2271
  });
2271
2272
  }
2272
- let d;
2273
+ let g;
2273
2274
  if (e.buildId)
2274
- d = e.buildId;
2275
+ g = e.buildId;
2275
2276
  else {
2276
- const f = await Ki(Number(u));
2277
+ const f = await Ki(Number(d));
2277
2278
  if (f.length) {
2278
- const g = await Te({
2279
+ const h = await Te({
2279
2280
  message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
2280
2281
  required: !1,
2281
- choices: f.map(({ id: h, name: j, date: X, builder: P }) => ({
2282
- value: h,
2283
- name: `${j} ${P} ${X}`
2282
+ choices: f.map(({ id: C, name: ee, date: T, builder: U }) => ({
2283
+ value: C,
2284
+ name: `${ee} ${U} ${T}`
2284
2285
  }))
2285
2286
  });
2286
- g.length ? d = g.join(",") : d = "";
2287
+ h.length ? g = h.join(",") : g = "";
2287
2288
  } else
2288
- o.warn("当前执行下没有构建,使用默认【主干】"), d = "";
2289
+ o.warn("当前执行下没有构建,使用默认【主干】"), g = "";
2289
2290
  }
2290
2291
  o.start("上传中...");
2291
2292
  for (const f of c)
@@ -2293,20 +2294,20 @@ async function qa(e) {
2293
2294
  caseId: f.id,
2294
2295
  caseResult: "fail",
2295
2296
  stepResults: f.result,
2296
- runner: E("ldapAccount"),
2297
- executionId: u,
2298
- openedBuild: d
2297
+ runner: A("ldapAccount"),
2298
+ executionId: d,
2299
+ openedBuild: g
2299
2300
  });
2300
2301
  o.succeed(
2301
- `用例执行完成。查看相关BUG(${Y("ZenTaoDomain")}/zentao/execution-bug-${u}.html}) `
2302
+ `用例执行完成。查看相关BUG(${X("ZenTaoDomain")}/zentao/execution-bug-${d}.html}) `
2302
2303
  );
2303
2304
  }
2304
2305
  }
2305
- x.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认「主干」").action((...e) => M(qa, ...e));
2306
+ R.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认主干(trunk)").action((...e) => M(qa, ...e));
2306
2307
  function Va() {
2307
2308
  process.on("unhandledRejection", (e) => {
2308
2309
  }), process.on("uncaughtException", (e) => {
2309
- }), D.config.fatal = !0, D.config.silent = !0, D.config.verbose = !1;
2310
+ }), P.config.fatal = !0, P.config.silent = !0, P.config.verbose = !1;
2310
2311
  }
2311
2312
  async function Za() {
2312
2313
  const e = de("latestCheckVersionTimestamp"), t = de("versionCheckDuring");
@@ -2331,7 +2332,7 @@ async function Ha() {
2331
2332
  const e = xt(process.argv.slice(2));
2332
2333
  if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
2333
2334
  if (He()) {
2334
- const t = A.readJSONSync($e());
2335
+ const t = j.readJSONSync($e());
2335
2336
  O(t.profile), oe(t.main), Ie(t.constants), await Za();
2336
2337
  } else
2337
2338
  l(`请先初始化z-develop(执行 z i)。更多见${Ve}`);
@@ -2339,5 +2340,5 @@ async function Ha() {
2339
2340
  async function Ka() {
2340
2341
  Va(), await Ha();
2341
2342
  }
2342
- x.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(Ve)}`).usage("<command> [options]").hook("preAction", Ka).version(te.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
2343
- x.parse();
2343
+ R.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(Ve)}`).usage("<command> [options]").hook("preAction", Ka).version(te.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
2344
+ R.parse();