cli-z-develop 0.16.2 → 0.16.4

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 +605 -598
  2. package/package.json +1 -1
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";
@@ -9,11 +9,11 @@ import ca from "dayjs";
9
9
  import N from "shelljs";
10
10
  import la, { tmpdir as ua } from "node:os";
11
11
  import tt from "child_process";
12
- import { confirm as Le, select as k, input as F, password as pa, checkbox as Re, number as at } from "@inquirer/prompts";
12
+ import { confirm as Le, select as E, input as F, password as pa, checkbox as Re, number as at } from "@inquirer/prompts";
13
13
  import y from "ora";
14
14
  import L from "fs-extra";
15
15
  import ma from "open";
16
- import { select as W } from "inquirer-select-pro";
16
+ import { select as V } from "inquirer-select-pro";
17
17
  import da from "lint-staged";
18
18
  import fa from "semver";
19
19
  import { run as ga } from "npm-check-updates";
@@ -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.2", 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.4", 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.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" }, tn = { "@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 = {
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: {
@@ -335,7 +335,7 @@ function We() {
335
335
  const e = f.join("package.json");
336
336
  return j(e) || m(`当前目录(${N.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), q = L.readJsonSync(e), q;
337
337
  }
338
- function V() {
338
+ function W() {
339
339
  if (Z)
340
340
  return Z;
341
341
  const e = St();
@@ -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 = V(), 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);
@@ -385,7 +385,7 @@ function X() {
385
385
  }
386
386
  );
387
387
  }
388
- function E(e, t) {
388
+ function k(e, t) {
389
389
  t !== void 0 ? M.profile[e] = t : M.profile = {
390
390
  ...M.profile,
391
391
  ...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
  */
@@ -618,7 +618,7 @@ class Rs {
618
618
  */
619
619
  saveToken(t) {
620
620
  const a = Date.now() + t.expires_in * 1e3;
621
- E("gitToken", this.generateBearerToken(t.access_token, t.token_type)), E("gitLabRefreshToken", t.refresh_token), E("gitTokenExpiry", a), X();
621
+ k("gitToken", this.generateBearerToken(t.access_token, t.token_type)), k("gitLabRefreshToken", t.refresh_token), k("gitTokenExpiry", a), X();
622
622
  }
623
623
  /**
624
624
  * 使用 refresh_token 刷新 Access Token
@@ -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
- console.log(A.yellow("⚠️ Token 刷新失败,需要重新授权")), E("gitToken", ""), E("gitLabRefreshToken", ""), E("gitTokenExpiry", ""), X();
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 已失效,正在重新授权...")), E("gitToken", ""), E("gitLabRefreshToken", ""), E("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: {
@@ -715,14 +715,14 @@ async function Cs() {
715
715
  password: I("ldapPassword")
716
716
  }
717
717
  });
718
- return E("zenTaoToken", t), X(), t;
718
+ return k("zenTaoToken", t), X(), t;
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")) {
@@ -731,26 +731,26 @@ async function Ce(e) {
731
731
  return JSON.parse(a.data);
732
732
  }
733
733
  if (typeof t == "object")
734
- return t.error === "Unauthorized" || t.data.indexOf("<script>") < 0 ? (E("zenTaoToken", ""), Ce({
734
+ return t.error === "Unauthorized" || t.data.indexOf("<script>") < 0 ? (k("zenTaoToken", ""), Ce({
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 === "用户登录" ? (E("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: {
@@ -761,10 +761,10 @@ async function Ls() {
761
761
  password: I("ldapPassword")
762
762
  }
763
763
  }), a = `Bearer ${t}`;
764
- return E("k8sToken", a), X(), a;
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,123 +878,123 @@ 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 W({
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
- let i = await W({
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的配置文件,确认重新配置?"
996
996
  }) ? N.rm("-rf", xe()) : process.exit(0)), await fe(Ne(), { recursive: !0 });
997
- const t = await k({
997
+ const t = await E({
998
998
  message: "请选择岗位类型",
999
999
  choices: [
1000
1000
  {
@@ -1015,15 +1015,15 @@ 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(), E("jobType", t), E("ldapAccount", a), E("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
- E({
1026
+ k({
1027
1027
  weWorkName: r,
1028
1028
  weWorkUserId: c
1029
1029
  });
@@ -1032,43 +1032,43 @@ async function rn() {
1032
1032
  }
1033
1033
  const e = y("配置信息初始化中").start();
1034
1034
  try {
1035
- const t = await Vs();
1036
- E({
1035
+ const t = await Wn();
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();
1062
- const { language: e } = V();
1061
+ `, { mode: 493 }), os();
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 k({
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,37 +1132,37 @@ 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
- e.branchType ? t = e.branchType : t = await k({
1165
+ e.branchType ? t = e.branchType : t = await E({
1166
1166
  message: "请选择创建分支的类型",
1167
1167
  choices: [
1168
1168
  {
@@ -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,20 +1255,20 @@ 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
- if (t ? a = T.CHORE : a = await k({
1271
+ if (t ? a = T.CHORE : a = await E({
1272
1272
  message: "请选择你要创建的模板类型",
1273
1273
  choices: [
1274
1274
  {
@@ -1289,58 +1289,58 @@ 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,
1334
1334
  disabled: !1
1335
1335
  };
1336
1336
  return D.includes(le.name) && (et.disabled = "目录下已存在同名文件夹"), et;
1337
- }), Kt = await k({
1337
+ }), Kt = await E({
1338
1338
  message: "请选择一个项目模板",
1339
1339
  choices: te
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 k({
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",
@@ -1418,7 +1418,7 @@ async function vn(e, t) {
1418
1418
  "commit-msg",
1419
1419
  "cm"
1420
1420
  /* CommitMsgAbbr */
1421
- ].includes(e) ? a = "commit-msg" : m("参数输入错误") : a = await k({
1421
+ ].includes(e) ? a = "commit-msg" : m("参数输入错误") : a = await E({
1422
1422
  message: "请选择你要创建的类型",
1423
1423
  choices: [
1424
1424
  {
@@ -1437,92 +1437,99 @@ 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 = () => {
1453
- const e = V();
1453
+ const e = W();
1454
1454
  return e.language || m("未找到当前项目的语言类型,请先通过 z . 对项目进行初始化!"), e.language;
1455
1455
  }, Ot = () => {
1456
- const e = V();
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
- if (V()?.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}。`);
1473
+ if (W()?.repository?.url || m(".z/project.json中缺少repository.url"), t === Y.H5) {
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 k({
1487
+ const s = await V({
1488
1488
  message: "请选择执行",
1489
- choices: a.map((s) => ({
1490
- name: s.label,
1491
- value: s.value
1492
- }))
1489
+ options: (n) => {
1490
+ const i = a.map((o) => ({
1491
+ name: o.label,
1492
+ value: o.value
1493
+ }));
1494
+ return n ? i.filter((o) => o.name.includes(n)) : i;
1495
+ },
1496
+ pageSize: 20,
1497
+ loop: !0,
1498
+ multiple: !1,
1499
+ filter: !0
1493
1500
  });
1494
- t.start("创建或更新执行构建..."), await Ts({
1501
+ t.start("创建或更新执行构建..."), await kn({
1495
1502
  appName: e.name,
1496
- executionId: Number(n),
1503
+ executionId: Number(s),
1497
1504
  ldapAccount: I("ldapAccount")
1498
1505
  }), t.succeed("创建或更新执行构建成功");
1499
- }, jn = [w.TEST, w.MASTER];
1506
+ }, js = [w.TEST, w.MASTER];
1500
1507
  async function Bt(e, t) {
1501
1508
  ee(), H();
1502
- let a = e, n = t.platform;
1503
- const s = V();
1504
- if (s.language === $.JAVA && (n = Y.SERVER), a && !Object.values(w).includes(a) && m("仅支持发布指定环境分支"), n && !Object.values(Y).includes(n) && m("发布平台错误"), n || (n = await k({
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({
1505
1512
  message: "请选择平台",
1506
1513
  choices: ka
1507
- })), n === Y.NPM && (a = w.MASTER), !a) {
1508
- const l = await k({
1514
+ })), s === Y.NPM && (a = w.MASTER), !a) {
1515
+ const l = await E({
1509
1516
  message: "请选择部署环境",
1510
1517
  choices: At
1511
1518
  });
1512
1519
  a = Ga(l);
1513
1520
  }
1514
- a === w.TEST && await Nn();
1521
+ a === w.TEST && await Ns();
1515
1522
  let i = "";
1516
- s.language === $.JAVASCRIPT && (i = Ra);
1523
+ n.language === $.JAVASCRIPT && (i = Ra);
1517
1524
  const o = [];
1518
- if (s.language === $.JAVASCRIPT) {
1525
+ if (n.language === $.JAVASCRIPT) {
1519
1526
  let l = "";
1520
1527
  const d = We();
1521
1528
  d.name.startsWith("@") && d.name.includes("/") ? l = d.name.split("/").pop() || "" : l = d.name, l && o.push(l);
1522
1529
  }
1523
- if (s.language === $.JAVA) {
1524
- const { projects: l } = await Ds(), d = l.find(
1525
- (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)
1526
1533
  );
1527
1534
  if (!d)
1528
1535
  m("未找到项目对应的模块信息");
@@ -1536,7 +1543,7 @@ async function Bt(e, t) {
1536
1543
  const v = new Set(t.module.split(Fe));
1537
1544
  g.forEach((R) => v.has(R.value) && o.push(R.value));
1538
1545
  }
1539
- const h = await W({
1546
+ const h = await V({
1540
1547
  message: "请选择部署模块",
1541
1548
  options: (v) => v ? g.filter((R) => R.name.includes(v)) : g,
1542
1549
  pageSize: 20,
@@ -1555,18 +1562,18 @@ async function Bt(e, t) {
1555
1562
  }
1556
1563
  }
1557
1564
  let r = [];
1558
- const c = jn.includes(a);
1565
+ const c = js.includes(a);
1559
1566
  !t.skipSelectionNotification && !c && (r = await Pt("请选择部署成功要通知的人员:", () => !0, !0));
1560
1567
  let u = [];
1561
- if (!t.skipGroupNotification && !c && (u = await nn("请选择部署成功要通知的群组:", () => !0, !0)), c && !t.skipGroupNotification && !u.length) {
1562
- const l = await bn();
1568
+ if (!t.skipGroupNotification && !c && (u = await is("请选择部署成功要通知的群组:", () => !0, !0)), c && !t.skipGroupNotification && !u.length) {
1569
+ const l = await bs();
1563
1570
  l && u.push(l);
1564
1571
  }
1565
- if (s.language === $.JAVASCRIPT) {
1572
+ if (n.language === $.JAVASCRIPT) {
1566
1573
  const l = Fa(a);
1567
- Sn(l, n);
1574
+ Ss(l, s);
1568
1575
  }
1569
- await An({
1576
+ await As({
1570
1577
  moduleNames: o,
1571
1578
  k8sGroupName: i,
1572
1579
  branchName: a,
@@ -1574,17 +1581,17 @@ async function Bt(e, t) {
1574
1581
  notifyGroups: u
1575
1582
  });
1576
1583
  }
1577
- async function zt(e, t, a, n) {
1578
- const s = y(`分支合并中,${e} -> ${t}`).start();
1584
+ async function zt(e, t, a, s) {
1585
+ const n = y(`分支合并中,${e} -> ${t}`).start();
1579
1586
  let i = 0;
1580
1587
  try {
1581
- const { iid: r } = await Zs({
1588
+ const { iid: r } = await Kn({
1582
1589
  title: `${e} -> ${t} by z-develop`,
1583
1590
  id: a.id,
1584
1591
  source_branch: e,
1585
1592
  target_branch: t,
1586
1593
  // 合到主分支上的分支需要在合并完成后被移除
1587
- remove_source_branch: n ? !1 : w.MASTER === t
1594
+ remove_source_branch: s ? !1 : w.MASTER === t
1588
1595
  });
1589
1596
  i = r;
1590
1597
  } catch (r) {
@@ -1594,40 +1601,40 @@ async function zt(e, t, a, n) {
1594
1601
  try {
1595
1602
  await new Promise((r) => {
1596
1603
  setTimeout(r, 5e3);
1597
- }), await Ks({
1604
+ }), await Yn({
1598
1605
  id: a.id,
1599
1606
  iid: i
1600
- }), s.succeed(`分支${e}已合并到分支${t}`);
1607
+ }), n.succeed(`分支${e}已合并到分支${t}`);
1601
1608
  } catch (r) {
1602
1609
  me.isAxiosError(r) || m(r);
1603
1610
  const c = r?.response?.status;
1604
1611
  if (c === 406)
1605
1612
  return await o();
1606
- if (await Ys({
1613
+ if (await Xn({
1607
1614
  id: a.id,
1608
1615
  iid: i,
1609
1616
  state_event: "close"
1610
1617
  }), c === 405) {
1611
- const u = await Xs({
1618
+ const u = await Qn({
1612
1619
  id: a.id,
1613
1620
  iid: i
1614
1621
  });
1615
1622
  if (u.merge_status === "cannot_be_merged" && u.diff_refs.base_sha === u.diff_refs.head_sha) {
1616
- s.warn("MR已关闭。判定为空的合并请求(没有新内容),可继续进行部署");
1623
+ n.warn("MR已关闭。判定为空的合并请求(没有新内容),可继续进行部署");
1617
1624
  return;
1618
1625
  }
1619
1626
  }
1620
- s.fail("合并过程中出现冲突,MR已关闭。建议在本地完成合并。"), process.exit(1);
1627
+ n.fail("合并过程中出现冲突,MR已关闭。建议在本地完成合并。"), process.exit(1);
1621
1628
  }
1622
1629
  };
1623
1630
  await o();
1624
1631
  }
1625
- async function Tn(e, t) {
1626
- 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`);
1627
1634
  await p(
1628
- `git log ${n}...${s} -b ${a}`
1635
+ `git log ${s}...${n} -b ${a}`
1629
1636
  ) || m(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await p(
1630
- `git branch --contains ${n} -r ${a}`
1637
+ `git branch --contains ${s} -r ${a}`
1631
1638
  ) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await zt(w.MASTER, e.sourceBranch, e)), t === w.MASTER && (await p(
1632
1639
  `git cherry origin/${O.TEST} ${a} origin/${w.MASTER}`
1633
1640
  )).split(`
@@ -1640,11 +1647,11 @@ const lt = async (e, t) => {
1640
1647
  m(`合并到远程分支 ${e} 失败,${a}`);
1641
1648
  }
1642
1649
  };
1643
- async function kn(e, t) {
1650
+ async function ks(e, t) {
1644
1651
  ee(), H(), await ge();
1645
- const a = await ss();
1652
+ const a = await nn();
1646
1653
  Object.values(w).includes(a.sourceBranch) && m(`当前分支${a.sourceBranch}不可作为源分支合并到目标分支。`);
1647
- 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) => {
1648
1655
  let u = c.name;
1649
1656
  return Object.values(w).includes(u) && (u = A.bold.blue(u)), {
1650
1657
  name: u,
@@ -1652,9 +1659,9 @@ async function kn(e, t) {
1652
1659
  };
1653
1660
  });
1654
1661
  let i;
1655
- e && !s.filter((c) => c.value === e).length && m(`未找到目标分支${e}`), e ? i = e : i = await k({
1662
+ e && !n.filter((c) => c.value === e).length && m(`未找到目标分支${e}`), e ? i = e : i = await E({
1656
1663
  message: "请选择要合并到的目标分支:",
1657
- choices: s
1664
+ choices: n
1658
1665
  });
1659
1666
  const o = y(`本地分支${a.sourceBranch}检测中`).start();
1660
1667
  if (await p(`git ls-remote --heads origin ${a.sourceBranch}`)) {
@@ -1665,7 +1672,7 @@ async function kn(e, t) {
1665
1672
  ), process.exit(1));
1666
1673
  } else
1667
1674
  await lt(a.sourceBranch, o);
1668
- 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(
1669
1676
  `${a.sourceBranch}分支已移除,当前已切换到最新的${w.MASTER}。如需继续开发,请检出新分支(z c b)。`
1670
1677
  )), Object.values(w).includes(i) && await Bt(i, {
1671
1678
  platform: t.deployPlatform,
@@ -1673,9 +1680,9 @@ async function kn(e, t) {
1673
1680
  skipGroupNotification: t.skipGroupNotification
1674
1681
  });
1675
1682
  }
1676
- 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));
1677
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));
1678
- async function En() {
1685
+ async function Es() {
1679
1686
  try {
1680
1687
  await p("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
1681
1688
  silent: !1
@@ -1684,42 +1691,42 @@ async function En() {
1684
1691
  m("checkstyle执行出错"), process.exit(1);
1685
1692
  }
1686
1693
  }
1687
- 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) => {
1688
1695
  await p("git fetch --prune");
1689
1696
  const t = `${Ie}${e}`, a = await p(`git branch -r --merged ${t}`, {
1690
1697
  encoding: "utf8"
1691
- }), n = await p(`git branch --merged ${t}`, {
1698
+ }), s = await p(`git branch --merged ${t}`, {
1692
1699
  encoding: "utf8"
1693
- }), s = /* @__PURE__ */ new Map();
1700
+ }), n = /* @__PURE__ */ new Map();
1694
1701
  return a.split(`
1695
1702
  `).forEach((i) => {
1696
1703
  const o = i.trim();
1697
- if (o && o !== t && !o.startsWith(`${Ie}HEAD`) && !In.includes(o)) {
1704
+ if (o && o !== t && !o.startsWith(`${Ie}HEAD`) && !Is.includes(o)) {
1698
1705
  const r = o.replace(new RegExp(`^${Ie}`), "");
1699
- s.set(r, {
1706
+ n.set(r, {
1700
1707
  name: r,
1701
1708
  value: r,
1702
- hasLocal: s.get(r)?.hasLocal ?? !1,
1709
+ hasLocal: n.get(r)?.hasLocal ?? !1,
1703
1710
  hasRemote: !0
1704
1711
  });
1705
1712
  }
1706
- }), n.split(`
1713
+ }), s.split(`
1707
1714
  `).forEach((i) => {
1708
1715
  const o = i.replace(/^\*?\s*/, "").trim();
1709
- if (o && o !== e && !Rn.includes(o)) {
1710
- const r = s.get(o);
1711
- s.set(o, {
1716
+ if (o && o !== e && !Rs.includes(o)) {
1717
+ const r = n.get(o);
1718
+ n.set(o, {
1712
1719
  name: o,
1713
1720
  value: o,
1714
1721
  hasLocal: !0,
1715
1722
  hasRemote: r?.hasRemote ?? !1
1716
1723
  });
1717
1724
  }
1718
- }), [...s.values()].map((i) => ({
1725
+ }), [...n.values()].map((i) => ({
1719
1726
  ...i,
1720
1727
  name: `${i.value}${i.hasRemote && i.hasLocal ? "(本地/远程)" : i.hasRemote ? "(远程)" : "(本地)"}`
1721
1728
  })).sort((i, o) => i.value.localeCompare(o.value));
1722
- }, Ln = (e) => W({
1729
+ }, Ls = (e) => V({
1723
1730
  message: "请选择需要删除的分支",
1724
1731
  options: (t) => t ? e.filter((a) => a.name.includes(t)) : e,
1725
1732
  pageSize: 20,
@@ -1733,18 +1740,18 @@ const Ie = "origin/", In = Object.values(w).map((e) => `${Ie}${e}`), Rn = Object
1733
1740
  renderSelectedOptions: (t) => t.map((a) => a.value).join(", ")
1734
1741
  }
1735
1742
  }
1736
- }), 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) => {
1737
1744
  Ve(`git push origin --delete ${e}`);
1738
- }, Dn = (e) => {
1745
+ }, Ds = (e) => {
1739
1746
  Ve(`git branch -d ${e}`);
1740
- }, On = async () => {
1747
+ }, Os = async () => {
1741
1748
  await ge();
1742
- const e = y(`正在查询本地和远程已经合并到${Ee}的分支...`).start(), t = await Cn(Ee);
1749
+ const e = y(`正在查询本地和远程已经合并到${Ee}的分支...`).start(), t = await Cs(Ee);
1743
1750
  if (e.succeed(`查询到 ${t.length} 个已合并到 ${Ee} 的分支`), !t.length) {
1744
1751
  J(`未查询到已合并到 ${Ee} 的可删除分支`);
1745
1752
  return;
1746
1753
  }
1747
- const a = await Ln(t);
1754
+ const a = await Ls(t);
1748
1755
  if (!await Le({
1749
1756
  message: `确认删除选中的 ${a.length} 个分支对应的远程分支和本地分支?`,
1750
1757
  default: !1
@@ -1752,21 +1759,21 @@ const Ie = "origin/", In = Object.values(w).map((e) => `${Ie}${e}`), Rn = Object
1752
1759
  J("已取消删除");
1753
1760
  return;
1754
1761
  }
1755
- 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();
1756
1763
  try {
1757
1764
  for (const l of c) {
1758
1765
  const { value: d, hasLocal: g, hasRemote: h } = l;
1759
- 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) {
1760
1767
  g && i.push(d);
1761
1768
  continue;
1762
1769
  }
1763
- !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));
1764
1771
  }
1765
1772
  } catch (l) {
1766
1773
  throw u.fail("删除分支失败"), l;
1767
1774
  }
1768
1775
  u.succeed("分支删除完成"), o.length && U(`远程分支删除完成:${o.join(", ")}`), r.length && U(`本地分支删除完成:${r.join(", ")}`), i.length && J(`${i.join(", ")} 为当前分支,无法删除本地分支`);
1769
- }, _t = "0000000000000000000000000000000000000000", ut = "refs/heads/", Mn = async (e, t) => {
1776
+ }, _t = "0000000000000000000000000000000000000000", ut = "refs/heads/", Ms = async (e, t) => {
1770
1777
  if (t === _t) {
1771
1778
  try {
1772
1779
  const a = await p(`git rev-parse --verify --quiet origin/${w.MASTER}`);
@@ -1777,48 +1784,48 @@ const Ie = "origin/", In = Object.values(w).map((e) => `${Ie}${e}`), Rn = Object
1777
1784
  return null;
1778
1785
  }
1779
1786
  return `${t}..${e}`;
1780
- }, Bn = async (e) => {
1787
+ }, Bs = async (e) => {
1781
1788
  try {
1782
1789
  return (await p(`git log ${e} --grep="(cherry picked from commit" --format="%H"`)).split(`
1783
1790
  `).filter(Boolean);
1784
1791
  } catch {
1785
1792
  return [];
1786
1793
  }
1787
- }, zn = async (e) => {
1794
+ }, zs = async (e) => {
1788
1795
  try {
1789
1796
  return (await p(`git log ${e} --format="%H %at %ct"`)).split(`
1790
1797
  `).flatMap((a) => {
1791
- const [n, s, i] = a.split(" ");
1792
- return n && s !== i ? [n] : [];
1798
+ const [s, n, i] = a.split(" ");
1799
+ return s && n !== i ? [s] : [];
1793
1800
  });
1794
1801
  } catch {
1795
1802
  return [];
1796
1803
  }
1797
- }, _n = async () => {
1798
- const { skipGitPushLimit: e } = V(), t = Object.values(w), a = dt(0, "utf-8");
1804
+ }, _s = async () => {
1805
+ const { skipGitPushLimit: e } = W(), t = Object.values(w), a = dt(0, "utf-8");
1799
1806
  if (!a)
1800
1807
  return;
1801
- const n = a.trim().split(`
1802
- `), s = n.length;
1803
- for (let i = 0; i < s; i++) {
1804
- 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+/);
1805
1812
  if (!r.startsWith(ut) || o === _t)
1806
1813
  continue;
1807
1814
  const u = r.replace(ut, "");
1808
1815
  !e && t.includes(u) && m(`禁止直接 Push 到环境分支:${u}`);
1809
- const l = await Mn(o, c);
1816
+ const l = await Ms(o, c);
1810
1817
  if (!l)
1811
1818
  continue;
1812
1819
  const [d, g] = await Promise.all([
1813
- Bn(l),
1814
- zn(l)
1820
+ Bs(l),
1821
+ zs(l)
1815
1822
  ]), h = [.../* @__PURE__ */ new Set([...d, ...g])];
1816
1823
  h.length > 0 && m(`以下提交中检测到包含 cherry-pick 特征,本次 Push 已被拒绝
1817
1824
  ${h.join(`
1818
1825
  `)}`);
1819
1826
  }
1820
1827
  };
1821
- async function Fn() {
1828
+ async function Fs() {
1822
1829
  j(f.resolve("node_modules", ".bin", "markdownlint")) || m("该项目未安装markdownlint,请安装后重试");
1823
1830
  const e = y("markdownlint执行中...").start();
1824
1831
  try {
@@ -1829,26 +1836,26 @@ async function Fn() {
1829
1836
  e.fail("markdownlint校验出错"), process.exit(1);
1830
1837
  }
1831
1838
  }
1832
- const Gn = () => {
1839
+ const Gs = () => {
1833
1840
  m("禁止执行 rebase,请使用 git merge!");
1834
1841
  };
1835
- function Jn() {
1836
- const e = V();
1842
+ function Js() {
1843
+ const e = W();
1837
1844
  if (e["lint-staged"])
1838
1845
  return e["lint-staged"];
1839
1846
  throw new Error("未找到lint配置");
1840
1847
  }
1841
- async function Un() {
1848
+ async function Us() {
1842
1849
  const e = y("代码风格检测中...").start();
1843
1850
  await da({
1844
1851
  concurrent: 4,
1845
1852
  debug: !1,
1846
- config: Jn(),
1853
+ config: Js(),
1847
1854
  quiet: !0,
1848
1855
  relative: !0
1849
1856
  }) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
1850
1857
  }
1851
- function Vn(e) {
1858
+ function Vs(e) {
1852
1859
  if (e.includes("Merge") && e.includes("# Conflicts:") || fa.valid(e))
1853
1860
  return !0;
1854
1861
  const t = e.split(": ");
@@ -1857,11 +1864,11 @@ function Vn(e) {
1857
1864
  const a = t[0];
1858
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 : "不存在的提交类型。";
1859
1866
  }
1860
- async function Wn() {
1861
- 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);
1862
1869
  a === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${a}`), process.exit(1));
1863
1870
  }
1864
- async function Hn() {
1871
+ async function Hs() {
1865
1872
  await ge();
1866
1873
  const e = await ga({
1867
1874
  // 分组,展示仓库链接
@@ -1875,12 +1882,12 @@ async function Hn() {
1875
1882
  });
1876
1883
  if (e && Object.keys(e).length) {
1877
1884
  U("升级完成 🎉");
1878
- const t = Object.entries(e).map(([a, n]) => `${a}@${n}`).join("; ");
1885
+ const t = Object.entries(e).map(([a, s]) => `${a}@${s}`).join("; ");
1879
1886
  await p(`git add . && git commit -m "chore: 依赖升级。${t}"`);
1880
1887
  }
1881
1888
  process.exit(0);
1882
1889
  }
1883
- async function qn(e) {
1890
+ async function qs(e) {
1884
1891
  j(f.resolve("node_modules", ".bin", "eslint")) || m("该项目未安装eslint,请安装后重试");
1885
1892
  const t = y("eslint执行中...").start();
1886
1893
  try {
@@ -1892,7 +1899,7 @@ async function qn(e) {
1892
1899
  t.fail("eslint校验出错"), process.exit(1);
1893
1900
  }
1894
1901
  }
1895
- async function Zn() {
1902
+ async function Zs() {
1896
1903
  j(f.resolve("node_modules", ".bin", "prettier")) || m("该项目未安装prettier,请安装后重试");
1897
1904
  const e = y("prettier执行中...").start();
1898
1905
  try {
@@ -1906,10 +1913,10 @@ async function Zn() {
1906
1913
  e.fail("prettier校验出错"), process.exit(1);
1907
1914
  }
1908
1915
  }
1909
- function Kn() {
1916
+ function Ks() {
1910
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);
1911
1918
  }
1912
- const Yn = [
1919
+ const Ys = [
1913
1920
  [
1914
1921
  "cm",
1915
1922
  "commit-msg"
@@ -1965,7 +1972,7 @@ const Yn = [
1965
1972
  "detect-push"
1966
1973
  /* DetectPush */
1967
1974
  ]
1968
- ], Xn = {
1975
+ ], Xs = {
1969
1976
  [$.JAVA]: [
1970
1977
  {
1971
1978
  name: "执行 check-style",
@@ -2012,30 +2019,30 @@ const Yn = [
2012
2019
  /* DependencyCheck */
2013
2020
  }
2014
2021
  ]
2015
- }, Qn = (e) => Reflect.get(Xn, e) ?? [], ei = {
2016
- "commit-msg": Wn,
2017
- "commit-files": Un,
2018
- prettier: Zn,
2019
- eslint: qn,
2020
- "type-check": Kn,
2021
- "dependency-check": Hn,
2022
- checkstyle: En,
2023
- "markdown-lint": Fn,
2024
- "delete-merged": On,
2025
- "not-allow-rebase": Gn,
2026
- "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
2027
2034
  }, ti = async (e, t) => {
2028
2035
  const a = Reflect.get(ei, e);
2029
2036
  a && typeof a == "function" && await a(t);
2030
2037
  }, ai = (e) => {
2031
- for (const [t, a] of Yn)
2038
+ for (const [t, a] of Ys)
2032
2039
  if (e === t || e === a)
2033
2040
  return a;
2034
2041
  m("参数输入错误");
2035
2042
  };
2036
- async function si(e, t) {
2043
+ async function ni(e, t) {
2037
2044
  ee(), H();
2038
- const a = V(), n = e ? ai(e) : await k({
2045
+ const a = W(), s = e ? ai(e) : await E({
2039
2046
  message: "请选择你要执行的操作",
2040
2047
  choices: [
2041
2048
  {
@@ -2043,7 +2050,7 @@ async function si(e, t) {
2043
2050
  value: "prettier"
2044
2051
  /* Prettier */
2045
2052
  },
2046
- ...Qn(a.language),
2053
+ ...Qs(a.language),
2047
2054
  {
2048
2055
  name: "执行 delete-merged",
2049
2056
  value: "delete-merged"
@@ -2051,12 +2058,12 @@ async function si(e, t) {
2051
2058
  }
2052
2059
  ]
2053
2060
  });
2054
- await ti(n, t);
2061
+ await ti(s, t);
2055
2062
  }
2056
2063
  P.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint / delete-merged。").argument(
2057
2064
  "[type]",
2058
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。"
2059
- ).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));
2060
2067
  async function Ft(e = "latest") {
2061
2068
  const t = y("安装中...").start();
2062
2069
  await p(`npm i -g ${ce.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", de("latestCheckVersionTimestamp", Date.now()), de("version", e);
@@ -2085,13 +2092,13 @@ function Jt(e) {
2085
2092
  };
2086
2093
  }
2087
2094
  async function ie(e, t = {}) {
2088
- const { exclude: a = Ke } = t, n = [];
2089
- async function s(i) {
2095
+ const { exclude: a = Ke } = t, s = [];
2096
+ async function n(i) {
2090
2097
  const o = f.basename(i);
2091
- if ((await na(i)).isFile())
2098
+ if ((await sa(i)).isFile())
2092
2099
  return null;
2093
2100
  const c = await Ue(i, { withFileTypes: !0 }), u = (await Promise.all(
2094
- 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)))
2095
2102
  )).filter(Boolean), { type: l, id: d, displayName: g } = Jt(o), h = {
2096
2103
  name: o,
2097
2104
  id: d,
@@ -2100,19 +2107,19 @@ async function ie(e, t = {}) {
2100
2107
  type: l,
2101
2108
  children: u
2102
2109
  };
2103
- return (t.hasRoot || f.resolve(e) !== i) && n.push(h), h;
2110
+ return (t.hasRoot || f.resolve(e) !== i) && s.push(h), h;
2104
2111
  }
2105
- return await s(f.resolve(e)), n;
2112
+ return await n(f.resolve(e)), s;
2106
2113
  }
2107
2114
  async function Ut(e, t = {}) {
2108
2115
  const { exclude: a = Ke } = t;
2109
2116
  try {
2110
- const n = await Ue(f.resolve(e), { withFileTypes: !0 });
2117
+ const s = await Ue(f.resolve(e), { withFileTypes: !0 });
2111
2118
  return await Promise.all(
2112
- n.filter((s) => s.isDirectory() && !a.test(s.name)).map((s) => {
2113
- 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);
2114
2121
  return {
2115
- name: s.name,
2122
+ name: n.name,
2116
2123
  id: r,
2117
2124
  displayName: c,
2118
2125
  path: i,
@@ -2120,8 +2127,8 @@ async function Ut(e, t = {}) {
2120
2127
  };
2121
2128
  })
2122
2129
  );
2123
- } catch (n) {
2124
- return m(`读取目录失败: ${e} : ${n}`), [];
2130
+ } catch (s) {
2131
+ return m(`读取目录失败: ${e} : ${s}`), [];
2125
2132
  }
2126
2133
  }
2127
2134
  function Q(e, t, a) {
@@ -2134,29 +2141,29 @@ function Q(e, t, a) {
2134
2141
  return t;
2135
2142
  }
2136
2143
  }
2137
- async function je(e, t, a, n) {
2144
+ async function je(e, t, a, s) {
2138
2145
  try {
2139
- const s = f.basename(e), i = Q(a, t, n);
2140
- if (s === i)
2146
+ const n = f.basename(e), i = Q(a, t, s);
2147
+ if (n === i)
2141
2148
  return !0;
2142
2149
  const o = f.dirname(e), r = f.join(o, i);
2143
2150
  return await Ja(e) ? await ft(e, r) : (await p(`git mv "${e}" "${r}"`), await p("git add .")), !0;
2144
- } catch (s) {
2145
- return m(`重命名文件夹失败: ${e} -> ${t}。${s}`), !1;
2151
+ } catch (n) {
2152
+ return m(`重命名文件夹失败: ${e} -> ${t}。${n}`), !1;
2146
2153
  }
2147
2154
  }
2148
- async function ni(e, t, a = {}) {
2149
- const { exclude: n = Ke } = a;
2150
- async function s(i, o) {
2155
+ async function si(e, t, a = {}) {
2156
+ const { exclude: s = Ke } = a;
2157
+ async function n(i, o) {
2151
2158
  if (!i || i.length === 0) return;
2152
- const r = await Ut(o, { exclude: n });
2159
+ const r = await Ut(o, { exclude: s });
2153
2160
  for (const c of i) {
2154
2161
  const u = String(c.value), l = Q("module", c.label, u), d = r.find((h) => h.id === u);
2155
2162
  let g = d?.path || f.join(o, l);
2156
- 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);
2157
2164
  }
2158
2165
  }
2159
- await s(e, f.resolve(t));
2166
+ await n(e, f.resolve(t));
2160
2167
  }
2161
2168
  async function Vt(e) {
2162
2169
  const t = {
@@ -2167,16 +2174,16 @@ async function Vt(e) {
2167
2174
  if (e)
2168
2175
  Number.isNaN(Number(e)) && m("请输入正确的产品ID"), t.id = Number(e);
2169
2176
  else {
2170
- const a = await rs();
2171
- t.id = await k({
2177
+ const a = await on();
2178
+ t.id = await E({
2172
2179
  message: "请选择产品",
2173
- choices: a.map((n) => ({
2174
- name: `${n.label}[${n.value}]`,
2175
- value: n.value
2180
+ choices: a.map((s) => ({
2181
+ name: `${s.label}[${s.value}]`,
2182
+ value: s.value
2176
2183
  }))
2177
2184
  });
2178
2185
  }
2179
- 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;
2180
2187
  }
2181
2188
  async function Ye(e) {
2182
2189
  return (await Ut(Gt)).find((a) => Number(a.id) === e.id);
@@ -2187,7 +2194,7 @@ async function Wt(e, t) {
2187
2194
  priority: e.pri,
2188
2195
  steps: []
2189
2196
  };
2190
- a.steps = await ls(e.id), L.writeJSONSync(t, a, {
2197
+ a.steps = await un(e.id), L.writeJSONSync(t, a, {
2191
2198
  spaces: 2
2192
2199
  });
2193
2200
  }
@@ -2196,17 +2203,17 @@ async function Ht(e, t) {
2196
2203
  recursive: !0
2197
2204
  }), await Wt(e, f.join(t, "config.json")), L.ensureFileSync(f.join(t, "data.yaml")), await _(
2198
2205
  f.join(t, "data.yaml"),
2199
- 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()
2200
2207
  ), L.ensureFileSync(f.join(t, "main.py")), await _(
2201
2208
  f.join(t, "main.py"),
2202
- 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()
2203
2210
  );
2204
2211
  }
2205
2212
  function Xe(e) {
2206
2213
  if (e) {
2207
2214
  const t = e.split(",").map((a) => a.trim()).filter((a) => {
2208
- const n = Number(a);
2209
- return Number.isInteger(n) && n > 0;
2215
+ const s = Number(a);
2216
+ return Number.isInteger(s) && s > 0;
2210
2217
  }).map((a) => Number(a));
2211
2218
  return t.length === 0 ? (m('未找到有效的ID,请输入格式如 "1,2,3,4" 的正整数ID'), []) : t;
2212
2219
  }
@@ -2215,14 +2222,14 @@ function Xe(e) {
2215
2222
  async function Oe(e, t) {
2216
2223
  ee(), H(), await ge();
2217
2224
  let a;
2218
- t ? ([C.MODULE, C.CASE].includes(t) || m(`不支持的参数${t}。参数值应为 ${C.MODULE} 或者 ${C.CASE}。`), a = t) : a = await k({
2225
+ t ? ([C.MODULE, C.CASE].includes(t) || m(`不支持的参数${t}。参数值应为 ${C.MODULE} 或者 ${C.CASE}。`), a = t) : a = await E({
2219
2226
  message: `请选择要${e}的数据类型`,
2220
2227
  choices: Ca
2221
2228
  });
2222
- const n = a === C.MODULE ? "模块" : C.CASE === a ? "用例" : "";
2229
+ const s = a === C.MODULE ? "模块" : C.CASE === a ? "用例" : "";
2223
2230
  return {
2224
2231
  type: a,
2225
- typeStr: n
2232
+ typeStr: s
2226
2233
  };
2227
2234
  }
2228
2235
  async function Me(e) {
@@ -2234,10 +2241,10 @@ async function Me(e) {
2234
2241
  }
2235
2242
  async function ii(e, t, a) {
2236
2243
  e.text = "查找本地产品目录...", await Ye(t) || m(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
2237
- const s = Xe(a);
2244
+ const n = Xe(a);
2238
2245
  let i = await ie(t.path);
2239
2246
  e.text = "获取远程用例列表...";
2240
- const o = await cs(t.id, s);
2247
+ const o = await ln(t.id, n);
2241
2248
  e.text = "本地用例同步中...";
2242
2249
  for (const r of o) {
2243
2250
  let c;
@@ -2259,15 +2266,15 @@ async function ri(e, t) {
2259
2266
  e.text = "本地产品目录查找中...";
2260
2267
  const a = await Ye(t);
2261
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 = "获取远程模块列表...";
2262
- const n = await Rt(t.id);
2263
- e.text = "本地同步模块中...", await ni(n || [], t.path);
2269
+ const s = await Rt(t.id);
2270
+ e.text = "本地同步模块中...", await si(s || [], t.path);
2264
2271
  }
2265
2272
  async function oi(e, t) {
2266
- const { type: a, typeStr: n } = await Oe("拉取", e), s = await Vt(t.productId), i = y(`${n}同步中...`).start();
2267
- 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")) {
2268
2275
  const o = y("代码提交中...").start();
2269
2276
  try {
2270
- await p(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
2277
+ await p(`git add . && git commit -m "chore: 同步禅道${s}数据"`), o.succeed("代码已提交 ✅");
2271
2278
  } catch (r) {
2272
2279
  o.fail(`提交失败,${r}`), process.exit(1);
2273
2280
  }
@@ -2275,84 +2282,84 @@ async function oi(e, t) {
2275
2282
  }
2276
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));
2277
2284
  async function ci(e, t, a) {
2278
- let n = await F({
2285
+ let s = await F({
2279
2286
  message: "请输入你要创建的用例的前置条件(可不填)"
2280
2287
  });
2281
- n = n.trim();
2282
- const s = y(`用例【${a}】开始创建...`).start();
2283
- s.text = "远程用例创建中...";
2284
- const i = await ps({
2288
+ s = s.trim();
2289
+ const n = y(`用例【${a}】开始创建...`).start();
2290
+ n.text = "远程用例创建中...";
2291
+ const i = await mn({
2285
2292
  product: Number(e.id),
2286
2293
  // 如果父模块是产品根目录,parent=0
2287
2294
  module: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
2288
2295
  title: a,
2289
2296
  type: "interface",
2290
2297
  openedBy: I("ldapAccount"),
2291
- precondition: n || ""
2298
+ precondition: s || ""
2292
2299
  });
2293
- s.text = "远程用例步骤创建中...", await ms({
2300
+ n.text = "远程用例步骤创建中...", await dn({
2294
2301
  case: i,
2295
2302
  type: "step",
2296
2303
  desc: "按照预期执行",
2297
2304
  expect: "正常执行,符合预期"
2298
- }), s.text = "本地用例创建中...";
2305
+ }), n.text = "本地用例创建中...";
2299
2306
  const o = f.join(t.path, Q("case", a, String(i)));
2300
2307
  return j(o) ? U(`${o}已存在,请检查是否对应,本地不再创建。`) : (await Ht(
2301
2308
  {
2302
2309
  id: i,
2303
2310
  pri: 3,
2304
- precondition: n
2311
+ precondition: s
2305
2312
  },
2306
2313
  o
2307
- ), s.succeed(`用例【[${o}】创建完成 🎉`), o);
2314
+ ), n.succeed(`用例【[${o}】创建完成 🎉`), o);
2308
2315
  }
2309
2316
  async function li(e, t, a) {
2310
- const n = y(`模块【${a}】开始创建...`).start();
2311
- n.text = "远程模块创建中...";
2312
- const s = await us({
2317
+ const s = y(`模块【${a}】开始创建...`).start();
2318
+ s.text = "远程模块创建中...";
2319
+ const n = await pn({
2313
2320
  root: Number(e.id),
2314
2321
  name: a,
2315
2322
  // 如果父模块是产品根目录,parent=0
2316
2323
  parent: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
2317
2324
  });
2318
- n.text = "本地模块创建中...";
2319
- 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)));
2320
2327
  if (j(i))
2321
2328
  return U(`${i}已存在,请检查是否对应,本地不再创建。`);
2322
2329
  await fe(i, {
2323
2330
  recursive: !0
2324
- }), n.succeed(`模块【${i}】创建完成 🎉`);
2331
+ }), s.succeed(`模块【${i}】创建完成 🎉`);
2325
2332
  }
2326
2333
  function ui(e) {
2327
- function t(n) {
2328
- if (!n.children || n.children.length === 0) return;
2329
- const s = n.children[0];
2330
- s && s.label === n.label && s.value === n.value && (!s.children || s.children.length === 0) || n.children.unshift({
2331
- value: n.value,
2332
- label: n.label,
2333
- 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,
2334
2341
  children: void 0,
2335
2342
  tempTitle: "当前层级"
2336
2343
  });
2337
2344
  }
2338
- async function a(n, s = []) {
2339
- const i = s.length ? `请选择层级(当前:${s.join(" / ")})` : "请选择层级", o = await k({
2345
+ async function a(s, n = []) {
2346
+ const i = n.length ? `请选择层级(当前:${n.join(" / ")})` : "请选择层级", o = await E({
2340
2347
  message: i,
2341
- choices: n.map((r) => ({
2348
+ choices: s.map((r) => ({
2342
2349
  name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
2343
2350
  value: r
2344
2351
  }))
2345
2352
  });
2346
- 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;
2347
2354
  }
2348
2355
  return a(e);
2349
2356
  }
2350
2357
  async function pi(e, t) {
2351
- 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);
2352
2359
  if (!l?.path || !j(l.path))
2353
2360
  return m(`本地不存在${c}模块`);
2354
2361
  let d = await F({
2355
- message: `请输入你要创建的${n}名称`,
2362
+ message: `请输入你要创建的${s}名称`,
2356
2363
  required: !0,
2357
2364
  validate: (h) => h.length > 0 && h.length < 255
2358
2365
  });
@@ -2369,22 +2376,22 @@ async function pi(e, t) {
2369
2376
  }
2370
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));
2371
2378
  async function mi(e, t) {
2372
- const n = (await ie(e.path)).filter((r) => r.type === "case");
2373
- let s = [];
2379
+ const s = (await ie(e.path)).filter((r) => r.type === "case");
2380
+ let n = [];
2374
2381
  if (t.length)
2375
- s = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
2382
+ n = s.filter((r) => t.includes(Number(r.id))).map((r) => ({
2376
2383
  id: Number(r.id),
2377
2384
  path: r.path
2378
- })), s.length || m(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
2385
+ })), n.length || m(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
2379
2386
  else {
2380
- const r = n.map((c) => ({
2387
+ const r = s.map((c) => ({
2381
2388
  value: {
2382
2389
  id: Number(c.id),
2383
2390
  path: c.path
2384
2391
  },
2385
2392
  name: c.path.replace(f.resolve(e.path), "")
2386
2393
  }));
2387
- s = await W({
2394
+ n = await V({
2388
2395
  message: "选择要删除的用例",
2389
2396
  pageSize: 100,
2390
2397
  loop: !1,
@@ -2394,32 +2401,32 @@ async function mi(e, t) {
2394
2401
  }
2395
2402
  });
2396
2403
  }
2397
- const i = y("远程用例删除中...").start(), o = s.map((r) => r.id);
2398
- await fs({
2404
+ const i = y("远程用例删除中...").start(), o = n.map((r) => r.id);
2405
+ await gn({
2399
2406
  product: Number(e.id),
2400
2407
  caseIds: o
2401
2408
  }), i.text = "本地用例删除中...";
2402
- for (const r of s)
2409
+ for (const r of n)
2403
2410
  j(r.path) && N.rm("-rf", r.path);
2404
2411
  return i.succeed("用例删除完成"), o;
2405
2412
  }
2406
2413
  async function di(e, t) {
2407
- const n = (await ie(e.path)).filter((r) => r.type === "module");
2408
- let s = [];
2414
+ const s = (await ie(e.path)).filter((r) => r.type === "module");
2415
+ let n = [];
2409
2416
  if (t.length)
2410
- s = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
2417
+ n = s.filter((r) => t.includes(Number(r.id))).map((r) => ({
2411
2418
  id: Number(r.id),
2412
2419
  path: r.path
2413
- })), s.length || m(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
2420
+ })), n.length || m(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
2414
2421
  else {
2415
- const r = n.map((c) => ({
2422
+ const r = s.map((c) => ({
2416
2423
  value: {
2417
2424
  id: Number(c.id),
2418
2425
  path: c.path
2419
2426
  },
2420
2427
  name: c.path.replace(f.resolve(e.path), "")
2421
2428
  }));
2422
- s = await W({
2429
+ n = await V({
2423
2430
  message: "选择要删除的模块",
2424
2431
  pageSize: 100,
2425
2432
  loop: !1,
@@ -2429,23 +2436,23 @@ async function di(e, t) {
2429
2436
  }
2430
2437
  });
2431
2438
  }
2432
- s = s.sort((r, c) => r.path.localeCompare(c.path));
2433
- const i = y("远程模块删除中...").start(), o = s.map((r) => r.id);
2434
- 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({
2435
2442
  product: Number(e.id),
2436
2443
  moduleIds: o
2437
2444
  }), i.text = "本地模块删除中...";
2438
- for (const r of s)
2445
+ for (const r of n)
2439
2446
  j(r.path) && N.rm("-rf", r.path);
2440
2447
  return i.succeed("模块删除完成"), o;
2441
2448
  }
2442
2449
  async function fi(e, t) {
2443
- 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);
2444
2451
  let o = [];
2445
- 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")) {
2446
2453
  const r = y("代码提交中...").start();
2447
2454
  try {
2448
- 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("代码已提交 ✅");
2449
2456
  } catch (c) {
2450
2457
  r.fail(`提交失败,${c}`), process.exit(1);
2451
2458
  }
@@ -2453,13 +2460,13 @@ async function fi(e, t) {
2453
2460
  }
2454
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));
2455
2462
  async function gi(e, t) {
2456
- const n = (await ie(e.path)).filter((g) => g.type === "case");
2457
- let s;
2463
+ const s = (await ie(e.path)).filter((g) => g.type === "case");
2464
+ let n;
2458
2465
  if (t.targetId) {
2459
- 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)
2460
2467
  return m(`未找到对应用例,请确认输入的用例ID(${t.targetId})是否正确`);
2461
2468
  } else {
2462
- const g = n.map((h) => ({
2469
+ const g = s.map((h) => ({
2463
2470
  value: {
2464
2471
  id: Number(h.id),
2465
2472
  path: h.path,
@@ -2467,7 +2474,7 @@ async function gi(e, t) {
2467
2474
  },
2468
2475
  name: h.path.replace(f.resolve(e.path), "")
2469
2476
  }));
2470
- [s] = await W({
2477
+ [n] = await V({
2471
2478
  message: "选择要更新的用例",
2472
2479
  pageSize: 100,
2473
2480
  loop: !1,
@@ -2480,18 +2487,18 @@ async function gi(e, t) {
2480
2487
  }
2481
2488
  let i = await F({
2482
2489
  message: "修改用例名称",
2483
- default: s.displayName,
2490
+ default: n.displayName,
2484
2491
  required: !0,
2485
2492
  validate: (g) => g.length > 0 && g.length < 255,
2486
2493
  prefill: "editable"
2487
2494
  });
2488
2495
  i = i.trim();
2489
2496
  const o = y("用例重命名中...").start();
2490
- i !== s.displayName ? (await hs({
2491
- id: Number(s.id),
2497
+ i !== n.displayName ? (await wn({
2498
+ id: Number(n.id),
2492
2499
  name: i
2493
- }), 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("用例名称无变动");
2494
- 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;
2495
2502
  t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await at({
2496
2503
  message: "修改用例优先级",
2497
2504
  min: 1,
@@ -2508,17 +2515,17 @@ async function gi(e, t) {
2508
2515
  validate: (g) => g > 0 && g < 6
2509
2516
  });
2510
2517
  const u = y("用例优先级设置中...").start();
2511
- c !== r.priority ? (await ws({
2512
- id: Number(s.id),
2518
+ c !== r.priority ? (await yn({
2519
+ id: Number(n.id),
2513
2520
  priority: c
2514
2521
  }), L.writeJSONSync(
2515
- f.join(s.path, "config.json"),
2522
+ f.join(n.path, "config.json"),
2516
2523
  {
2517
2524
  ...r,
2518
2525
  priority: c
2519
2526
  },
2520
2527
  { spaces: 2 }
2521
- ), 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"));
2522
2529
  let l;
2523
2530
  t.casePrecondition ? l = t.casePrecondition : (l = await F({
2524
2531
  message: "修改用例前置条件",
@@ -2526,26 +2533,26 @@ async function gi(e, t) {
2526
2533
  prefill: "editable"
2527
2534
  }), l = l.trim());
2528
2535
  const d = y("用例前置条件设置中...").start();
2529
- return l !== r.precondition ? (await ys({
2530
- id: Number(s.id),
2536
+ return l !== r.precondition ? (await $n({
2537
+ id: Number(n.id),
2531
2538
  precondition: l
2532
2539
  }), L.writeJSONSync(
2533
- f.join(s.path, "config.json"),
2540
+ f.join(n.path, "config.json"),
2534
2541
  {
2535
2542
  ...r,
2536
2543
  precondition: l
2537
2544
  },
2538
2545
  { spaces: 2 }
2539
- ), d.succeed(`用例前置条件修改成功:${r.precondition} -> ${l}`)) : d.succeed("用例前置条件无变动"), s.id;
2546
+ ), d.succeed(`用例前置条件修改成功:${r.precondition} -> ${l}`)) : d.succeed("用例前置条件无变动"), n.id;
2540
2547
  }
2541
2548
  async function hi(e, t) {
2542
- const n = (await ie(e.path)).filter((r) => r.type === "module");
2543
- let s;
2549
+ const s = (await ie(e.path)).filter((r) => r.type === "module");
2550
+ let n;
2544
2551
  if (t.targetId) {
2545
- 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)
2546
2553
  return m(`未找到对应模块,请确认输入的模块ID(${t.targetId})是否正确`);
2547
2554
  } else {
2548
- const r = n.map((c) => ({
2555
+ const r = s.map((c) => ({
2549
2556
  value: {
2550
2557
  id: Number(c.id),
2551
2558
  path: c.path,
@@ -2553,7 +2560,7 @@ async function hi(e, t) {
2553
2560
  },
2554
2561
  name: c.path.replace(f.resolve(e.path), "")
2555
2562
  }));
2556
- [s] = await W({
2563
+ [n] = await V({
2557
2564
  message: "选择要更新的模块",
2558
2565
  pageSize: 100,
2559
2566
  loop: !1,
@@ -2566,25 +2573,25 @@ async function hi(e, t) {
2566
2573
  }
2567
2574
  let i = await F({
2568
2575
  message: "修改模块名称",
2569
- default: s.displayName,
2576
+ default: n.displayName,
2570
2577
  required: !0,
2571
2578
  validate: (r) => r.length > 0 && r.length < 255,
2572
2579
  prefill: "editable"
2573
2580
  });
2574
2581
  i = i.trim();
2575
2582
  const o = y("模块重命名中...").start();
2576
- return i !== s.displayName ? (await gs({
2577
- id: Number(s.id),
2583
+ return i !== n.displayName ? (await hn({
2584
+ id: Number(n.id),
2578
2585
  name: i
2579
- }), 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;
2580
2587
  }
2581
2588
  async function wi(e, t) {
2582
- 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);
2583
2590
  let i;
2584
- 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")) {
2585
2592
  const o = y("代码提交中...").start();
2586
2593
  try {
2587
- 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("代码已提交 ✅");
2588
2595
  } catch (r) {
2589
2596
  o.fail(`提交失败,${r}`), process.exit(1);
2590
2597
  }
@@ -2594,30 +2601,30 @@ P.command("qa-update").alias("qu").description("修改模块或者用例").argum
2594
2601
  async function yi(e, t) {
2595
2602
  if (!e.length)
2596
2603
  return [];
2597
- const a = ha(20), n = e.map(
2598
- (s) => a(async () => {
2604
+ const a = ha(20), s = e.map(
2605
+ (n) => a(async () => {
2599
2606
  try {
2600
- 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}`);
2601
2608
  try {
2602
- s.result = JSON.parse(o);
2609
+ n.result = JSON.parse(o);
2603
2610
  } catch {
2604
- m(`用例${s.displayName}[${s.id}]返回格式错误:${o}`);
2611
+ m(`用例${n.displayName}[${n.id}]返回格式错误:${o}`);
2605
2612
  }
2606
2613
  } catch (i) {
2607
2614
  const o = i instanceof Error ? i.message : String(i);
2608
- m(`用例${s.displayName}[${s.id}]执行失败: ${o}`);
2615
+ m(`用例${n.displayName}[${n.id}]执行失败: ${o}`);
2609
2616
  }
2610
2617
  })
2611
2618
  );
2612
- return await Promise.all(n), e;
2619
+ return await Promise.all(s), e;
2613
2620
  }
2614
2621
  async function $i(e) {
2615
2622
  ee(), H();
2616
2623
  const { localProduct: t } = await Me(e.productId);
2617
2624
  let a = [];
2618
- const s = (await ie(t.path)).filter((c) => c.type === "case");
2625
+ const n = (await ie(t.path)).filter((c) => c.type === "case");
2619
2626
  if (e.all)
2620
- a = s.map((c) => ({
2627
+ a = n.map((c) => ({
2621
2628
  id: Number(c.id),
2622
2629
  path: c.path,
2623
2630
  displayName: c.displayName
@@ -2625,13 +2632,13 @@ async function $i(e) {
2625
2632
  else {
2626
2633
  const c = Xe(e.caseIds);
2627
2634
  if (c.length)
2628
- a = s.filter((u) => c.includes(Number(u.id))).map((u) => ({
2635
+ a = n.filter((u) => c.includes(Number(u.id))).map((u) => ({
2629
2636
  id: Number(u.id),
2630
2637
  path: u.path,
2631
2638
  displayName: u.displayName
2632
2639
  }));
2633
2640
  else {
2634
- const u = s.map((l) => ({
2641
+ const u = n.map((l) => ({
2635
2642
  value: {
2636
2643
  id: Number(l.id),
2637
2644
  path: l.path,
@@ -2639,7 +2646,7 @@ async function $i(e) {
2639
2646
  },
2640
2647
  name: l.path.replace(f.resolve(t.path), "")
2641
2648
  }));
2642
- a = await W({
2649
+ a = await V({
2643
2650
  message: "选择要执行的用例",
2644
2651
  pageSize: 100,
2645
2652
  loop: !1,
@@ -2662,11 +2669,11 @@ async function $i(e) {
2662
2669
  if (e.executionId)
2663
2670
  Number.isNaN(Number(e.executionId)) && m(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
2664
2671
  else {
2665
- const d = await vs(), g = await k({
2672
+ const d = await An(), g = await E({
2666
2673
  message: "请选择用例执行出错后,BUG所属的项目",
2667
2674
  choices: d.map(({ id: v, name: R }) => ({ name: R, value: v }))
2668
- }), h = await As(g);
2669
- u = await k({
2675
+ }), h = await bn(g);
2676
+ u = await E({
2670
2677
  message: "请选择用例执行出错后,BUG所属的执行",
2671
2678
  choices: h.map(({ id: v, name: R }) => ({ name: R, value: v }))
2672
2679
  });
@@ -2675,7 +2682,7 @@ async function $i(e) {
2675
2682
  if (e.buildId)
2676
2683
  l = e.buildId;
2677
2684
  else {
2678
- const d = await bs(Number(u));
2685
+ const d = await Sn(Number(u));
2679
2686
  if (d.length) {
2680
2687
  const g = await Re({
2681
2688
  message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
@@ -2691,7 +2698,7 @@ async function $i(e) {
2691
2698
  }
2692
2699
  i.start("上传中...");
2693
2700
  for (const d of r)
2694
- await $s({
2701
+ await vn({
2695
2702
  caseId: d.id,
2696
2703
  caseResult: "fail",
2697
2704
  stepResults: d.result,
@@ -2706,44 +2713,44 @@ async function $i(e) {
2706
2713
  }
2707
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));
2708
2715
  const vi = async () => {
2709
- const { projects: e } = await Os(), t = V();
2716
+ const { projects: e } = await Mn(), t = W();
2710
2717
  if (t.serverProjectURL) {
2711
- const n = e.find(
2712
- (s) => Pe(s.url, t.serverProjectURL)
2718
+ const s = e.find(
2719
+ (n) => Pe(n.url, t.serverProjectURL)
2713
2720
  );
2714
- if (n)
2721
+ if (s)
2715
2722
  return {
2716
- projectId: decodeURIComponent(se(t.serverProjectURL)),
2717
- moduleList: n.modules || []
2723
+ projectId: decodeURIComponent(ne(t.serverProjectURL)),
2724
+ moduleList: s.modules || []
2718
2725
  };
2719
2726
  }
2720
- const a = await k({
2727
+ const a = await E({
2721
2728
  message: "请选择本项目对应的服务端项目",
2722
- choices: e.map((n) => ({
2723
- name: `${n.name}(${n.url})`,
2724
- value: n.url
2729
+ choices: e.map((s) => ({
2730
+ name: `${s.name}(${s.url})`,
2731
+ value: s.url
2725
2732
  }))
2726
2733
  });
2727
2734
  return It({ ...t, serverProjectURL: a }), {
2728
- projectId: decodeURIComponent(se(a)),
2729
- moduleList: e.find((n) => n.url === a)?.modules || []
2735
+ projectId: decodeURIComponent(ne(a)),
2736
+ moduleList: e.find((s) => s.url === a)?.modules || []
2730
2737
  };
2731
2738
  }, Ai = async (e, t) => {
2732
- 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())) : [];
2733
2740
  if (a.length)
2734
2741
  return a;
2735
- const n = await Re({
2742
+ const s = await Re({
2736
2743
  message: "请选择对应的后端服务,不选默认全部",
2737
- choices: e.map((s) => ({
2738
- name: `${s.name}(${s.desc})`,
2739
- value: s.name
2744
+ choices: e.map((n) => ({
2745
+ name: `${n.name}(${n.desc})`,
2746
+ value: n.name
2740
2747
  })),
2741
2748
  required: !1,
2742
2749
  pageSize: 10,
2743
2750
  loop: !0
2744
2751
  });
2745
- return n?.length ? n : e.map((s) => s.name);
2746
- }, pt = [O.DEV, O.TEST], bi = async (e) => e && pt.includes(e.trim()) ? e : await k({
2752
+ return s?.length ? s : e.map((n) => n.name);
2753
+ }, pt = [O.DEV, O.TEST], bi = async (e) => e && pt.includes(e.trim()) ? e : await E({
2747
2754
  message: "请选择对应的环境",
2748
2755
  choices: At.filter((t) => pt.includes(t.value))
2749
2756
  }), Qe = (e) => {
@@ -2751,12 +2758,12 @@ const vi = async () => {
2751
2758
  return e.match(t)?.[1];
2752
2759
  }, Si = async (e, t) => {
2753
2760
  try {
2754
- const a = await ne({
2761
+ const a = await se({
2755
2762
  url: e,
2756
2763
  method: "get"
2757
- }), n = Qe(e);
2758
- return n && (a.paths = Object.fromEntries(
2759
- 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])
2760
2767
  )), wa(a, {
2761
2768
  throwOnValidateError: !t
2762
2769
  });
@@ -2765,40 +2772,40 @@ const vi = async () => {
2765
2772
  }
2766
2773
  }, Ni = (e) => {
2767
2774
  const t = (a) => {
2768
- const { reason: n, url: s } = a;
2769
- return `## ${Qe(s)}服务接口文档校验失败
2770
- ${n.message}`;
2775
+ const { reason: s, url: n } = a;
2776
+ return `## ${Qe(n)}服务接口文档校验失败
2777
+ ${s.message}`;
2771
2778
  };
2772
2779
  return `# 服务端接口文档校验失败
2773
2780
  ${e.map(t).join(`
2774
2781
  `)}`;
2775
2782
  }, ji = async (e, t) => {
2776
- const a = Ni(e), n = V(), { groups: s } = await Ct(), i = s.find(
2777
- (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))
2778
2785
  );
2779
2786
  t.fail("API数据解析失败"), i || (t.fail("未找到对应的项目群聊组!"), process.stdout.write(`${A.red(a)}
2780
2787
  `), process.exit(1));
2781
- const { code: o, message: r } = await Ss({
2788
+ const { code: o, message: r } = await Nn({
2782
2789
  content: a,
2783
2790
  webhooks: [i.url]
2784
2791
  });
2785
2792
  o !== 0 && t.fail(`发送消息到企微群组失败: ${A.red(r)}`), process.stdout.write(`${A.red(a)}
2786
2793
  `), process.exit(1);
2787
2794
  }, Ti = async (e) => {
2788
- 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);
2789
2796
  if (!i.length)
2790
2797
  throw new Error("Failed to fetch Swagger JSON");
2791
2798
  const o = i.flatMap((l) => {
2792
- const d = l.find((g) => g.env === n);
2799
+ const d = l.find((g) => g.env === s);
2793
2800
  return d ? [d.url] : [];
2794
2801
  });
2795
2802
  if (!o.length)
2796
2803
  throw new Error("Failed to fetch Swagger JSON");
2797
- 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(
2798
2805
  (l, d) => l.status === "rejected" ? [{ reason: l.reason, url: o[d] }] : []
2799
2806
  );
2800
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 }] : []);
2801
- }, ki = () => k({
2808
+ }, ki = () => E({
2802
2809
  message: "请选择生成API的范围",
2803
2810
  choices: [
2804
2811
  {
@@ -2814,16 +2821,16 @@ ${e.map(t).join(`
2814
2821
  message: e,
2815
2822
  options: t,
2816
2823
  emptyValidateMsg: a,
2817
- pageSize: n = 20,
2818
- multiple: s = !0,
2824
+ pageSize: s = 20,
2825
+ multiple: n = !0,
2819
2826
  formatShowToValue: i
2820
2827
  }) => {
2821
2828
  const o = i ? typeof i == "function" ? i : (r) => r.map((c) => String(c.value)).join(", ") : void 0;
2822
- return W({
2829
+ return V({
2823
2830
  message: e,
2824
- pageSize: n,
2831
+ pageSize: s,
2825
2832
  clearInputWhenSelected: !0,
2826
- multiple: s,
2833
+ multiple: n,
2827
2834
  loop: !0,
2828
2835
  options: (r) => r ? t.filter((c) => (c.name ?? c.label ?? c.value).includes(r)) : t,
2829
2836
  validate: a ? (r) => r.length ? !0 : a : void 0,
@@ -2864,13 +2871,13 @@ class qt {
2864
2871
  this.o = y("API 开始生成...").start(), a === "single" ? await this.startGenerateSingleApi() : await this.startGenerateAllApi(), this.o.succeed("API 生成成功");
2865
2872
  }
2866
2873
  async startGenerateSingleApi() {
2867
- const t = [], a = this.options.remoteSwaggerJsons.map((n) => n.swaggerJson);
2874
+ const t = [], a = this.options.remoteSwaggerJsons.map((s) => s.swaggerJson);
2868
2875
  this.o.text = "获取 API 列表...";
2869
- for (const n of a) {
2870
- const { apis: s } = await ya(n, {
2876
+ for (const s of a) {
2877
+ const { apis: n } = await ya(s, {
2871
2878
  throwOnValidateError: !this.options.skipSwaggerValidate
2872
2879
  });
2873
- 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 })));
2874
2881
  }
2875
2882
  this.o.stop();
2876
2883
  try {
@@ -2882,22 +2889,22 @@ class qt {
2882
2889
  formatShowToValue: !0
2883
2890
  })
2884
2891
  );
2885
- } catch (n) {
2886
- this.o.fail(`API 生成失败: ${n.message}`);
2892
+ } catch (s) {
2893
+ this.o.fail(`API 生成失败: ${s.message}`);
2887
2894
  }
2888
2895
  }
2889
2896
  async startGenerateAllApi() {
2890
2897
  const t = await this.generateAllApi();
2891
2898
  this.o.stop();
2892
- const a = await Ei(this.options.dir), n = pe(a);
2893
- ta(n, { recursive: !0 });
2894
- const s = [];
2899
+ const a = await Ei(this.options.dir), s = pe(a);
2900
+ ta(s, { recursive: !0 });
2901
+ const n = [];
2895
2902
  this.o.start(), this.o.text = "API 生成中...";
2896
2903
  for (const i of t) {
2897
- const { path: o, content: r } = i, c = pe(n, o);
2898
- s.push(c), ve(c, r);
2904
+ const { path: o, content: r } = i, c = pe(s, o);
2905
+ n.push(c), ve(c, r);
2899
2906
  }
2900
- 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} 目录下`);
2901
2908
  }
2902
2909
  }
2903
2910
  class Ii extends qt {
@@ -2914,14 +2921,14 @@ class Ii extends qt {
2914
2921
  );
2915
2922
  }
2916
2923
  async generateSingleApi(t) {
2917
- const { remoteSwaggerJsons: a, skipSwaggerValidate: n } = this.options;
2918
- 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) {
2919
2926
  if (!t.some((r) => r.startsWith(`/${i}`)))
2920
2927
  continue;
2921
2928
  const o = await va({
2922
- swaggerJson: s,
2929
+ swaggerJson: n,
2923
2930
  controller: t,
2924
- throwOnValidateError: !n,
2931
+ throwOnValidateError: !s,
2925
2932
  showHeaderComment: !1
2926
2933
  });
2927
2934
  console.log(ht(o, { language: "typescript", ignoreIllegals: !0 }));
@@ -2936,11 +2943,11 @@ class Ci extends qt {
2936
2943
  try {
2937
2944
  const a = await Ri.lintFiles(t);
2938
2945
  await wt.outputFixes(a);
2939
- for (const n of t) {
2940
- const s = pe(n), i = dt(s, "utf-8"), o = await Sa.format(i, {
2941
- 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
2942
2949
  });
2943
- ve(s, o);
2950
+ ve(n, o);
2944
2951
  }
2945
2952
  } catch (a) {
2946
2953
  console.error(a), this.o.stop(), m("API 格式化失败,请检查是否配置 eslint 和 prettier");
@@ -2956,15 +2963,15 @@ class Ci extends qt {
2956
2963
  );
2957
2964
  }
2958
2965
  async generateSingleApi(t) {
2959
- const { remoteSwaggerJsons: a, skipSwaggerValidate: n } = this.options;
2960
- 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) {
2961
2968
  if (!t.some((r) => r.startsWith(`/${i}`)))
2962
2969
  continue;
2963
2970
  const o = await ba({
2964
- swaggerJson: s,
2971
+ swaggerJson: n,
2965
2972
  merge: !0,
2966
2973
  controller: t,
2967
- throwOnValidateError: !n,
2974
+ throwOnValidateError: !s,
2968
2975
  importMethods: !1
2969
2976
  });
2970
2977
  console.log(ht(o, { language: "typescript", ignoreIllegals: !0 }));
@@ -2984,11 +2991,11 @@ const Li = (e) => {
2984
2991
  };
2985
2992
  async function Pi(e) {
2986
2993
  ee(), H();
2987
- 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({
2988
2995
  moduleList: t,
2989
2996
  services: i,
2990
2997
  env: r,
2991
- skipSwaggerValidate: s
2998
+ skipSwaggerValidate: n
2992
2999
  }), u = await ki();
2993
3000
  await xi({
2994
3001
  remoteSwaggerJsons: c,
@@ -3009,18 +3016,18 @@ const Di = 10, Oi = async () => {
3009
3016
  `remotes/origin/${w.MASTER}`
3010
3017
  ];
3011
3018
  return (await p("git branch -a")).trim().split(`
3012
- `).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) => ({
3013
- name: n,
3014
- 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
3015
3022
  }));
3016
3023
  }, Mi = async (e) => (await p(
3017
3024
  `git log ${e} -n ${Di} --format="%H%x1f%s%x1f%an%x1f%ae%x1f%aI" --no-merges`
3018
3025
  )).trim().split(`
3019
3026
  `).filter((a) => a.trim() !== "").map((a) => {
3020
- const [n = "", s = "", i = "", o = "", r = ""] = a.split("");
3027
+ const [s = "", n = "", i = "", o = "", r = ""] = a.split("");
3021
3028
  return {
3022
- hash: n,
3023
- message: s,
3029
+ hash: s,
3030
+ message: n,
3024
3031
  authorName: i,
3025
3032
  authorEmail: o,
3026
3033
  authorDate: r
@@ -3043,7 +3050,7 @@ const Di = 10, Oi = async () => {
3043
3050
  return [];
3044
3051
  }
3045
3052
  }, Fi = async (e, t) => {
3046
- 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`);
3047
3054
  try {
3048
3055
  ye(t, `正在生成 patch: ${e.hash.slice(0, 8)} ${e.message}`);
3049
3056
  const i = we(`git format-patch -1 ${e.hash} --stdout --binary --full-index`, {
@@ -3054,7 +3061,7 @@ const Di = 10, Oi = async () => {
3054
3061
  status: "failed",
3055
3062
  message: he(i.stderr) || `生成 patch 失败: ${e.hash}`
3056
3063
  };
3057
- 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}"`, {
3058
3065
  silent: !0
3059
3066
  }).code === 0)
3060
3067
  return {
@@ -3062,7 +3069,7 @@ const Di = 10, Oi = async () => {
3062
3069
  reason: `已跳过重复 patch: ${e.hash.slice(0, 8)} ${e.message}`
3063
3070
  };
3064
3071
  ye(t, `正在应用 patch: ${e.hash.slice(0, 8)} ${e.message}`);
3065
- const r = we(`git apply --3way --whitespace=nowarn "${n}"`, {
3072
+ const r = we(`git apply --3way --whitespace=nowarn "${s}"`, {
3066
3073
  silent: !0
3067
3074
  });
3068
3075
  if (r.code !== 0) {
@@ -3086,7 +3093,7 @@ const Di = 10, Oi = async () => {
3086
3093
  message: he(c.stderr) || `暂存 patch 失败: ${e.hash}`
3087
3094
  };
3088
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}`);
3089
- const u = we(`git commit --file "${s}"`, {
3096
+ const u = we(`git commit --file "${n}"`, {
3090
3097
  silent: !0
3091
3098
  });
3092
3099
  return u.code !== 0 ? {
@@ -3096,14 +3103,14 @@ const Di = 10, Oi = async () => {
3096
3103
  status: "success"
3097
3104
  };
3098
3105
  } finally {
3099
- 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, {
3100
3107
  force: !0,
3101
3108
  recursive: !0
3102
3109
  });
3103
3110
  }
3104
- }, 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) => {
3105
- const s = e.indexOf(a);
3106
- 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;
3107
3114
  });
3108
3115
  async function Vi() {
3109
3116
  ee(), H(), await ge();
@@ -3119,21 +3126,21 @@ async function Vi() {
3119
3126
  });
3120
3127
  if (!a)
3121
3128
  return;
3122
- const n = await Mi(a), s = n.map((r) => ({
3129
+ const s = await Mi(a), n = s.map((r) => ({
3123
3130
  name: Ji(r),
3124
3131
  value: r.hash
3125
3132
  })), i = await Je({
3126
3133
  message: "选择需要pick的commit。选中的 commit 会按照提交时间顺序执行。",
3127
- options: s,
3134
+ options: n,
3128
3135
  emptyValidateMsg: "至少选择一个commit",
3129
3136
  formatShowToValue: (r) => r.map((c) => {
3130
- const u = n.find((l) => l.hash === c.value);
3137
+ const u = s.find((l) => l.hash === c.value);
3131
3138
  return u ? Zt(u.hash) : String(c.value);
3132
3139
  }).join(", ")
3133
3140
  });
3134
3141
  if (!i?.length)
3135
3142
  return;
3136
- const o = Ui(n, i);
3143
+ const o = Ui(s, i);
3137
3144
  e.start(`开始处理分支 ${a} 的 commit...`);
3138
3145
  for (const r of o) {
3139
3146
  const c = await Fi(r, e);
@@ -3165,17 +3172,17 @@ async function Hi() {
3165
3172
  if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
3166
3173
  const a = await He();
3167
3174
  De(a);
3168
- let n;
3175
+ let s;
3169
3176
  try {
3170
- const s = "TIME_OUT", i = new Promise((o) => {
3171
- setTimeout(() => o(s), 3e3);
3177
+ const n = "TIME_OUT", i = new Promise((o) => {
3178
+ setTimeout(() => o(n), 3e3);
3172
3179
  });
3173
- n = await Promise.race([
3180
+ s = await Promise.race([
3174
3181
  i,
3175
3182
  p(`npm view ${ce.name} version --registry https://registry.npmmirror.com/`)
3176
- ]), n !== s && n !== ce.version && (console.log(`${A.blue(ce.name)}本地版本为${ce.version},低于线上版本${n},开始升级`), await Ft(n)), de("latestCheckVersionTimestamp", Date.now()), X();
3177
- } catch (s) {
3178
- 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);
3179
3186
  }
3180
3187
  }
3181
3188
  }
@@ -3184,7 +3191,7 @@ async function qi() {
3184
3191
  if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
3185
3192
  if (jt()) {
3186
3193
  const t = L.readJSONSync(xe());
3187
- E(t.profile), de(t.main), De(t.constants), await Hi();
3194
+ k(t.profile), de(t.main), De(t.constants), await Hi();
3188
3195
  } else
3189
3196
  m(`请先初始化z-develop(执行 z i)。更多见${bt}`);
3190
3197
  }