cli-z-develop 0.14.4 → 0.14.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +397 -380
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,46 +2,46 @@ import { program as D } from "commander";
2
2
  import kt from "node:child_process";
3
3
  import * as Je from "node:fs";
4
4
  import { existsSync as $, readdirSync as Tt, lstatSync as Et, createWriteStream as Rt, writeFileSync as It } from "node:fs";
5
- import { readdir as Ie, mkdir as pe, writeFile as P, rename as qe, readFile as Re, stat as Ct } from "node:fs/promises";
5
+ import { readdir as Ce, mkdir as pe, writeFile as P, rename as qe, readFile as Ie, stat as Ct } from "node:fs/promises";
6
6
  import l from "node:path";
7
7
  import le, { AxiosError as xt } from "axios";
8
- import k from "chalk";
8
+ import A from "chalk";
9
9
  import Dt from "dayjs";
10
10
  import L from "shelljs";
11
11
  import Pt from "node:os";
12
- import Fe from "child_process";
13
- import { confirm as He, select as b, input as U, password as Lt, checkbox as ve, number as Ue } from "@inquirer/prompts";
12
+ import Ue from "child_process";
13
+ import { confirm as Ze, select as b, input as B, password as Lt, checkbox as ve, number as Be } from "@inquirer/prompts";
14
14
  import y from "ora";
15
15
  import C from "fs-extra";
16
- import { select as ee } from "inquirer-select-pro";
16
+ import { select as te } from "inquirer-select-pro";
17
17
  import Ot from "lint-staged";
18
18
  import Mt from "semver";
19
19
  import { run as zt } from "npm-check-updates";
20
- import Jt from "p-limit";
21
- import { generateTypescriptBundleApi as Ft, validateSwagger as Ut, getParsedSwagger as Bt, generateTypescriptApi as _t } from "@lonely9/api-generate";
20
+ import Ft from "p-limit";
21
+ import { generateTypescriptBundleApi as Jt, validateSwagger as Ut, getParsedSwagger as Bt, generateTypescriptApi as _t } from "@lonely9/api-generate";
22
22
  import { highlight as Gt } from "cli-highlight";
23
- import { ESLint as Ze } from "eslint";
23
+ import { ESLint as He } from "eslint";
24
24
  import { readFileSync as Wt } from "fs";
25
25
  import Vt from "prettier";
26
26
  import qt from "minimist";
