cli-z-develop 0.16.3 → 0.16.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +562 -562
  2. package/package.json +25 -25
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { program as P } from "commander";
2
2
  import Yt from "node:child_process";
3
- import { existsSync as j, readdirSync as Xt, lstatSync as Qt, createWriteStream as ea, writeFileSync as ve, readFileSync as dt, mkdirSync as ta, mkdtempSync as aa, rmSync as sa } from "node:fs";
4
- import { readdir as Ue, mkdir as fe, writeFile as _, rename as ft, readFile as _e, stat as na } from "node:fs/promises";
3
+ import { existsSync as j, readdirSync as Xt, lstatSync as Qt, createWriteStream as ea, writeFileSync as ve, readFileSync as dt, mkdirSync as ta, mkdtempSync as aa, rmSync as na } from "node:fs";
4
+ import { readdir as Ue, mkdir as fe, writeFile as _, rename as ft, readFile as _e, stat as sa } from "node:fs/promises";
5
5
  import f, { resolve as pe, isAbsolute as ia, normalize as ra, sep as oa } from "node:path";
6
6
  import me, { AxiosError as gt } from "axios";
7
7
  import A from "chalk";
@@ -85,7 +85,7 @@ const Ca = [
85
85
  value: "case"
86
86
  /* CASE */
87
87
  }
88
- ], La = 150 * 1024, st = 0.8 * 1024 * 1024, Fe = ",", xa = ".z", Pa = "develop-config.json", K = ".z", Da = ".commit-msg-tpl", Oa = "project.json";
88
+ ], La = 150 * 1024, nt = 0.8 * 1024 * 1024, Fe = ",", xa = ".z", Pa = "develop-config.json", K = ".z", Da = ".commit-msg-tpl", Oa = "project.json";
89
89
  function x(e = "") {
90
90
  return f.join(K, e);
91
91
  }