27
- const Ke = "dev", Ye = "test", Xe = "release", Ht = "production", Zt = "master";
28
- var S = /* @__PURE__ */ ((e) => (e[e.DEV = Ke] = "DEV", e[e.TEST = Ye] = "TEST", e[e.RELEASE = Xe] = "RELEASE", e[e.PROD = Ht] = "PROD", e))(S || {}), v = /* @__PURE__ */ ((e) => (e[e.DEV = Ke] = "DEV", e[e.TEST = Ye] = "TEST", e[e.RELEASE = Xe] = "RELEASE", e[e.MASTER = Zt] = "MASTER", e))(v || {}), W = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(W || {});
27
+ const Ke = "dev", Ye = "test", Xe = "release", Zt = "production", Ht = "master";
28
+ var k = /* @__PURE__ */ ((e) => (e[e.DEV = Ke] = "DEV", e[e.TEST = Ye] = "TEST", e[e.RELEASE = Xe] = "RELEASE", e[e.PROD = Zt] = "PROD", e))(k || {}), v = /* @__PURE__ */ ((e) => (e[e.DEV = Ke] = "DEV", e[e.TEST = Ye] = "TEST", e[e.RELEASE = Xe] = "RELEASE", e[e.MASTER = Ht] = "MASTER", e))(v || {}), W = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(W || {});
29
29
  const Qe = [
30
30
  {
31
- name: `开发环境 - ${S.DEV}`,
32
- value: S.DEV
31
+ name: `开发环境 - ${k.DEV}`,
32
+ value: k.DEV
33
33
  },
34
34
  {
35
- name: `测试环境 - ${S.TEST}`,
36
- value: S.TEST
35
+ name: `测试环境 - ${k.TEST}`,
36
+ value: k.TEST
37
37
  },
38
38
  {
39
- name: `预发环境 - ${S.RELEASE}`,
40
- value: S.RELEASE
39
+ name: `预发环境 - ${k.RELEASE}`,
40
+ value: k.RELEASE
41
41
  },
42
42
  {
43
- name: `正式环境 - ${S.PROD}`,
44
- value: S.PROD
43
+ name: `正式环境 - ${k.PROD}`,
44
+ value: k.PROD
45
45
  }
46
46
  ], Kt = [
47
47
  {
@@ -72,7 +72,7 @@ const Yt = {
72
72
  8: "财务",
73
73
  9: "其他"
74
74
  }, fe = "http://git.cxlqd.com", Xt = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
75
- var j = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(j || {});
75
+ var S = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(S || {});
76
76
  const Qt = "fe-biz7tvsd", et = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
77
77
  var I = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(I || {});
78
78
  const ea = [
@@ -86,9 +86,9 @@ const ea = [
86
86
  value: "case"
87
87
  /* CASE */
88
88
  }
89
- ], ta = 150 * 1024, aa = ".z", ia = "develop-config.json", Y = ".z", na = ".commit-msg-tpl", sa = "project.json";
89
+ ], ta = 150 * 1024, aa = ".z", ia = "develop-config.json", X = ".z", na = ".commit-msg-tpl", sa = "project.json";
90
90
  function R(e = "") {
91
- return l.join(Y, e);
91
+ return l.join(X, e);
92
92
  }
93
93
  function tt() {
94
94
  return R(sa);
@@ -97,7 +97,7 @@ function Ne() {
97
97
  return R(na);
98
98
  }
99
99
  function at() {
100
- Fe.spawnSync("git", ["config", "core.hooksPath", R()]), Fe.spawnSync("git", ["config", "commit.template", Ne()]);
100
+ Ue.spawnSync("git", ["config", "core.hooksPath", R()]), Ue.spawnSync("git", ["config", "commit.template", Ne()]);
101
101
  }
102
102
  function he(e = "") {
103
103
  return l.resolve(Pt.homedir(), aa, e);
@@ -111,7 +111,7 @@ function ra() {
111
111
  function it() {
112
112
  return ra() && $(Ae());
113
113
  }
114
- function X(e, t = !0) {
114
+ function Q(e, t = !0) {
115
115
  let a = e.trim();
116
116
  const n = a.match(/^git@([^:]+):(.+)$/);
117
117
  if (n)
@@ -124,27 +124,27 @@ function X(e, t = !0) {
124
124
  return t ? encodeURIComponent(i) : i;
125
125
  }
126
126
  function nt(e, t) {
127
- return X(e) === X(t);
127
+ return Q(e) === Q(t);
128
128
  }
129
- const { red: Be, green: oa, blue: is, magenta: ca, yellow: ns } = k;
129
+ const { red: _e, green: oa, blue: ns, magenta: ca, yellow: ss } = A;
130
130
  function ye(...e) {
131
131
  }
132
132
  function V(...e) {
133
133
  console.log(oa(...e));
134
134
  }
135
135
  function st(e) {
136
- e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(k.cyan(" 👋 下次见~")), console.log(), process.exit(1));
136
+ e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(A.cyan(" 👋 下次见~")), console.log(), process.exit(1));
137
137
  }
138
138
  function m(e, t = !1) {
139
139
  st(e);
140
140
  let a = e;
141
- e instanceof Error ? (a = e.message, le.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(Be(a)), console.log(ca(e.stack))) : console.log(Be(e)), t || process.exit(1);
141
+ e instanceof Error ? (a = e.message, le.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(_e(a)), console.log(ca(e.stack))) : console.log(_e(e)), t || process.exit(1);
142
142
  }
143
- function _e(e) {
143
+ function Ge(e) {
144
144
  return $(e) ? Et(e).isDirectory() : !1;
145
145
  }
146
146
  function rt(e = process.cwd()) {
147
- return _e(e) ? Tt(e).filter((a) => _e(l.resolve(e, a))) : [];
147
+ return Ge(e) ? Tt(e).filter((a) => Ge(l.resolve(e, a))) : [];
148
148
  }
149
149
  async function d(e, t = {
150
150
  removeTailLinkBreak: !0,
@@ -176,22 +176,22 @@ function la(e, t) {
176
176
  return !1;
177
177
  return !0;
178
178
  }
179
- function te() {
179
+ function ae() {
180
180
  $(R()) || m("当前不在项目根目录。请切换到项目根目录");
181
181
  }
182
- function H() {
182
+ function Z() {
183
183
  $(l.resolve(".git")) || m("当前不是git项目根目录,请先执行git init,或切换到根目录");
184
184
  }
185
185
  async function be() {
186
186
  await d("git status -s") !== "" && m("请先提交代码变动,再进行操作");
187
187
  }
188
188
  function ma(e) {
189
- return e === v.MASTER ? S.PROD : e;
189
+ return e === v.MASTER ? k.PROD : e;
190
190
  }
191
191
  function pa(e) {
192
- return e === S.PROD ? v.MASTER : e;
192
+ return e === k.PROD ? v.MASTER : e;
193
193
  }
194
- async function z(e, ...t) {
194
+ async function F(e, ...t) {
195
195
  try {
196
196
  await e(...t);
197
197
  } catch (a) {
@@ -199,7 +199,7 @@ async function z(e, ...t) {
199
199
  }
200
200
  }
201
201
  async function da(e) {
202
- return (await Ie(e)).length === 0;
202
+ return (await Ce(e)).length === 0;
203
203
  }
204
204
  function fa(e = "项目中文名", t = "项目描述") {
205
205
  return `
@@ -276,7 +276,7 @@ const ga = {
276
276
  "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
277
277
  "**/*.md": "markdownlint --fix"
278
278
  }
279
- }, ha = "cli-z-develop", wa = "0.14.4", ya = "技术团队开发流程管理工具", va = "dist/index.js", $a = { z: "bin/z.js", "z-develop": "bin/z.js" }, Na = { 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", 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" }, Aa = "module", ba = "z", ja = { "@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" }, Sa = { "@inquirer/prompts": "^8.4.1", "@lonely9/api-generate": "^0.2.4", 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", ora: "^9.3.0", "p-limit": "^7.3.0", prettier: "^3.8.2", semver: "^7.7.4", shelljs: "^0.10.0" }, re = {
279
+ }, ha = "cli-z-develop", wa = "0.14.5", ya = "技术团队开发流程管理工具", va = "dist/index.js", $a = { z: "bin/z.js", "z-develop": "bin/z.js" }, Na = { 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", 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" }, Aa = "module", ba = "z", ja = { "@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" }, Sa = { "@inquirer/prompts": "^8.4.1", "@lonely9/api-generate": "^0.2.5", 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", ora: "^9.3.0", "p-limit": "^7.3.0", prettier: "^3.8.2", semver: "^7.7.4", shelljs: "^0.10.0" }, re = {
280
280
  name: ha,
281
281
  version: wa,
282
282
  description: ya,
@@ -327,17 +327,17 @@ function E(e) {
327
327
  function ge(e) {
328
328
  return e ? x.main[e] : x.main;
329
329
  }
330
- function B(e) {
330
+ function z(e) {
331
331
  return e ? x.constants[e] : x.constants;
332
332
  }
333
333
  let _ = null, G = null;
334
- function Ce() {
334
+ function xe() {
335
335
  if (_)
336
336
  return _;
337
337
  const e = l.join("package.json");
338
338
  return $(e) || m(`当前目录(${L.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), _ = C.readJsonSync(e), _;
339
339
  }
340
- function ae() {
340
+ function ie() {
341
341
  if (G)
342
342
  return G;
343
343
  const e = tt();
@@ -357,7 +357,7 @@ function ka(e) {
357
357
  ...e
358
358
  } : _ = e, C.writeJSONSync(l.join("package.json"), _, { spaces: 2 });
359
359
  }
360
- const K = {
360
+ const Y = {
361
361
  id: 0,
362
362
  path: "",
363
363
  group: "",
@@ -365,14 +365,14 @@ const K = {
365
365
  mergeRequestUrl: ""
366
366
  };
367
367
  async function Ta() {
368
- if (!K.id)
368
+ if (!Y.id)
369
369
  try {
370
- const e = ae(), t = X(e.repository.url), a = await mt(t);
371
- K.id = a.id, K.path = t, K.group = a.namespace.full_path, K.mergeRequestUrl = `${a.web_url}/merge_requests`;
370
+ const e = ie(), t = Q(e.repository.url), a = await mt(t);
371
+ Y.id = a.id, Y.path = t, Y.group = a.namespace.full_path, Y.mergeRequestUrl = `${a.web_url}/merge_requests`;
372
372
  } catch (e) {
373
373
  m(e);
374
374
  }
375
- return K.sourceBranch || (K.sourceBranch = await d("git branch --show-current")), K;
375
+ return Y.sourceBranch || (Y.sourceBranch = await d("git branch --show-current")), Y;
376
376
  }
377
377
  function oe() {
378
378
  C.writeJSONSync(
@@ -380,7 +380,7 @@ function oe() {
380
380
  {
381
381
  main: ge(),
382
382
  profile: E(),
383
- constants: B()
383
+ constants: z()
384
384
  },
385
385
  {
386
386
  spaces: 2
@@ -405,7 +405,7 @@ function me(e, t) {
405
405
  ...e
406
406
  };
407
407
  }
408
- async function ie(e) {
408
+ async function H(e) {
409
409
  const t = e.method || "get", a = e.headers || {}, n = e.data || {}, i = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
410
410
  try {
411
411
  const s = {
@@ -415,11 +415,11 @@ async function ie(e) {
415
415
  headers: a,
416
416
  responseType: e?.responseType || "json"
417
417
  };
418
- ye(k.magenta(s.method.toUpperCase()), k.yellow(s.url), JSON.stringify(s.headers)), ye(k.gray(JSON.stringify(s[i], null, 2)));
418
+ ye(A.magenta(s.method.toUpperCase()), A.yellow(s.url), JSON.stringify(s.headers)), ye(A.gray(JSON.stringify(s[i], null, 2)));
419
419
  const o = await le(s);
420
- return ye(k.green("Response"), k.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
420
+ return ye(A.green("Response"), A.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
421
421
  } catch (s) {
422
- return s instanceof xt && ye(k.red("Error"), k.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
422
+ return s instanceof xt && ye(A.red("Error"), A.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
423
423
  }
424
424
  }
425
425
  async function Ea() {
@@ -427,7 +427,7 @@ async function Ea() {
427
427
  if (e)
428
428
  return e;
429
429
  {
430
- const { access_token: t } = await ie({
430
+ const { access_token: t } = await H({
431
431
  url: `${fe}/oauth/token`,
432
432
  method: "post",
433
433
  data: {
@@ -440,7 +440,7 @@ async function Ea() {
440
440
  }
441
441
  }
442
442
  async function N(e) {
443
- return ie({
443
+ return H({
444
444
  ...e,
445
445
  headers: {
446
446
  Authorization: await Ea()
@@ -452,8 +452,8 @@ async function Ra() {
452
452
  if (e)
453
453
  return e;
454
454
  {
455
- const { token: t } = await ie({
456
- url: `${B("ZenTaoDomain")}/api.php/v1/tokens`,
455
+ const { token: t } = await H({
456
+ url: `${z("ZenTaoDomain")}/api.php/v1/tokens`,
457
457
  method: "post",
458
458
  data: {
459
459
  account: E("ldapAccount"),
@@ -464,7 +464,7 @@ async function Ra() {
464
464
  }
465
465
  }
466
466
  async function $e(e) {
467
- const t = await ie({
467
+ const t = await H({
468
468
  ...e,
469
469
  headers: {
470
470
  Token: await Ra()
@@ -495,8 +495,8 @@ async function Ia() {
495
495
  if (e)
496
496
  return e;
497
497
  {
498
- const { access_token: t } = await ie({
499
- url: `${B("K8sDomain")}/oauth/login/LDAP`,
498
+ const { access_token: t } = await H({
499
+ url: `${z("K8sDomain")}/oauth/login/LDAP`,
500
500
  method: "post",
501
501
  headers: {
502
502
  "Content-Type": "application/x-www-form-urlencoded"
@@ -510,7 +510,7 @@ async function Ia() {
510
510
  }
511
511
  }
512
512
  async function ut(e) {
513
- const t = await ie({
513
+ const t = await H({
514
514
  ...e,
515
515
  headers: {
516
516
  Authorization: await Ia()
@@ -537,65 +537,65 @@ async function Ca(e, t) {
537
537
  throw console.error("下载失败:", a), a;
538
538
  }
539
539
  }
540
- const J = () => `${fe}/api/v4`, F = (e) => `${J()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
540
+ const J = () => `${fe}/api/v4`, U = (e) => `${J()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
541
541
  function xa() {
542
542
  return N({
543
- url: F("src/data/template-projects.json")
543
+ url: U("src/data/template-projects.json")
544
544
  });
545
545
  }
546
546
  function Da() {
547
547
  return N({
548
- url: F("src/data/java-project-module.json")
548
+ url: U("src/data/java-project-module.json")
549
549
  });
550
550
  }
551
551
  function Pa() {
552
552
  return N({
553
- url: F("src/data/java-project-api.json")
553
+ url: U("src/data/java-project-api.json")
554
554
  });
555
555
  }
556
- function xe() {
556
+ function De() {
557
557
  return N({
558
- url: F("src/data/z-develop-config.json")
558
+ url: U("src/data/z-develop-config.json")
559
559
  });
560
560
  }
561
561
  function La() {
562
562
  return N({
563
- url: F("src/assets/tsconfig.browser.json")
563
+ url: U("src/assets/tsconfig.browser.json")
564
564
  });
565
565
  }
566
566
  function Oa() {
567
567
  return N({
568
- url: F("src/assets/tsconfig.node.json")
568
+ url: U("src/assets/tsconfig.node.json")
569
569
  });
570
570
  }
571
571
  function Ma() {
572
572
  return N({
573
- url: F("src/assets/.prettierignore")
573
+ url: U("src/assets/.prettierignore")
574
574
  });
575
575
  }
576
576
  function za() {
577
577
  return N({
578
- url: F("src/assets/.prettierrc.json")
578
+ url: U("src/assets/.prettierrc.json")
579
579
  });
580
580
  }
581
- function Ja() {
581
+ function Fa() {
582
582
  return N({
583
- url: F("src/assets/data.yaml")
583
+ url: U("src/assets/data.yaml")
584
584
  });
585
585
  }
586
- function Fa() {
586
+ function Ja() {
587
587
  return N({
588
- url: F("src/assets/main.py")
588
+ url: U("src/assets/main.py")
589
589
  });
590
590
  }
591
591
  function Ua() {
592
592
  return N({
593
- url: F("src/assets/checkstyle.xml")
593
+ url: U("src/assets/checkstyle.xml")
594
594
  });
595
595
  }
596
596
  function lt() {
597
597
  return N({
598
- url: F("src/data/project-group-chats.json")
598
+ url: U("src/data/project-group-chats.json")
599
599
  });
600
600
  }
601
601
  function Ba() {
@@ -642,14 +642,14 @@ function qa(e) {
642
642
  method: "put"
643
643
  });
644
644
  }
645
- function Ha(e) {
645
+ function Za(e) {
646
646
  return N({
647
647
  url: `${J()}/projects/${e.id}/merge_requests/${e.iid}`,
648
648
  method: "put",
649
649
  data: e
650
650
  });
651
651
  }
652
- function Za(e) {
652
+ function Ha(e) {
653
653
  return N({
654
654
  url: `${J()}/projects/${e.id}/merge_requests/${e.iid}`,
655
655
  method: "get"
@@ -682,46 +682,58 @@ async function Qa() {
682
682
  }).filter((a) => !!a);
683
683
  C.writeJSONSync(he("fe-groups.json"), { groups: t }, { spaces: 2 });
684
684
  }
685
- async function A(e) {
686
- const t = `${B("FEServerDomain")}/api`, a = await ie({
685
+ async function j(e) {
686
+ const t = `${z("FEServerDomain")}/api`, a = await H({
687
687
  url: t + e.url,
688
688
  headers: {
689
689
  "the-key-one": "z-develop",
690
- "the-key-two": B("ZDevelopPassword")
690
+ "the-key-two": z("ZDevelopPassword")
691
691
  },
692
692
  data: e.data,
693
693
  method: e.method || "post"
694
694
  });
695
695
  return a.code !== 0 && m(`${a.code}: ${a.message}`), a.data;
696
696
  }
697
- function ei() {
698
- return A({
699
- url: "/user/list2"
697
+ async function ei(e) {
698
+ const t = `${z("FEServerDomain")}/api`;
699
+ return await H({
700
+ url: t + e.url,
701
+ headers: {
702
+ "the-key-one": "z-develop",
703
+ "the-key-two": z("ZDevelopPassword")
704
+ },
705
+ data: e.data,
706
+ method: e.method || "post"
700
707
  });
701
708
  }
702
709
  function ti() {
703
- return A({
710
+ return j({
711
+ url: "/user/list2"
712
+ });
713
+ }
714
+ function ai() {
715
+ return j({
704
716
  url: "/zen/testcase/product/list"
705
717
  });
706
718
  }
707
719
  function pt(e) {
708
- return A({
720
+ return j({
709
721
  url: "/zen/testcase/product/module/list",
710
722
  data: {
711
723
  product: e
712
724
  }
713
725
  });
714
726
  }
715
- function ai(e) {
716
- return A({
727
+ function ii(e) {
728
+ return j({
717
729
  url: "/zen/testcase/product/name",
718
730
  data: {
719
731
  product: e
720
732
  }
721
733
  });
722
734
  }
723
- function ii(e, t) {
724
- return A({
735
+ function ni(e, t) {
736
+ return j({
725
737
  url: "/zen/testcase/product/auto-case/list",
726
738
  data: {
727
739
  product: e,
@@ -729,108 +741,108 @@ function ii(e, t) {
729
741
  }
730
742
  });
731
743
  }
732
- function ni(e) {
733
- return A({
744
+ function si(e) {
745
+ return j({
734
746
  url: "/zen/testcase/step/list",
735
747
  data: {
736
748
  id: e
737
749
  }
738
750
  });
739
751
  }
740
- function si(e) {
741
- return A({
752
+ function ri(e) {
753
+ return j({
742
754
  url: "/zen/testcase/module/create",
743
755
  data: e
744
756
  });
745
757
  }
746
- function ri(e) {
747
- return A({
758
+ function oi(e) {
759
+ return j({
748
760
  url: "/zen/testcase/create",
749
761
  data: e
750
762
  });
751
763
  }
752
- function oi(e) {
753
- return A({
764
+ function ci(e) {
765
+ return j({
754
766
  url: "/zen/testcase/step/create",
755
767
  data: e
756
768
  });
757
769
  }
758
- function ci(e) {
759
- return A({
770
+ function ui(e) {
771
+ return j({
760
772
  url: "/zen/testcase/modules/remove",
761
773
  data: e
762
774
  });
763
775
  }
764
- function ui(e) {
765
- return A({
776
+ function li(e) {
777
+ return j({
766
778
  url: "/zen/testcase/cases/remove",
767
779
  data: e
768
780
  });
769
781
  }
770
- function li(e) {
771
- return A({
782
+ function mi(e) {
783
+ return j({
772
784
  url: "/zen/testcase/module/update/name",
773
785
  data: e
774
786
  });
775
787
  }
776
- function mi(e) {
777
- return A({
788
+ function pi(e) {
789
+ return j({
778
790
  url: "/zen/testcase/case/update/name",
779
791
  data: e
780
792
  });
781
793
  }
782
- function pi(e) {
783
- return A({
794
+ function di(e) {
795
+ return j({
784
796
  url: "/zen/testcase/case/update/priority",
785
797
  data: e
786
798
  });
787
799
  }
788
- function di(e) {
789
- return A({
800
+ function fi(e) {
801
+ return j({
790
802
  url: "/zen/testcase/case/update/precondition",
791
803
  data: e
792
804
  });
793
805
  }
794
- function fi(e) {
795
- return A({
806
+ function gi(e) {
807
+ return j({
796
808
  url: "/zen/testcase/case/result/create",
797
809
  data: e
798
810
  });
799
811
  }
800
- function gi() {
801
- return A({
812
+ function hi() {
813
+ return j({
802
814
  url: "/zen/testcase/project/list"
803
815
  });
804
816
  }
805
- function hi(e) {
806
- return A({
817
+ function wi(e) {
818
+ return j({
807
819
  url: "/zen/testcase/project/execution/list",
808
820
  data: {
809
821
  project: e
810
822
  }
811
823
  });
812
824
  }
813
- function wi(e) {
814
- return A({
825
+ function yi(e) {
826
+ return j({
815
827
  url: "/zen/testcase/execution/build/list",
816
828
  data: {
817
829
  id: e
818
830
  }
819
831
  });
820
832
  }
821
- function yi(e) {
822
- return A({
833
+ function vi(e) {
834
+ return j({
823
835
  url: "/common/ai/talk",
824
836
  data: e
825
837
  });
826
838
  }
827
- function vi(e) {
828
- return A({
839
+ function $i(e) {
840
+ return ei({
829
841
  url: "/common/notify/group/send",
830
842
  data: e
831
843
  });
832
844
  }
833
- function $i(e, t) {
845
+ function Ni(e, t) {
834
846
  const a = [];
835
847
  t.forEach((s) => {
836
848
  e.includes(s.value) && a.push(s);
@@ -847,7 +859,7 @@ function $i(e, t) {
847
859
  }), oe();
848
860
  }
849
861
  async function dt() {
850
- const t = (await ei()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
862
+ const t = (await ti()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
851
863
  name: `${s.nick} - ${Yt[s.title]}`,
852
864
  value: s.weWorkUserId
853
865
  })), a = ge("weWorkListCache"), n = a.map((s) => s.value), i = [];
@@ -861,7 +873,7 @@ async function dt() {
861
873
  }
862
874
  async function ft(e, t, a) {
863
875
  const n = await dt();
864
- let i = await ee({
876
+ let i = await te({
865
877
  message: e,
866
878
  loop: !0,
867
879
  pageSize: n.length || 5,
@@ -870,14 +882,14 @@ async function ft(e, t, a) {
870
882
  options: (s) => s ? n.filter((o) => o.name.includes(s)) : n,
871
883
  validate: t
872
884
  });
873
- return i = Array.isArray(i) ? i : [i], $i(i, n), i;
885
+ return i = Array.isArray(i) ? i : [i], Ni(i, n), i;
874
886
  }
875
- async function Ni(e, t, a) {
887
+ async function Ai(e, t, a) {
876
888
  const { groups: n } = await lt(), i = n.map((o) => ({
877
889
  name: o.name,
878
890
  value: o.url
879
891
  }));
880
- let s = await ee({
892
+ let s = await te({
881
893
  message: e,
882
894
  loop: !0,
883
895
  pageSize: i.length || 5,
@@ -888,9 +900,9 @@ async function Ni(e, t, a) {
888
900
  });
889
901
  return s = Array.isArray(s) ? s : [s], s;
890
902
  }
891
- async function Ai() {
903
+ async function bi() {
892
904
  try {
893
- it() && (await He({
905
+ it() && (await Ze({
894
906
  message: "系统中已存在z的配置文件,确认重新配置?"
895
907
  }) ? L.rm("-rf", Ae()) : process.exit(0)), await pe(he(), { recursive: !0 });
896
908
  const t = await b({
@@ -910,7 +922,7 @@ async function Ai() {
910
922
  }
911
923
  ]
912
924
  });
913
- let a = await U({
925
+ let a = await B({
914
926
  message: "请输入LDAP账号:"
915
927
  });
916
928
  a = a.trim();
@@ -919,7 +931,7 @@ async function Ai() {
919
931
  mask: !0
920
932
  });
921
933
  n = n.trim(), M("jobType", t), M("ldapAccount", a), M("ldapPassword", n);
922
- const i = await xe();
934
+ const i = await De();
923
935
  je(i);
924
936
  const s = await dt(), o = await ft("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((u) => u.value === o[0]);
925
937
  M({
@@ -942,12 +954,12 @@ async function Ai() {
942
954
  e.fail("配置信息初始化失败"), le.isAxiosError(t) && m("请检查你的域名及令牌配置"), m(t);
943
955
  }
944
956
  }
945
- async function bi() {
957
+ async function ji() {
946
958
  await P(Ne(), "", { mode: 493 }), await P(R(".gitignore"), `.commit-msg-tpl
947
959
  `, { mode: 493 }), await P(R("commit-msg"), `#!/usr/bin/env sh
948
960
  z run commit-msg`, { mode: 493 }), await P(R("pre-commit"), `#!/usr/bin/env sh
949
961
  z run commit-files`, { mode: 493 });
950
- const { language: e } = ae();
962
+ const { language: e } = ie();
951
963
  if ([w.JAVASCRIPT, w.MARKDOWN].includes(e) && (await P(
952
964
  R(".prettierrc.json"),
953
965
  `${JSON.stringify(await za(), null, 2)}
@@ -956,7 +968,7 @@ z run commit-files`, { mode: 493 });
956
968
  mode: 493
957
969
  }
958
970
  ), await P(R(".prettierignore"), await Ma(), { mode: 493 }), await P(R("tsconfig.node.json"), await Oa(), { mode: 493 }), await P(R("tsconfig.browser.json"), await La(), { mode: 493 })), e === w.JAVA) {
959
- await Ca(`${B("FECDNDomain")}/file/vgnlfbfHRF.jar`, R("checkstyle.jar")), await P(R("checkstyle.xml"), await Ua(), { mode: 493 });
971
+ await Ca(`${z("FECDNDomain")}/file/vgnlfbfHRF.jar`, R("checkstyle.jar")), await P(R("checkstyle.xml"), await Ua(), { mode: 493 });
960
972
  const t = l.join("package.json");
961
973
  $(t) || await P(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
962
974
  mode: 493
@@ -964,7 +976,7 @@ z run commit-files`, { mode: 493 });
964
976
  }
965
977
  at();
966
978
  }
967
- async function ji(e, t) {
979
+ async function Si(e, t) {
968
980
  const a = await d("git remote get-url --push origin");
969
981
  a || m("获取项目远程git地址失败,请配置后重试");
970
982
  let n = e;
@@ -991,7 +1003,7 @@ async function ji(e, t) {
991
1003
  }));
992
1004
  let i = t;
993
1005
  if (!i) {
994
- const s = X(a), o = await mt(s);
1006
+ const s = Q(a), o = await mt(s);
995
1007
  if (!o)
996
1008
  return m(`未找到项目,请确认项目${a}是否存在,或者当前账号权限`);
997
1009
  i = o.namespace.full_path;
@@ -1005,21 +1017,21 @@ async function ji(e, t) {
1005
1017
  }
1006
1018
  });
1007
1019
  }
1008
- async function De(e, t) {
1009
- e ? L.rm("-rf", Y) : $(R()) && (await He({
1010
- message: `当前项目中已存在配置文件夹${Y},确认重新配置?`
1011
- }) ? L.rm("-rf", Y) : process.exit(0)), await pe(R(), { recursive: !0 }), await ji(e, t);
1020
+ async function Pe(e, t) {
1021
+ e ? L.rm("-rf", X) : $(R()) && (await Ze({
1022
+ message: `当前项目中已存在配置文件夹${X},确认重新配置?`
1023
+ }) ? L.rm("-rf", X) : process.exit(0)), await pe(R(), { recursive: !0 }), await Si(e, t);
1012
1024
  const a = y("项目初始化中...").start();
1013
- await bi(), a.succeed("项目初始化完成");
1025
+ await ji(), a.succeed("项目初始化完成");
1014
1026
  }
1015
- async function Si() {
1016
- $(R()) && $(Ne()) ? at() : await De(), process.exit(0);
1027
+ async function ki() {
1028
+ $(R()) && $(Ne()) ? at() : await Pe(), process.exit(0);
1017
1029
  }
1018
- async function ki(e, t) {
1019
- t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && m("项目语言不支持"), e ? (H(), e === "." ? (await De(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await Si() : m("参数错误。执行 z init -h 查看帮助。")) : await Ai();
1020
- }
1021
- D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => z(ki, ...e));
1022
1030
  async function Ti(e, t) {
1031
+ t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && m("项目语言不支持"), e ? (Z(), e === "." ? (await Pe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await ki() : m("参数错误。执行 z init -h 查看帮助。")) : await bi();
1032
+ }
1033
+ D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => F(Ti, ...e));
1034
+ async function Ei(e, t) {
1023
1035
  if (!e)
1024
1036
  return "不能为空";
1025
1037
  if (!/^[a-z0-9-]+$/.test(e))
@@ -1029,14 +1041,14 @@ async function Ti(e, t) {
1029
1041
  const i = (await Wa(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
1030
1042
  return i ? `远程仓库中已存在同名项目(${i.http_url_to_repo}),请更名后重试` : !0;
1031
1043
  }
1032
- function Ei(e) {
1044
+ function Ri(e) {
1033
1045
  return e ? !0 : "不能为空";
1034
1046
  }
1035
- function Ri(e) {
1047
+ function Ii(e) {
1036
1048
  return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
1037
1049
  }
1038
- async function Ii(e) {
1039
- te(), H(), await be();
1050
+ async function Ci(e) {
1051
+ ae(), Z(), await be();
1040
1052
  let t, a;
1041
1053
  e.branchType ? t = e.branchType : t = await b({
1042
1054
  message: "请选择创建分支的类型",
@@ -1054,15 +1066,15 @@ async function Ii(e) {
1054
1066
  value: de.REFACTOR
1055
1067
  }
1056
1068
  ]
1057
- }), e.branchPurpose ? a = e.branchPurpose : (a = await U({
1069
+ }), e.branchPurpose ? a = e.branchPurpose : (a = await B({
1058
1070
  message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
1059
- validate: Ri
1071
+ validate: Ii
1060
1072
  }), a = a.trim());
1061
1073
  const n = `${t}_${a}_${ot()}`;
1062
1074
  await d(`git fetch origin ${v.MASTER}`), await d(`git checkout -b ${n} origin/${v.MASTER}`), await d(`git push -u origin ${n}`), process.exit(0);
1063
1075
  }
1064
- const gt = (e) => `${B("ZenTaoDomain")}${e}`;
1065
- async function Ci() {
1076
+ const gt = (e) => `${z("ZenTaoDomain")}${e}`;
1077
+ async function xi() {
1066
1078
  const e = await $e({
1067
1079
  url: gt("/my-work-task.json?tid=mrrferp8"),
1068
1080
  method: "get"
@@ -1075,7 +1087,7 @@ async function Ci() {
1075
1087
  name: a
1076
1088
  })) : [];
1077
1089
  }
1078
- async function xi() {
1090
+ async function Di() {
1079
1091
  const e = await $e({
1080
1092
  url: gt("/my-work-bug.json?tid=mrrferp8"),
1081
1093
  method: "get"
@@ -1088,7 +1100,7 @@ async function xi() {
1088
1100
  }
1089
1101
  })) : [];
1090
1102
  }
1091
- async function Ge(e) {
1103
+ async function We(e) {
1092
1104
  const t = await d(`
1093
1105
  git diff --name-only HEAD | while read file; do
1094
1106
  if [ -f "$file" ] && [ $(stat -f%z "$file") -lt ${ta} ]; then
@@ -1097,7 +1109,7 @@ async function Ge(e) {
1097
1109
  done | xargs git diff HEAD --
1098
1110
  `);
1099
1111
  t || m("git暂存区没有内容,请先git add添加文件到暂存区");
1100
- const a = await yi({
1112
+ const a = await vi({
1101
1113
  type: "commit-message-v2",
1102
1114
  input: t
1103
1115
  // modelName: "qwen-turbo",
@@ -1107,39 +1119,39 @@ async function Ge(e) {
1107
1119
  async function Ee(e, t, a) {
1108
1120
  const n = y("🤖 生成提交信息中...").start();
1109
1121
  let i = "", s = !0;
1110
- if ([j.FEAT, j.FIX, j.REFACTOR].includes(e)) {
1122
+ if ([S.FEAT, S.FIX, S.REFACTOR].includes(e)) {
1111
1123
  const o = t.map((r) => r.value).join(",");
1112
- if (a || (i = await Ge(`${e}(${o}): `)), !i) {
1124
+ if (a || (i = await We(`${e}(${o}): `)), !i) {
1113
1125
  const r = t.map((c) => c.name).join(";");
1114
1126
  i = `${e}(${o}): ${r}`, s = !1;
1115
1127
  }
1116
1128
  }
1117
- e === j.CHORE && (t ? i = `${e}: ${t}` : i = await Ge(`${e}: `)), await P(Ne(), i, "utf-8"), s || a ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(k.yellow(i));
1129
+ e === S.CHORE && (t ? i = `${e}: ${t}` : i = await We(`${e}: `)), await P(Ne(), i, "utf-8"), s || a ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(A.yellow(i));
1118
1130
  }
1119
- async function Di(e) {
1131
+ async function Pi(e) {
1120
1132
  const t = await b({
1121
1133
  message: "请选择你要创建的模板类型",
1122
1134
  choices: [
1123
1135
  {
1124
1136
  name: "feat - 业务需求/功能开发/BUG修复",
1125
- value: j.FEAT
1137
+ value: S.FEAT
1126
1138
  },
1127
1139
  {
1128
1140
  name: "fix - bug修复",
1129
- value: j.FIX
1141
+ value: S.FIX
1130
1142
  },
1131
1143
  {
1132
1144
  name: "refactor - 技术重构/性能优化/代码规范",
1133
- value: j.REFACTOR
1145
+ value: S.REFACTOR
1134
1146
  },
1135
1147
  {
1136
1148
  name: "chore - 其他",
1137
- value: j.CHORE
1149
+ value: S.CHORE
1138
1150
  }
1139
1151
  ]
1140
1152
  });
1141
- if ([j.FEAT, j.REFACTOR].includes(t)) {
1142
- const a = await Ci();
1153
+ if ([S.FEAT, S.REFACTOR].includes(t)) {
1154
+ const a = await xi();
1143
1155
  if (!a.length)
1144
1156
  return V("🤷 暂无开发任务");
1145
1157
  const n = await ve({
@@ -1151,10 +1163,10 @@ async function Di(e) {
1151
1163
  })),
1152
1164
  pageSize: a.length
1153
1165
  });
1154
- await Ee(j.FEAT, n, e);
1166
+ await Ee(S.FEAT, n, e);
1155
1167
  }
1156
- if (t === j.FIX) {
1157
- const a = await xi();
1168
+ if (t === S.FIX) {
1169
+ const a = await Di();
1158
1170
  if (!a.length)
1159
1171
  return V("🤷 暂无BUG");
1160
1172
  const n = await ve({
@@ -1166,58 +1178,58 @@ async function Di(e) {
1166
1178
  })),
1167
1179
  pageSize: a.length
1168
1180
  });
1169
- await Ee(j.FIX, n, e);
1181
+ await Ee(S.FIX, n, e);
1170
1182
  }
1171
- if (t === j.CHORE) {
1183
+ if (t === S.CHORE) {
1172
1184
  let a = "";
1173
- e && (a = await U({
1185
+ e && (a = await B({
1174
1186
  message: "请输入commit msg:",
1175
1187
  validate: (n) => n.length === 0 ? "请输入commit msg" : !0
1176
- }), a = a.trim()), await Ee(j.CHORE, a);
1188
+ }), a = a.trim()), await Ee(S.CHORE, a);
1177
1189
  }
1178
1190
  process.exit(0);
1179
1191
  }
1180
- async function Pi() {
1192
+ async function Li() {
1181
1193
  try {
1182
1194
  const e = {}, t = async () => {
1183
- const O = rt(), { projects: se } = await xa(), Z = se.map((ce) => {
1184
- const ze = {
1195
+ const O = rt(), { projects: se } = await xa(), K = se.map((ce) => {
1196
+ const Fe = {
1185
1197
  name: `${ce.name} [${ce.desc}]`,
1186
1198
  value: ce.name,
1187
1199
  disabled: !1
1188
1200
  };
1189
- return O.includes(ce.name) && (ze.disabled = "目录下已存在同名文件夹"), ze;
1201
+ return O.includes(ce.name) && (Fe.disabled = "目录下已存在同名文件夹"), Fe;
1190
1202
  }), St = await b({
1191
1203
  message: "请选择一个项目模板",
1192
- choices: Z
1204
+ choices: K
1193
1205
  }), Te = se.find((ce) => ce.name === St);
1194
1206
  e.tplName = Te.name, e.tplUrl = Te.url, e.tplLanguage = Te.language;
1195
1207
  }, a = async () => {
1196
1208
  const { groups: O } = Xa(), se = await b({
1197
1209
  message: "请选择一个分组",
1198
- choices: O.map((Z) => ({
1199
- name: `${Z.name} [${Z.description}]`,
1200
- value: Z.id,
1201
- short: Z.name
1210
+ choices: O.map((K) => ({
1211
+ name: `${K.name} [${K.description}]`,
1212
+ value: K.id,
1213
+ short: K.name
1202
1214
  }))
1203
1215
  });
1204
1216
  e.group = {
1205
1217
  id: se,
1206
- name: O.find((Z) => Z.id === se)?.name
1218
+ name: O.find((K) => K.id === se)?.name
1207
1219
  };
1208
1220
  }, n = async () => {
1209
- e.projectName = await U({
1221
+ e.projectName = await B({
1210
1222
  message: "请输入项目名称",
1211
- validate: (O) => Ti(O, e.group?.name || "")
1212
- }), e.projectName = e.projectName.trim(), e.projectDesc = await U({
1223
+ validate: (O) => Ei(O, e.group?.name || "")
1224
+ }), e.projectName = e.projectName.trim(), e.projectDesc = await B({
1213
1225
  message: "请输入项目描述",
1214
- validate: Ei
1226
+ validate: Ri
1215
1227
  }), e.projectDesc = e.projectDesc.trim();
1216
1228
  };
1217
1229
  await t(), await a(), await n();
1218
1230
  const i = `${fe}/${e.group?.name}/${e.projectName}.git`, s = y("模版初始化中").start();
1219
1231
  await d(`git clone --depth=1 ${e.tplUrl}`), await qe(e.tplName, e.projectName), L.cd(e.projectName), L.rm("-rf", ".git"), await d(`git init --initial-branch=${v.MASTER}`), await d(`git remote add origin ${i}`), await d(`git config user.name ${E("gitName")}`), await d(`git config user.email ${E("gitEmail")}`);
1220
- const o = Ce();
1232
+ const o = xe();
1221
1233
  ka({
1222
1234
  ...o,
1223
1235
  name: e.projectName,
@@ -1226,7 +1238,7 @@ async function Pi() {
1226
1238
  ...o.scripts,
1227
1239
  prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
1228
1240
  }
1229
- }), await C.writeFile(l.resolve("README.md"), fa(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await De(e.tplLanguage, e.group?.name);
1241
+ }), await C.writeFile(l.resolve("README.md"), fa(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Pe(e.tplLanguage, e.group?.name);
1230
1242
  const r = y("依赖安装中").start();
1231
1243
  await d("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
1232
1244
  const c = y("项目推送中").start();
@@ -1238,7 +1250,7 @@ async function Pi() {
1238
1250
  visibility: "private",
1239
1251
  namespace_id: e.group?.id
1240
1252
  });
1241
- await d(`git push -u origin ${v.MASTER}`), await d(`git push origin HEAD:${v.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${k.blue(i)}`);
1253
+ await d(`git push -u origin ${v.MASTER}`), await d(`git push origin HEAD:${v.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${A.blue(i)}`);
1242
1254
  const p = y("初始化分支中").start(), g = `feat_init_${ot()}`, f = [v.DEV, v.TEST, v.RELEASE, g], h = await Promise.allSettled(
1243
1255
  f.map(
1244
1256
  (O) => Ka({
@@ -1250,14 +1262,14 @@ async function Pi() {
1250
1262
  ), T = [];
1251
1263
  h.forEach(({ status: O }, se) => {
1252
1264
  O === "fulfilled" && T.push(f[se]);
1253
- }), await d("git pull"), T.includes(g) ? (await d(`git checkout -b ${g} origin/${g}`), p.succeed(`项目已切换到初始分支: ${k.blue(g)}`)) : p.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
1265
+ }), await d("git pull"), T.includes(g) ? (await d(`git checkout -b ${g} origin/${g}`), p.succeed(`项目已切换到初始分支: ${A.blue(g)}`)) : p.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
1254
1266
  const ne = `cd ${e.projectName} && z start`;
1255
- console.log(`输入 ${k.green(ne)} 开始开发吧~`), process.exit(0);
1267
+ console.log(`输入 ${A.green(ne)} 开始开发吧~`), process.exit(0);
1256
1268
  } catch (e) {
1257
1269
  m(e);
1258
1270
  }
1259
1271
  }
1260
- async function Li(e, t) {
1272
+ async function Oi(e, t) {
1261
1273
  let a;
1262
1274
  e ? [
1263
1275
  "project",
@@ -1290,20 +1302,20 @@ async function Li(e, t) {
1290
1302
  /* Project */
1291
1303
  }
1292
1304
  ]
1293
- }), a === "project" ? await Pi() : (te(), H(), a === "branch" ? await Ii(t) : a === "commit-msg" && (await d("git status -s") ? await Di(t.commitMessageCloseAi) : m("没有要变动的文件,无法生成提交信息")));
1305
+ }), a === "project" ? await Li() : (ae(), Z(), a === "branch" ? await Ci(t) : a === "commit-msg" && (await d("git status -s") ? await Pi(t.commitMessageCloseAi) : m("没有要变动的文件,无法生成提交信息")));
1294
1306
  }
1295
- D.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(de).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").action((...e) => z(Li, ...e));
1296
- function Oi(e) {
1307
+ D.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(de).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").action((...e) => F(Oi, ...e));
1308
+ function Mi(e) {
1297
1309
  return ut({
1298
- url: `${B("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${e.groupName}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
1310
+ url: `${z("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${e.groupName}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
1299
1311
  method: "post",
1300
1312
  data: e.params
1301
1313
  });
1302
1314
  }
1303
- async function Mi(e) {
1315
+ async function zi(e) {
1304
1316
  const t = y("部署任务创建中").start(), { targetBranch: a, notify: n, projectName: i } = e, s = n ? [.../* @__PURE__ */ new Set([E("weWorkUserId"), ...n])] : [E("weWorkUserId")];
1305
1317
  try {
1306
- const { metadata: o, spec: r } = await Oi({
1318
+ const { metadata: o, spec: r } = await Mi({
1307
1319
  projectName: i,
1308
1320
  branchName: a,
1309
1321
  groupName: e.groupName,
@@ -1319,24 +1331,24 @@ async function Mi(e) {
1319
1331
  }
1320
1332
  ]
1321
1333
  }
1322
- }), c = `${B("K8SWebDomain")}/youshou-local/clusters/youshou-local/devops/${o.namespace}/pipelines/${r.pipelineRef.name}/branch/${r.scm.refName}/run/${o.name}/task-status`;
1323
- t.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${k.blue(c)}`), process.exit(0);
1334
+ }), c = `${z("K8SWebDomain")}/youshou-local/clusters/youshou-local/devops/${o.namespace}/pipelines/${r.pipelineRef.name}/branch/${r.scm.refName}/run/${o.name}/task-status`;
1335
+ t.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${A.blue(c)}`), process.exit(0);
1324
1336
  } catch (o) {
1325
1337
  t.fail("部署任务创建失败"), m(o);
1326
1338
  }
1327
1339
  }
1328
- function zi(e, t) {
1329
- const a = Ce();
1330
- if (ae()?.repository?.url || m(".z/project.json中缺少repository.url"), t === W.H5) {
1340
+ function Fi(e, t) {
1341
+ const a = xe();
1342
+ if (ie()?.repository?.url || m(".z/project.json中缺少repository.url"), t === W.H5) {
1331
1343
  const i = `build:${e}`;
1332
1344
  a?.scripts[i] || m(`项目package.json文件scripts不存在命令${i}。`);
1333
1345
  }
1334
1346
  t === W.NPM && (a?.scripts.build || m("项目package.json文件scripts不存在命令build。")), t === W.SERVER && (a?.scripts.build || m("项目package.json文件scripts不存在命令build。"));
1335
1347
  }
1336
1348
  async function ht(e, t) {
1337
- te(), H();
1349
+ ae(), Z();
1338
1350
  let a = e, n = t.platform;
1339
- const i = ae();
1351
+ const i = ie();
1340
1352
  if (i.language === w.JAVA && (n = W.SERVER), a && !Object.values(v).includes(a) && m("仅支持发布指定环境分支"), n && !Object.values(W).includes(n) && m("发布平台错误"), n || (n = await b({
1341
1353
  message: "请选择平台",
1342
1354
  choices: Kt
@@ -1351,12 +1363,12 @@ async function ht(e, t) {
1351
1363
  i.language === w.JAVASCRIPT && (s = Qt);
1352
1364
  let o = "";
1353
1365
  if (i.language === w.JAVASCRIPT) {
1354
- const u = Ce();
1366
+ const u = xe();
1355
1367
  u.name.startsWith("@") && u.name.includes("/") ? o = u.name.split("/").pop() || "" : o = u.name;
1356
1368
  }
1357
1369
  if (i.language === w.JAVA) {
1358
1370
  const { projects: u } = await Da(), p = u.find(
1359
- (g) => X(g.url) === X(i.repository.url)
1371
+ (g) => Q(g.url) === Q(i.repository.url)
1360
1372
  );
1361
1373
  if (!p)
1362
1374
  m("未找到项目对应的模块信息");
@@ -1379,11 +1391,11 @@ async function ht(e, t) {
1379
1391
  let r = [];
1380
1392
  t.skipSelectionNotification || (r = await ft("请选择部署成功要通知的人员:", () => !0, !0));
1381
1393
  let c = [];
1382
- if (t.skipGroupNotification || (c = await Ni("请选择部署成功要通知的群组:", () => !0, !0)), i.language === w.JAVASCRIPT) {
1394
+ if (t.skipGroupNotification || (c = await Ai("请选择部署成功要通知的群组:", () => !0, !0)), i.language === w.JAVASCRIPT) {
1383
1395
  const u = ma(a);
1384
- zi(u, n);
1396
+ Fi(u, n);
1385
1397
  }
1386
- await Mi({
1398
+ await zi({
1387
1399
  projectName: o,
1388
1400
  groupName: s,
1389
1401
  targetBranch: a,
@@ -1420,12 +1432,12 @@ async function wt(e, t, a, n) {
1420
1432
  const c = r?.response?.status;
1421
1433
  if (c === 406)
1422
1434
  return await o();
1423
- if (await Ha({
1435
+ if (await Za({
1424
1436
  id: a.id,
1425
1437
  iid: s,
1426
1438
  state_event: "close"
1427
1439
  }), c === 405) {
1428
- const u = await Za({
1440
+ const u = await Ha({
1429
1441
  id: a.id,
1430
1442
  iid: s
1431
1443
  });
@@ -1445,22 +1457,22 @@ async function Ji(e, t) {
1445
1457
  );
1446
1458
  if (s || m(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await d(
1447
1459
  `git branch --contains ${n} -r ${a}`
1448
- ) || (console.log(k.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await wt(v.MASTER, e.sourceBranch, e)), t === v.MASTER) {
1460
+ ) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await wt(v.MASTER, e.sourceBranch, e)), t === v.MASTER) {
1449
1461
  const r = s.split(`
1450
- `).filter((g) => g), c = await d(`git log -b origin/${S.TEST} -1 --format=%H`), p = (await d(
1451
- `git log ${n}...${c} -b origin/${S.TEST}`
1462
+ `).filter((g) => g), c = await d(`git log -b origin/${k.TEST} -1 --format=%H`), p = (await d(
1463
+ `git log ${n}...${c} -b origin/${k.TEST}`
1452
1464
  )).split(`
1453
1465
  `).filter((g) => g);
1454
1466
  la(p, r) || m("请先在测试环境发布要部署的代码");
1455
1467
  }
1456
1468
  }
1457
- async function Fi(e, t) {
1458
- te(), H(), await be();
1469
+ async function Ui(e, t) {
1470
+ ae(), Z(), await be();
1459
1471
  const a = await Ta();
1460
1472
  Object.values(v).includes(a.sourceBranch) && m(`当前分支${a.sourceBranch}不可作为源分支合并到目标分支。`);
1461
1473
  const i = (await Ya(a.id)).filter((c) => ![a.sourceBranch].includes(c.name)).map((c) => {
1462
1474
  let u = c.name;
1463
- return Object.values(v).includes(u) && (u = k.bold.blue(u)), {
1475
+ return Object.values(v).includes(u) && (u = A.bold.blue(u)), {
1464
1476
  name: u,
1465
1477
  value: c.name
1466
1478
  };
@@ -1487,9 +1499,9 @@ async function Fi(e, t) {
1487
1499
  skipGroupNotification: t.skipGroupNotification
1488
1500
  });
1489
1501
  }
1490
- D.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(W).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => z(Fi, ...e));
1491
- D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(v).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(W).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => z(ht, ...e));
1492
- async function Ui() {
1502
+ D.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(W).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => F(Ui, ...e));
1503
+ D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(v).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(W).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => F(ht, ...e));
1504
+ async function Bi() {
1493
1505
  try {
1494
1506
  await d("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
1495
1507
  silent: !1
@@ -1498,7 +1510,7 @@ async function Ui() {
1498
1510
  m("checkstyle执行出错"), process.exit(1);
1499
1511
  }
1500
1512
  }
1501
- async function Bi() {
1513
+ async function _i() {
1502
1514
  $(l.resolve("node_modules", ".bin", "markdownlint")) || m("该项目未安装markdownlint,请安装后重试");
1503
1515
  const e = y("markdownlint执行中...").start();
1504
1516
  try {
@@ -1509,36 +1521,36 @@ async function Bi() {
1509
1521
  e.fail("markdownlint校验出错"), process.exit(1);
1510
1522
  }
1511
1523
  }
1512
- function _i() {
1513
- const e = ae();
1524
+ function Gi() {
1525
+ const e = ie();
1514
1526
  if (e["lint-staged"])
1515
1527
  return e["lint-staged"];
1516
1528
  throw new Error("未找到lint配置");
1517
1529
  }
1518
- async function Gi() {
1530
+ async function Wi() {
1519
1531
  const e = y("代码风格检测中...").start();
1520
1532
  await Ot({
1521
1533
  concurrent: 4,
1522
1534
  debug: !1,
1523
- config: _i(),
1535
+ config: Gi(),
1524
1536
  quiet: !0,
1525
1537
  relative: !0
1526
1538
  }) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
1527
1539
  }
1528
- function Wi(e) {
1540
+ function Vi(e) {
1529
1541
  if (e.includes("Merge") && e.includes("# Conflicts:") || Mt.valid(e))
1530
1542
  return !0;
1531
1543
  const t = e.split(": ");
1532
1544
  if (t.length === 1)
1533
1545
  return "body前缺少「: 」";
1534
1546
  const a = t[0];
1535
- return /^(feat|fix|refactor)/.test(a) ? /\(\d+(?:,\d+)*\)/.test(a) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(a) ? [j.CHORE, j.CI].includes(a) ? !0 : "chore/ci类型无需填写ID。" : j.Break === a ? !0 : "不存在的提交类型。";
1547
+ return /^(feat|fix|refactor)/.test(a) ? /\(\d+(?:,\d+)*\)/.test(a) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(a) ? [S.CHORE, S.CI].includes(a) ? !0 : "chore/ci类型无需填写ID。" : S.Break === a ? !0 : "不存在的提交类型。";
1536
1548
  }
1537
- async function Vi() {
1538
- const e = await Re(l.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), a = Wi(e);
1549
+ async function qi() {
1550
+ const e = await Ie(l.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), a = Vi(e);
1539
1551
  a === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${a}`), process.exit(1));
1540
1552
  }
1541
- async function qi() {
1553
+ async function Zi() {
1542
1554
  await be();
1543
1555
  const e = await zt({
1544
1556
  // 分组,展示仓库链接
@@ -1569,7 +1581,7 @@ async function Hi(e) {
1569
1581
  t.fail("eslint校验出错"), process.exit(1);
1570
1582
  }
1571
1583
  }
1572
- async function Zi() {
1584
+ async function Ki() {
1573
1585
  $(l.resolve("node_modules", ".bin", "prettier")) || m("该项目未安装prettier,请安装后重试");
1574
1586
  const e = y("prettier执行中...").start();
1575
1587
  try {
@@ -1583,12 +1595,12 @@ async function Zi() {
1583
1595
  e.fail("prettier校验出错"), process.exit(1);
1584
1596
  }
1585
1597
  }
1586
- function Ki() {
1598
+ function Yi() {
1587
1599
  $(l.resolve("./node_modules/.bin/vue-tsc")) || m("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), ua("npx vue-tsc --build"), process.exit(0);
1588
1600
  }
1589
- async function Yi(e, t) {
1590
- te(), H();
1591
- const a = ae();
1601
+ async function Xi(e, t) {
1602
+ ae(), Z();
1603
+ const a = ie();
1592
1604
  let n;
1593
1605
  if (e)
1594
1606
  [
@@ -1678,20 +1690,20 @@ async function Yi(e, t) {
1678
1690
  choices: i
1679
1691
  });
1680
1692
  }
1681
- n === "commit-msg" ? await Vi() : n === "commit-files" ? await Gi() : n === "prettier" ? await Zi() : n === "eslint" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await Hi(t) : n === "type-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? Ki() : n === "dependency-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await qi() : n === "checkstyle" && a.language === w.JAVA ? await Ui() : n === "markdown-lint" && a.language === w.MARKDOWN && await Bi();
1693
+ n === "commit-msg" ? await qi() : n === "commit-files" ? await Wi() : n === "prettier" ? await Ki() : n === "eslint" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await Hi(t) : n === "type-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? Yi() : n === "dependency-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await Zi() : n === "checkstyle" && a.language === w.JAVA ? await Bi() : n === "markdown-lint" && a.language === w.MARKDOWN && await _i();
1682
1694
  }
1683
1695
  D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint。").argument(
1684
1696
  "[type]",
1685
1697
  "非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs, markdown-lint|ml。"
1686
- ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(Yi, ...e));
1698
+ ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => F(Xi, ...e));
1687
1699
  async function yt(e = "latest") {
1688
1700
  const t = y("安装中...").start();
1689
1701
  await d(`npm i -g ${re.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", me("latestCheckVersionTimestamp", Date.now()), me("version", e);
1690
- const a = await xe();
1702
+ const a = await De();
1691
1703
  je(a), oe(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
1692
1704
  }
1693
- D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(yt, ...e));
1694
- const Pe = /Thumbs\.db|\.git|DS_Store|idea/, vt = "testcase";
1705
+ D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => F(yt, ...e));
1706
+ const Le = /Thumbs\.db|\.git|DS_Store|idea/, vt = "testcase";
1695
1707
  function $t(e) {
1696
1708
  const t = e.match(/^(.*[^[])?\[(\d+)]$/);
1697
1709
  if (t && !e.startsWith("["))
@@ -1711,13 +1723,13 @@ function $t(e) {
1711
1723
  displayName: e
1712
1724
  };
1713
1725
  }
1714
- async function Q(e, t = {}) {
1715
- const { exclude: a = Pe } = t, n = [];
1726
+ async function ee(e, t = {}) {
1727
+ const { exclude: a = Le } = t, n = [];
1716
1728
  async function i(s) {
1717
1729
  const o = l.basename(s);
1718
1730
  if ((await Ct(s)).isFile())
1719
1731
  return null;
1720
- const c = await Ie(s, { withFileTypes: !0 }), u = (await Promise.all(
1732
+ const c = await Ce(s, { withFileTypes: !0 }), u = (await Promise.all(
1721
1733
  c.filter((T) => T.isDirectory() && !a.test(T.name)).map((T) => i(l.join(s, T.name)))
1722
1734
  )).filter(Boolean), { type: p, id: g, displayName: f } = $t(o), h = {
1723
1735
  name: o,
@@ -1732,9 +1744,9 @@ async function Q(e, t = {}) {
1732
1744
  return await i(l.resolve(e)), n;
1733
1745
  }
1734
1746
  async function Nt(e, t = {}) {
1735
- const { exclude: a = Pe } = t;
1747
+ const { exclude: a = Le } = t;
1736
1748
  try {
1737
- const n = await Ie(l.resolve(e), { withFileTypes: !0 });
1749
+ const n = await Ce(l.resolve(e), { withFileTypes: !0 });
1738
1750
  return await Promise.all(
1739
1751
  n.filter((i) => i.isDirectory() && !a.test(i.name)).map((i) => {
1740
1752
  const s = l.join(e, i.name), { type: o, id: r, displayName: c } = $t(i.name);
@@ -1772,8 +1784,8 @@ async function we(e, t, a, n) {
1772
1784
  return m(`重命名文件夹失败: ${e} -> ${t}。${i}`), !1;
1773
1785
  }
1774
1786
  }
1775
- async function Xi(e, t, a = {}) {
1776
- const { exclude: n = Pe } = a;
1787
+ async function Qi(e, t, a = {}) {
1788
+ const { exclude: n = Le } = a;
1777
1789
  async function i(s, o) {
1778
1790
  if (!s || s.length === 0) return;
1779
1791
  const r = await Nt(o, { exclude: n });
@@ -1794,7 +1806,7 @@ async function At(e) {
1794
1806
  if (e)
1795
1807
  Number.isNaN(Number(e)) && m("请输入正确的产品ID"), t.id = Number(e);
1796
1808
  else {
1797
- const a = await ti();
1809
+ const a = await ai();
1798
1810
  t.id = await b({
1799
1811
  message: "请选择产品",
1800
1812
  choices: a.map((n) => ({
@@ -1803,9 +1815,9 @@ async function At(e) {
1803
1815
  }))
1804
1816
  });
1805
1817
  }
1806
- return t.name = await ai(t.id), t.path = l.join(vt, q("module", t.name, String(t.id))), t;
1818
+ return t.name = await ii(t.id), t.path = l.join(vt, q("module", t.name, String(t.id))), t;
1807
1819
  }
1808
- async function Le(e) {
1820
+ async function Oe(e) {
1809
1821
  return (await Nt(vt)).find((a) => Number(a.id) === e.id);
1810
1822
  }
1811
1823
  async function bt(e, t) {
@@ -1814,7 +1826,7 @@ async function bt(e, t) {
1814
1826
  priority: e.pri,
1815
1827
  steps: []
1816
1828
  };
1817
- a.steps = await ni(e.id), C.writeJSONSync(t, a, {
1829
+ a.steps = await si(e.id), C.writeJSONSync(t, a, {
1818
1830
  spaces: 2
1819
1831
  });
1820
1832
  }
@@ -1823,13 +1835,13 @@ async function jt(e, t) {
1823
1835
  recursive: !0
1824
1836
  }), await bt(e, l.join(t, "config.json")), C.ensureFileSync(l.join(t, "data.yaml")), await P(
1825
1837
  l.join(t, "data.yaml"),
1826
- $(l.resolve(Y, "data.yaml")) ? await Re(l.resolve(Y, "data.yaml")) : await Ja()
1838
+ $(l.resolve(X, "data.yaml")) ? await Ie(l.resolve(X, "data.yaml")) : await Fa()
1827
1839
  ), C.ensureFileSync(l.join(t, "main.py")), await P(
1828
1840
  l.join(t, "main.py"),
1829
- $(l.resolve(Y, "main.py")) ? await Re(l.resolve(Y, "main.py")) : await Fa()
1841
+ $(l.resolve(X, "main.py")) ? await Ie(l.resolve(X, "main.py")) : await Ja()
1830
1842
  );
1831
1843
  }
1832
- function Oe(e) {
1844
+ function Me(e) {
1833
1845
  if (e) {
1834
1846
  const t = e.split(",").map((a) => a.trim()).filter((a) => {
1835
1847
  const n = Number(a);
@@ -1840,7 +1852,7 @@ function Oe(e) {
1840
1852
  return [];
1841
1853
  }
1842
1854
  async function Se(e, t) {
1843
- te(), H(), await be();
1855
+ ae(), Z(), await be();
1844
1856
  let a;
1845
1857
  t ? ([I.MODULE, I.CASE].includes(t) || m(`不支持的参数${t}。参数值应为 ${I.MODULE} 或者 ${I.CASE}。`), a = t) : a = await b({
1846
1858
  message: `请选择要${e}的数据类型`,
@@ -1853,18 +1865,18 @@ async function Se(e, t) {
1853
1865
  };
1854
1866
  }
1855
1867
  async function ke(e) {
1856
- const t = await At(e), a = await Le(t);
1868
+ const t = await At(e), a = await Oe(t);
1857
1869
  return a || m(`本地未找到产品【${t.name}[${t.id}]】`), {
1858
1870
  product: t,
1859
1871
  localProduct: a
1860
1872
  };
1861
1873
  }
1862
- async function Qi(e, t, a) {
1863
- e.text = "查找本地产品目录...", await Le(t) || m(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
1864
- const i = Oe(a);
1865
- let s = await Q(t.path);
1874
+ async function en(e, t, a) {
1875
+ e.text = "查找本地产品目录...", await Oe(t) || m(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
1876
+ const i = Me(a);
1877
+ let s = await ee(t.path);
1866
1878
  e.text = "获取远程用例列表...";
1867
- const o = await ii(t.id, i);
1879
+ const o = await ni(t.id, i);
1868
1880
  e.text = "本地用例同步中...";
1869
1881
  for (const r of o) {
1870
1882
  let c;
@@ -1872,7 +1884,7 @@ async function Qi(e, t, a) {
1872
1884
  return m(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
1873
1885
  const u = s.find(({ id: p }) => r.id === Number(p));
1874
1886
  if (u)
1875
- u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && V(`重命名成功: ${u.displayName} -> ${r.title}`), s = await Q(t.path), r.module === 0 ? c = l.resolve(t.path) : c = s.find((p) => Number(p.id) === r.module)?.path || "", await bt(
1887
+ u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && V(`重命名成功: ${u.displayName} -> ${r.title}`), s = await ee(t.path), r.module === 0 ? c = l.resolve(t.path) : c = s.find((p) => Number(p.id) === r.module)?.path || "", await bt(
1876
1888
  r,
1877
1889
  l.join(c, q("case", r.title, String(r.id)), "config.json")
1878
1890
  );
@@ -1882,16 +1894,16 @@ async function Qi(e, t, a) {
1882
1894
  }
1883
1895
  }
1884
1896
  }
1885
- async function en(e, t) {
1897
+ async function tn(e, t) {
1886
1898
  e.text = "本地产品目录查找中...";
1887
- const a = await Le(t);
1899
+ const a = await Oe(t);
1888
1900
  a ? (e.text = "找到产品目录。开始重命名...", a.displayName !== t.name && await we(a.path, t.name, a.type, a.id) && (e.text = `重命名成功: ${a.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await pe(t.path, { recursive: !0 }), await d("git add .")), e.text = "获取远程模块列表...";
1889
1901
  const n = await pt(t.id);
1890
- e.text = "本地同步模块中...", await Xi(n || [], t.path);
1902
+ e.text = "本地同步模块中...", await Qi(n || [], t.path);
1891
1903
  }
1892
- async function tn(e, t) {
1904
+ async function an(e, t) {
1893
1905
  const { type: a, typeStr: n } = await Se("拉取", e), i = await At(t.productId), s = y(`${n}同步中...`).start();
1894
- if (I.MODULE === a && await en(s, i), I.CASE === a && await Qi(s, i, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await d("git status -s")) {
1906
+ if (I.MODULE === a && await tn(s, i), I.CASE === a && await en(s, i, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await d("git status -s")) {
1895
1907
  const o = y("代码提交中...").start();
1896
1908
  try {
1897
1909
  await d(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
@@ -1900,15 +1912,15 @@ async function tn(e, t) {
1900
1912
  }
1901
1913
  }
1902
1914
  }
1903
- D.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) => z(tn, ...e));
1904
- async function an(e, t, a) {
1905
- let n = await U({
1915
+ D.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) => F(an, ...e));
1916
+ async function nn(e, t, a) {
1917
+ let n = await B({
1906
1918
  message: "请输入你要创建的用例的前置条件(可不填)"
1907
1919
  });
1908
1920
  n = n.trim();
1909
1921
  const i = y(`用例【${a}】开始创建...`).start();
1910
1922
  i.text = "远程用例创建中...";
1911
- const s = await ri({
1923
+ const s = await oi({
1912
1924
  product: Number(e.id),
1913
1925
  // 如果父模块是产品根目录,parent=0
1914
1926
  module: l.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
@@ -1917,7 +1929,7 @@ async function an(e, t, a) {
1917
1929
  openedBy: E("ldapAccount"),
1918
1930
  precondition: n || ""
1919
1931
  });
1920
- i.text = "远程用例步骤创建中...", await oi({
1932
+ i.text = "远程用例步骤创建中...", await ci({
1921
1933
  case: s,
1922
1934
  type: "step",
1923
1935
  desc: "按照预期执行",
@@ -1933,10 +1945,10 @@ async function an(e, t, a) {
1933
1945
  o
1934
1946
  ), i.succeed(`用例【[${o}】创建完成 🎉`), o);
1935
1947
  }
1936
- async function nn(e, t, a) {
1948
+ async function sn(e, t, a) {
1937
1949
  const n = y(`模块【${a}】开始创建...`).start();
1938
1950
  n.text = "远程模块创建中...";
1939
- const i = await si({
1951
+ const i = await ri({
1940
1952
  root: Number(e.id),
1941
1953
  name: a,
1942
1954
  // 如果父模块是产品根目录,parent=0
@@ -1950,7 +1962,7 @@ async function nn(e, t, a) {
1950
1962
  recursive: !0
1951
1963
  }), n.succeed(`模块【${s}】创建完成 🎉`);
1952
1964
  }
1953
- function sn(e) {
1965
+ function rn(e) {
1954
1966
  function t(n) {
1955
1967
  if (!n.children || n.children.length === 0) return;
1956
1968
  const i = n.children[0];
@@ -1974,18 +1986,18 @@ function sn(e) {
1974
1986
  }
1975
1987
  return a(e);
1976
1988
  }
1977
- async function rn(e, t) {
1978
- const { type: a, typeStr: n } = await Se("创建", e), { product: i, localProduct: s } = await ke(t.productId), o = await pt(i.id), r = await sn(o), c = q("module", r.label, String(r.value)), p = (await Q(i.path, { hasRoot: !0 })).find((h) => h.name === c);
1989
+ async function on(e, t) {
1990
+ const { type: a, typeStr: n } = await Se("创建", e), { product: i, localProduct: s } = await ke(t.productId), o = await pt(i.id), r = await rn(o), c = q("module", r.label, String(r.value)), p = (await ee(i.path, { hasRoot: !0 })).find((h) => h.name === c);
1979
1991
  if (!p?.path || !$(p.path))
1980
1992
  return m(`本地不存在${c}模块`);
1981
- let g = await U({
1993
+ let g = await B({
1982
1994
  message: `请输入你要创建的${n}名称`,
1983
1995
  required: !0,
1984
1996
  validate: (h) => h.length > 0 && h.length < 255
1985
1997
  });
1986
1998
  g = g.trim();
1987
1999
  let f = "";
1988
- if (I.MODULE === a && await nn(s, p, g), I.CASE === a && (f = await an(s, p, g)), !t.disableAutoCommit && I.CASE === a) {
2000
+ if (I.MODULE === a && await sn(s, p, g), I.CASE === a && (f = await nn(s, p, g)), !t.disableAutoCommit && I.CASE === a) {
1989
2001
  const h = y("代码提交中...").start();
1990
2002
  try {
1991
2003
  await d(`git add . && git commit -m "chore: 创建了用例${l.basename(f)}"`), h.succeed("代码已提交 ✅");
@@ -1994,9 +2006,9 @@ async function rn(e, t) {
1994
2006
  }
1995
2007
  }
1996
2008
  }
1997
- D.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(rn, ...e));
1998
- async function on(e, t) {
1999
- const n = (await Q(e.path)).filter((r) => r.type === "case");
2009
+ D.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => F(on, ...e));
2010
+ async function cn(e, t) {
2011
+ const n = (await ee(e.path)).filter((r) => r.type === "case");
2000
2012
  let i = [];
2001
2013
  if (t.length)
2002
2014
  i = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
@@ -2011,7 +2023,7 @@ async function on(e, t) {
2011
2023
  },
2012
2024
  name: c.path.replace(l.resolve(e.path), "")
2013
2025
  }));
2014
- i = await ee({
2026
+ i = await te({
2015
2027
  message: "选择要删除的用例",
2016
2028
  pageSize: 100,
2017
2029
  loop: !1,
@@ -2022,7 +2034,7 @@ async function on(e, t) {
2022
2034
  });
2023
2035
  }
2024
2036
  const s = y("远程用例删除中...").start(), o = i.map((r) => r.id);
2025
- await ui({
2037
+ await li({
2026
2038
  product: Number(e.id),
2027
2039
  caseIds: o
2028
2040
  }), s.text = "本地用例删除中...";
@@ -2030,8 +2042,8 @@ async function on(e, t) {
2030
2042
  $(r.path) && L.rm("-rf", r.path);
2031
2043
  return s.succeed("用例删除完成"), o;
2032
2044
  }
2033
- async function cn(e, t) {
2034
- const n = (await Q(e.path)).filter((r) => r.type === "module");
2045
+ async function un(e, t) {
2046
+ const n = (await ee(e.path)).filter((r) => r.type === "module");
2035
2047
  let i = [];
2036
2048
  if (t.length)
2037
2049
  i = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
@@ -2046,7 +2058,7 @@ async function cn(e, t) {
2046
2058
  },
2047
2059
  name: c.path.replace(l.resolve(e.path), "")
2048
2060
  }));
2049
- i = await ee({
2061
+ i = await te({
2050
2062
  message: "选择要删除的模块",
2051
2063
  pageSize: 100,
2052
2064
  loop: !1,
@@ -2058,7 +2070,7 @@ async function cn(e, t) {
2058
2070
  }
2059
2071
  i = i.sort((r, c) => r.path.localeCompare(c.path));
2060
2072
  const s = y("远程模块删除中...").start(), o = i.map((r) => r.id);
2061
- await ci({
2073
+ await ui({
2062
2074
  product: Number(e.id),
2063
2075
  moduleIds: o
2064
2076
  }), s.text = "本地模块删除中...";
@@ -2066,10 +2078,10 @@ async function cn(e, t) {
2066
2078
  $(r.path) && L.rm("-rf", r.path);
2067
2079
  return s.succeed("模块删除完成"), o;
2068
2080
  }
2069
- async function un(e, t) {
2070
- const { type: a, typeStr: n } = await Se("删除", e), { localProduct: i } = await ke(t.productId), s = Oe(t.targetIds);
2081
+ async function ln(e, t) {
2082
+ const { type: a, typeStr: n } = await Se("删除", e), { localProduct: i } = await ke(t.productId), s = Me(t.targetIds);
2071
2083
  let o = [];
2072
- if (I.MODULE === a ? o = await cn(i, s) : I.CASE === a && (o = await on(i, s)), !t.disableAutoCommit && await d("git status -s")) {
2084
+ if (I.MODULE === a ? o = await un(i, s) : I.CASE === a && (o = await cn(i, s)), !t.disableAutoCommit && await d("git status -s")) {
2073
2085
  const r = y("代码提交中...").start();
2074
2086
  try {
2075
2087
  await d(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
@@ -2078,9 +2090,9 @@ async function un(e, t) {
2078
2090
  }
2079
2091
  }
2080
2092
  }
2081
- D.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) => z(un, ...e));
2082
- async function ln(e, t) {
2083
- const n = (await Q(e.path)).filter((f) => f.type === "case");
2093
+ D.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) => F(ln, ...e));
2094
+ async function mn(e, t) {
2095
+ const n = (await ee(e.path)).filter((f) => f.type === "case");
2084
2096
  let i;
2085
2097
  if (t.targetId) {
2086
2098
  if (i = n.find((f) => Number(f.id) === Number(t.targetId)), !i)
@@ -2094,7 +2106,7 @@ async function ln(e, t) {
2094
2106
  },
2095
2107
  name: h.path.replace(l.resolve(e.path), "")
2096
2108
  }));
2097
- [i] = await ee({
2109
+ [i] = await te({
2098
2110
  message: "选择要更新的用例",
2099
2111
  pageSize: 100,
2100
2112
  loop: !1,
@@ -2105,7 +2117,7 @@ async function ln(e, t) {
2105
2117
  }
2106
2118
  });
2107
2119
  }
2108
- let s = await U({
2120
+ let s = await B({
2109
2121
  message: "修改用例名称",
2110
2122
  default: i.displayName,
2111
2123
  required: !0,
@@ -2114,19 +2126,19 @@ async function ln(e, t) {
2114
2126
  });
2115
2127
  s = s.trim();
2116
2128
  const o = y("用例重命名中...").start();
2117
- s !== i.displayName ? (await mi({
2129
+ s !== i.displayName ? (await pi({
2118
2130
  id: Number(i.id),
2119
2131
  name: s
2120
2132
  }), await we(i.path, s, "case", String(i.id)) && o.succeed(`用例重命名成功: ${i.displayName} -> ${s}`), i.displayName = s, i.path = l.join(l.dirname(i.path), q("case", s, String(i.id)))) : o.succeed("用例名称无变动");
2121
2133
  let r = C.readJsonSync(l.join(i.path, "config.json")), c;
2122
- t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await Ue({
2134
+ t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await Be({
2123
2135
  message: "修改用例优先级",
2124
2136
  min: 1,
2125
2137
  max: 5,
2126
2138
  required: !0,
2127
2139
  default: r.priority,
2128
2140
  validate: (f) => f > 0 && f < 6
2129
- }) : c = await Ue({
2141
+ }) : c = await Be({
2130
2142
  message: "修改用例优先级",
2131
2143
  min: 1,
2132
2144
  max: 5,
@@ -2135,7 +2147,7 @@ async function ln(e, t) {
2135
2147
  validate: (f) => f > 0 && f < 6
2136
2148
  });
2137
2149
  const u = y("用例优先级设置中...").start();
2138
- c !== r.priority ? (await pi({
2150
+ c !== r.priority ? (await di({
2139
2151
  id: Number(i.id),
2140
2152
  priority: c
2141
2153
  }), C.writeJSONSync(
@@ -2147,13 +2159,13 @@ async function ln(e, t) {
2147
2159
  { spaces: 2 }
2148
2160
  ), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = C.readJsonSync(l.join(i.path, "config.json"));
2149
2161
  let p;
2150
- t.casePrecondition ? p = t.casePrecondition : (p = await U({
2162
+ t.casePrecondition ? p = t.casePrecondition : (p = await B({
2151
2163
  message: "修改用例前置条件",
2152
2164
  default: r.precondition,
2153
2165
  prefill: "editable"
2154
2166
  }), p = p.trim());
2155
2167
  const g = y("用例前置条件设置中...").start();
2156
- return p !== r.precondition ? (await di({
2168
+ return p !== r.precondition ? (await fi({
2157
2169
  id: Number(i.id),
2158
2170
  precondition: p
2159
2171
  }), C.writeJSONSync(
@@ -2165,8 +2177,8 @@ async function ln(e, t) {
2165
2177
  { spaces: 2 }
2166
2178
  ), g.succeed(`用例前置条件修改成功:${r.precondition} -> ${p}`)) : g.succeed("用例前置条件无变动"), i.id;
2167
2179
  }
2168
- async function mn(e, t) {
2169
- const n = (await Q(e.path)).filter((r) => r.type === "module");
2180
+ async function pn(e, t) {
2181
+ const n = (await ee(e.path)).filter((r) => r.type === "module");
2170
2182
  let i;
2171
2183
  if (t.targetId) {
2172
2184
  if (i = n.find((r) => Number(r.id) === Number(t.targetId)), !i)
@@ -2180,7 +2192,7 @@ async function mn(e, t) {
2180
2192
  },
2181
2193
  name: c.path.replace(l.resolve(e.path), "")
2182
2194
  }));
2183
- [i] = await ee({
2195
+ [i] = await te({
2184
2196
  message: "选择要更新的模块",
2185
2197
  pageSize: 100,
2186
2198
  loop: !1,
@@ -2191,7 +2203,7 @@ async function mn(e, t) {
2191
2203
  }
2192
2204
  });
2193
2205
  }
2194
- let s = await U({
2206
+ let s = await B({
2195
2207
  message: "修改模块名称",
2196
2208
  default: i.displayName,
2197
2209
  required: !0,
@@ -2200,15 +2212,15 @@ async function mn(e, t) {
2200
2212
  });
2201
2213
  s = s.trim();
2202
2214
  const o = y("模块重命名中...").start();
2203
- return s !== i.displayName ? (await li({
2215
+ return s !== i.displayName ? (await mi({
2204
2216
  id: Number(i.id),
2205
2217
  name: s
2206
2218
  }), await we(i.path, s, "module", String(i.id)) && o.succeed(`模块重命名成功: ${i.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), i.id;
2207
2219
  }
2208
- async function pn(e, t) {
2220
+ async function dn(e, t) {
2209
2221
  const { type: a, typeStr: n } = await Se("修改", e), { localProduct: i } = await ke(t.productId);
2210
2222
  let s;
2211
- if (I.MODULE === a ? s = await mn(i, t) : I.CASE === a && (s = await ln(i, t)), !t.disableAutoCommit && await d("git status -s")) {
2223
+ if (I.MODULE === a ? s = await pn(i, t) : I.CASE === a && (s = await mn(i, t)), !t.disableAutoCommit && await d("git status -s")) {
2212
2224
  const o = y("代码提交中...").start();
2213
2225
  try {
2214
2226
  await d(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
@@ -2217,11 +2229,11 @@ async function pn(e, t) {
2217
2229
  }
2218
2230
  }
2219
2231
  }
2220
- D.command("qa-update").alias("qu").description("修改模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-id <targetId>", "可传指定目标(用例/模块)ID").option("--target-name <targetName>", "可传指定目标(用例/模块)修改后的名称").option("--case-priority <casePriority>", "如果是用例,指定修改后的优先级").option("--case-precondition <casePrecondition>", "如果是用例,指定修改后的前置条件").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(pn, ...e));
2221
- async function dn(e, t) {
2232
+ D.command("qa-update").alias("qu").description("修改模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-id <targetId>", "可传指定目标(用例/模块)ID").option("--target-name <targetName>", "可传指定目标(用例/模块)修改后的名称").option("--case-priority <casePriority>", "如果是用例,指定修改后的优先级").option("--case-precondition <casePrecondition>", "如果是用例,指定修改后的前置条件").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => F(dn, ...e));
2233
+ async function fn(e, t) {
2222
2234
  if (!e.length)
2223
2235
  return [];
2224
- const a = Jt(20), n = e.map(
2236
+ const a = Ft(20), n = e.map(
2225
2237
  (i) => a(async () => {
2226
2238
  try {
2227
2239
  const s = t.env || "production", o = await d(`python ${i.path}/main.py --env ${s}`);
@@ -2238,11 +2250,11 @@ async function dn(e, t) {
2238
2250
  );
2239
2251
  return await Promise.all(n), e;
2240
2252
  }
2241
- async function fn(e) {
2242
- te(), H();
2253
+ async function gn(e) {
2254
+ ae(), Z();
2243
2255
  const { localProduct: t } = await ke(e.productId);
2244
2256
  let a = [];
2245
- const i = (await Q(t.path)).filter((c) => c.type === "case");
2257
+ const i = (await ee(t.path)).filter((c) => c.type === "case");
2246
2258
  if (e.all)
2247
2259
  a = i.map((c) => ({
2248
2260
  id: Number(c.id),
@@ -2250,7 +2262,7 @@ async function fn(e) {
2250
2262
  displayName: c.displayName
2251
2263
  }));
2252
2264
  else {
2253
- const c = Oe(e.caseIds);
2265
+ const c = Me(e.caseIds);
2254
2266
  if (c.length)
2255
2267
  a = i.filter((u) => c.includes(Number(u.id))).map((u) => ({
2256
2268
  id: Number(u.id),
@@ -2266,7 +2278,7 @@ async function fn(e) {
2266
2278
  },
2267
2279
  name: p.path.replace(l.resolve(t.path), "")
2268
2280
  }));
2269
- a = await ee({
2281
+ a = await te({
2270
2282
  message: "选择要执行的用例",
2271
2283
  pageSize: 100,
2272
2284
  loop: !1,
@@ -2277,7 +2289,7 @@ async function fn(e) {
2277
2289
  });
2278
2290
  }
2279
2291
  }
2280
- const s = y("用例执行中...").start(), r = (await dn(a, e)).filter((c) => c.result.length);
2292
+ const s = y("用例执行中...").start(), r = (await fn(a, e)).filter((c) => c.result.length);
2281
2293
  if (r.length === 0)
2282
2294
  s.succeed("所有用例执行通过 🎉");
2283
2295
  else {
@@ -2289,10 +2301,10 @@ async function fn(e) {
2289
2301
  if (e.executionId)
2290
2302
  Number.isNaN(Number(e.executionId)) && m(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
2291
2303
  else {
2292
- const g = await gi(), f = await b({
2304
+ const g = await hi(), f = await b({
2293
2305
  message: "请选择用例执行出错后,BUG所属的项目",
2294
2306
  choices: g.map(({ id: T, name: ne }) => ({ name: ne, value: T }))
2295
- }), h = await hi(f);
2307
+ }), h = await wi(f);
2296
2308
  u = await b({
2297
2309
  message: "请选择用例执行出错后,BUG所属的执行",
2298
2310
  choices: h.map(({ id: T, name: ne }) => ({ name: ne, value: T }))
@@ -2302,7 +2314,7 @@ async function fn(e) {
2302
2314
  if (e.buildId)
2303
2315
  p = e.buildId;
2304
2316
  else {
2305
- const g = await wi(Number(u));
2317
+ const g = await yi(Number(u));
2306
2318
  if (g.length) {
2307
2319
  const f = await ve({
2308
2320
  message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
@@ -2318,7 +2330,7 @@ async function fn(e) {
2318
2330
  }
2319
2331
  s.start("上传中...");
2320
2332
  for (const g of r)
2321
- await fi({
2333
+ await gi({
2322
2334
  caseId: g.id,
2323
2335
  caseResult: "fail",
2324
2336
  stepResults: g.result,
@@ -2327,12 +2339,12 @@ async function fn(e) {
2327
2339
  openedBuild: p
2328
2340
  });
2329
2341
  s.succeed(
2330
- `用例执行完成。查看相关BUG(${B("ZenTaoDomain")}/zentao/execution-bug-${u}.html}) `
2342
+ `用例执行完成。查看相关BUG(${z("ZenTaoDomain")}/zentao/execution-bug-${u}.html}) `
2331
2343
  );
2332
2344
  }
2333
2345
  }
2334
- D.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) => z(fn, ...e));
2335
- const We = (e) => {
2346
+ D.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) => F(gn, ...e));
2347
+ const Ve = (e) => {
2336
2348
  const t = e.trim();
2337
2349
  if (!t)
2338
2350
  return "请输入生成目录";
@@ -2342,15 +2354,15 @@ const We = (e) => {
2342
2354
  return "只允许输入相对路径";
2343
2355
  const a = l.normalize(t);
2344
2356
  return !a || a === "." || a === ".." ? "请输入有效的目录路径" : a.startsWith(`..${l.sep}`) ? "路径不能跳出当前项目" : !0;
2345
- }, gn = async () => {
2346
- const { projects: e } = await Pa(), t = ae();
2357
+ }, hn = async () => {
2358
+ const { projects: e } = await Pa(), t = ie();
2347
2359
  if (t.serverProjectURL) {
2348
2360
  const n = e.find(
2349
2361
  (i) => nt(i.url, t.serverProjectURL)
2350
2362
  );
2351
2363
  if (n)
2352
2364
  return {
2353
- projectId: decodeURIComponent(X(t.serverProjectURL)),
2365
+ projectId: decodeURIComponent(Q(t.serverProjectURL)),
2354
2366
  moduleList: n.modules || []
2355
2367
  };
2356
2368
  }
@@ -2362,10 +2374,10 @@ const We = (e) => {
2362
2374
  }))
2363
2375
  });
2364
2376
  return ct({ ...t, serverProjectURL: a }), {
2365
- projectId: decodeURIComponent(X(a)),
2377
+ projectId: decodeURIComponent(Q(a)),
2366
2378
  moduleList: e.find((n) => n.url === a)?.modules || []
2367
2379
  };
2368
- }, hn = async (e) => {
2380
+ }, wn = async (e) => {
2369
2381
  if (e) {
2370
2382
  if (["all", "single"].includes(e))
2371
2383
  return e;
@@ -2384,7 +2396,7 @@ const We = (e) => {
2384
2396
  }
2385
2397
  ]
2386
2398
  });
2387
- }, wn = async (e, t) => {
2399
+ }, yn = async (e, t) => {
2388
2400
  if (e)
2389
2401
  return e.split(",").filter((a) => t.map((n) => n.name).includes(a.trim()));
2390
2402
  {
@@ -2400,35 +2412,35 @@ const We = (e) => {
2400
2412
  });
2401
2413
  return a?.length ? a : t.map((n) => n.name);
2402
2414
  }
2403
- }, yn = async (e) => e && [S.DEV, S.TEST, S.RELEASE, S.PROD].includes(e.trim()) ? e : await b({
2415
+ }, vn = async (e) => e && [k.DEV, k.TEST, k.RELEASE, k.PROD].includes(e.trim()) ? e : await b({
2404
2416
  message: "请选择对应的环境",
2405
2417
  // 去掉prod 环境
2406
- choices: Qe.filter((t) => t.value !== S.PROD)
2407
- }), Me = (e) => {
2418
+ choices: Qe.filter((t) => t.value !== k.PROD)
2419
+ }), ze = (e) => {
2408
2420
  const t = /^https?:\/\/[^/]+\/api\/([^/]+)\/v3\//;
2409
2421
  return e.match(t)?.[1];
2410
- }, vn = async (e) => {
2422
+ }, $n = async (e) => {
2411
2423
  try {
2412
- const t = await ie({
2424
+ const t = await H({
2413
2425
  url: e,
2414
2426
  method: "get"
2415
- }), a = Me(e);
2427
+ }), a = ze(e);
2416
2428
  return a && (t.paths = Object.fromEntries(
2417
2429
  Object.entries(t.paths).map(([n, i]) => [`/${a}${n}`, i])
2418
2430
  )), Ut(t);
2419
2431
  } catch (t) {
2420
2432
  throw m(`Error fetching Swagger JSON: ${t.message}`), t;
2421
2433
  }
2422
- }, Ve = (e) => {
2434
+ }, Re = (e) => {
2423
2435
  const t = (a) => {
2424
2436
  const { reason: n, url: i } = a;
2425
- return `## ${Me(i)}服务接口文档校验失败
2437
+ return `## ${ze(i)}服务接口文档校验失败
2426
2438
  ${n.message}`;
2427
2439
  };
2428
2440
  return `# 服务端接口文档校验失败
2429
2441
  ${e.map(t).join(`
2430
2442
  `)}`;
2431
- }, $n = async (e, t, a) => {
2443
+ }, Nn = async (e, t, a) => {
2432
2444
  const n = e.filter((i) => t.includes(i.name)).map((i) => i.swagger);
2433
2445
  if (n.length) {
2434
2446
  const i = n.flatMap((s) => {
@@ -2436,29 +2448,34 @@ ${e.map(t).join(`
2436
2448
  return o ? [o.url] : [];
2437
2449
  });
2438
2450
  if (i.length) {
2439
- const s = y("API数据请求中...").start(), o = await Promise.allSettled(i.map(vn)), r = o.flatMap(
2451
+ const s = y("API数据请求中...").start(), o = await Promise.allSettled(i.map($n)), r = o.flatMap(
2440
2452
  (c, u) => c.status === "rejected" ? [{ reason: c.reason, url: i[u] }] : []
2441
2453
  );
2442
2454
  if (r.length) {
2443
- const c = ae(), { groups: u } = await lt(), p = u.find(
2455
+ const c = ie(), { groups: u } = await lt(), p = u.find(
2444
2456
  (g) => g.projects.some((f) => nt(f, c.serverProjectURL))
2445
2457
  );
2446
- p ? await vi({
2447
- content: Ve(r),
2448
- webhooks: [p.url]
2449
- }) : (s.fail("未找到对应的项目群聊组!"), s.fail(Ve(r))), s.fail("API数据解析失败"), process.exit(1);
2458
+ if (p) {
2459
+ const { code: g, message: f } = await $i({
2460
+ content: Re(r),
2461
+ webhooks: [p.url]
2462
+ });
2463
+ g !== 0 && (s.fail(`发送消息到企微群组失败: ${A.red(f)}`), s.text = A.red(Re(r)), s.start(), process.exit(1));
2464
+ } else
2465
+ s.fail("未找到对应的项目群聊组!"), s.fail(Re(r));
2466
+ s.fail("API数据解析失败"), process.exit(1);
2450
2467
  } else
2451
- return s.succeed("API数据请求成功"), o.flatMap((c, u) => c.status === "fulfilled" ? [{ serverName: Me(i[u]), swaggerJson: c.value }] : []);
2468
+ return s.succeed("API数据请求成功"), o.flatMap((c, u) => c.status === "fulfilled" ? [{ serverName: ze(i[u]), swaggerJson: c.value }] : []);
2452
2469
  }
2453
2470
  }
2454
2471
  throw new Error("Failed to fetch Swagger JSON");
2455
- }, Nn = async (e) => {
2472
+ }, An = async (e) => {
2456
2473
  const t = [];
2457
2474
  for (const a of e) {
2458
2475
  const { apis: n } = await Bt(a);
2459
2476
  t.push(...n.map((i) => ({ name: i.path, value: i.path })));
2460
2477
  }
2461
- return ee({
2478
+ return te({
2462
2479
  message: "请选择需要生成的API",
2463
2480
  options: (a) => a ? t.filter((n) => n.name.includes(a)) : t,
2464
2481
  pageSize: 20,
@@ -2468,7 +2485,7 @@ ${e.map(t).join(`
2468
2485
  validate: (a) => a.length ? !0 : "至少选择一个API",
2469
2486
  filter: !0
2470
2487
  });
2471
- }, An = async (e, t) => {
2488
+ }, bn = async (e, t) => {
2472
2489
  const a = y("API 开始生成...").start();
2473
2490
  try {
2474
2491
  a.stop();
@@ -2482,40 +2499,40 @@ ${e.map(t).join(`
2482
2499
  } catch (n) {
2483
2500
  a.fail(`API 生成失败: ${n.message}`);
2484
2501
  }
2485
- }, bn = (e) => {
2502
+ }, jn = (e) => {
2486
2503
  if (e) {
2487
- const t = We(e);
2504
+ const t = Ve(e);
2488
2505
  return t !== !0 && m(t), e;
2489
2506
  }
2490
- return U({
2507
+ return B({
2491
2508
  message: "请输入 API 输出目录,默认为 src/services",
2492
2509
  default: "src/services",
2493
- validate: We
2510
+ validate: Ve
2494
2511
  });
2495
- }, jn = new Ze({
2512
+ }, Sn = new He({
2496
2513
  fix: !0
2497
- }), Sn = async (e) => {
2498
- const t = await jn.lintFiles(e);
2499
- await Ze.outputFixes(t);
2514
+ }), kn = async (e) => {
2515
+ const t = await Sn.lintFiles(e);
2516
+ await He.outputFixes(t);
2500
2517
  for (const a of e) {
2501
2518
  const n = l.resolve(a), i = Wt(n, "utf-8"), s = await Vt.format(i, {
2502
2519
  filepath: n
2503
2520
  });
2504
2521
  It(n, s);
2505
2522
  }
2506
- }, kn = async (e, t, a) => {
2523
+ }, Tn = async (e, t, a) => {
2507
2524
  const n = e.map((i) => i.swaggerJson);
2508
2525
  if (t === "single") {
2509
- const i = await Nn(n);
2510
- await An(e, i);
2526
+ const i = await An(n);
2527
+ await bn(e, i);
2511
2528
  } else {
2512
- const i = y("API 开始生成...").start(), s = await Ft(
2529
+ const i = y("API 开始生成...").start(), s = await Jt(
2513
2530
  n.map((u) => ({
2514
2531
  swaggerJson: u
2515
2532
  }))
2516
2533
  );
2517
2534
  i.stop();
2518
- const o = await bn(a), r = l.resolve(o);
2535
+ const o = await jn(a), r = l.resolve(o);
2519
2536
  Je.mkdirSync(r, { recursive: !0 });
2520
2537
  const c = [];
2521
2538
  i.start(), i.text = "API 生成中...";
@@ -2523,24 +2540,24 @@ ${e.map(t).join(`
2523
2540
  const { path: p, content: g } = u, f = l.resolve(r, p);
2524
2541
  c.push(f), Je.writeFileSync(f, g);
2525
2542
  }
2526
- i.text = "开始格式化代码", await Sn(c), i.text = "代码格式化完成", i.succeed(`API 已生成到 ${o} 目录下`);
2543
+ i.text = "开始格式化代码", await kn(c), i.text = "代码格式化完成", i.succeed(`API 已生成到 ${o} 目录下`);
2527
2544
  }
2528
2545
  };
2529
- async function Tn(e, t) {
2530
- te(), H();
2531
- const { moduleList: a } = await gn(), { module: n, env: i, dir: s } = t, o = await wn(n, a), r = await yn(i), c = await $n(a, o, r), u = await hn(e);
2532
- await kn(c, u, s), process.exit(0);
2546
+ async function En(e, t) {
2547
+ ae(), Z();
2548
+ const { moduleList: a } = await hn(), { module: n, env: i, dir: s } = t, o = await yn(n, a), r = await vn(i), c = await Nn(a, o, r), u = await wn(e);
2549
+ await Tn(c, u, s), process.exit(0);
2533
2550
  }
2534
- D.command("api").alias("a").description("选择对应的服务端项目,获取接口并转成ts接口代码及类型").argument("[type]", "可选值为service单个服务, controller单个controller, single单个接口").option("--module [module]", "模块名称。多个使用逗号隔开").option("--env [env]", "指定环境。dev/test/release").option("--controller-name [controllerName]", "controller名称").option("--api-name [apiName]", "api名称").action((...e) => z(Tn, ...e));
2535
- function En() {
2551
+ D.command("api").alias("a").description("选择对应的服务端项目,获取接口并转成ts接口代码及类型").argument("[type]", "可选值为service单个服务, controller单个controller, single单个接口").option("--module [module]", "模块名称。多个使用逗号隔开").option("--env [env]", "指定环境。dev/test/release").option("--controller-name [controllerName]", "controller名称").option("--api-name [apiName]", "api名称").action((...e) => F(En, ...e));
2552
+ function Rn() {
2536
2553
  process.on("unhandledRejection", (e) => {
2537
2554
  }), process.on("uncaughtException", (e) => {
2538
2555
  }), L.config.fatal = !0, L.config.silent = !0, L.config.verbose = !1;
2539
2556
  }
2540
- async function Rn() {
2557
+ async function In() {
2541
2558
  const e = ge("latestCheckVersionTimestamp"), t = ge("versionCheckDuring");
2542
2559
  if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
2543
- const a = await xe();
2560
+ const a = await De();
2544
2561
  je(a);
2545
2562
  let n;
2546
2563
  try {
@@ -2550,23 +2567,23 @@ async function Rn() {
2550
2567
  n = await Promise.race([
2551
2568
  s,
2552
2569
  d(`npm view ${re.name} version --registry https://registry.npmmirror.com/`)
2553
- ]), n !== i && n !== re.version && (console.log(`${k.blue(re.name)}本地版本为${re.version},低于线上版本${n},开始升级`), await yt(n)), me("latestCheckVersionTimestamp", Date.now()), oe();
2570
+ ]), n !== i && n !== re.version && (console.log(`${A.blue(re.name)}本地版本为${re.version},低于线上版本${n},开始升级`), await yt(n)), me("latestCheckVersionTimestamp", Date.now()), oe();
2554
2571
  } catch (i) {
2555
2572
  console.log("升级出错!请重试,或者手动升级"), m(i);
2556
2573
  }
2557
2574
  }
2558
2575
  }
2559
- async function In() {
2576
+ async function Cn() {
2560
2577
  const e = qt(process.argv.slice(2));
2561
2578
  if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
2562
2579
  if (it()) {
2563
2580
  const t = C.readJSONSync(Ae());
2564
- M(t.profile), me(t.main), je(t.constants), await Rn();
2581
+ M(t.profile), me(t.main), je(t.constants), await In();
2565
2582
  } else
2566
2583
  m(`请先初始化z-develop(执行 z i)。更多见${et}`);
2567
2584
  }
2568
- async function Cn() {
2569
- En(), await In();
2585
+ async function xn() {
2586
+ Rn(), await Cn();
2570
2587
  }
2571
- D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${k.blue(et)}`).usage("<command> [options]").hook("preAction", Cn).version(re.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
2588
+ D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${A.blue(et)}`).usage("<command> [options]").hook("preAction", xn).version(re.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
2572
2589
  D.parse();