@@ -110,22 +110,22 @@ function Ma() {
110
110
  function jt() {
111
111
  return Ma() && j(xe());
112
112
  }
113
- function se(e, t = !0) {
113
+ function ne(e, t = !0) {
114
114
  let a = e.trim();
115
- const n = a.match(/^git@([^:]+):(.+)$/);
116
- if (n)
117
- a = n[2];
115
+ const s = a.match(/^git@([^:]+):(.+)$/);
116
+ if (s)
117
+ a = s[2];
118
118
  else {
119
119
  const i = Ae.replace(/^https?:\/\//, "").replace(/\/$/, "");
120
120
  a = a.replace(/^https?:\/\//, ""), a.startsWith(`${i}/`) ? a = a.slice(i.length + 1) : a = a.replace(`${Ae.replace(/\/$/, "")}/`, "");
121
121
  }
122
- const s = a.replace(/\.git$/, "");
123
- return t ? encodeURIComponent(s) : s;
122
+ const n = a.replace(/\.git$/, "");
123
+ return t ? encodeURIComponent(n) : n;
124
124
  }
125
125
  function Pe(e, t) {
126
- return se(e) === se(t);
126
+ return ne(e) === ne(t);
127
127
  }
128
- const { red: nt, green: Ba, blue: Ar, magenta: za, yellow: _a } = A;
128
+ const { red: st, green: Ba, blue: Ar, magenta: za, yellow: _a } = A;
129
129
  function Te(...e) {
130
130
  }
131
131
  function J(...e) {
@@ -140,7 +140,7 @@ function Tt(e) {
140
140
  function m(e, t = !1) {
141
141
  Tt(e);
142
142
  let a = e;
143
- e instanceof Error ? (a = e.message, me.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(nt(a)), console.log(za(e.stack))) : console.log(nt(e)), t || process.exit(1);
143
+ e instanceof Error ? (a = e.message, me.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(st(a)), console.log(za(e.stack))) : console.log(st(e)), t || process.exit(1);
144
144
  }
145
145
  function it(e) {
146
146
  return j(e) ? Qt(e).isDirectory() : !1;
@@ -154,17 +154,17 @@ async function p(e, t = {}) {
154
154
  silent: !0,
155
155
  ...t
156
156
  };
157
- let n = await new Promise((s, i) => {
157
+ let s = await new Promise((n, i) => {
158
158
  try {
159
159
  const o = N.exec(e, {
160
160
  silent: a.silent
161
161
  });
162
- s(o);
162
+ n(o);
163
163
  } catch (o) {
164
164
  i(o);
165
165
  }
166
166
  });
167
- return n = n.toString(), a.removeTailLinkBreak && (n = n.replace(/\n$/, "")), n;
167
+ return s = s.toString(), a.removeTailLinkBreak && (s = s.replace(/\n$/, "")), s;
168
168
  }
169
169
  function Ve(e) {
170
170
  Yt.execSync(e, {
@@ -274,7 +274,7 @@ const Va = {
274
274
  "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
275
275
  "**/*.md": "markdownlint --fix"
276
276
  }
277
- }, Wa = "cli-z-develop", Ha = "0.16.3", qa = "技术团队开发流程管理工具", Za = "dist/index.js", Ka = { z: "bin/z.js", "z-develop": "bin/z.js" }, Ya = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", test: "bun src/main.ts", "test:debug": "DEBUG=true bun src/main.ts", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", "build:w": "vite build --watch", 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" }, Xa = "module", Qa = "z", es = { "@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" }, ts = { "@inquirer/prompts": "^8.4.1", "@lonely9/api-generate": "^0.2.13", axios: "^1.15.0", chalk: "^5.6.2", "cli-highlight": "^2.1.11", commander: "^14.0.3", dayjs: "^1.11.20", eslint: "^9.39.2", "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", open: "^11.0.2", ora: "^9.3.0", "p-limit": "^7.3.0", prettier: "^3.8.2", semver: "^7.7.4", shelljs: "^0.10.0" }, ce = {
277
+ }, Wa = "cli-z-develop", Ha = "0.16.5", qa = "技术团队开发流程管理工具", Za = "dist/index.js", Ka = { z: "bin/z.js", "z-develop": "bin/z.js" }, Ya = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", test: "bun src/main.ts", "test:debug": "DEBUG=true bun src/main.ts", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", "build:w": "vite build --watch", 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" }, Xa = "module", Qa = "z", en = { "@lonely9/eslint-config-team": "^1.4.0", "@tsconfig/node22": "^22.0.6", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.10", "@types/minimist": "^1.2.5", "@types/node": "^22.15.29", "@types/semver": "^7.8.0", "@types/shelljs": "^0.10.0", "@typescript-eslint/eslint-plugin": "^8.70.0", "@typescript-eslint/parser": "^8.70.0", eslint: "^10.10.0", jiti: "^2.7.0", prettier: "^3.9.8", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.3.11" }, tn = { "@inquirer/prompts": "^8.7.2", "@lonely9/api-generate": "^0.2.13", axios: "^1.20.0", chalk: "^6.0.0", "cli-highlight": "^2.1.11", commander: "^15.0.0", dayjs: "^1.11.23", eslint: "^10.10.0", "fs-extra": "^11.4.0", "inquirer-select-pro": "^1.0.0-alpha.9", "lint-staged": "^17.5.1", minimist: "^1.2.8", "npm-check-updates": "^23.1.0", open: "^11.0.4", ora: "^9.4.1", "p-limit": "^7.3.2", prettier: "^3.9.8", semver: "^7.8.5", shelljs: "^0.10.0" }, ce = {
278
278
  name: Wa,
279
279
  version: Ha,
280
280
  description: qa,
@@ -283,8 +283,8 @@ const Va = {
283
283
  scripts: Ya,
284
284
  type: Xa,
285
285
  author: Qa,
286
- devDependencies: es,
287
- dependencies: ts
286
+ devDependencies: en,
287
+ dependencies: tn
288
288
  }, M = {
289
289
  // 个人数据
290
290
  profile: {
@@ -349,7 +349,7 @@ function It(e) {
349
349
  ...e
350
350
  } : Z = e, L.writeJSONSync(St(), Z, { spaces: 2 });
351
351
  }
352
- function as(e) {
352
+ function an(e) {
353
353
  q ? q = {
354
354
  ...q,
355
355
  ...e
@@ -362,10 +362,10 @@ const ae = {
362
362
  sourceBranch: "",
363
363
  mergeRequestUrl: ""
364
364
  };
365
- async function ss() {
365
+ async function nn() {
366
366
  if (!ae.id)
367
367
  try {
368
- const e = W(), t = se(e.repository.url), a = await Lt(t);
368
+ const e = W(), t = ne(e.repository.url), a = await Lt(t);
369
369
  ae.id = a.id, ae.path = t, ae.group = a.namespace.full_path, ae.mergeRequestUrl = `${a.web_url}/merge_requests`;
370
370
  } catch (e) {
371
371
  m(e);
@@ -404,7 +404,7 @@ function de(e, t) {
404
404
  };
405
405
  }
406
406
  async function b(e) {
407
- const t = await ne({
407
+ const t = await se({
408
408
  url: "https://pai.zxfqf.com/api" + e.url,
409
409
  headers: {
410
410
  "the-key-one": "z-develop",
@@ -415,8 +415,8 @@ async function b(e) {
415
415
  });
416
416
  return t.code !== 0 && (m(`${t.code}: ${t.message}`, e.stopBubble), e.stopBubble) ? Promise.reject(t) : t.data;
417
417
  }
418
- async function ns(e) {
419
- return await ne({
418
+ async function sn(e) {
419
+ return await se({
420
420
  url: "https://pai.zxfqf.com/api" + e.url,
421
421
  headers: {
422
422
  "the-key-one": "z-develop",
@@ -426,12 +426,12 @@ async function ns(e) {
426
426
  method: e.method || "post"
427
427
  });
428
428
  }
429
- function is() {
429
+ function rn() {
430
430
  return b({
431
431
  url: "/user/list2"
432
432
  });
433
433
  }
434
- function rs() {
434
+ function on() {
435
435
  return b({
436
436
  url: "/zen/testcase/product/list"
437
437
  });
@@ -444,7 +444,7 @@ function Rt(e) {
444
444
  }
445
445
  });
446
446
  }
447
- function os(e) {
447
+ function cn(e) {
448
448
  return b({
449
449
  url: "/zen/testcase/product/name",
450
450
  data: {
@@ -452,7 +452,7 @@ function os(e) {
452
452
  }
453
453
  });
454
454
  }
455
- function cs(e, t) {
455
+ function ln(e, t) {
456
456
  return b({
457
457
  url: "/zen/testcase/product/auto-case/list",
458
458
  data: {
@@ -461,7 +461,7 @@ function cs(e, t) {
461
461
  }
462
462
  });
463
463
  }
464
- function ls(e) {
464
+ function un(e) {
465
465
  return b({
466
466
  url: "/zen/testcase/step/list",
467
467
  data: {
@@ -469,72 +469,72 @@ function ls(e) {
469
469
  }
470
470
  });
471
471
  }
472
- function us(e) {
472
+ function pn(e) {
473
473
  return b({
474
474
  url: "/zen/testcase/module/create",
475
475
  data: e
476
476
  });
477
477
  }
478
- function ps(e) {
478
+ function mn(e) {
479
479
  return b({
480
480
  url: "/zen/testcase/create",
481
481
  data: e
482
482
  });
483
483
  }
484
- function ms(e) {
484
+ function dn(e) {
485
485
  return b({
486
486
  url: "/zen/testcase/step/create",
487
487
  data: e
488
488
  });
489
489
  }
490
- function ds(e) {
490
+ function fn(e) {
491
491
  return b({
492
492
  url: "/zen/testcase/modules/remove",
493
493
  data: e
494
494
  });
495
495
  }
496
- function fs(e) {
496
+ function gn(e) {
497
497
  return b({
498
498
  url: "/zen/testcase/cases/remove",
499
499
  data: e
500
500
  });
501
501
  }
502
- function gs(e) {
502
+ function hn(e) {
503
503
  return b({
504
504
  url: "/zen/testcase/module/update/name",
505
505
  data: e
506
506
  });
507
507
  }
508
- function hs(e) {
508
+ function wn(e) {
509
509
  return b({
510
510
  url: "/zen/testcase/case/update/name",
511
511
  data: e
512
512
  });
513
513
  }
514
- function ws(e) {
514
+ function yn(e) {
515
515
  return b({
516
516
  url: "/zen/testcase/case/update/priority",
517
517
  data: e
518
518
  });
519
519
  }
520
- function ys(e) {
520
+ function $n(e) {
521
521
  return b({
522
522
  url: "/zen/testcase/case/update/precondition",
523
523
  data: e
524
524
  });
525
525
  }
526
- function $s(e) {
526
+ function vn(e) {
527
527
  return b({
528
528
  url: "/zen/testcase/case/result/create",
529
529
  data: e
530
530
  });
531
531
  }
532
- function vs() {
532
+ function An() {
533
533
  return b({
534
534
  url: "/zen/testcase/project/list"
535
535
  });
536
536
  }
537
- function As(e) {
537
+ function bn(e) {
538
538
  return b({
539
539
  url: "/zen/testcase/project/execution/list",
540
540
  data: {
@@ -542,7 +542,7 @@ function As(e) {
542
542
  }
543
543
  });
544
544
  }
545
- function bs(e) {
545
+ function Sn(e) {
546
546
  return b({
547
547
  url: "/zen/testcase/execution/build/list",
548
548
  data: {
@@ -556,19 +556,19 @@ function rt(e) {
556
556
  data: e
557
557
  });
558
558
  }
559
- function Ss(e) {
560
- return ns({
559
+ function Nn(e) {
560
+ return sn({
561
561
  url: "/common/notify/group/send",
562
562
  data: e
563
563
  });
564
564
  }
565
- function Ns(e) {
565
+ function jn(e) {
566
566
  return b({
567
567
  url: "/deploy/create/chain",
568
568
  data: e
569
569
  });
570
570
  }
571
- function js(e) {
571
+ function Tn(e) {
572
572
  return b({
573
573
  url: "/zen/product/execution/list",
574
574
  data: {
@@ -576,18 +576,18 @@ function js(e) {
576
576
  }
577
577
  });
578
578
  }
579
- function Ts(e) {
579
+ function kn(e) {
580
580
  return b({
581
581
  url: "/zen/execution/build/createOrUpdate",
582
582
  data: e
583
583
  });
584
584
  }
585
- function ks() {
585
+ function En() {
586
586
  return b({
587
587
  url: "/auth/gitlab/oauth/authorize"
588
588
  });
589
589
  }
590
- function Es(e) {
590
+ function In(e) {
591
591
  return b({
592
592
  url: "/auth/gitlab/oauth/token",
593
593
  data: {
@@ -596,7 +596,7 @@ function Es(e) {
596
596
  stopBubble: !0
597
597
  });
598
598
  }
599
- function Is(e) {
599
+ function Rn(e) {
600
600
  return b({
601
601
  url: "/auth/gitlab/oauth/token/refresh",
602
602
  data: {
@@ -605,7 +605,7 @@ function Is(e) {
605
605
  stopBubble: !0
606
606
  });
607
607
  }
608
- class Rs {
608
+ class Cn {
609
609
  /**
610
610
  * 生成带 Bearer 前缀的 Token
611
611
  */
@@ -626,21 +626,21 @@ class Rs {
626
626
  * @private
627
627
  */
628
628
  async refreshAccessToken(t) {
629
- const a = await Is(t);
629
+ const a = await Rn(t);
630
630
  return this.saveToken(a), this.generateBearerToken(a.access_token, a.token_type);
631
631
  }
632
632
  /**
633
633
  * 执行完整的 OAuth 授权流程
634
634
  */
635
635
  async auth() {
636
- const t = await ks(), a = `${Ae}/oauth/authorize?${new URLSearchParams({
636
+ const t = await En(), a = `${Ae}/oauth/authorize?${new URLSearchParams({
637
637
  ...t
638
638
  })}`;
639
- return console.log(A.cyan("正在打开浏览器进行 GitLab 授权,如果浏览器未自动打开,请访问: ")), console.log(A.blue(a)), new Promise((n) => {
640
- Es(t.state).then((s) => {
641
- s ? (console.log(A.green("✅ GitLab 授权成功!")), this.saveToken(s), n(this.generateBearerToken(s.access_token, s.token_type))) : m("❌ GitLab 授权失败!");
642
- }).catch((s) => {
643
- m(`❌ GitLab 授权失败:${s.message}`);
639
+ return console.log(A.cyan("正在打开浏览器进行 GitLab 授权,如果浏览器未自动打开,请访问: ")), console.log(A.blue(a)), new Promise((s) => {
640
+ In(t.state).then((n) => {
641
+ n ? (console.log(A.green("✅ GitLab 授权成功!")), this.saveToken(n), s(this.generateBearerToken(n.access_token, n.token_type))) : m("❌ GitLab 授权失败!");
642
+ }).catch((n) => {
643
+ m(`❌ GitLab 授权失败:${n.message}`);
644
644
  }), ma(a);
645
645
  });
646
646
  }
@@ -655,28 +655,28 @@ class Rs {
655
655
  const t = I("gitToken"), a = I("gitTokenExpiry");
656
656
  if (t && a && Date.now() < a)
657
657
  return t;
658
- const n = I("gitLabRefreshToken");
659
- if (n)
658
+ const s = I("gitLabRefreshToken");
659
+ if (s)
660
660
  try {
661
- return await this.refreshAccessToken(n);
661
+ return await this.refreshAccessToken(s);
662
662
  } catch {
663
663
  console.log(A.yellow("⚠️ Token 刷新失败,需要重新授权")), k("gitToken", ""), k("gitLabRefreshToken", ""), k("gitTokenExpiry", ""), X();
664
664
  }
665
665
  return await this.auth();
666
666
  }
667
667
  }
668
- const ot = new Rs();
669
- async function ne(e) {
670
- const t = e.method || "get", a = e.headers || {}, n = e.data || {}, s = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
668
+ const ot = new Cn();
669
+ async function se(e) {
670
+ const t = e.method || "get", a = e.headers || {}, s = e.data || {}, n = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
671
671
  try {
672
672
  const i = {
673
673
  url: e.url,
674
674
  method: t,
675
- [s]: n,
675
+ [n]: s,
676
676
  headers: a,
677
677
  responseType: e?.responseType || "json"
678
678
  };
679
- Te(A.magenta(i.method.toUpperCase()), A.yellow(i.url), JSON.stringify(i.headers)), Te(A.gray(JSON.stringify(i[s], null, 2)));
679
+ Te(A.magenta(i.method.toUpperCase()), A.yellow(i.url), JSON.stringify(i.headers)), Te(A.gray(JSON.stringify(i[n], null, 2)));
680
680
  const o = await me(i);
681
681
  return Te(A.green("Response"), A.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
682
682
  } catch (i) {
@@ -685,7 +685,7 @@ async function ne(e) {
685
685
  }
686
686
  async function S(e) {
687
687
  try {
688
- return await ne({
688
+ return await se({
689
689
  ...e,
690
690
  headers: {
691
691
  Authorization: await ot.getToken()
@@ -693,7 +693,7 @@ async function S(e) {
693
693
  });
694
694
  } catch (t) {
695
695
  if (t instanceof gt && t.response?.status === 401)
696
- return console.log(A.yellow("⚠️ GitLab Token 已失效,正在重新授权...")), k("gitToken", ""), k("gitLabRefreshToken", ""), k("gitTokenExpiry", ""), X(), ne({
696
+ return console.log(A.yellow("⚠️ GitLab Token 已失效,正在重新授权...")), k("gitToken", ""), k("gitLabRefreshToken", ""), k("gitTokenExpiry", ""), X(), se({
697
697
  ...e,
698
698
  headers: {
699
699
  Authorization: await ot.getToken()
@@ -702,12 +702,12 @@ async function S(e) {
702
702
  throw t;
703
703
  }
704
704
  }
705
- async function Cs() {
705
+ async function Ln() {
706
706
  const e = I("zenTaoToken");
707
707
  if (e)
708
708
  return e;
709
709
  {
710
- const { token: t } = await ne({
710
+ const { token: t } = await se({
711
711
  url: `${re("ZenTaoDomain")}/api.php/v1/tokens`,
712
712
  method: "post",
713
713
  data: {
@@ -719,10 +719,10 @@ async function Cs() {
719
719
  }
720
720
  }
721
721
  async function Ce(e) {
722
- const t = await ne({
722
+ const t = await se({
723
723
  ...e,
724
724
  headers: {
725
- Token: await Cs()
725
+ Token: await Ln()
726
726
  }
727
727
  });
728
728
  if (e.url.includes("local")) {
@@ -735,22 +735,22 @@ async function Ce(e) {
735
735
  ...e
736
736
  })) : t;
737
737
  } else {
738
- const { status: a, data: n } = t;
738
+ const { status: a, data: s } = t;
739
739
  if (a === "success") {
740
- const s = JSON.parse(n);
741
- return s.title === "用户登录" ? (k("zenTaoToken", ""), Ce({
740
+ const n = JSON.parse(s);
741
+ return n.title === "用户登录" ? (k("zenTaoToken", ""), Ce({
742
742
  ...e
743
- })) : s;
743
+ })) : n;
744
744
  } else
745
745
  return {};
746
746
  }
747
747
  }
748
- async function Ls() {
748
+ async function xn() {
749
749
  const e = I("k8sToken");
750
750
  if (e)
751
751
  return e;
752
752
  {
753
- const { access_token: t } = await ne({
753
+ const { access_token: t } = await se({
754
754
  url: `${re("K8sDomain")}/oauth/login/LDAP`,
755
755
  method: "post",
756
756
  headers: {
@@ -764,7 +764,7 @@ async function Ls() {
764
764
  return k("k8sToken", a), X(), a;
765
765
  }
766
766
  }
767
- async function xs(e, t) {
767
+ async function Pn(e, t) {
768
768
  try {
769
769
  const a = ea(t, { mode: 493 });
770
770
  return (await me({
@@ -774,25 +774,25 @@ async function xs(e, t) {
774
774
  headers: {
775
775
  "Content-Type": "application/octet-stream"
776
776
  }
777
- })).data.pipe(a), new Promise((s, i) => {
778
- a.on("finish", () => s(1)), a.on("error", i);
777
+ })).data.pipe(a), new Promise((n, i) => {
778
+ a.on("finish", () => n(1)), a.on("error", i);
779
779
  });
780
780
  } catch (a) {
781
781
  throw console.error("下载失败:", a), a;
782
782
  }
783
783
  }
784
784
  const G = () => `${Ae}/api/v4`, z = (e) => `${G()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
785
- function Ps() {
785
+ function Dn() {
786
786
  return S({
787
787
  url: z("src/data/template-projects.json")
788
788
  });
789
789
  }
790
- function Ds() {
790
+ function On() {
791
791
  return S({
792
792
  url: z("src/data/java-project-module.json")
793
793
  });
794
794
  }
795
- function Os() {
795
+ function Mn() {
796
796
  return S({
797
797
  url: z("src/data/java-project-api.json")
798
798
  });
@@ -802,37 +802,37 @@ function He() {
802
802
  url: z("src/data/z-develop-config.json")
803
803
  });
804
804
  }
805
- function Ms() {
805
+ function Bn() {
806
806
  return S({
807
807
  url: z("src/assets/tsconfig.browser.json")
808
808
  });
809
809
  }
810
- function Bs() {
810
+ function zn() {
811
811
  return S({
812
812
  url: z("src/assets/tsconfig.node.json")
813
813
  });
814
814
  }
815
- function zs() {
815
+ function _n() {
816
816
  return S({
817
817
  url: z("src/assets/.prettierignore")
818
818
  });
819
819
  }
820
- function _s() {
820
+ function Fn() {
821
821
  return S({
822
822
  url: z("src/assets/.prettierrc.json")
823
823
  });
824
824
  }
825
- function Fs() {
825
+ function Gn() {
826
826
  return S({
827
827
  url: z("src/assets/data.yaml")
828
828
  });
829
829
  }
830
- function Gs() {
830
+ function Jn() {
831
831
  return S({
832
832
  url: z("src/assets/main.py")
833
833
  });
834
834
  }
835
- function Js() {
835
+ function Un() {
836
836
  return S({
837
837
  url: z("src/assets/checkstyle.xml")
838
838
  });
@@ -842,22 +842,22 @@ function Ct() {
842
842
  url: z("src/data/project-group-chats.json")
843
843
  });
844
844
  }
845
- function Us() {
845
+ function Vn() {
846
846
  return S({
847
847
  url: z("src/data/project-zen-tao-id.json")
848
848
  });
849
849
  }
850
- function Vs() {
850
+ function Wn() {
851
851
  return S({
852
852
  url: `${G()}/user`
853
853
  });
854
854
  }
855
- function Ws() {
855
+ function Hn() {
856
856
  return S({
857
857
  url: `${G()}/groups`
858
858
  });
859
859
  }
860
- function Hs(e) {
860
+ function qn(e) {
861
861
  return S({
862
862
  url: `${G()}/projects`,
863
863
  method: "post",
@@ -869,7 +869,7 @@ function Lt(e) {
869
869
  url: `${G()}/projects/${e}`
870
870
  });
871
871
  }
872
- function qs(e) {
872
+ function Zn(e) {
873
873
  return S({
874
874
  url: `${G()}/projects`,
875
875
  data: {
@@ -878,118 +878,118 @@ function qs(e) {
878
878
  }
879
879
  });
880
880
  }
881
- function Zs(e) {
881
+ function Kn(e) {
882
882
  return S({
883
883
  url: `${G()}/projects/${e.id}/merge_requests`,
884
884
  method: "post",
885
885
  data: e
886
886
  });
887
887
  }
888
- function Ks(e) {
888
+ function Yn(e) {
889
889
  return S({
890
890
  url: `${G()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
891
891
  method: "put"
892
892
  });
893
893
  }
894
- function Ys(e) {
894
+ function Xn(e) {
895
895
  return S({
896
896
  url: `${G()}/projects/${e.id}/merge_requests/${e.iid}`,
897
897
  method: "put",
898
898
  data: e
899
899
  });
900
900
  }
901
- function Xs(e) {
901
+ function Qn(e) {
902
902
  return S({
903
903
  url: `${G()}/projects/${e.id}/merge_requests/${e.iid}`,
904
904
  method: "get"
905
905
  });
906
906
  }
907
- function Qs(e) {
907
+ function es(e) {
908
908
  return S({
909
909
  url: `${G()}/projects/${e.id}/repository/branches`,
910
910
  method: "post",
911
911
  data: e
912
912
  });
913
913
  }
914
- function en(e) {
914
+ function ts(e) {
915
915
  return S({
916
916
  url: `${G()}/projects/${e}/repository/branches`
917
917
  });
918
918
  }
919
- function tn() {
919
+ function as() {
920
920
  const e = Ne("fe-groups.json");
921
921
  return j(e) ? L.readJSONSync(e) : { groups: [] };
922
922
  }
923
- async function an() {
924
- const e = await Ws(), t = Ia.map((a) => {
925
- const n = e.find((s) => s.name === a);
926
- return n ? {
927
- name: n.name,
928
- id: n.id,
929
- description: n.description
923
+ async function ns() {
924
+ const e = await Hn(), t = Ia.map((a) => {
925
+ const s = e.find((n) => n.name === a);
926
+ return s ? {
927
+ name: s.name,
928
+ id: s.id,
929
+ description: s.description
930
930
  } : !1;
931
931
  }).filter((a) => !!a);
932
932
  L.writeJSONSync(Ne("fe-groups.json"), { groups: t }, { spaces: 2 });
933
933
  }
934
- function sn(e, t) {
934
+ function ss(e, t) {
935
935
  const a = [];
936
936
  t.forEach((i) => {
937
937
  e.includes(i.value) && a.push(i);
938
938
  });
939
- const n = be("weWorkListCache"), s = n.map((i) => i.value);
939
+ const s = be("weWorkListCache"), n = s.map((i) => i.value);
940
940
  a.forEach((i) => {
941
- const o = s.indexOf(i.value);
942
- o > -1 ? n[o].usageCount += 1 : n.push({
941
+ const o = n.indexOf(i.value);
942
+ o > -1 ? s[o].usageCount += 1 : s.push({
943
943
  ...i,
944
944
  usageCount: 1
945
945
  });
946
946
  }), de({
947
- weWorkListCache: n.sort((i, o) => o.usageCount - i.usageCount)
947
+ weWorkListCache: s.sort((i, o) => o.usageCount - i.usageCount)
948
948
  }), X();
949
949
  }
950
950
  async function xt() {
951
- const t = (await is()).filter((i) => [1, 2, 3, 4, 5].includes(i.title)).map((i) => ({
951
+ const t = (await rn()).filter((i) => [1, 2, 3, 4, 5].includes(i.title)).map((i) => ({
952
952
  name: `${i.nick} - ${Ea[i.title]}`,
953
953
  value: i.weWorkUserId
954
- })), a = be("weWorkListCache"), n = a.map((i) => i.value), s = [];
954
+ })), a = be("weWorkListCache"), s = a.map((i) => i.value), n = [];
955
955
  return t.forEach((i) => {
956
- const o = n.indexOf(i.value);
957
- s.push({
956
+ const o = s.indexOf(i.value);
957
+ n.push({
958
958
  ...i,
959
959
  usageCount: o > -1 ? a[o].usageCount : 0
960
960
  });
961
- }), s.sort((i, o) => o.usageCount - i.usageCount);
961
+ }), n.sort((i, o) => o.usageCount - i.usageCount);
962
962
  }
963
963
  async function Pt(e, t, a) {
964
- const n = await xt();
965
- let s = await V({
964
+ const s = await xt();
965
+ let n = await V({
966
966
  message: e,
967
967
  loop: !0,
968
- pageSize: n.length || 5,
968
+ pageSize: s.length || 5,
969
969
  clearInputWhenSelected: !0,
970
970
  multiple: a,
971
- options: (i) => i ? n.filter((o) => o.name.includes(i)) : n,
971
+ options: (i) => i ? s.filter((o) => o.name.includes(i)) : s,
972
972
  validate: t
973
973
  });
974
- return s = Array.isArray(s) ? s : [s], sn(s, n), s;
974
+ return n = Array.isArray(n) ? n : [n], ss(n, s), n;
975
975
  }
976
- async function nn(e, t, a) {
977
- const { groups: n } = await Ct(), s = n.map((o) => ({
976
+ async function is(e, t, a) {
977
+ const { groups: s } = await Ct(), n = s.map((o) => ({
978
978
  name: o.name,
979
979
  value: o.url
980
980
  }));
981
981
  let i = await V({
982
982
  message: e,
983
983
  loop: !0,
984
- pageSize: s.length || 5,
984
+ pageSize: n.length || 5,
985
985
  clearInputWhenSelected: !0,
986
986
  multiple: a,
987
- options: (o) => o ? s.filter((r) => r.name.includes(o)) : s,
987
+ options: (o) => o ? n.filter((r) => r.name.includes(o)) : n,
988
988
  validate: t
989
989
  });
990
990
  return i = Array.isArray(i) ? i : [i], i;
991
991
  }
992
- async function rn() {
992
+ async function rs() {
993
993
  try {
994
994
  jt() && (await Le({
995
995
  message: "系统中已存在z的配置文件,确认重新配置?"
@@ -1015,13 +1015,13 @@ async function rn() {
1015
1015
  message: "请输入LDAP账号:"
1016
1016
  });
1017
1017
  a = a.trim();
1018
- let n = await pa({
1018
+ let s = await pa({
1019
1019
  message: "请输入LDAP密码:",
1020
1020
  mask: !0
1021
1021
  });
1022
- n = n.trim(), k("jobType", t), k("ldapAccount", a), k("ldapPassword", n);
1023
- const s = await He();
1024
- De(s);
1022
+ s = s.trim(), k("jobType", t), k("ldapAccount", a), k("ldapPassword", s);
1023
+ const n = await He();
1024
+ De(n);
1025
1025
  const i = await xt(), o = await Pt("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = i.find((u) => u.value === o[0]);
1026
1026
  k({
1027
1027
  weWorkName: r,
@@ -1032,43 +1032,43 @@ async function rn() {
1032
1032
  }
1033
1033
  const e = y("配置信息初始化中").start();
1034
1034
  try {
1035
- const t = await Vs();
1035
+ const t = await Wn();
1036
1036
  k({
1037
1037
  gitUserId: t.id,
1038
1038
  gitName: t.name,
1039
1039
  gitEnglishName: t.username,
1040
1040
  gitEmail: t.email
1041
- }), de("latestCheckVersionTimestamp", Date.now()), X(), I("jobType") === ue.FRONT_END && await an(), e.succeed("配置信息初始化完成"), process.exit(0);
1041
+ }), de("latestCheckVersionTimestamp", Date.now()), X(), I("jobType") === ue.FRONT_END && await ns(), e.succeed("配置信息初始化完成"), process.exit(0);
1042
1042
  } catch (t) {
1043
1043
  e.fail("配置信息初始化失败"), me.isAxiosError(t) && m("请检查你的域名及令牌配置"), m(t);
1044
1044
  }
1045
1045
  }
1046
1046
  const ke = (e, t, a) => {
1047
- const n = [
1047
+ const s = [
1048
1048
  "#!/usr/bin/env sh",
1049
1049
  ...Array.isArray(t) ? t : [t],
1050
1050
  ""
1051
1051
  ].join(`
1052
1052
  `).trim();
1053
- ve(x(e), n, {
1053
+ ve(x(e), s, {
1054
1054
  mode: 493
1055
1055
  });
1056
- }, on = () => {
1056
+ }, os = () => {
1057
1057
  ke("commit-msg", "z run commit-msg"), ke("pre-commit", "z run commit-files"), ke("pre-rebase", "z run not-allow-rebase"), ke("pre-push", "z run detect-push");
1058
1058
  };
1059
- async function cn() {
1059
+ async function cs() {
1060
1060
  await _(Se(), "", { mode: 493 }), await _(x(".gitignore"), `.commit-msg-tpl
1061
- `, { mode: 493 }), on();
1061
+ `, { mode: 493 }), os();
1062
1062
  const { language: e } = W();
1063
1063
  if ([$.JAVASCRIPT, $.MARKDOWN].includes(e) && (await _(
1064
1064
  x(".prettierrc.json"),
1065
- `${JSON.stringify(await _s(), null, 2)}
1065
+ `${JSON.stringify(await Fn(), null, 2)}
1066
1066
  `,
1067
1067
  {
1068
1068
  mode: 493
1069
1069
  }
1070
- ), await _(x(".prettierignore"), await zs(), { mode: 493 }), await _(x("tsconfig.node.json"), await Bs(), { mode: 493 }), await _(x("tsconfig.browser.json"), await Ms(), { mode: 493 })), e === $.JAVA) {
1071
- await xs(`${re("FECDNDomain")}/file/vgnlfbfHRF.jar`, x("checkstyle.jar")), await _(x("checkstyle.xml"), await Js(), { mode: 493 });
1070
+ ), await _(x(".prettierignore"), await _n(), { mode: 493 }), await _(x("tsconfig.node.json"), await zn(), { mode: 493 }), await _(x("tsconfig.browser.json"), await Bn(), { mode: 493 })), e === $.JAVA) {
1071
+ await Pn(`${re("FECDNDomain")}/file/vgnlfbfHRF.jar`, x("checkstyle.jar")), await _(x("checkstyle.xml"), await Un(), { mode: 493 });
1072
1072
  const t = f.join("package.json");
1073
1073
  j(t) || await _(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
1074
1074
  mode: 493
@@ -1076,11 +1076,11 @@ async function cn() {
1076
1076
  }
1077
1077
  Nt(), await p(`git add ${K}`);
1078
1078
  }
1079
- async function ln(e, t) {
1079
+ async function ls(e, t) {
1080
1080
  const a = await p("git remote get-url --push origin");
1081
1081
  a || m("获取项目远程git地址失败,请配置后重试");
1082
- let n = e;
1083
- n || (n = await E({
1082
+ let s = e;
1083
+ s || (s = await E({
1084
1084
  message: "请选择项目语言",
1085
1085
  choices: [
1086
1086
  {
@@ -1101,12 +1101,12 @@ async function ln(e, t) {
1101
1101
  }
1102
1102
  ]
1103
1103
  }));
1104
- let s = t;
1105
- if (!s) {
1106
- const o = se(a), r = await Lt(o);
1104
+ let n = t;
1105
+ if (!n) {
1106
+ const o = ne(a), r = await Lt(o);
1107
1107
  if (!r)
1108
1108
  return m(`未找到项目,请确认项目${a}是否存在,或者当前账号权限`);
1109
- s = r.namespace.full_path;
1109
+ n = r.namespace.full_path;
1110
1110
  }
1111
1111
  let i = await Le({
1112
1112
  message: "是否允许直接推送代码到环境分支?默认否",
@@ -1120,11 +1120,11 @@ async function ln(e, t) {
1120
1120
  i = ["是", "yes", "y", "Y"].includes(o), i || J("✅ 已修改为不允许直接推送代码到分支环境");
1121
1121
  }
1122
1122
  It({
1123
- language: n,
1124
- "lint-staged": Va[n],
1123
+ language: s,
1124
+ "lint-staged": Va[s],
1125
1125
  repository: {
1126
1126
  url: a,
1127
- group: s
1127
+ group: n
1128
1128
  },
1129
1129
  skipGitPushLimit: i
1130
1130
  });
@@ -1132,34 +1132,34 @@ async function ln(e, t) {
1132
1132
  async function qe(e, t) {
1133
1133
  e ? N.rm("-rf", K) : j(x()) && (await Le({
1134
1134
  message: `当前项目中已存在配置文件夹${K},确认重新配置?`
1135
- }) ? N.rm("-rf", K) : process.exit(0)), await fe(x(), { recursive: !0 }), await ln(e, t);
1135
+ }) ? N.rm("-rf", K) : process.exit(0)), await fe(x(), { recursive: !0 }), await ls(e, t);
1136
1136
  const a = y("项目初始化中...").start();
1137
- await cn(), a.succeed("项目初始化完成");
1137
+ await cs(), a.succeed("项目初始化完成");
1138
1138
  }
1139
- async function un() {
1139
+ async function us() {
1140
1140
  j(x()) && j(Se()) ? Nt() : await qe(), process.exit(0);
1141
1141
  }
1142
- async function pn(e, t) {
1143
- t.projectLanguage && !Object.values($).includes(t.projectLanguage) && m("项目语言不支持"), e ? (H(), e === "." ? (await qe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await un() : m("参数错误。执行 z init -h 查看帮助。")) : await rn();
1142
+ async function ps(e, t) {
1143
+ t.projectLanguage && !Object.values($).includes(t.projectLanguage) && m("项目语言不支持"), e ? (H(), e === "." ? (await qe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await us() : m("参数错误。执行 z init -h 查看帮助。")) : await rs();
1144
1144
  }
1145
- P.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values($).join("/")} `).action((...e) => B(pn, ...e));
1146
- async function mn(e, t) {
1145
+ P.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values($).join("/")} `).action((...e) => B(ps, ...e));
1146
+ async function ms(e, t) {
1147
1147
  if (!e)
1148
1148
  return "不能为空";
1149
1149
  if (!/^[a-z0-9-]+$/.test(e))
1150
1150
  return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
1151
1151
  if (kt().includes(e))
1152
1152
  return "当前目录下已存在同名文件夹,请先处理。";
1153
- const s = (await qs(e)).find((i) => i.path_with_namespace === `${t}/${e}`);
1154
- return s ? `远程仓库中已存在同名项目(${s.http_url_to_repo}),请更名后重试` : !0;
1153
+ const n = (await Zn(e)).find((i) => i.path_with_namespace === `${t}/${e}`);
1154
+ return n ? `远程仓库中已存在同名项目(${n.http_url_to_repo}),请更名后重试` : !0;
1155
1155
  }
1156
- function dn(e) {
1156
+ function ds(e) {
1157
1157
  return e ? !0 : "不能为空";
1158
1158
  }
1159
- function fn(e) {
1159
+ function fs(e) {
1160
1160
  return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
1161
1161
  }
1162
- async function gn(e) {
1162
+ async function gs(e) {
1163
1163
  ee(), H(), await ge();
1164
1164
  let t, a;
1165
1165
  e.branchType ? t = e.branchType : t = await E({
@@ -1180,13 +1180,13 @@ async function gn(e) {
1180
1180
  ]
1181
1181
  }), e.branchPurpose ? a = e.branchPurpose : (a = await F({
1182
1182
  message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
1183
- validate: fn
1183
+ validate: fs
1184
1184
  }), a = a.trim());
1185
- const n = `${t}_${a}_${Et()}`;
1186
- await p(`git fetch origin ${w.MASTER}`), await p(`git checkout -b ${n} origin/${w.MASTER}`), await p(`git push -u origin ${n}`), process.exit(0);
1185
+ const s = `${t}_${a}_${Et()}`;
1186
+ await p(`git fetch origin ${w.MASTER}`), await p(`git checkout -b ${s} origin/${w.MASTER}`), await p(`git push -u origin ${s}`), process.exit(0);
1187
1187
  }
1188
1188
  const Dt = (e) => `${re("ZenTaoDomain")}${e}`;
1189
- async function hn() {
1189
+ async function hs() {
1190
1190
  const e = await Ce({
1191
1191
  url: Dt("/my-work-task.json?tid=mrrferp8"),
1192
1192
  method: "get"
@@ -1199,7 +1199,7 @@ async function hn() {
1199
1199
  name: a
1200
1200
  })) : [];
1201
1201
  }
1202
- async function wn() {
1202
+ async function ws() {
1203
1203
  const e = await Ce({
1204
1204
  url: Dt("/my-work-bug.json?tid=mrrferp8"),
1205
1205
  method: "get"
@@ -1220,7 +1220,7 @@ async function ct(e, t) {
1220
1220
  const a = await p("git diff HEAD", {
1221
1221
  removeTailLinkBreak: !1
1222
1222
  });
1223
- if (a || m("git暂存区没有内容,请先git add添加文件到暂存区"), Buffer.byteLength(a, "utf-8") < st) {
1223
+ if (a || m("git暂存区没有内容,请先git add添加文件到暂存区"), Buffer.byteLength(a, "utf-8") < nt) {
1224
1224
  const u = await rt({
1225
1225
  type: "commit-message-v2",
1226
1226
  input: a
@@ -1228,12 +1228,12 @@ async function ct(e, t) {
1228
1228
  });
1229
1229
  return e + u;
1230
1230
  }
1231
- const n = await p("git diff --name-only HEAD");
1232
- n || m("git暂存区没有内容,请先git add添加文件到暂存区");
1233
- const s = n.replace(/\r\n/g, `
1231
+ const s = await p("git diff --name-only HEAD");
1232
+ s || m("git暂存区没有内容,请先git add添加文件到暂存区");
1233
+ const n = s.replace(/\r\n/g, `
1234
1234
  `).split(`
1235
1235
  `).filter(Boolean), i = [], o = [];
1236
- for (const u of s)
1236
+ for (const u of n)
1237
1237
  try {
1238
1238
  const l = u.replace(/(["\\$`])/g, "\\$1"), d = await p(`git diff HEAD -- "${l}"`, {
1239
1239
  removeTailLinkBreak: !1
@@ -1243,7 +1243,7 @@ async function ct(e, t) {
1243
1243
  }
1244
1244
  const r = o.join(`
1245
1245
  `);
1246
- if (i.length === 0 || Buffer.byteLength(r, "utf-8") > st)
1246
+ if (i.length === 0 || Buffer.byteLength(r, "utf-8") > nt)
1247
1247
  return J("变更内容太大,无法自动生成commit msg"), t.stop(), await Ge();
1248
1248
  if (!r)
1249
1249
  return J("无法获取文件差异信息"), t.stop(), await Ge();
@@ -1255,18 +1255,18 @@ async function ct(e, t) {
1255
1255
  return e + c;
1256
1256
  }
1257
1257
  async function ze(e, t, a) {
1258
- const n = y("🤖 生成提交信息中...").start();
1259
- let s = "", i = !0;
1258
+ const s = y("🤖 生成提交信息中...").start();
1259
+ let n = "", i = !0;
1260
1260
  if ([T.FEAT, T.FIX, T.REFACTOR].includes(e)) {
1261
1261
  const o = t.map((r) => r.value).join(",");
1262
- if (a || (s = await ct(`${e}(${o}): `, n)), !s) {
1262
+ if (a || (n = await ct(`${e}(${o}): `, s)), !n) {
1263
1263
  const r = t.map((c) => c.name).join(";");
1264
- s = `${e}(${o}): ${r}`, i = !1;
1264
+ n = `${e}(${o}): ${r}`, i = !1;
1265
1265
  }
1266
1266
  }
1267
- e === T.CHORE && (t ? s = `${e}: ${t}` : s = await ct(`${e}: `, n)), await _(Se(), s, "utf-8"), i || a ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(A.yellow(s));
1267
+ e === T.CHORE && (t ? n = `${e}: ${t}` : n = await ct(`${e}: `, s)), await _(Se(), n, "utf-8"), i || a ? s.succeed("提交信息已生成(↓),可以进行提交了!") : s.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(A.yellow(n));
1268
1268
  }
1269
- async function yn({ commitMessageCloseAi: e, commitMessageUseChoreType: t }) {
1269
+ async function ys({ commitMessageCloseAi: e, commitMessageUseChoreType: t }) {
1270
1270
  let a;
1271
1271
  if (t ? a = T.CHORE : a = await E({
1272
1272
  message: "请选择你要创建的模板类型",
@@ -1289,45 +1289,45 @@ async function yn({ commitMessageCloseAi: e, commitMessageUseChoreType: t }) {
1289
1289
  }
1290
1290
  ]
1291
1291
  }), [T.FEAT, T.REFACTOR].includes(a)) {
1292
- const n = await hn();
1293
- if (!n.length)
1292
+ const s = await hs();
1293
+ if (!s.length)
1294
1294
  return U("🤷 暂无开发任务");
1295
- const s = await Re({
1295
+ const n = await Re({
1296
1296
  message: "请关联开发任务(可多选):",
1297
1297
  validate: (i) => i.length === 0 ? "请选择项" : !0,
1298
- choices: n.map((i) => ({
1298
+ choices: s.map((i) => ({
1299
1299
  ...i,
1300
1300
  name: `[${i.value.value}]: ${i.name}`
1301
1301
  })),
1302
- pageSize: n.length
1302
+ pageSize: s.length
1303
1303
  });
1304
- await ze(T.FEAT, s, e);
1304
+ await ze(T.FEAT, n, e);
1305
1305
  }
1306
1306
  if (a === T.FIX) {
1307
- const n = await wn();
1308
- if (!n.length)
1307
+ const s = await ws();
1308
+ if (!s.length)
1309
1309
  return U("🤷 暂无BUG");
1310
- const s = await Re({
1310
+ const n = await Re({
1311
1311
  message: "请关联Bug(可多选):",
1312
1312
  validate: (i) => i.length === 0 ? "请选择项" : !0,
1313
- choices: n.map((i) => ({
1313
+ choices: s.map((i) => ({
1314
1314
  ...i,
1315
1315
  name: `[${i.value.value}]: ${i.name}`
1316
1316
  })),
1317
- pageSize: n.length
1317
+ pageSize: s.length
1318
1318
  });
1319
- await ze(T.FIX, s, e);
1319
+ await ze(T.FIX, n, e);
1320
1320
  }
1321
1321
  if (a === T.CHORE) {
1322
- let n = "";
1323
- e && (n = await Ge()), await ze(T.CHORE, n);
1322
+ let s = "";
1323
+ e && (s = await Ge()), await ze(T.CHORE, s);
1324
1324
  }
1325
1325
  process.exit(0);
1326
1326
  }
1327
- async function $n() {
1327
+ async function $s() {
1328
1328
  try {
1329
1329
  const e = {}, t = async () => {
1330
- const D = kt(), { projects: oe } = await Ps(), te = oe.map((le) => {
1330
+ const D = kt(), { projects: oe } = await Dn(), te = oe.map((le) => {
1331
1331
  const et = {
1332
1332
  name: `${le.name} [${le.desc}]`,
1333
1333
  value: le.name,
@@ -1340,7 +1340,7 @@ async function $n() {
1340
1340
  }), Be = oe.find((le) => le.name === Kt);
1341
1341
  e.tplName = Be.name, e.tplUrl = Be.url, e.tplLanguage = Be.language;
1342
1342
  }, a = async () => {
1343
- const { groups: D } = tn(), oe = await E({
1343
+ const { groups: D } = as(), oe = await E({
1344
1344
  message: "请选择一个分组",
1345
1345
  choices: D.map((te) => ({
1346
1346
  name: `${te.name} [${te.description}]`,
@@ -1352,20 +1352,20 @@ async function $n() {
1352
1352
  id: oe,
1353
1353
  name: D.find((te) => te.id === oe)?.name
1354
1354
  };
1355
- }, n = async () => {
1355
+ }, s = async () => {
1356
1356
  e.projectName = await F({
1357
1357
  message: "请输入项目名称",
1358
- validate: (D) => mn(D, e.group?.name || "")
1358
+ validate: (D) => ms(D, e.group?.name || "")
1359
1359
  }), e.projectName = e.projectName.trim(), e.projectDesc = await F({
1360
1360
  message: "请输入项目描述",
1361
- validate: dn
1361
+ validate: ds
1362
1362
  }), e.projectDesc = e.projectDesc.trim();
1363
1363
  };
1364
- await t(), await a(), await n();
1365
- const s = `${Ae}/${e.group?.name}/${e.projectName}.git`, i = y("模版初始化中").start();
1366
- await p(`git clone --depth=1 ${e.tplUrl}`), await ft(e.tplName, e.projectName), N.cd(e.projectName), N.rm("-rf", ".git"), await p(`git init --initial-branch=${w.MASTER}`), await p(`git remote add origin ${s}`), await p(`git config user.name ${I("gitName")}`), await p(`git config user.email ${I("gitEmail")}`);
1364
+ await t(), await a(), await s();
1365
+ const n = `${Ae}/${e.group?.name}/${e.projectName}.git`, i = y("模版初始化中").start();
1366
+ await p(`git clone --depth=1 ${e.tplUrl}`), await ft(e.tplName, e.projectName), N.cd(e.projectName), N.rm("-rf", ".git"), await p(`git init --initial-branch=${w.MASTER}`), await p(`git remote add origin ${n}`), await p(`git config user.name ${I("gitName")}`), await p(`git config user.email ${I("gitEmail")}`);
1367
1367
  const o = We();
1368
- as({
1368
+ an({
1369
1369
  ...o,
1370
1370
  name: e.projectName,
1371
1371
  description: e.projectDesc,
@@ -1378,17 +1378,17 @@ async function $n() {
1378
1378
  await p("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
1379
1379
  const c = y("项目推送中").start();
1380
1380
  await p('git add . && git commit -m "chore: 项目初始化"'), await p("git tag v0.0.1");
1381
- const u = await Hs({
1381
+ const u = await qn({
1382
1382
  name: e.projectName,
1383
1383
  description: e.projectDesc,
1384
1384
  path: e.projectName,
1385
1385
  visibility: "private",
1386
1386
  namespace_id: e.group?.id
1387
1387
  });
1388
- await p(`git push -u origin ${w.MASTER}`), await p(`git push origin HEAD:${w.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${A.blue(s)}`);
1388
+ await p(`git push -u origin ${w.MASTER} --no-verify`), await p(`git push origin HEAD:${w.MASTER} --tags --no-verify`), c.succeed(`项目已推送到远程,地址: ${A.blue(n)}`);
1389
1389
  const l = y("初始化分支中").start(), d = `feat_init_${Et()}`, g = [w.DEV, w.TEST, w.RELEASE, d], h = await Promise.allSettled(
1390
1390
  g.map(
1391
- (D) => Qs({
1391
+ (D) => es({
1392
1392
  id: u.id,
1393
1393
  branch: D,
1394
1394
  ref: w.MASTER
@@ -1404,7 +1404,7 @@ async function $n() {
1404
1404
  m(e);
1405
1405
  }
1406
1406
  }
1407
- async function vn(e, t) {
1407
+ async function vs(e, t) {
1408
1408
  let a;
1409
1409
  e ? [
1410
1410
  "project",
@@ -1437,16 +1437,16 @@ async function vn(e, t) {
1437
1437
  /* Project */
1438
1438
  }
1439
1439
  ]
1440
- }), a === "project" ? await $n() : (ee(), H(), a === "branch" ? await gn(t) : a === "commit-msg" && (await p("git status -s") ? await yn(t) : m("没有要变动的文件,无法生成提交信息")));
1440
+ }), a === "project" ? await $s() : (ee(), H(), a === "branch" ? await gs(t) : a === "commit-msg" && (await p("git status -s") ? await ys(t) : m("没有要变动的文件,无法生成提交信息")));
1441
1441
  }
1442
- P.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values($e).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").option("-c, --commit-message-use-chore-type", "创建提交信息时,直接使用chore类型。").action((...e) => B(vn, ...e));
1443
- const An = async (e) => {
1444
- const t = await Ls(), a = I("weWorkUserId"), { notifyUsers: n, notifyGroups: s, ...i } = e, o = y("部署任务创建中").start(), r = await Ns({
1442
+ P.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values($e).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").option("-c, --commit-message-use-chore-type", "创建提交信息时,直接使用chore类型。").action((...e) => B(vs, ...e));
1443
+ const As = async (e) => {
1444
+ const t = await xn(), a = I("weWorkUserId"), { notifyUsers: s, notifyGroups: n, ...i } = e, o = y("部署任务创建中").start(), r = await jn({
1445
1445
  ...i,
1446
1446
  userToken: t,
1447
1447
  userWeworkId: a,
1448
- notifyUsers: [.../* @__PURE__ */ new Set([a, ...n])].join(Fe),
1449
- notifyGroups: s.join(Fe)
1448
+ notifyUsers: [.../* @__PURE__ */ new Set([a, ...s])].join(Fe),
1449
+ notifyGroups: n.join(Fe)
1450
1450
  });
1451
1451
  i.moduleNames.length > 1 ? (o.succeed(`多模块部署任务创建完成,共 ${i.moduleNames.length} 个模块`), o.succeed(`当前已创建首个模块 ${A.blue(i.moduleNames[0])} 的 k8s 地址:`), console.log(A.blue(r)), o.info("后续模块会在前一个模块完成后依次部署,并通过企微通知下发对应地址。")) : (o.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${A.blue(r)}`));
1452
1452
  }, Ze = () => {
@@ -1456,80 +1456,80 @@ const An = async (e) => {
1456
1456
  const e = W();
1457
1457
  return e.repository?.url || m("未找到当前项目的仓库地址,请先通过 z . 对项目进行初始化"), e.repository.url;
1458
1458
  }, Mt = async () => {
1459
- const e = Ot(), t = Ze(), { groups: a } = await Us();
1460
- return a.find((n) => {
1461
- const s = $.JAVASCRIPT === t ? n.projects?.web : $.JAVA === t ? n.projects?.server : [];
1462
- return s.length && s.some((i) => Pe(i.url, e)) && n.zenTaoProductId ? n.zenTaoProductId : !1;
1459
+ const e = Ot(), t = Ze(), { groups: a } = await Vn();
1460
+ return a.find((s) => {
1461
+ const n = $.JAVASCRIPT === t ? s.projects?.web : $.JAVA === t ? s.projects?.server : [];
1462
+ return n.length && n.some((i) => Pe(i.url, e)) && s.zenTaoProductId ? s.zenTaoProductId : !1;
1463
1463
  });
1464
- }, bn = async () => {
1464
+ }, bs = async () => {
1465
1465
  const e = await Mt();
1466
1466
  if (!e)
1467
1467
  return;
1468
- const t = Ot(), a = Ze(), n = $.JAVASCRIPT === a ? e.projects?.web : $.JAVA === a ? e.projects?.server : [];
1469
- return n.length ? n.find((i) => Pe(i.url, t))?.chatGroupWebhook ?? e.chatGroupWebhook : void 0;
1468
+ const t = Ot(), a = Ze(), s = $.JAVASCRIPT === a ? e.projects?.web : $.JAVA === a ? e.projects?.server : [];
1469
+ return s.length ? s.find((i) => Pe(i.url, t))?.chatGroupWebhook ?? e.chatGroupWebhook : void 0;
1470
1470
  };
1471
- function Sn(e, t) {
1471
+ function Ss(e, t) {
1472
1472
  const a = We();
1473
1473
  if (W()?.repository?.url || m(".z/project.json中缺少repository.url"), t === Y.H5) {
1474
- const s = `build:${e}`;
1475
- a?.scripts[s] || m(`项目package.json文件scripts不存在命令${s}。`);
1474
+ const n = `build:${e}`;
1475
+ a?.scripts[n] || m(`项目package.json文件scripts不存在命令${n}。`);
1476
1476
  }
1477
1477
  t === Y.NPM && (a?.scripts.build || m("项目package.json文件scripts不存在命令build。")), t === Y.SERVER && (a?.scripts.build || m("项目package.json文件scripts不存在命令build。"));
1478
1478
  }
1479
- const Nn = async () => {
1479
+ const Ns = async () => {
1480
1480
  const e = await Mt();
1481
1481
  if (!e) {
1482
1482
  m("未找到关联的禅道产品,请先关联禅道产品!");
1483
1483
  return;
1484
1484
  }
1485
- const t = y("查询禅道执行中...").start(), a = await js(Number(e.zenTaoProductId));
1485
+ const t = y("查询禅道执行中...").start(), a = await Tn(Number(e.zenTaoProductId));
1486
1486
  a.length || (t.fail("查询禅道执行失败"), m(`${e.name} 项目在禅道中未创建执行!`)), t.stop();
1487
- const n = await V({
1487
+ const s = await V({
1488
1488
  message: "请选择执行",
1489
- options: (s) => {
1489
+ options: (n) => {
1490
1490
  const i = a.map((o) => ({
1491
1491
  name: o.label,
1492
1492
  value: o.value
1493
1493
  }));
1494
- return s ? i.filter((o) => o.name.includes(s)) : i;
1494
+ return n ? i.filter((o) => o.name.includes(n)) : i;
1495
1495
  },
1496
1496
  pageSize: 20,
1497
1497
  loop: !0,
1498
1498
  multiple: !1,
1499
1499
  filter: !0
1500
1500
  });
1501
- t.start("创建或更新执行构建..."), await Ts({
1501
+ t.start("创建或更新执行构建..."), await kn({
1502
1502
  appName: e.name,
1503
- executionId: Number(n),
1503
+ executionId: Number(s),
1504
1504
  ldapAccount: I("ldapAccount")
1505
1505
  }), t.succeed("创建或更新执行构建成功");
1506
- }, jn = [w.TEST, w.MASTER];
1506
+ }, js = [w.TEST, w.MASTER];
1507
1507
  async function Bt(e, t) {
1508
1508
  ee(), H();
1509
- let a = e, n = t.platform;
1510
- const s = W();
1511
- if (s.language === $.JAVA && (n = Y.SERVER), a && !Object.values(w).includes(a) && m("仅支持发布指定环境分支"), n && !Object.values(Y).includes(n) && m("发布平台错误"), n || (n = await E({
1509
+ let a = e, s = t.platform;
1510
+ const n = W();
1511
+ if (n.language === $.JAVA && (s = Y.SERVER), a && !Object.values(w).includes(a) && m("仅支持发布指定环境分支"), s && !Object.values(Y).includes(s) && m("发布平台错误"), s || (s = await E({
1512
1512
  message: "请选择平台",
1513
1513
  choices: ka
1514
- })), n === Y.NPM && (a = w.MASTER), !a) {
1514
+ })), s === Y.NPM && (a = w.MASTER), !a) {
1515
1515
  const l = await E({
1516
1516
  message: "请选择部署环境",
1517
1517
  choices: At
1518
1518
  });
1519
1519
  a = Ga(l);
1520
1520
  }
1521
- a === w.TEST && await Nn();
1521
+ a === w.TEST && await Ns();
1522
1522
  let i = "";
1523
- s.language === $.JAVASCRIPT && (i = Ra);
1523
+ n.language === $.JAVASCRIPT && (i = Ra);
1524
1524
  const o = [];
1525
- if (s.language === $.JAVASCRIPT) {
1525
+ if (n.language === $.JAVASCRIPT) {
1526
1526
  let l = "";
1527
1527
  const d = We();
1528
1528
  d.name.startsWith("@") && d.name.includes("/") ? l = d.name.split("/").pop() || "" : l = d.name, l && o.push(l);
1529
1529
  }
1530
- if (s.language === $.JAVA) {
1531
- const { projects: l } = await Ds(), d = l.find(
1532
- (g) => se(g.url) === se(s.repository.url)
1530
+ if (n.language === $.JAVA) {
1531
+ const { projects: l } = await On(), d = l.find(
1532
+ (g) => ne(g.url) === ne(n.repository.url)
1533
1533
  );
1534
1534
  if (!d)
1535
1535
  m("未找到项目对应的模块信息");
@@ -1562,18 +1562,18 @@ async function Bt(e, t) {
1562
1562
  }
1563
1563
  }
1564
1564
  let r = [];
1565
- const c = jn.includes(a);
1565
+ const c = js.includes(a);
1566
1566
  !t.skipSelectionNotification && !c && (r = await Pt("请选择部署成功要通知的人员:", () => !0, !0));
1567
1567
  let u = [];
1568
- if (!t.skipGroupNotification && !c && (u = await nn("请选择部署成功要通知的群组:", () => !0, !0)), c && !t.skipGroupNotification && !u.length) {
1569
- const l = await bn();
1568
+ if (!t.skipGroupNotification && !c && (u = await is("请选择部署成功要通知的群组:", () => !0, !0)), c && !t.skipGroupNotification && !u.length) {
1569
+ const l = await bs();
1570
1570
  l && u.push(l);
1571
1571
  }
1572
- if (s.language === $.JAVASCRIPT) {
1572
+ if (n.language === $.JAVASCRIPT) {
1573
1573
  const l = Fa(a);
1574
- Sn(l, n);
1574
+ Ss(l, s);
1575
1575
  }
1576
- await An({
1576
+ await As({
1577
1577
  moduleNames: o,
1578
1578
  k8sGroupName: i,
1579
1579
  branchName: a,
@@ -1581,17 +1581,17 @@ async function Bt(e, t) {
1581
1581
  notifyGroups: u
1582
1582
  });
1583
1583
  }
1584
- async function zt(e, t, a, n) {
1585
- const s = y(`分支合并中,${e} -> ${t}`).start();
1584
+ async function zt(e, t, a, s) {
1585
+ const n = y(`分支合并中,${e} -> ${t}`).start();
1586
1586
  let i = 0;
1587
1587
  try {
1588
- const { iid: r } = await Zs({
1588
+ const { iid: r } = await Kn({
1589
1589
  title: `${e} -> ${t} by z-develop`,
1590
1590
  id: a.id,
1591
1591
  source_branch: e,
1592
1592
  target_branch: t,
1593
1593
  // 合到主分支上的分支需要在合并完成后被移除
1594
- remove_source_branch: n ? !1 : w.MASTER === t
1594
+ remove_source_branch: s ? !1 : w.MASTER === t
1595
1595
  });
1596
1596
  i = r;
1597
1597
  } catch (r) {
@@ -1601,40 +1601,40 @@ async function zt(e, t, a, n) {
1601
1601
  try {
1602
1602
  await new Promise((r) => {
1603
1603
  setTimeout(r, 5e3);
1604
- }), await Ks({
1604
+ }), await Yn({
1605
1605
  id: a.id,
1606
1606
  iid: i
1607
- }), s.succeed(`分支${e}已合并到分支${t}`);
1607
+ }), n.succeed(`分支${e}已合并到分支${t}`);
1608
1608
  } catch (r) {
1609
1609
  me.isAxiosError(r) || m(r);
1610
1610
  const c = r?.response?.status;
1611
1611
  if (c === 406)
1612
1612
  return await o();
1613
- if (await Ys({
1613
+ if (await Xn({
1614
1614
  id: a.id,
1615
1615
  iid: i,
1616
1616
  state_event: "close"
1617
1617
  }), c === 405) {
1618
- const u = await Xs({
1618
+ const u = await Qn({
1619
1619
  id: a.id,
1620
1620
  iid: i
1621
1621
  });
1622
1622
  if (u.merge_status === "cannot_be_merged" && u.diff_refs.base_sha === u.diff_refs.head_sha) {
1623
- s.warn("MR已关闭。判定为空的合并请求(没有新内容),可继续进行部署");
1623
+ n.warn("MR已关闭。判定为空的合并请求(没有新内容),可继续进行部署");
1624
1624
  return;
1625
1625
  }
1626
1626
  }
1627
- s.fail("合并过程中出现冲突,MR已关闭。建议在本地完成合并。"), process.exit(1);
1627
+ n.fail("合并过程中出现冲突,MR已关闭。建议在本地完成合并。"), process.exit(1);
1628
1628
  }
1629
1629
  };
1630
1630
  await o();
1631
1631
  }
1632
- async function Tn(e, t) {
1633
- const a = `origin/${e.sourceBranch}`, n = await p(`git log -b origin/${w.MASTER} -1 --format=%H`), s = await p(`git log -b origin/${e.sourceBranch} -1 --format=%H`);
1632
+ async function Ts(e, t) {
1633
+ const a = `origin/${e.sourceBranch}`, s = await p(`git log -b origin/${w.MASTER} -1 --format=%H`), n = await p(`git log -b origin/${e.sourceBranch} -1 --format=%H`);
1634
1634
  await p(
1635
- `git log ${n}...${s} -b ${a}`
1635
+ `git log ${s}...${n} -b ${a}`
1636
1636
  ) || m(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await p(
1637
- `git branch --contains ${n} -r ${a}`
1637
+ `git branch --contains ${s} -r ${a}`
1638
1638
  ) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await zt(w.MASTER, e.sourceBranch, e)), t === w.MASTER && (await p(
1639
1639
  `git cherry origin/${O.TEST} ${a} origin/${w.MASTER}`
1640
1640
  )).split(`
@@ -1647,11 +1647,11 @@ const lt = async (e, t) => {
1647
1647
  m(`合并到远程分支 ${e} 失败,${a}`);
1648
1648
  }
1649
1649
  };
1650
- async function kn(e, t) {
1650
+ async function ks(e, t) {
1651
1651
  ee(), H(), await ge();
1652
- const a = await ss();
1652
+ const a = await nn();
1653
1653
  Object.values(w).includes(a.sourceBranch) && m(`当前分支${a.sourceBranch}不可作为源分支合并到目标分支。`);
1654
- const s = (await en(a.id)).filter((c) => ![a.sourceBranch].includes(c.name)).map((c) => {
1654
+ const n = (await ts(a.id)).filter((c) => ![a.sourceBranch].includes(c.name)).map((c) => {
1655
1655
  let u = c.name;
1656
1656
  return Object.values(w).includes(u) && (u = A.bold.blue(u)), {
1657
1657
  name: u,
@@ -1659,9 +1659,9 @@ async function kn(e, t) {
1659
1659
  };
1660
1660
  });
1661
1661
  let i;
1662
- e && !s.filter((c) => c.value === e).length && m(`未找到目标分支${e}`), e ? i = e : i = await E({
1662
+ e && !n.filter((c) => c.value === e).length && m(`未找到目标分支${e}`), e ? i = e : i = await E({
1663
1663
  message: "请选择要合并到的目标分支:",
1664
- choices: s
1664
+ choices: n
1665
1665
  });
1666
1666
  const o = y(`本地分支${a.sourceBranch}检测中`).start();
1667
1667
  if (await p(`git ls-remote --heads origin ${a.sourceBranch}`)) {
@@ -1672,7 +1672,7 @@ async function kn(e, t) {
1672
1672
  ), process.exit(1));
1673
1673
  } else
1674
1674
  await lt(a.sourceBranch, o);
1675
- await Tn(a, i), await zt(a.sourceBranch, i, a, t.keepBranchAfterMergeMaster), w.MASTER === i && !t.keepBranchAfterMergeMaster && (await p(`git checkout ${w.MASTER}`), await p(`git pull origin ${w.MASTER}`), await p(`git branch -d ${a.sourceBranch}`), U(
1675
+ await Ts(a, i), await zt(a.sourceBranch, i, a, t.keepBranchAfterMergeMaster), w.MASTER === i && !t.keepBranchAfterMergeMaster && (await p(`git checkout ${w.MASTER}`), await p(`git pull origin ${w.MASTER}`), await p(`git branch -d ${a.sourceBranch}`), U(
1676
1676
  `${a.sourceBranch}分支已移除,当前已切换到最新的${w.MASTER}。如需继续开发,请检出新分支(z c b)。`
1677
1677
  )), Object.values(w).includes(i) && await Bt(i, {
1678
1678
  platform: t.deployPlatform,
@@ -1680,9 +1680,9 @@ async function kn(e, t) {
1680
1680
  skipGroupNotification: t.skipGroupNotification
1681
1681
  });
1682
1682
  }
1683
- P.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(Y).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => B(kn, ...e));
1683
+ P.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(Y).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => B(ks, ...e));
1684
1684
  P.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(w).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(Y).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称,多个使用逗号分隔").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => B(Bt, ...e));
1685
- async function En() {
1685
+ async function Es() {
1686
1686
  try {
1687
1687
  await p("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
1688
1688
  silent: !1
@@ -1691,42 +1691,42 @@ async function En() {
1691
1691
  m("checkstyle执行出错"), process.exit(1);
1692
1692
  }
1693
1693
  }
1694
- const Ie = "origin/", In = Object.values(w).map((e) => `${Ie}${e}`), Rn = Object.values(w), Ee = w.MASTER, Cn = async (e) => {
1694
+ const Ie = "origin/", Is = Object.values(w).map((e) => `${Ie}${e}`), Rs = Object.values(w), Ee = w.MASTER, Cs = async (e) => {
1695
1695
  await p("git fetch --prune");
1696
1696
  const t = `${Ie}${e}`, a = await p(`git branch -r --merged ${t}`, {
1697
1697
  encoding: "utf8"
1698
- }), n = await p(`git branch --merged ${t}`, {
1698
+ }), s = await p(`git branch --merged ${t}`, {
1699
1699
  encoding: "utf8"
1700
- }), s = /* @__PURE__ */ new Map();
1700
+ }), n = /* @__PURE__ */ new Map();
1701
1701
  return a.split(`
1702
1702
  `).forEach((i) => {
1703
1703
  const o = i.trim();
1704
- if (o && o !== t && !o.startsWith(`${Ie}HEAD`) && !In.includes(o)) {
1704
+ if (o && o !== t && !o.startsWith(`${Ie}HEAD`) && !Is.includes(o)) {
1705
1705
  const r = o.replace(new RegExp(`^${Ie}`), "");
1706
- s.set(r, {
1706
+ n.set(r, {
1707
1707
  name: r,
1708
1708
  value: r,
1709
- hasLocal: s.get(r)?.hasLocal ?? !1,
1709
+ hasLocal: n.get(r)?.hasLocal ?? !1,
1710
1710
  hasRemote: !0
1711
1711
  });
1712
1712
  }
1713
- }), n.split(`
1713
+ }), s.split(`
1714
1714
  `).forEach((i) => {
1715
1715
  const o = i.replace(/^\*?\s*/, "").trim();
1716
- if (o && o !== e && !Rn.includes(o)) {
1717
- const r = s.get(o);
1718
- s.set(o, {
1716
+ if (o && o !== e && !Rs.includes(o)) {
1717
+ const r = n.get(o);
1718
+ n.set(o, {
1719
1719
  name: o,
1720
1720
  value: o,
1721
1721
  hasLocal: !0,
1722
1722
  hasRemote: r?.hasRemote ?? !1
1723
1723
  });
1724
1724
  }
1725
- }), [...s.values()].map((i) => ({
1725
+ }), [...n.values()].map((i) => ({
1726
1726
  ...i,
1727
1727
  name: `${i.value}${i.hasRemote && i.hasLocal ? "(本地/远程)" : i.hasRemote ? "(远程)" : "(本地)"}`
1728
1728
  })).sort((i, o) => i.value.localeCompare(o.value));
1729
- }, Ln = (e) => V({
1729
+ }, Ls = (e) => V({
1730
1730
  message: "请选择需要删除的分支",
1731
1731
  options: (t) => t ? e.filter((a) => a.name.includes(t)) : e,
1732
1732
  pageSize: 20,
@@ -1740,18 +1740,18 @@ const Ie = "origin/", In = Object.values(w).map((e) => `${Ie}${e}`), Rn = Object
1740
1740
  renderSelectedOptions: (t) => t.map((a) => a.value).join(", ")
1741
1741
  }
1742
1742
  }
1743
- }), xn = async (e) => (await p(`git branch --list ${e}`)).trim() !== "", Pn = (e) => {
1743
+ }), xs = async (e) => (await p(`git branch --list ${e}`)).trim() !== "", Ps = (e) => {
1744
1744
  Ve(`git push origin --delete ${e}`);
1745
- }, Dn = (e) => {
1745
+ }, Ds = (e) => {
1746
1746
  Ve(`git branch -d ${e}`);
1747
- }, On = async () => {
1747
+ }, Os = async () => {
1748
1748
  await ge();
1749
- const e = y(`正在查询本地和远程已经合并到${Ee}的分支...`).start(), t = await Cn(Ee);
1749
+ const e = y(`正在查询本地和远程已经合并到${Ee}的分支...`).start(), t = await Cs(Ee);
1750
1750
  if (e.succeed(`查询到 ${t.length} 个已合并到 ${Ee} 的分支`), !t.length) {
1751
1751
  J(`未查询到已合并到 ${Ee} 的可删除分支`);
1752
1752
  return;
1753
1753
  }
1754
- const a = await Ln(t);
1754
+ const a = await Ls(t);
1755
1755
  if (!await Le({
1756
1756
  message: `确认删除选中的 ${a.length} 个分支对应的远程分支和本地分支?`,
1757
1757
  default: !1
@@ -1759,21 +1759,21 @@ const Ie = "origin/", In = Object.values(w).map((e) => `${Ie}${e}`), Rn = Object
1759
1759
  J("已取消删除");
1760
1760
  return;
1761
1761
  }
1762
- const s = await p("git branch --show-current"), i = [], o = [], r = [], c = t.filter((l) => a.includes(l.value)), u = y("正在删除分支...").start();
1762
+ const n = await p("git branch --show-current"), i = [], o = [], r = [], c = t.filter((l) => a.includes(l.value)), u = y("正在删除分支...").start();
1763
1763
  try {
1764
1764
  for (const l of c) {
1765
1765
  const { value: d, hasLocal: g, hasRemote: h } = l;
1766
- if (h && (u.text = `正在删除远程分支 ${d}...`, Pn(d), o.push(d)), d === s) {
1766
+ if (h && (u.text = `正在删除远程分支 ${d}...`, Ps(d), o.push(d)), d === n) {
1767
1767
  g && i.push(d);
1768
1768
  continue;
1769
1769
  }
1770
- !g || !await xn(d) || (u.text = `正在删除本地分支 ${d}...`, Dn(d), r.push(d));
1770
+ !g || !await xs(d) || (u.text = `正在删除本地分支 ${d}...`, Ds(d), r.push(d));
1771
1771
  }
1772
1772
  } catch (l) {
1773
1773
  throw u.fail("删除分支失败"), l;
1774
1774
  }
1775
1775
  u.succeed("分支删除完成"), o.length && U(`远程分支删除完成:${o.join(", ")}`), r.length && U(`本地分支删除完成:${r.join(", ")}`), i.length && J(`${i.join(", ")} 为当前分支,无法删除本地分支`);
1776
- }, _t = "0000000000000000000000000000000000000000", ut = "refs/heads/", Mn = async (e, t) => {
1776
+ }, _t = "0000000000000000000000000000000000000000", ut = "refs/heads/", Ms = async (e, t) => {
1777
1777
  if (t === _t) {
1778
1778
  try {
1779
1779
  const a = await p(`git rev-parse --verify --quiet origin/${w.MASTER}`);
@@ -1784,48 +1784,48 @@ const Ie = "origin/", In = Object.values(w).map((e) => `${Ie}${e}`), Rn = Object
1784
1784
  return null;
1785
1785
  }
1786
1786
  return `${t}..${e}`;
1787
- }, Bn = async (e) => {
1787
+ }, Bs = async (e) => {
1788
1788
  try {
1789
1789
  return (await p(`git log ${e} --grep="(cherry picked from commit" --format="%H"`)).split(`
1790
1790
  `).filter(Boolean);
1791
1791
  } catch {
1792
1792
  return [];
1793
1793
  }
1794
- }, zn = async (e) => {
1794
+ }, zs = async (e) => {
1795
1795
  try {
1796
1796
  return (await p(`git log ${e} --format="%H %at %ct"`)).split(`
1797
1797
  `).flatMap((a) => {
1798
- const [n, s, i] = a.split(" ");
1799
- return n && s !== i ? [n] : [];
1798
+ const [s, n, i] = a.split(" ");
1799
+ return s && n !== i ? [s] : [];
1800
1800
  });
1801
1801
  } catch {
1802
1802
  return [];
1803
1803
  }
1804
- }, _n = async () => {
1804
+ }, _s = async () => {
1805
1805
  const { skipGitPushLimit: e } = W(), t = Object.values(w), a = dt(0, "utf-8");
1806
1806
  if (!a)
1807
1807
  return;
1808
- const n = a.trim().split(`
1809
- `), s = n.length;
1810
- for (let i = 0; i < s; i++) {
1811
- const [, o, r, c] = n[i].split(/\s+/);
1808
+ const s = a.trim().split(`
1809
+ `), n = s.length;
1810
+ for (let i = 0; i < n; i++) {
1811
+ const [, o, r, c] = s[i].split(/\s+/);
1812
1812
  if (!r.startsWith(ut) || o === _t)
1813
1813
  continue;
1814
1814
  const u = r.replace(ut, "");
1815
1815
  !e && t.includes(u) && m(`禁止直接 Push 到环境分支:${u}`);
1816
- const l = await Mn(o, c);
1816
+ const l = await Ms(o, c);
1817
1817
  if (!l)
1818
1818
  continue;
1819
1819
  const [d, g] = await Promise.all([
1820
- Bn(l),
1821
- zn(l)
1820
+ Bs(l),
1821
+ zs(l)
1822
1822
  ]), h = [.../* @__PURE__ */ new Set([...d, ...g])];
1823
1823
  h.length > 0 && m(`以下提交中检测到包含 cherry-pick 特征,本次 Push 已被拒绝
1824
1824
  ${h.join(`
1825
1825
  `)}`);
1826
1826
  }
1827
1827
  };
1828
- async function Fn() {
1828
+ async function Fs() {
1829
1829
  j(f.resolve("node_modules", ".bin", "markdownlint")) || m("该项目未安装markdownlint,请安装后重试");
1830
1830
  const e = y("markdownlint执行中...").start();
1831
1831
  try {
@@ -1836,26 +1836,26 @@ async function Fn() {
1836
1836
  e.fail("markdownlint校验出错"), process.exit(1);
1837
1837
  }
1838
1838
  }
1839
- const Gn = () => {
1839
+ const Gs = () => {
1840
1840
  m("禁止执行 rebase,请使用 git merge!");
1841
1841
  };
1842
- function Jn() {
1842
+ function Js() {
1843
1843
  const e = W();
1844
1844
  if (e["lint-staged"])
1845
1845
  return e["lint-staged"];
1846
1846
  throw new Error("未找到lint配置");
1847
1847
  }
1848
- async function Un() {
1848
+ async function Us() {
1849
1849
  const e = y("代码风格检测中...").start();
1850
1850
  await da({
1851
1851
  concurrent: 4,
1852
1852
  debug: !1,
1853
- config: Jn(),
1853
+ config: Js(),
1854
1854
  quiet: !0,
1855
1855
  relative: !0
1856
1856
  }) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
1857
1857
  }
1858
- function Vn(e) {
1858
+ function Vs(e) {
1859
1859
  if (e.includes("Merge") && e.includes("# Conflicts:") || fa.valid(e))
1860
1860
  return !0;
1861
1861
  const t = e.split(": ");
@@ -1864,11 +1864,11 @@ function Vn(e) {
1864
1864
  const a = t[0];
1865
1865
  return /^(feat|fix|refactor)/.test(a) ? /\(\d+(?:,\d+)*\)/.test(a) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(a) ? [T.CHORE, T.CI].includes(a) ? !0 : "chore/ci类型无需填写ID。" : T.Break === a ? !0 : "不存在的提交类型。";
1866
1866
  }
1867
- async function Wn() {
1868
- const e = await _e(f.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), a = Vn(e);
1867
+ async function Ws() {
1868
+ const e = await _e(f.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), a = Vs(e);
1869
1869
  a === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${a}`), process.exit(1));
1870
1870
  }
1871
- async function Hn() {
1871
+ async function Hs() {
1872
1872
  await ge();
1873
1873
  const e = await ga({
1874
1874
  // 分组,展示仓库链接
@@ -1882,12 +1882,12 @@ async function Hn() {
1882
1882
  });
1883
1883
  if (e && Object.keys(e).length) {
1884
1884
  U("升级完成 🎉");
1885
- const t = Object.entries(e).map(([a, n]) => `${a}@${n}`).join("; ");
1885
+ const t = Object.entries(e).map(([a, s]) => `${a}@${s}`).join("; ");
1886
1886
  await p(`git add . && git commit -m "chore: 依赖升级。${t}"`);
1887
1887
  }
1888
1888
  process.exit(0);
1889
1889
  }
1890
- async function qn(e) {
1890
+ async function qs(e) {
1891
1891
  j(f.resolve("node_modules", ".bin", "eslint")) || m("该项目未安装eslint,请安装后重试");
1892
1892
  const t = y("eslint执行中...").start();
1893
1893
  try {
@@ -1899,7 +1899,7 @@ async function qn(e) {
1899
1899
  t.fail("eslint校验出错"), process.exit(1);
1900
1900
  }
1901
1901
  }
1902
- async function Zn() {
1902
+ async function Zs() {
1903
1903
  j(f.resolve("node_modules", ".bin", "prettier")) || m("该项目未安装prettier,请安装后重试");
1904
1904
  const e = y("prettier执行中...").start();
1905
1905
  try {
@@ -1913,10 +1913,10 @@ async function Zn() {
1913
1913
  e.fail("prettier校验出错"), process.exit(1);
1914
1914
  }
1915
1915
  }
1916
- function Kn() {
1916
+ function Ks() {
1917
1917
  j(f.resolve("./node_modules/.bin/vue-tsc")) || m("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), Ve("npx vue-tsc --build"), process.exit(0);
1918
1918
  }
1919
- const Yn = [
1919
+ const Ys = [
1920
1920
  [
1921
1921
  "cm",
1922
1922
  "commit-msg"
@@ -1972,7 +1972,7 @@ const Yn = [
1972
1972
  "detect-push"
1973
1973
  /* DetectPush */
1974
1974
  ]
1975
- ], Xn = {
1975
+ ], Xs = {
1976
1976
  [$.JAVA]: [
1977
1977
  {
1978
1978
  name: "执行 check-style",
@@ -2019,30 +2019,30 @@ const Yn = [
2019
2019
  /* DependencyCheck */
2020
2020
  }
2021
2021
  ]
2022
- }, Qn = (e) => Reflect.get(Xn, e) ?? [], ei = {
2023
- "commit-msg": Wn,
2024
- "commit-files": Un,
2025
- prettier: Zn,
2026
- eslint: qn,
2027
- "type-check": Kn,
2028
- "dependency-check": Hn,
2029
- checkstyle: En,
2030
- "markdown-lint": Fn,
2031
- "delete-merged": On,
2032
- "not-allow-rebase": Gn,
2033
- "detect-push": _n
2022
+ }, Qs = (e) => Reflect.get(Xs, e) ?? [], ei = {
2023
+ "commit-msg": Ws,
2024
+ "commit-files": Us,
2025
+ prettier: Zs,
2026
+ eslint: qs,
2027
+ "type-check": Ks,
2028
+ "dependency-check": Hs,
2029
+ checkstyle: Es,
2030
+ "markdown-lint": Fs,
2031
+ "delete-merged": Os,
2032
+ "not-allow-rebase": Gs,
2033
+ "detect-push": _s
2034
2034
  }, ti = async (e, t) => {
2035
2035
  const a = Reflect.get(ei, e);
2036
2036
  a && typeof a == "function" && await a(t);
2037
2037
  }, ai = (e) => {
2038
- for (const [t, a] of Yn)
2038
+ for (const [t, a] of Ys)
2039
2039
  if (e === t || e === a)
2040
2040
  return a;
2041
2041
  m("参数输入错误");
2042
2042
  };
2043
- async function si(e, t) {
2043
+ async function ni(e, t) {
2044
2044
  ee(), H();
2045
- const a = W(), n = e ? ai(e) : await E({
2045
+ const a = W(), s = e ? ai(e) : await E({
2046
2046
  message: "请选择你要执行的操作",
2047
2047
  choices: [
2048
2048
  {
@@ -2050,7 +2050,7 @@ async function si(e, t) {
2050
2050
  value: "prettier"
2051
2051
  /* Prettier */
2052
2052
  },
2053
- ...Qn(a.language),
2053
+ ...Qs(a.language),
2054
2054
  {
2055
2055
  name: "执行 delete-merged",
2056
2056
  value: "delete-merged"
@@ -2058,12 +2058,12 @@ async function si(e, t) {
2058
2058
  }
2059
2059
  ]
2060
2060
  });
2061
- await ti(n, t);
2061
+ await ti(s, t);
2062
2062
  }
2063
2063
  P.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint / delete-merged。").argument(
2064
2064
  "[type]",
2065
2065
  "非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs, markdown-lint|ml, delete-merged|dm。"
2066
- ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => B(si, ...e));
2066
+ ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => B(ni, ...e));
2067
2067
  async function Ft(e = "latest") {
2068
2068
  const t = y("安装中...").start();
2069
2069
  await p(`npm i -g ${ce.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", de("latestCheckVersionTimestamp", Date.now()), de("version", e);
@@ -2092,13 +2092,13 @@ function Jt(e) {
2092
2092
  };
2093
2093
  }
2094
2094
  async function ie(e, t = {}) {
2095
- const { exclude: a = Ke } = t, n = [];
2096
- async function s(i) {
2095
+ const { exclude: a = Ke } = t, s = [];
2096
+ async function n(i) {
2097
2097
  const o = f.basename(i);
2098
- if ((await na(i)).isFile())
2098
+ if ((await sa(i)).isFile())
2099
2099
  return null;
2100
2100
  const c = await Ue(i, { withFileTypes: !0 }), u = (await Promise.all(
2101
- c.filter((v) => v.isDirectory() && !a.test(v.name)).map((v) => s(f.join(i, v.name)))
2101
+ c.filter((v) => v.isDirectory() && !a.test(v.name)).map((v) => n(f.join(i, v.name)))
2102
2102
  )).filter(Boolean), { type: l, id: d, displayName: g } = Jt(o), h = {
2103
2103
  name: o,
2104
2104
  id: d,
@@ -2107,19 +2107,19 @@ async function ie(e, t = {}) {
2107
2107
  type: l,
2108
2108
  children: u
2109
2109
  };
2110
- return (t.hasRoot || f.resolve(e) !== i) && n.push(h), h;
2110
+ return (t.hasRoot || f.resolve(e) !== i) && s.push(h), h;
2111
2111
  }
2112
- return await s(f.resolve(e)), n;
2112
+ return await n(f.resolve(e)), s;
2113
2113
  }
2114
2114
  async function Ut(e, t = {}) {
2115
2115
  const { exclude: a = Ke } = t;
2116
2116
  try {
2117
- const n = await Ue(f.resolve(e), { withFileTypes: !0 });
2117
+ const s = await Ue(f.resolve(e), { withFileTypes: !0 });
2118
2118
  return await Promise.all(
2119
- n.filter((s) => s.isDirectory() && !a.test(s.name)).map((s) => {
2120
- const i = f.join(e, s.name), { type: o, id: r, displayName: c } = Jt(s.name);
2119
+ s.filter((n) => n.isDirectory() && !a.test(n.name)).map((n) => {
2120
+ const i = f.join(e, n.name), { type: o, id: r, displayName: c } = Jt(n.name);
2121
2121
  return {
2122
- name: s.name,
2122
+ name: n.name,
2123
2123
  id: r,
2124
2124
  displayName: c,
2125
2125
  path: i,
@@ -2127,8 +2127,8 @@ async function Ut(e, t = {}) {
2127
2127
  };
2128
2128
  })
2129
2129
  );
2130
- } catch (n) {
2131
- return m(`读取目录失败: ${e} : ${n}`), [];
2130
+ } catch (s) {
2131
+ return m(`读取目录失败: ${e} : ${s}`), [];
2132
2132
  }
2133
2133
  }
2134
2134
  function Q(e, t, a) {
@@ -2141,29 +2141,29 @@ function Q(e, t, a) {
2141
2141
  return t;
2142
2142
  }
2143
2143
  }
2144
- async function je(e, t, a, n) {
2144
+ async function je(e, t, a, s) {
2145
2145
  try {
2146
- const s = f.basename(e), i = Q(a, t, n);
2147
- if (s === i)
2146
+ const n = f.basename(e), i = Q(a, t, s);
2147
+ if (n === i)
2148
2148
  return !0;
2149
2149
  const o = f.dirname(e), r = f.join(o, i);
2150
2150
  return await Ja(e) ? await ft(e, r) : (await p(`git mv "${e}" "${r}"`), await p("git add .")), !0;
2151
- } catch (s) {
2152
- return m(`重命名文件夹失败: ${e} -> ${t}。${s}`), !1;
2151
+ } catch (n) {
2152
+ return m(`重命名文件夹失败: ${e} -> ${t}。${n}`), !1;
2153
2153
  }
2154
2154
  }
2155
- async function ni(e, t, a = {}) {
2156
- const { exclude: n = Ke } = a;
2157
- async function s(i, o) {
2155
+ async function si(e, t, a = {}) {
2156
+ const { exclude: s = Ke } = a;
2157
+ async function n(i, o) {
2158
2158
  if (!i || i.length === 0) return;
2159
- const r = await Ut(o, { exclude: n });
2159
+ const r = await Ut(o, { exclude: s });
2160
2160
  for (const c of i) {
2161
2161
  const u = String(c.value), l = Q("module", c.label, u), d = r.find((h) => h.id === u);
2162
2162
  let g = d?.path || f.join(o, l);
2163
- d ? d.displayName !== c.label && await je(d.path, c.label, "module", u) && (g = f.join(o, l)) : (await fe(g, { recursive: !0 }), await p(`git add "${g}"`)), c.children && c.children.length > 0 && await s(c.children, g);
2163
+ d ? d.displayName !== c.label && await je(d.path, c.label, "module", u) && (g = f.join(o, l)) : (await fe(g, { recursive: !0 }), await p(`git add "${g}"`)), c.children && c.children.length > 0 && await n(c.children, g);
2164
2164
  }
2165
2165
  }
2166
- await s(e, f.resolve(t));
2166
+ await n(e, f.resolve(t));
2167
2167
  }
2168
2168
  async function Vt(e) {
2169
2169
  const t = {
@@ -2174,16 +2174,16 @@ async function Vt(e) {
2174
2174
  if (e)
2175
2175
  Number.isNaN(Number(e)) && m("请输入正确的产品ID"), t.id = Number(e);
2176
2176
  else {
2177
- const a = await rs();
2177
+ const a = await on();
2178
2178
  t.id = await E({
2179
2179
  message: "请选择产品",
2180
- choices: a.map((n) => ({
2181
- name: `${n.label}[${n.value}]`,
2182
- value: n.value
2180
+ choices: a.map((s) => ({
2181
+ name: `${s.label}[${s.value}]`,
2182
+ value: s.value
2183
2183
  }))
2184
2184
  });
2185
2185
  }
2186
- return t.name = await os(t.id), t.path = f.join(Gt, Q("module", t.name, String(t.id))), t;
2186
+ return t.name = await cn(t.id), t.path = f.join(Gt, Q("module", t.name, String(t.id))), t;
2187
2187
  }
2188
2188
  async function Ye(e) {
2189
2189
  return (await Ut(Gt)).find((a) => Number(a.id) === e.id);
@@ -2194,7 +2194,7 @@ async function Wt(e, t) {
2194
2194
  priority: e.pri,
2195
2195
  steps: []
2196
2196
  };
2197
- a.steps = await ls(e.id), L.writeJSONSync(t, a, {
2197
+ a.steps = await un(e.id), L.writeJSONSync(t, a, {
2198
2198
  spaces: 2
2199
2199
  });
2200
2200
  }
@@ -2203,17 +2203,17 @@ async function Ht(e, t) {
2203
2203
  recursive: !0
2204
2204
  }), await Wt(e, f.join(t, "config.json")), L.ensureFileSync(f.join(t, "data.yaml")), await _(
2205
2205
  f.join(t, "data.yaml"),
2206
- j(f.resolve(K, "data.yaml")) ? await _e(f.resolve(K, "data.yaml")) : await Fs()
2206
+ j(f.resolve(K, "data.yaml")) ? await _e(f.resolve(K, "data.yaml")) : await Gn()
2207
2207
  ), L.ensureFileSync(f.join(t, "main.py")), await _(
2208
2208
  f.join(t, "main.py"),
2209
- j(f.resolve(K, "main.py")) ? await _e(f.resolve(K, "main.py")) : await Gs()
2209
+ j(f.resolve(K, "main.py")) ? await _e(f.resolve(K, "main.py")) : await Jn()
2210
2210
  );
2211
2211
  }
2212
2212
  function Xe(e) {
2213
2213
  if (e) {
2214
2214
  const t = e.split(",").map((a) => a.trim()).filter((a) => {
2215
- const n = Number(a);
2216
- return Number.isInteger(n) && n > 0;
2215
+ const s = Number(a);
2216
+ return Number.isInteger(s) && s > 0;
2217
2217
  }).map((a) => Number(a));
2218
2218
  return t.length === 0 ? (m('未找到有效的ID,请输入格式如 "1,2,3,4" 的正整数ID'), []) : t;
2219
2219
  }
@@ -2226,10 +2226,10 @@ async function Oe(e, t) {
2226
2226
  message: `请选择要${e}的数据类型`,
2227
2227
  choices: Ca
2228
2228
  });
2229
- const n = a === C.MODULE ? "模块" : C.CASE === a ? "用例" : "";
2229
+ const s = a === C.MODULE ? "模块" : C.CASE === a ? "用例" : "";
2230
2230
  return {
2231
2231
  type: a,
2232
- typeStr: n
2232
+ typeStr: s
2233
2233
  };
2234
2234
  }
2235
2235
  async function Me(e) {
@@ -2241,10 +2241,10 @@ async function Me(e) {
2241
2241
  }
2242
2242
  async function ii(e, t, a) {
2243
2243
  e.text = "查找本地产品目录...", await Ye(t) || m(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
2244
- const s = Xe(a);
2244
+ const n = Xe(a);
2245
2245
  let i = await ie(t.path);
2246
2246
  e.text = "获取远程用例列表...";
2247
- const o = await cs(t.id, s);
2247
+ const o = await ln(t.id, n);
2248
2248
  e.text = "本地用例同步中...";
2249
2249
  for (const r of o) {
2250
2250
  let c;
@@ -2266,15 +2266,15 @@ async function ri(e, t) {
2266
2266
  e.text = "本地产品目录查找中...";
2267
2267
  const a = await Ye(t);
2268
2268
  a ? (e.text = "找到产品目录。开始重命名...", a.displayName !== t.name && await je(a.path, t.name, a.type, a.id) && (e.text = `重命名成功: ${a.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await fe(t.path, { recursive: !0 }), await p("git add .")), e.text = "获取远程模块列表...";
2269
- const n = await Rt(t.id);
2270
- e.text = "本地同步模块中...", await ni(n || [], t.path);
2269
+ const s = await Rt(t.id);
2270
+ e.text = "本地同步模块中...", await si(s || [], t.path);
2271
2271
  }
2272
2272
  async function oi(e, t) {
2273
- const { type: a, typeStr: n } = await Oe("拉取", e), s = await Vt(t.productId), i = y(`${n}同步中...`).start();
2274
- if (C.MODULE === a && await ri(i, s), C.CASE === a && await ii(i, s, t.caseIds), i.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await p("git status -s")) {
2273
+ const { type: a, typeStr: s } = await Oe("拉取", e), n = await Vt(t.productId), i = y(`${s}同步中...`).start();
2274
+ if (C.MODULE === a && await ri(i, n), C.CASE === a && await ii(i, n, t.caseIds), i.succeed(`${s}同步完成 🎉`), !t.disableAutoCommit && await p("git status -s")) {
2275
2275
  const o = y("代码提交中...").start();
2276
2276
  try {
2277
- await p(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
2277
+ await p(`git add . && git commit -m "chore: 同步禅道${s}数据"`), o.succeed("代码已提交 ✅");
2278
2278
  } catch (r) {
2279
2279
  o.fail(`提交失败,${r}`), process.exit(1);
2280
2280
  }
@@ -2282,84 +2282,84 @@ async function oi(e, t) {
2282
2282
  }
2283
2283
  P.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) => B(oi, ...e));
2284
2284
  async function ci(e, t, a) {
2285
- let n = await F({
2285
+ let s = await F({
2286
2286
  message: "请输入你要创建的用例的前置条件(可不填)"
2287
2287
  });
2288
- n = n.trim();
2289
- const s = y(`用例【${a}】开始创建...`).start();
2290
- s.text = "远程用例创建中...";
2291
- const i = await ps({
2288
+ s = s.trim();
2289
+ const n = y(`用例【${a}】开始创建...`).start();
2290
+ n.text = "远程用例创建中...";
2291
+ const i = await mn({
2292
2292
  product: Number(e.id),
2293
2293
  // 如果父模块是产品根目录,parent=0
2294
2294
  module: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
2295
2295
  title: a,
2296
2296
  type: "interface",
2297
2297
  openedBy: I("ldapAccount"),
2298
- precondition: n || ""
2298
+ precondition: s || ""
2299
2299
  });
2300
- s.text = "远程用例步骤创建中...", await ms({
2300
+ n.text = "远程用例步骤创建中...", await dn({
2301
2301
  case: i,
2302
2302
  type: "step",
2303
2303
  desc: "按照预期执行",
2304
2304
  expect: "正常执行,符合预期"
2305
- }), s.text = "本地用例创建中...";
2305
+ }), n.text = "本地用例创建中...";
2306
2306
  const o = f.join(t.path, Q("case", a, String(i)));
2307
2307
  return j(o) ? U(`${o}已存在,请检查是否对应,本地不再创建。`) : (await Ht(
2308
2308
  {
2309
2309
  id: i,
2310
2310
  pri: 3,
2311
- precondition: n
2311
+ precondition: s
2312
2312
  },
2313
2313
  o
2314
- ), s.succeed(`用例【[${o}】创建完成 🎉`), o);
2314
+ ), n.succeed(`用例【[${o}】创建完成 🎉`), o);
2315
2315
  }
2316
2316
  async function li(e, t, a) {
2317
- const n = y(`模块【${a}】开始创建...`).start();
2318
- n.text = "远程模块创建中...";
2319
- const s = await us({
2317
+ const s = y(`模块【${a}】开始创建...`).start();
2318
+ s.text = "远程模块创建中...";
2319
+ const n = await pn({
2320
2320
  root: Number(e.id),
2321
2321
  name: a,
2322
2322
  // 如果父模块是产品根目录,parent=0
2323
2323
  parent: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
2324
2324
  });
2325
- n.text = "本地模块创建中...";
2326
- const i = f.join(t.path, Q("module", a, String(s)));
2325
+ s.text = "本地模块创建中...";
2326
+ const i = f.join(t.path, Q("module", a, String(n)));
2327
2327
  if (j(i))
2328
2328
  return U(`${i}已存在,请检查是否对应,本地不再创建。`);
2329
2329
  await fe(i, {
2330
2330
  recursive: !0
2331
- }), n.succeed(`模块【${i}】创建完成 🎉`);
2331
+ }), s.succeed(`模块【${i}】创建完成 🎉`);
2332
2332
  }
2333
2333
  function ui(e) {
2334
- function t(n) {
2335
- if (!n.children || n.children.length === 0) return;
2336
- const s = n.children[0];
2337
- s && s.label === n.label && s.value === n.value && (!s.children || s.children.length === 0) || n.children.unshift({
2338
- value: n.value,
2339
- label: n.label,
2340
- type: n.type,
2334
+ function t(s) {
2335
+ if (!s.children || s.children.length === 0) return;
2336
+ const n = s.children[0];
2337
+ n && n.label === s.label && n.value === s.value && (!n.children || n.children.length === 0) || s.children.unshift({
2338
+ value: s.value,
2339
+ label: s.label,
2340
+ type: s.type,
2341
2341
  children: void 0,
2342
2342
  tempTitle: "当前层级"
2343
2343
  });
2344
2344
  }
2345
- async function a(n, s = []) {
2346
- const i = s.length ? `请选择层级(当前:${s.join(" / ")})` : "请选择层级", o = await E({
2345
+ async function a(s, n = []) {
2346
+ const i = n.length ? `请选择层级(当前:${n.join(" / ")})` : "请选择层级", o = await E({
2347
2347
  message: i,
2348
- choices: n.map((r) => ({
2348
+ choices: s.map((r) => ({
2349
2349
  name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
2350
2350
  value: r
2351
2351
  }))
2352
2352
  });
2353
- return o?.children?.length ? (t(o), a(o.children, [...s, o.label])) : o;
2353
+ return o?.children?.length ? (t(o), a(o.children, [...n, o.label])) : o;
2354
2354
  }
2355
2355
  return a(e);
2356
2356
  }
2357
2357
  async function pi(e, t) {
2358
- const { type: a, typeStr: n } = await Oe("创建", e), { product: s, localProduct: i } = await Me(t.productId), o = await Rt(s.id), r = await ui(o), c = Q("module", r.label, String(r.value)), l = (await ie(s.path, { hasRoot: !0 })).find((h) => h.name === c);
2358
+ const { type: a, typeStr: s } = await Oe("创建", e), { product: n, localProduct: i } = await Me(t.productId), o = await Rt(n.id), r = await ui(o), c = Q("module", r.label, String(r.value)), l = (await ie(n.path, { hasRoot: !0 })).find((h) => h.name === c);
2359
2359
  if (!l?.path || !j(l.path))
2360
2360
  return m(`本地不存在${c}模块`);
2361
2361
  let d = await F({
2362
- message: `请输入你要创建的${n}名称`,
2362
+ message: `请输入你要创建的${s}名称`,
2363
2363
  required: !0,
2364
2364
  validate: (h) => h.length > 0 && h.length < 255
2365
2365
  });
@@ -2376,22 +2376,22 @@ async function pi(e, t) {
2376
2376
  }
2377
2377
  P.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => B(pi, ...e));
2378
2378
  async function mi(e, t) {
2379
- const n = (await ie(e.path)).filter((r) => r.type === "case");
2380
- let s = [];
2379
+ const s = (await ie(e.path)).filter((r) => r.type === "case");
2380
+ let n = [];
2381
2381
  if (t.length)
2382
- s = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
2382
+ n = s.filter((r) => t.includes(Number(r.id))).map((r) => ({
2383
2383
  id: Number(r.id),
2384
2384
  path: r.path
2385
- })), s.length || m(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
2385
+ })), n.length || m(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
2386
2386
  else {
2387
- const r = n.map((c) => ({
2387
+ const r = s.map((c) => ({
2388
2388
  value: {
2389
2389
  id: Number(c.id),
2390
2390
  path: c.path
2391
2391
  },
2392
2392
  name: c.path.replace(f.resolve(e.path), "")
2393
2393
  }));
2394
- s = await V({
2394
+ n = await V({
2395
2395
  message: "选择要删除的用例",
2396
2396
  pageSize: 100,
2397
2397
  loop: !1,
@@ -2401,32 +2401,32 @@ async function mi(e, t) {
2401
2401
  }
2402
2402
  });
2403
2403
  }
2404
- const i = y("远程用例删除中...").start(), o = s.map((r) => r.id);
2405
- await fs({
2404
+ const i = y("远程用例删除中...").start(), o = n.map((r) => r.id);
2405
+ await gn({
2406
2406
  product: Number(e.id),
2407
2407
  caseIds: o
2408
2408
  }), i.text = "本地用例删除中...";
2409
- for (const r of s)
2409
+ for (const r of n)
2410
2410
  j(r.path) && N.rm("-rf", r.path);
2411
2411
  return i.succeed("用例删除完成"), o;
2412
2412
  }
2413
2413
  async function di(e, t) {
2414
- const n = (await ie(e.path)).filter((r) => r.type === "module");
2415
- let s = [];
2414
+ const s = (await ie(e.path)).filter((r) => r.type === "module");
2415
+ let n = [];
2416
2416
  if (t.length)
2417
- s = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
2417
+ n = s.filter((r) => t.includes(Number(r.id))).map((r) => ({
2418
2418
  id: Number(r.id),
2419
2419
  path: r.path
2420
- })), s.length || m(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
2420
+ })), n.length || m(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
2421
2421
  else {
2422
- const r = n.map((c) => ({
2422
+ const r = s.map((c) => ({
2423
2423
  value: {
2424
2424
  id: Number(c.id),
2425
2425
  path: c.path
2426
2426
  },
2427
2427
  name: c.path.replace(f.resolve(e.path), "")
2428
2428
  }));
2429
- s = await V({
2429
+ n = await V({
2430
2430
  message: "选择要删除的模块",
2431
2431
  pageSize: 100,
2432
2432
  loop: !1,
@@ -2436,23 +2436,23 @@ async function di(e, t) {
2436
2436
  }
2437
2437
  });
2438
2438
  }
2439
- s = s.sort((r, c) => r.path.localeCompare(c.path));
2440
- const i = y("远程模块删除中...").start(), o = s.map((r) => r.id);
2441
- await ds({
2439
+ n = n.sort((r, c) => r.path.localeCompare(c.path));
2440
+ const i = y("远程模块删除中...").start(), o = n.map((r) => r.id);
2441
+ await fn({
2442
2442
  product: Number(e.id),
2443
2443
  moduleIds: o
2444
2444
  }), i.text = "本地模块删除中...";
2445
- for (const r of s)
2445
+ for (const r of n)
2446
2446
  j(r.path) && N.rm("-rf", r.path);
2447
2447
  return i.succeed("模块删除完成"), o;
2448
2448
  }
2449
2449
  async function fi(e, t) {
2450
- const { type: a, typeStr: n } = await Oe("删除", e), { localProduct: s } = await Me(t.productId), i = Xe(t.targetIds);
2450
+ const { type: a, typeStr: s } = await Oe("删除", e), { localProduct: n } = await Me(t.productId), i = Xe(t.targetIds);
2451
2451
  let o = [];
2452
- if (C.MODULE === a ? o = await di(s, i) : C.CASE === a && (o = await mi(s, i)), !t.disableAutoCommit && await p("git status -s")) {
2452
+ if (C.MODULE === a ? o = await di(n, i) : C.CASE === a && (o = await mi(n, i)), !t.disableAutoCommit && await p("git status -s")) {
2453
2453
  const r = y("代码提交中...").start();
2454
2454
  try {
2455
- await p(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
2455
+ await p(`git add . && git commit -m 'chore: 删除了一些${s}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
2456
2456
  } catch (c) {
2457
2457
  r.fail(`提交失败,${c}`), process.exit(1);
2458
2458
  }
@@ -2460,13 +2460,13 @@ async function fi(e, t) {
2460
2460
  }
2461
2461
  P.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) => B(fi, ...e));
2462
2462
  async function gi(e, t) {
2463
- const n = (await ie(e.path)).filter((g) => g.type === "case");
2464
- let s;
2463
+ const s = (await ie(e.path)).filter((g) => g.type === "case");
2464
+ let n;
2465
2465
  if (t.targetId) {
2466
- if (s = n.find((g) => Number(g.id) === Number(t.targetId)), !s)
2466
+ if (n = s.find((g) => Number(g.id) === Number(t.targetId)), !n)
2467
2467
  return m(`未找到对应用例,请确认输入的用例ID(${t.targetId})是否正确`);
2468
2468
  } else {
2469
- const g = n.map((h) => ({
2469
+ const g = s.map((h) => ({
2470
2470
  value: {
2471
2471
  id: Number(h.id),
2472
2472
  path: h.path,
@@ -2474,7 +2474,7 @@ async function gi(e, t) {
2474
2474
  },
2475
2475
  name: h.path.replace(f.resolve(e.path), "")
2476
2476
  }));
2477
- [s] = await V({
2477
+ [n] = await V({
2478
2478
  message: "选择要更新的用例",
2479
2479
  pageSize: 100,
2480
2480
  loop: !1,
@@ -2487,18 +2487,18 @@ async function gi(e, t) {
2487
2487
  }
2488
2488
  let i = await F({
2489
2489
  message: "修改用例名称",
2490
- default: s.displayName,
2490
+ default: n.displayName,
2491
2491
  required: !0,
2492
2492
  validate: (g) => g.length > 0 && g.length < 255,
2493
2493
  prefill: "editable"
2494
2494
  });
2495
2495
  i = i.trim();
2496
2496
  const o = y("用例重命名中...").start();
2497
- i !== s.displayName ? (await hs({
2498
- id: Number(s.id),
2497
+ i !== n.displayName ? (await wn({
2498
+ id: Number(n.id),
2499
2499
  name: i
2500
- }), await je(s.path, i, "case", String(s.id)) && o.succeed(`用例重命名成功: ${s.displayName} -> ${i}`), s.displayName = i, s.path = f.join(f.dirname(s.path), Q("case", i, String(s.id)))) : o.succeed("用例名称无变动");
2501
- let r = L.readJsonSync(f.join(s.path, "config.json")), c;
2500
+ }), await je(n.path, i, "case", String(n.id)) && o.succeed(`用例重命名成功: ${n.displayName} -> ${i}`), n.displayName = i, n.path = f.join(f.dirname(n.path), Q("case", i, String(n.id)))) : o.succeed("用例名称无变动");
2501
+ let r = L.readJsonSync(f.join(n.path, "config.json")), c;
2502
2502
  t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await at({
2503
2503
  message: "修改用例优先级",
2504
2504
  min: 1,
@@ -2515,17 +2515,17 @@ async function gi(e, t) {
2515
2515
  validate: (g) => g > 0 && g < 6
2516
2516
  });
2517
2517
  const u = y("用例优先级设置中...").start();
2518
- c !== r.priority ? (await ws({
2519
- id: Number(s.id),
2518
+ c !== r.priority ? (await yn({
2519
+ id: Number(n.id),
2520
2520
  priority: c
2521
2521
  }), L.writeJSONSync(
2522
- f.join(s.path, "config.json"),
2522
+ f.join(n.path, "config.json"),
2523
2523
  {
2524
2524
  ...r,
2525
2525
  priority: c
2526
2526
  },
2527
2527
  { spaces: 2 }
2528
- ), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = L.readJsonSync(f.join(s.path, "config.json"));
2528
+ ), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = L.readJsonSync(f.join(n.path, "config.json"));
2529
2529
  let l;
2530
2530
  t.casePrecondition ? l = t.casePrecondition : (l = await F({
2531
2531
  message: "修改用例前置条件",
@@ -2533,26 +2533,26 @@ async function gi(e, t) {
2533
2533
  prefill: "editable"
2534
2534
  }), l = l.trim());
2535
2535
  const d = y("用例前置条件设置中...").start();
2536
- return l !== r.precondition ? (await ys({
2537
- id: Number(s.id),
2536
+ return l !== r.precondition ? (await $n({
2537
+ id: Number(n.id),
2538
2538
  precondition: l
2539
2539
  }), L.writeJSONSync(
2540
- f.join(s.path, "config.json"),
2540
+ f.join(n.path, "config.json"),
2541
2541
  {
2542
2542
  ...r,
2543
2543
  precondition: l
2544
2544
  },
2545
2545
  { spaces: 2 }
2546
- ), d.succeed(`用例前置条件修改成功:${r.precondition} -> ${l}`)) : d.succeed("用例前置条件无变动"), s.id;
2546
+ ), d.succeed(`用例前置条件修改成功:${r.precondition} -> ${l}`)) : d.succeed("用例前置条件无变动"), n.id;
2547
2547
  }
2548
2548
  async function hi(e, t) {
2549
- const n = (await ie(e.path)).filter((r) => r.type === "module");
2550
- let s;
2549
+ const s = (await ie(e.path)).filter((r) => r.type === "module");
2550
+ let n;
2551
2551
  if (t.targetId) {
2552
- if (s = n.find((r) => Number(r.id) === Number(t.targetId)), !s)
2552
+ if (n = s.find((r) => Number(r.id) === Number(t.targetId)), !n)
2553
2553
  return m(`未找到对应模块,请确认输入的模块ID(${t.targetId})是否正确`);
2554
2554
  } else {
2555
- const r = n.map((c) => ({
2555
+ const r = s.map((c) => ({
2556
2556
  value: {
2557
2557
  id: Number(c.id),
2558
2558
  path: c.path,
@@ -2560,7 +2560,7 @@ async function hi(e, t) {
2560
2560
  },
2561
2561
  name: c.path.replace(f.resolve(e.path), "")
2562
2562
  }));
2563
- [s] = await V({
2563
+ [n] = await V({
2564
2564
  message: "选择要更新的模块",
2565
2565
  pageSize: 100,
2566
2566
  loop: !1,
@@ -2573,25 +2573,25 @@ async function hi(e, t) {
2573
2573
  }
2574
2574
  let i = await F({
2575
2575
  message: "修改模块名称",
2576
- default: s.displayName,
2576
+ default: n.displayName,
2577
2577
  required: !0,
2578
2578
  validate: (r) => r.length > 0 && r.length < 255,
2579
2579
  prefill: "editable"
2580
2580
  });
2581
2581
  i = i.trim();
2582
2582
  const o = y("模块重命名中...").start();
2583
- return i !== s.displayName ? (await gs({
2584
- id: Number(s.id),
2583
+ return i !== n.displayName ? (await hn({
2584
+ id: Number(n.id),
2585
2585
  name: i
2586
- }), await je(s.path, i, "module", String(s.id)) && o.succeed(`模块重命名成功: ${s.displayName} -> ${i}`)) : o.succeed("模块名称无变动"), s.id;
2586
+ }), await je(n.path, i, "module", String(n.id)) && o.succeed(`模块重命名成功: ${n.displayName} -> ${i}`)) : o.succeed("模块名称无变动"), n.id;
2587
2587
  }
2588
2588
  async function wi(e, t) {
2589
- const { type: a, typeStr: n } = await Oe("修改", e), { localProduct: s } = await Me(t.productId);
2589
+ const { type: a, typeStr: s } = await Oe("修改", e), { localProduct: n } = await Me(t.productId);
2590
2590
  let i;
2591
- if (C.MODULE === a ? i = await hi(s, t) : C.CASE === a && (i = await gi(s, t)), !t.disableAutoCommit && await p("git status -s")) {
2591
+ if (C.MODULE === a ? i = await hi(n, t) : C.CASE === a && (i = await gi(n, t)), !t.disableAutoCommit && await p("git status -s")) {
2592
2592
  const o = y("代码提交中...").start();
2593
2593
  try {
2594
- await p(`git add . && git commit -m 'chore: 修改了一个${n}(${i})'`), o.succeed("代码已提交 ✅");
2594
+ await p(`git add . && git commit -m 'chore: 修改了一个${s}(${i})'`), o.succeed("代码已提交 ✅");
2595
2595
  } catch (r) {
2596
2596
  o.fail(`提交失败,${r}`), process.exit(1);
2597
2597
  }
@@ -2601,30 +2601,30 @@ P.command("qa-update").alias("qu").description("修改模块或者用例").argum
2601
2601
  async function yi(e, t) {
2602
2602
  if (!e.length)
2603
2603
  return [];
2604
- const a = ha(20), n = e.map(
2605
- (s) => a(async () => {
2604
+ const a = ha(20), s = e.map(
2605
+ (n) => a(async () => {
2606
2606
  try {
2607
- const i = t.env || "production", o = await p(`python ${s.path}/main.py --env ${i}`);
2607
+ const i = t.env || "production", o = await p(`python ${n.path}/main.py --env ${i}`);
2608
2608
  try {
2609
- s.result = JSON.parse(o);
2609
+ n.result = JSON.parse(o);
2610
2610
  } catch {
2611
- m(`用例${s.displayName}[${s.id}]返回格式错误:${o}`);
2611
+ m(`用例${n.displayName}[${n.id}]返回格式错误:${o}`);
2612
2612
  }
2613
2613
  } catch (i) {
2614
2614
  const o = i instanceof Error ? i.message : String(i);
2615
- m(`用例${s.displayName}[${s.id}]执行失败: ${o}`);
2615
+ m(`用例${n.displayName}[${n.id}]执行失败: ${o}`);
2616
2616
  }
2617
2617
  })
2618
2618
  );
2619
- return await Promise.all(n), e;
2619
+ return await Promise.all(s), e;
2620
2620
  }
2621
2621
  async function $i(e) {
2622
2622
  ee(), H();
2623
2623
  const { localProduct: t } = await Me(e.productId);
2624
2624
  let a = [];
2625
- const s = (await ie(t.path)).filter((c) => c.type === "case");
2625
+ const n = (await ie(t.path)).filter((c) => c.type === "case");
2626
2626
  if (e.all)
2627
- a = s.map((c) => ({
2627
+ a = n.map((c) => ({
2628
2628
  id: Number(c.id),
2629
2629
  path: c.path,
2630
2630
  displayName: c.displayName
@@ -2632,13 +2632,13 @@ async function $i(e) {
2632
2632
  else {
2633
2633
  const c = Xe(e.caseIds);
2634
2634
  if (c.length)
2635
- a = s.filter((u) => c.includes(Number(u.id))).map((u) => ({
2635
+ a = n.filter((u) => c.includes(Number(u.id))).map((u) => ({
2636
2636
  id: Number(u.id),
2637
2637
  path: u.path,
2638
2638
  displayName: u.displayName
2639
2639
  }));
2640
2640
  else {
2641
- const u = s.map((l) => ({
2641
+ const u = n.map((l) => ({
2642
2642
  value: {
2643
2643
  id: Number(l.id),
2644
2644
  path: l.path,
@@ -2669,10 +2669,10 @@ async function $i(e) {
2669
2669
  if (e.executionId)
2670
2670
  Number.isNaN(Number(e.executionId)) && m(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
2671
2671
  else {
2672
- const d = await vs(), g = await E({
2672
+ const d = await An(), g = await E({
2673
2673
  message: "请选择用例执行出错后,BUG所属的项目",
2674
2674
  choices: d.map(({ id: v, name: R }) => ({ name: R, value: v }))
2675
- }), h = await As(g);
2675
+ }), h = await bn(g);
2676
2676
  u = await E({
2677
2677
  message: "请选择用例执行出错后,BUG所属的执行",
2678
2678
  choices: h.map(({ id: v, name: R }) => ({ name: R, value: v }))
@@ -2682,7 +2682,7 @@ async function $i(e) {
2682
2682
  if (e.buildId)
2683
2683
  l = e.buildId;
2684
2684
  else {
2685
- const d = await bs(Number(u));
2685
+ const d = await Sn(Number(u));
2686
2686
  if (d.length) {
2687
2687
  const g = await Re({
2688
2688
  message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
@@ -2698,7 +2698,7 @@ async function $i(e) {
2698
2698
  }
2699
2699
  i.start("上传中...");
2700
2700
  for (const d of r)
2701
- await $s({
2701
+ await vn({
2702
2702
  caseId: d.id,
2703
2703
  caseResult: "fail",
2704
2704
  stepResults: d.result,
@@ -2713,43 +2713,43 @@ async function $i(e) {
2713
2713
  }
2714
2714
  P.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) => B($i, ...e));
2715
2715
  const vi = async () => {
2716
- const { projects: e } = await Os(), t = W();
2716
+ const { projects: e } = await Mn(), t = W();
2717
2717
  if (t.serverProjectURL) {
2718
- const n = e.find(
2719
- (s) => Pe(s.url, t.serverProjectURL)
2718
+ const s = e.find(
2719
+ (n) => Pe(n.url, t.serverProjectURL)
2720
2720
  );
2721
- if (n)
2721
+ if (s)
2722
2722
  return {
2723
- projectId: decodeURIComponent(se(t.serverProjectURL)),
2724
- moduleList: n.modules || []
2723
+ projectId: decodeURIComponent(ne(t.serverProjectURL)),
2724
+ moduleList: s.modules || []
2725
2725
  };
2726
2726
  }
2727
2727
  const a = await E({
2728
2728
  message: "请选择本项目对应的服务端项目",
2729
- choices: e.map((n) => ({
2730
- name: `${n.name}(${n.url})`,
2731
- value: n.url
2729
+ choices: e.map((s) => ({
2730
+ name: `${s.name}(${s.url})`,
2731
+ value: s.url
2732
2732
  }))
2733
2733
  });
2734
2734
  return It({ ...t, serverProjectURL: a }), {
2735
- projectId: decodeURIComponent(se(a)),
2736
- moduleList: e.find((n) => n.url === a)?.modules || []
2735
+ projectId: decodeURIComponent(ne(a)),
2736
+ moduleList: e.find((s) => s.url === a)?.modules || []
2737
2737
  };
2738
2738
  }, Ai = async (e, t) => {
2739
- const a = t ? t.split(",").filter((s) => e.map((i) => i.name).includes(s.trim())) : [];
2739
+ const a = t ? t.split(",").filter((n) => e.map((i) => i.name).includes(n.trim())) : [];
2740
2740
  if (a.length)
2741
2741
  return a;
2742
- const n = await Re({
2742
+ const s = await Re({
2743
2743
  message: "请选择对应的后端服务,不选默认全部",
2744
- choices: e.map((s) => ({
2745
- name: `${s.name}(${s.desc})`,
2746
- value: s.name
2744
+ choices: e.map((n) => ({
2745
+ name: `${n.name}(${n.desc})`,
2746
+ value: n.name
2747
2747
  })),
2748
2748
  required: !1,
2749
2749
  pageSize: 10,
2750
2750
  loop: !0
2751
2751
  });
2752
- return n?.length ? n : e.map((s) => s.name);
2752
+ return s?.length ? s : e.map((n) => n.name);
2753
2753
  }, pt = [O.DEV, O.TEST], bi = async (e) => e && pt.includes(e.trim()) ? e : await E({
2754
2754
  message: "请选择对应的环境",
2755
2755
  choices: At.filter((t) => pt.includes(t.value))
@@ -2758,12 +2758,12 @@ const vi = async () => {
2758
2758
  return e.match(t)?.[1];
2759
2759
  }, Si = async (e, t) => {
2760
2760
  try {
2761
- const a = await ne({
2761
+ const a = await se({
2762
2762
  url: e,
2763
2763
  method: "get"
2764
- }), n = Qe(e);
2765
- return n && (a.paths = Object.fromEntries(
2766
- Object.entries(a.paths).map(([s, i]) => [`/${n}${s}`, i])
2764
+ }), s = Qe(e);
2765
+ return s && (a.paths = Object.fromEntries(
2766
+ Object.entries(a.paths).map(([n, i]) => [`/${s}${n}`, i])
2767
2767
  )), wa(a, {
2768
2768
  throwOnValidateError: !t
2769
2769
  });
@@ -2772,36 +2772,36 @@ const vi = async () => {
2772
2772
  }
2773
2773
  }, Ni = (e) => {
2774
2774
  const t = (a) => {
2775
- const { reason: n, url: s } = a;
2776
- return `## ${Qe(s)}服务接口文档校验失败
2777
- ${n.message}`;
2775
+ const { reason: s, url: n } = a;
2776
+ return `## ${Qe(n)}服务接口文档校验失败
2777
+ ${s.message}`;
2778
2778
  };
2779
2779
  return `# 服务端接口文档校验失败
2780
2780
  ${e.map(t).join(`
2781
2781
  `)}`;
2782
2782
  }, ji = async (e, t) => {
2783
- const a = Ni(e), n = W(), { groups: s } = await Ct(), i = s.find(
2784
- (c) => c.projects.some((u) => Pe(u, n.serverProjectURL))
2783
+ const a = Ni(e), s = W(), { groups: n } = await Ct(), i = n.find(
2784
+ (c) => c.projects.some((u) => Pe(u, s.serverProjectURL))
2785
2785
  );
2786
2786
  t.fail("API数据解析失败"), i || (t.fail("未找到对应的项目群聊组!"), process.stdout.write(`${A.red(a)}
2787
2787
  `), process.exit(1));
2788
- const { code: o, message: r } = await Ss({
2788
+ const { code: o, message: r } = await Nn({
2789
2789
  content: a,
2790
2790
  webhooks: [i.url]
2791
2791
  });
2792
2792
  o !== 0 && t.fail(`发送消息到企微群组失败: ${A.red(r)}`), process.stdout.write(`${A.red(a)}
2793
2793
  `), process.exit(1);
2794
2794
  }, Ti = async (e) => {
2795
- const { moduleList: t, services: a, env: n, skipSwaggerValidate: s } = e, i = t.filter((l) => a.includes(l.name)).map((l) => l.swagger);
2795
+ const { moduleList: t, services: a, env: s, skipSwaggerValidate: n } = e, i = t.filter((l) => a.includes(l.name)).map((l) => l.swagger);
2796
2796
  if (!i.length)
2797
2797
  throw new Error("Failed to fetch Swagger JSON");
2798
2798
  const o = i.flatMap((l) => {
2799
- const d = l.find((g) => g.env === n);
2799
+ const d = l.find((g) => g.env === s);
2800
2800
  return d ? [d.url] : [];
2801
2801
  });
2802
2802
  if (!o.length)
2803
2803
  throw new Error("Failed to fetch Swagger JSON");
2804
- const r = y("API数据请求中...").start(), c = await Promise.allSettled(o.map((l) => Si(l, s))), u = c.flatMap(
2804
+ const r = y("API数据请求中...").start(), c = await Promise.allSettled(o.map((l) => Si(l, n))), u = c.flatMap(
2805
2805
  (l, d) => l.status === "rejected" ? [{ reason: l.reason, url: o[d] }] : []
2806
2806
  );
2807
2807
  return u.length && await ji(u, r), r.succeed("API数据请求成功"), c.flatMap((l, d) => l.status === "fulfilled" ? [{ serverName: Qe(o[d]), swaggerJson: l.value }] : []);
@@ -2821,16 +2821,16 @@ ${e.map(t).join(`
2821
2821
  message: e,
2822
2822
  options: t,
2823
2823
  emptyValidateMsg: a,
2824
- pageSize: n = 20,
2825
- multiple: s = !0,
2824
+ pageSize: s = 20,
2825
+ multiple: n = !0,
2826
2826
  formatShowToValue: i
2827
2827
  }) => {
2828
2828
  const o = i ? typeof i == "function" ? i : (r) => r.map((c) => String(c.value)).join(", ") : void 0;
2829
2829
  return V({
2830
2830
  message: e,
2831
- pageSize: n,
2831
+ pageSize: s,
2832
2832
  clearInputWhenSelected: !0,
2833
- multiple: s,
2833
+ multiple: n,
2834
2834
  loop: !0,
2835
2835
  options: (r) => r ? t.filter((c) => (c.name ?? c.label ?? c.value).includes(r)) : t,
2836
2836
  validate: a ? (r) => r.length ? !0 : a : void 0,
@@ -2871,13 +2871,13 @@ class qt {
2871
2871
  this.o = y("API 开始生成...").start(), a === "single" ? await this.startGenerateSingleApi() : await this.startGenerateAllApi(), this.o.succeed("API 生成成功");
2872
2872
  }
2873
2873
  async startGenerateSingleApi() {
2874
- const t = [], a = this.options.remoteSwaggerJsons.map((n) => n.swaggerJson);
2874
+ const t = [], a = this.options.remoteSwaggerJsons.map((s) => s.swaggerJson);
2875
2875
  this.o.text = "获取 API 列表...";
2876
- for (const n of a) {
2877
- const { apis: s } = await ya(n, {
2876
+ for (const s of a) {
2877
+ const { apis: n } = await ya(s, {
2878
2878
  throwOnValidateError: !this.options.skipSwaggerValidate
2879
2879
  });
2880
- t.push(...s.map((i) => ({ name: `${i.path}${i.summary ? `(${i.summary})` : ""}`, value: i.path })));
2880
+ t.push(...n.map((i) => ({ name: `${i.path}${i.summary ? `(${i.summary})` : ""}`, value: i.path })));
2881
2881
  }
2882
2882
  this.o.stop();
2883
2883
  try {
@@ -2889,22 +2889,22 @@ class qt {
2889
2889
  formatShowToValue: !0
2890
2890
  })
2891
2891
  );
2892
- } catch (n) {
2893
- this.o.fail(`API 生成失败: ${n.message}`);
2892
+ } catch (s) {
2893
+ this.o.fail(`API 生成失败: ${s.message}`);
2894
2894
  }
2895
2895
  }
2896
2896
  async startGenerateAllApi() {
2897
2897
  const t = await this.generateAllApi();
2898
2898
  this.o.stop();
2899
- const a = await Ei(this.options.dir), n = pe(a);
2900
- ta(n, { recursive: !0 });
2901
- const s = [];
2899
+ const a = await Ei(this.options.dir), s = pe(a);
2900
+ ta(s, { recursive: !0 });
2901
+ const n = [];
2902
2902
  this.o.start(), this.o.text = "API 生成中...";
2903
2903
  for (const i of t) {
2904
- const { path: o, content: r } = i, c = pe(n, o);
2905
- s.push(c), ve(c, r);
2904
+ const { path: o, content: r } = i, c = pe(s, o);
2905
+ n.push(c), ve(c, r);
2906
2906
  }
2907
- this.o.text = "开始格式化代码", await this.formatApiContent(s), this.o.text = "代码格式化完成", this.o.succeed(`API 已生成到 ${a} 目录下`);
2907
+ this.o.text = "开始格式化代码", await this.formatApiContent(n), this.o.text = "代码格式化完成", this.o.succeed(`API 已生成到 ${a} 目录下`);
2908
2908
  }
2909
2909
  }
2910
2910
  class Ii extends qt {
@@ -2921,14 +2921,14 @@ class Ii extends qt {
2921
2921
  );
2922
2922
  }
2923
2923
  async generateSingleApi(t) {
2924
- const { remoteSwaggerJsons: a, skipSwaggerValidate: n } = this.options;
2925
- for (const { swaggerJson: s, serverName: i } of a) {
2924
+ const { remoteSwaggerJsons: a, skipSwaggerValidate: s } = this.options;
2925
+ for (const { swaggerJson: n, serverName: i } of a) {
2926
2926
  if (!t.some((r) => r.startsWith(`/${i}`)))
2927
2927
  continue;
2928
2928
  const o = await va({
2929
- swaggerJson: s,
2929
+ swaggerJson: n,
2930
2930
  controller: t,
2931
- throwOnValidateError: !n,
2931
+ throwOnValidateError: !s,
2932
2932
  showHeaderComment: !1
2933
2933
  });
2934
2934
  console.log(ht(o, { language: "typescript", ignoreIllegals: !0 }));
@@ -2943,11 +2943,11 @@ class Ci extends qt {
2943
2943
  try {
2944
2944
  const a = await Ri.lintFiles(t);
2945
2945
  await wt.outputFixes(a);
2946
- for (const n of t) {
2947
- const s = pe(n), i = dt(s, "utf-8"), o = await Sa.format(i, {
2948
- filepath: s
2946
+ for (const s of t) {
2947
+ const n = pe(s), i = dt(n, "utf-8"), o = await Sa.format(i, {
2948
+ filepath: n
2949
2949
  });
2950
- ve(s, o);
2950
+ ve(n, o);
2951
2951
  }
2952
2952
  } catch (a) {
2953
2953
  console.error(a), this.o.stop(), m("API 格式化失败,请检查是否配置 eslint 和 prettier");
@@ -2963,15 +2963,15 @@ class Ci extends qt {
2963
2963
  );
2964
2964
  }
2965
2965
  async generateSingleApi(t) {
2966
- const { remoteSwaggerJsons: a, skipSwaggerValidate: n } = this.options;
2967
- for (const { swaggerJson: s, serverName: i } of a) {
2966
+ const { remoteSwaggerJsons: a, skipSwaggerValidate: s } = this.options;
2967
+ for (const { swaggerJson: n, serverName: i } of a) {
2968
2968
  if (!t.some((r) => r.startsWith(`/${i}`)))
2969
2969
  continue;
2970
2970
  const o = await ba({
2971
- swaggerJson: s,
2971
+ swaggerJson: n,
2972
2972
  merge: !0,
2973
2973
  controller: t,
2974
- throwOnValidateError: !n,
2974
+ throwOnValidateError: !s,
2975
2975
  importMethods: !1
2976
2976
  });
2977
2977
  console.log(ht(o, { language: "typescript", ignoreIllegals: !0 }));
@@ -2991,11 +2991,11 @@ const Li = (e) => {
2991
2991
  };
2992
2992
  async function Pi(e) {
2993
2993
  ee(), H();
2994
- const { moduleList: t } = await vi(), { services: a, env: n, skipSwaggerValidate: s = !1 } = e, i = await Ai(t, a), o = Ze(), r = await bi(n), c = await Ti({
2994
+ const { moduleList: t } = await vi(), { services: a, env: s, skipSwaggerValidate: n = !1 } = e, i = await Ai(t, a), o = Ze(), r = await bi(s), c = await Ti({
2995
2995
  moduleList: t,
2996
2996
  services: i,
2997
2997
  env: r,
2998
- skipSwaggerValidate: s
2998
+ skipSwaggerValidate: n
2999
2999
  }), u = await ki();
3000
3000
  await xi({
3001
3001
  remoteSwaggerJsons: c,
@@ -3016,18 +3016,18 @@ const Di = 10, Oi = async () => {
3016
3016
  `remotes/origin/${w.MASTER}`
3017
3017
  ];
3018
3018
  return (await p("git branch -a")).trim().split(`
3019
- `).map((n) => n.trim()).filter((n) => n && !n.includes("HEAD")).filter((n) => !t.includes(n)).filter((n, s, i) => i.indexOf(n) === s).map((n) => ({
3020
- name: n,
3021
- value: n
3019
+ `).map((s) => s.trim()).filter((s) => s && !s.includes("HEAD")).filter((s) => !t.includes(s)).filter((s, n, i) => i.indexOf(s) === n).map((s) => ({
3020
+ name: s,
3021
+ value: s
3022
3022
  }));
3023
3023
  }, Mi = async (e) => (await p(
3024
3024
  `git log ${e} -n ${Di} --format="%H%x1f%s%x1f%an%x1f%ae%x1f%aI" --no-merges`
3025
3025
  )).trim().split(`
3026
3026
  `).filter((a) => a.trim() !== "").map((a) => {
3027
- const [n = "", s = "", i = "", o = "", r = ""] = a.split("");
3027
+ const [s = "", n = "", i = "", o = "", r = ""] = a.split("");
3028
3028
  return {
3029
- hash: n,
3030
- message: s,
3029
+ hash: s,
3030
+ message: n,
3031
3031
  authorName: i,
3032
3032
  authorEmail: o,
3033
3033
  authorDate: r
@@ -3050,7 +3050,7 @@ const Di = 10, Oi = async () => {
3050
3050
  return [];
3051
3051
  }
3052
3052
  }, Fi = async (e, t) => {
3053
- const a = aa(pe(ua(), "z-pick-commit-")), n = pe(a, `${e.hash}.patch`), s = pe(a, `${e.hash}.message`);
3053
+ const a = aa(pe(ua(), "z-pick-commit-")), s = pe(a, `${e.hash}.patch`), n = pe(a, `${e.hash}.message`);
3054
3054
  try {
3055
3055
  ye(t, `正在生成 patch: ${e.hash.slice(0, 8)} ${e.message}`);
3056
3056
  const i = we(`git format-patch -1 ${e.hash} --stdout --binary --full-index`, {
@@ -3061,7 +3061,7 @@ const Di = 10, Oi = async () => {
3061
3061
  status: "failed",
3062
3062
  message: he(i.stderr) || `生成 patch 失败: ${e.hash}`
3063
3063
  };
3064
- if (ve(n, he(i.stdout)), ve(s, await Bi(e.hash)), ye(t, `正在检查 patch 是否已存在: ${e.hash.slice(0, 8)} ${e.message}`), we(`git apply --reverse --check "${n}"`, {
3064
+ if (ve(s, he(i.stdout)), ve(n, await Bi(e.hash)), ye(t, `正在检查 patch 是否已存在: ${e.hash.slice(0, 8)} ${e.message}`), we(`git apply --reverse --check "${s}"`, {
3065
3065
  silent: !0
3066
3066
  }).code === 0)
3067
3067
  return {
@@ -3069,7 +3069,7 @@ const Di = 10, Oi = async () => {
3069
3069
  reason: `已跳过重复 patch: ${e.hash.slice(0, 8)} ${e.message}`
3070
3070
  };
3071
3071
  ye(t, `正在应用 patch: ${e.hash.slice(0, 8)} ${e.message}`);
3072
- const r = we(`git apply --3way --whitespace=nowarn "${n}"`, {
3072
+ const r = we(`git apply --3way --whitespace=nowarn "${s}"`, {
3073
3073
  silent: !0
3074
3074
  });
3075
3075
  if (r.code !== 0) {
@@ -3093,7 +3093,7 @@ const Di = 10, Oi = async () => {
3093
3093
  message: he(c.stderr) || `暂存 patch 失败: ${e.hash}`
3094
3094
  };
3095
3095
  N.env.GIT_AUTHOR_NAME = e.authorName, N.env.GIT_AUTHOR_EMAIL = e.authorEmail, N.env.GIT_AUTHOR_DATE = e.authorDate, ye(t, `正在提交 commit: ${e.hash.slice(0, 8)} ${e.message}`);
3096
- const u = we(`git commit --file "${s}"`, {
3096
+ const u = we(`git commit --file "${n}"`, {
3097
3097
  silent: !0
3098
3098
  });
3099
3099
  return u.code !== 0 ? {
@@ -3103,14 +3103,14 @@ const Di = 10, Oi = async () => {
3103
3103
  status: "success"
3104
3104
  };
3105
3105
  } finally {
3106
- delete N.env.GIT_AUTHOR_NAME, delete N.env.GIT_AUTHOR_EMAIL, delete N.env.GIT_AUTHOR_DATE, sa(a, {
3106
+ delete N.env.GIT_AUTHOR_NAME, delete N.env.GIT_AUTHOR_EMAIL, delete N.env.GIT_AUTHOR_DATE, na(a, {
3107
3107
  force: !0,
3108
3108
  recursive: !0
3109
3109
  });
3110
3110
  }
3111
- }, Zt = (e) => e.slice(0, 8), Gi = (e) => e.replace("T", " ").slice(0, 16), Ji = (e) => `${Gi(e.authorDate)} ${e.authorName} ${Zt(e.hash)} ${e.message}`, Ui = (e, t) => t.map((a) => e.find((n) => n.hash === a)).filter((a) => !!a).sort((a, n) => {
3112
- const s = e.indexOf(a);
3113
- return e.indexOf(n) - s;
3111
+ }, Zt = (e) => e.slice(0, 8), Gi = (e) => e.replace("T", " ").slice(0, 16), Ji = (e) => `${Gi(e.authorDate)} ${e.authorName} ${Zt(e.hash)} ${e.message}`, Ui = (e, t) => t.map((a) => e.find((s) => s.hash === a)).filter((a) => !!a).sort((a, s) => {
3112
+ const n = e.indexOf(a);
3113
+ return e.indexOf(s) - n;
3114
3114
  });
3115
3115
  async function Vi() {
3116
3116
  ee(), H(), await ge();
@@ -3126,21 +3126,21 @@ async function Vi() {
3126
3126
  });
3127
3127
  if (!a)
3128
3128
  return;
3129
- const n = await Mi(a), s = n.map((r) => ({
3129
+ const s = await Mi(a), n = s.map((r) => ({
3130
3130
  name: Ji(r),
3131
3131
  value: r.hash
3132
3132
  })), i = await Je({
3133
3133
  message: "选择需要pick的commit。选中的 commit 会按照提交时间顺序执行。",
3134
- options: s,
3134
+ options: n,
3135
3135
  emptyValidateMsg: "至少选择一个commit",
3136
3136
  formatShowToValue: (r) => r.map((c) => {
3137
- const u = n.find((l) => l.hash === c.value);
3137
+ const u = s.find((l) => l.hash === c.value);
3138
3138
  return u ? Zt(u.hash) : String(c.value);
3139
3139
  }).join(", ")
3140
3140
  });
3141
3141
  if (!i?.length)
3142
3142
  return;
3143
- const o = Ui(n, i);
3143
+ const o = Ui(s, i);
3144
3144
  e.start(`开始处理分支 ${a} 的 commit...`);
3145
3145
  for (const r of o) {
3146
3146
  const c = await Fi(r, e);
@@ -3172,17 +3172,17 @@ async function Hi() {
3172
3172
  if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
3173
3173
  const a = await He();
3174
3174
  De(a);
3175
- let n;
3175
+ let s;
3176
3176
  try {
3177
- const s = "TIME_OUT", i = new Promise((o) => {
3178
- setTimeout(() => o(s), 3e3);
3177
+ const n = "TIME_OUT", i = new Promise((o) => {
3178
+ setTimeout(() => o(n), 3e3);
3179
3179
  });
3180
- n = await Promise.race([
3180
+ s = await Promise.race([
3181
3181
  i,
3182
3182
  p(`npm view ${ce.name} version --registry https://registry.npmmirror.com/`)
3183
- ]), n !== s && n !== ce.version && (console.log(`${A.blue(ce.name)}本地版本为${ce.version},低于线上版本${n},开始升级`), await Ft(n)), de("latestCheckVersionTimestamp", Date.now()), X();
3184
- } catch (s) {
3185
- console.log("升级出错!请重试,或者手动升级"), m(s);
3183
+ ]), s !== n && s !== ce.version && (console.log(`${A.blue(ce.name)}本地版本为${ce.version},低于线上版本${s},开始升级`), await Ft(s)), de("latestCheckVersionTimestamp", Date.now()), X();
3184
+ } catch (n) {
3185
+ console.log("升级出错!请重试,或者手动升级"), m(n);
3186
3186
  }
3187
3187
  }
3188
3188
  }