cli-z-develop 0.14.12 → 0.14.14

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 +1066 -982
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,47 +1,47 @@
1
- import { program as P } from "commander";
2
- import Pt from "node:child_process";
3
- import { existsSync as N, readdirSync as Dt, lstatSync as Lt, createWriteStream as Ot, mkdirSync as Mt, writeFileSync as Ye, readFileSync as Jt } from "node:fs";
4
- import { readdir as Pe, mkdir as me, writeFile as D, rename as Qe, readFile as Ie, stat as zt } from "node:fs/promises";
5
- import d, { resolve as Ce, isAbsolute as Ft, normalize as Bt, sep as Ut } from "node:path";
6
- import ue, { AxiosError as Gt } from "axios";
1
+ import { program as x } from "commander";
2
+ import Ot from "node:child_process";
3
+ import { existsSync as N, readdirSync as Mt, lstatSync as Bt, createWriteStream as Jt, mkdirSync as zt, writeFileSync as at, readFileSync as Ft } from "node:fs";
4
+ import { readdir as Oe, mkdir as me, writeFile as D, rename as it, readFile as Le, stat as Ut } from "node:fs/promises";
5
+ import f, { resolve as xe, isAbsolute as Gt, normalize as _t, sep as Vt } from "node:path";
6
+ import ue, { AxiosError as Wt } from "axios";
7
7
  import A from "chalk";
8
- import _t from "dayjs";
9
- import L from "shelljs";
10
- import Vt from "node:os";
11
- import Ue from "child_process";
12
- import { confirm as et, select as k, input as B, password as Wt, checkbox as ve, number as Ge } from "@inquirer/prompts";
8
+ import qt from "dayjs";
9
+ import P from "shelljs";
10
+ import Ht from "node:os";
11
+ import qe from "child_process";
12
+ import { confirm as Me, select as k, input as F, password as Zt, checkbox as Se, number as He } from "@inquirer/prompts";
13
13
  import y from "ora";
14
- import I from "fs-extra";
15
- import { select as Z } from "inquirer-select-pro";
16
- import qt from "lint-staged";
17
- import Ht from "semver";
18
- import { run as Zt } from "npm-check-updates";
19
- import Kt from "p-limit";
20
- import { validateSwagger as Xt, getParsedSwagger as Yt, generatePythonBundleApi as Qt, generatePythonApi as ei, generateTypescriptBundleApi as ti, generateTypescriptApi as ii } from "@lonely9/api-generate";
21
- import { highlight as tt } from "cli-highlight";
22
- import { ESLint as it } from "eslint";
23
- import ai from "prettier";
24
- import ni from "minimist";
25
- const at = "dev", nt = "test", st = "release", si = "production", ri = "master";
26
- var R = /* @__PURE__ */ ((e) => (e[e.DEV = at] = "DEV", e[e.TEST = nt] = "TEST", e[e.RELEASE = st] = "RELEASE", e[e.PROD = si] = "PROD", e))(R || {}), $ = /* @__PURE__ */ ((e) => (e[e.DEV = at] = "DEV", e[e.TEST = nt] = "TEST", e[e.RELEASE = st] = "RELEASE", e[e.MASTER = ri] = "MASTER", e))($ || {}), W = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(W || {});
27
- const rt = [
14
+ import R from "fs-extra";
15
+ import { select as _ } from "inquirer-select-pro";
16
+ import Kt from "lint-staged";
17
+ import Xt from "semver";
18
+ import { run as Yt } from "npm-check-updates";
19
+ import Qt from "p-limit";
20
+ import { validateSwagger as ea, getParsedSwagger as ta, generatePythonBundleApi as aa, generatePythonApi as ia, generateTypescriptBundleApi as na, generateTypescriptApi as sa } from "@lonely9/api-generate";
21
+ import { highlight as nt } from "cli-highlight";
22
+ import { ESLint as st } from "eslint";
23
+ import ra from "prettier";
24
+ import oa from "minimist";
25
+ const rt = "dev", ot = "test", ct = "release", ca = "production", la = "master";
26
+ var C = /* @__PURE__ */ ((e) => (e[e.DEV = rt] = "DEV", e[e.TEST = ot] = "TEST", e[e.RELEASE = ct] = "RELEASE", e[e.PROD = ca] = "PROD", e))(C || {}), v = /* @__PURE__ */ ((e) => (e[e.DEV = rt] = "DEV", e[e.TEST = ot] = "TEST", e[e.RELEASE = ct] = "RELEASE", e[e.MASTER = la] = "MASTER", e))(v || {}), H = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(H || {});
27
+ const lt = [
28
28
  {
29
- name: `开发环境 - ${R.DEV}`,
30
- value: R.DEV
29
+ name: `开发环境 - ${C.DEV}`,
30
+ value: C.DEV
31
31
  },
32
32
  {
33
- name: `测试环境 - ${R.TEST}`,
34
- value: R.TEST
33
+ name: `测试环境 - ${C.TEST}`,
34
+ value: C.TEST
35
35
  },
36
36
  {
37
- name: `预发环境 - ${R.RELEASE}`,
38
- value: R.RELEASE
37
+ name: `预发环境 - ${C.RELEASE}`,
38
+ value: C.RELEASE
39
39
  },
40
40
  {
41
- name: `正式环境 - ${R.PROD}`,
42
- value: R.PROD
41
+ name: `正式环境 - ${C.PROD}`,
42
+ value: C.PROD
43
43
  }
44
- ], oi = [
44
+ ], ua = [
45
45
  {
46
46
  name: "网页 - h5",
47
47
  value: "h5"
@@ -59,7 +59,7 @@ const rt = [
59
59
  }
60
60
  ];
61
61
  var de = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(de || {}), le = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(le || {}), w = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e.MARKDOWN = "Markdown", e))(w || {});
62
- const ci = {
62
+ const pa = {
63
63
  1: "研发",
64
64
  2: "测试",
65
65
  3: "产品",
@@ -69,11 +69,11 @@ const ci = {
69
69
  7: "行政",
70
70
  8: "财务",
71
71
  9: "其他"
72
- }, fe = "http://git.cxlqd.com", li = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
72
+ }, ge = "http://git.cxlqd.com", ma = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
73
73
  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 || {});
74
- const ui = "fe-biz7tvsd", ot = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
74
+ const da = "fe-biz7tvsd", ut = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
75
75
  var E = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(E || {});
76
- const pi = [
76
+ const fa = [
77
77
  {
78
78
  name: "模块",
79
79
  value: "module"
@@ -84,127 +84,127 @@ const pi = [
84
84
  value: "case"
85
85
  /* CASE */
86
86
  }
87
- ], mi = 150 * 1024, _e = 0.8 * 1024 * 1024, Re = ",", di = ".z", fi = "develop-config.json", ee = ".z", gi = ".commit-msg-tpl", hi = "project.json";
87
+ ], ga = 150 * 1024, Ze = 0.8 * 1024 * 1024, De = ",", ha = ".z", wa = "develop-config.json", ee = ".z", ya = ".commit-msg-tpl", va = "project.json";
88
88
  function T(e = "") {
89
- return d.join(ee, e);
89
+ return f.join(ee, e);
90
90
  }
91
- function ct() {
92
- return T(hi);
91
+ function pt() {
92
+ return T(va);
93
93
  }
94
- function Ae() {
95
- return T(gi);
94
+ function je() {
95
+ return T(ya);
96
96
  }
97
- function lt() {
98
- Ue.spawnSync("git", ["config", "core.hooksPath", T()]), Ue.spawnSync("git", ["config", "commit.template", Ae()]);
97
+ function mt() {
98
+ qe.spawnSync("git", ["config", "core.hooksPath", T()]), qe.spawnSync("git", ["config", "commit.template", je()]);
99
99
  }
100
- function he(e = "") {
101
- return d.resolve(Vt.homedir(), di, e);
100
+ function we(e = "") {
101
+ return f.resolve(Ht.homedir(), ha, e);
102
102
  }
103
- function Ne() {
104
- return he(fi);
103
+ function ke() {
104
+ return we(wa);
105
105
  }
106
- function wi() {
107
- return N(he());
106
+ function $a() {
107
+ return N(we());
108
108
  }
109
- function ut() {
110
- return wi() && N(Ne());
109
+ function dt() {
110
+ return $a() && N(ke());
111
111
  }
112
112
  function te(e, t = !0) {
113
- let i = e.trim();
114
- const n = i.match(/^git@([^:]+):(.+)$/);
113
+ let a = e.trim();
114
+ const n = a.match(/^git@([^:]+):(.+)$/);
115
115
  if (n)
116
- i = n[2];
116
+ a = n[2];
117
117
  else {
118
- const s = fe.replace(/^https?:\/\//, "").replace(/\/$/, "");
119
- i = i.replace(/^https?:\/\//, ""), i.startsWith(`${s}/`) ? i = i.slice(s.length + 1) : i = i.replace(`${fe.replace(/\/$/, "")}/`, "");
118
+ const s = ge.replace(/^https?:\/\//, "").replace(/\/$/, "");
119
+ a = a.replace(/^https?:\/\//, ""), a.startsWith(`${s}/`) ? a = a.slice(s.length + 1) : a = a.replace(`${ge.replace(/\/$/, "")}/`, "");
120
120
  }
121
- const a = i.replace(/\.git$/, "");
122
- return t ? encodeURIComponent(a) : a;
121
+ const i = a.replace(/\.git$/, "");
122
+ return t ? encodeURIComponent(i) : i;
123
123
  }
124
- function pt(e, t) {
124
+ function ft(e, t) {
125
125
  return te(e) === te(t);
126
126
  }
127
- const { red: Ve, green: yi, blue: ws, magenta: vi, yellow: $i } = A;
128
- function ye(...e) {
127
+ const { red: Ke, green: Aa, blue: Ts, magenta: Na, yellow: Sa } = A;
128
+ function $e(...e) {
129
129
  }
130
- function We(...e) {
131
- console.log($i(...e));
130
+ function fe(...e) {
131
+ console.log(Sa(...e));
132
132
  }
133
- function q(...e) {
134
- console.log(yi(...e));
133
+ function U(...e) {
134
+ console.log(Aa(...e));
135
135
  }
136
- function mt(e) {
136
+ function gt(e) {
137
137
  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));
138
138
  }
139
- function p(e, t = !1) {
140
- mt(e);
141
- let i = e;
142
- e instanceof Error ? (i = e.message, ue.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(Ve(i)), console.log(vi(e.stack))) : console.log(Ve(e)), t || process.exit(1);
139
+ function d(e, t = !1) {
140
+ gt(e);
141
+ let a = e;
142
+ e instanceof Error ? (a = e.message, ue.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(Ke(a)), console.log(Na(e.stack))) : console.log(Ke(e)), t || process.exit(1);
143
143
  }
144
- function qe(e) {
145
- return N(e) ? Lt(e).isDirectory() : !1;
144
+ function Xe(e) {
145
+ return N(e) ? Bt(e).isDirectory() : !1;
146
146
  }
147
- function dt(e = process.cwd()) {
148
- return qe(e) ? Dt(e).filter((i) => qe(d.resolve(e, i))) : [];
147
+ function ht(e = process.cwd()) {
148
+ return Xe(e) ? Mt(e).filter((a) => Xe(f.resolve(e, a))) : [];
149
149
  }
150
150
  async function m(e, t = {}) {
151
- const i = {
151
+ const a = {
152
152
  removeTailLinkBreak: !0,
153
153
  silent: !0,
154
154
  ...t
155
155
  };
156
- let n = await new Promise((a, s) => {
156
+ let n = await new Promise((i, s) => {
157
157
  try {
158
- const o = L.exec(e, {
159
- silent: i.silent
158
+ const o = P.exec(e, {
159
+ silent: a.silent
160
160
  });
161
- a(o);
161
+ i(o);
162
162
  } catch (o) {
163
163
  s(o);
164
164
  }
165
165
  });
166
- return n = n.toString(), i.removeTailLinkBreak && (n = n.replace(/\n$/, "")), n;
166
+ return n = n.toString(), a.removeTailLinkBreak && (n = n.replace(/\n$/, "")), n;
167
167
  }
168
- function Ai(e) {
169
- Pt.execSync(e, {
168
+ function Be(e) {
169
+ Ot.execSync(e, {
170
170
  stdio: "inherit"
171
171
  });
172
172
  }
173
- function ft() {
174
- return _t(Date.now()).format("YYMMDD");
173
+ function wt() {
174
+ return qt(Date.now()).format("YYMMDD");
175
175
  }
176
- function Ni(e, t) {
177
- for (const i of t)
178
- if (!e.includes(i))
176
+ function ba(e, t) {
177
+ for (const a of t)
178
+ if (!e.includes(a))
179
179
  return !1;
180
180
  return !0;
181
181
  }
182
- function ae() {
183
- N(T()) || p("当前不在项目根目录。请切换到项目根目录");
182
+ function ie() {
183
+ N(T()) || d("当前不在项目根目录。请切换到项目根目录");
184
184
  }
185
185
  function K() {
186
- N(d.resolve(".git")) || p("当前不是git项目根目录,请先执行git init,或切换到根目录");
186
+ N(f.resolve(".git")) || d("当前不是git项目根目录,请先执行git init,或切换到根目录");
187
187
  }
188
- async function Se() {
189
- await m("git status -s") !== "" && p("请先提交代码变动,再进行操作");
188
+ async function ye() {
189
+ await m("git status -s") !== "" && d("请先提交代码变动,再进行操作");
190
190
  }
191
- function Si(e) {
192
- return e === $.MASTER ? R.PROD : e;
191
+ function ja(e) {
192
+ return e === v.MASTER ? C.PROD : e;
193
193
  }
194
- function bi(e) {
195
- return e === R.PROD ? $.MASTER : e;
194
+ function ka(e) {
195
+ return e === C.PROD ? v.MASTER : e;
196
196
  }
197
197
  async function M(e, ...t) {
198
198
  try {
199
199
  await e(...t);
200
- } catch (i) {
201
- throw mt(i), i;
200
+ } catch (a) {
201
+ throw gt(a), a;
202
202
  }
203
203
  }
204
- async function ji(e) {
205
- return (await Pe(e)).length === 0;
204
+ async function Ta(e) {
205
+ return (await Oe(e)).length === 0;
206
206
  }
207
- function ki(e = "项目中文名", t = "项目描述") {
207
+ function Ea(e = "项目中文名", t = "项目描述") {
208
208
  return `
209
209
  # ${e}
210
210
  ${t}
@@ -261,7 +261,7 @@ ${t}
261
261
  在此处放入飞书文档链接。请在[前端团队-项目手册](https://hxhtbr8t8uy.feishu.cn/drive/folder/QfQ7favVWljQk7d63Prc8mUGnJf)中按照分类新建文档。
262
262
  `;
263
263
  }
264
- const Ti = {
264
+ const Ra = {
265
265
  [w.JAVA]: {
266
266
  "**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml"
267
267
  },
@@ -279,18 +279,18 @@ const Ti = {
279
279
  "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
280
280
  "**/*.md": "markdownlint --fix"
281
281
  }
282
- }, Ei = "cli-z-develop", Ii = "0.14.12", Ci = "技术团队开发流程管理工具", Ri = "dist/index.js", xi = { z: "bin/z.js", "z-develop": "bin/z.js" }, Pi = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", test: "bun src/main.ts", "test:debug": "DEBUG=true bun src/main.ts", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", "build:w": "vite build --watch", eslint: "eslint '**/*.{ts,js}' --fix", prettier: "prettier -wu .", upload: "npm run build && npm publish --access public --registry https://registry.npmjs.org/", "upload:patch": "npm version patch && npm run upload", "upload:minor": "npm version minor && npm run upload", "upload:major": "npm version major && npm run upload" }, Di = "module", Li = "z", Oi = { "@lonely9/eslint-config-team": "^1.3.8", "@tsconfig/node22": "^22.0.5", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.9", "@types/minimist": "^1.2.5", "@types/node": "^22.15.29", "@types/semver": "^7.7.1", "@types/shelljs": "^0.10.0", "@typescript-eslint/eslint-plugin": "^8.58.2", "@typescript-eslint/parser": "^8.58.2", eslint: "^9.39.2", jiti: "^2.6.1", prettier: "^3.8.2", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.2.6" }, Mi = { "@inquirer/prompts": "^8.4.1", "@lonely9/api-generate": "^0.2.11", 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 = {
283
- name: Ei,
284
- version: Ii,
285
- description: Ci,
286
- main: Ri,
287
- bin: xi,
288
- scripts: Pi,
289
- type: Di,
290
- author: Li,
291
- devDependencies: Oi,
292
- dependencies: Mi
293
- }, x = {
282
+ }, Ia = "cli-z-develop", Ca = "0.14.14", La = "技术团队开发流程管理工具", xa = "dist/index.js", Da = { z: "bin/z.js", "z-develop": "bin/z.js" }, Pa = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", test: "bun src/main.ts", "test:debug": "DEBUG=true bun src/main.ts", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", "build:w": "vite build --watch", eslint: "eslint '**/*.{ts,js}' --fix", prettier: "prettier -wu .", upload: "npm run build && npm publish --access public --registry https://registry.npmjs.org/", "upload:patch": "npm version patch && npm run upload", "upload:minor": "npm version minor && npm run upload", "upload:major": "npm version major && npm run upload" }, Oa = "module", Ma = "z", Ba = { "@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" }, Ja = { "@inquirer/prompts": "^8.4.1", "@lonely9/api-generate": "^0.2.11", 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 = {
283
+ name: Ia,
284
+ version: Ca,
285
+ description: La,
286
+ main: xa,
287
+ bin: Da,
288
+ scripts: Pa,
289
+ type: Oa,
290
+ author: Ma,
291
+ devDependencies: Ba,
292
+ dependencies: Ja
293
+ }, L = {
294
294
  // 个人数据
295
295
  profile: {
296
296
  ldapAccount: "",
@@ -324,41 +324,41 @@ const Ti = {
324
324
  FECDNDomain: ""
325
325
  }
326
326
  };
327
- function C(e) {
328
- return e ? x.profile[e] : x.profile;
327
+ function I(e) {
328
+ return e ? L.profile[e] : L.profile;
329
329
  }
330
- function ge(e) {
331
- return e ? x.main[e] : x.main;
330
+ function he(e) {
331
+ return e ? L.main[e] : L.main;
332
332
  }
333
- function U(e) {
334
- return e ? x.constants[e] : x.constants;
333
+ function G(e) {
334
+ return e ? L.constants[e] : L.constants;
335
335
  }
336
- let _ = null, V = null;
337
- function De() {
338
- if (_)
339
- return _;
340
- const e = d.join("package.json");
341
- return N(e) || p(`当前目录(${L.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), _ = I.readJsonSync(e), _;
336
+ let W = null, q = null;
337
+ function Je() {
338
+ if (W)
339
+ return W;
340
+ const e = f.join("package.json");
341
+ return N(e) || d(`当前目录(${P.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), W = R.readJsonSync(e), W;
342
342
  }
343
343
  function X() {
344
- if (V)
345
- return V;
346
- const e = ct();
347
- return N(e) || p(
348
- `当前目录(${L.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
349
- ), V = I.readJsonSync(e), V;
344
+ if (q)
345
+ return q;
346
+ const e = pt();
347
+ return N(e) || d(
348
+ `当前目录(${P.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
349
+ ), q = R.readJsonSync(e), q;
350
350
  }
351
- function gt(e) {
352
- V ? V = {
353
- ...V,
351
+ function yt(e) {
352
+ q ? q = {
353
+ ...q,
354
354
  ...e
355
- } : V = e, I.writeJSONSync(ct(), V, { spaces: 2 });
355
+ } : q = e, R.writeJSONSync(pt(), q, { spaces: 2 });
356
356
  }
357
- function Ji(e) {
358
- _ ? _ = {
359
- ..._,
357
+ function za(e) {
358
+ W ? W = {
359
+ ...W,
360
360
  ...e
361
- } : _ = e, I.writeJSONSync(d.join("package.json"), _, { spaces: 2 });
361
+ } : W = e, R.writeJSONSync(f.join("package.json"), W, { spaces: 2 });
362
362
  }
363
363
  const Q = {
364
364
  id: 0,
@@ -367,154 +367,154 @@ const Q = {
367
367
  sourceBranch: "",
368
368
  mergeRequestUrl: ""
369
369
  };
370
- async function zi() {
370
+ async function Fa() {
371
371
  if (!Q.id)
372
372
  try {
373
- const e = X(), t = te(e.repository.url), i = await wt(t);
374
- Q.id = i.id, Q.path = t, Q.group = i.namespace.full_path, Q.mergeRequestUrl = `${i.web_url}/merge_requests`;
373
+ const e = X(), t = te(e.repository.url), a = await $t(t);
374
+ Q.id = a.id, Q.path = t, Q.group = a.namespace.full_path, Q.mergeRequestUrl = `${a.web_url}/merge_requests`;
375
375
  } catch (e) {
376
- p(e);
376
+ d(e);
377
377
  }
378
378
  return Q.sourceBranch || (Q.sourceBranch = await m("git branch --show-current")), Q;
379
379
  }
380
380
  function oe() {
381
- I.writeJSONSync(
382
- Ne(),
381
+ R.writeJSONSync(
382
+ ke(),
383
383
  {
384
- main: ge(),
385
- profile: C(),
386
- constants: U()
384
+ main: he(),
385
+ profile: I(),
386
+ constants: G()
387
387
  },
388
388
  {
389
389
  spaces: 2
390
390
  }
391
391
  );
392
392
  }
393
- function F(e, t) {
394
- t !== void 0 ? x.profile[e] = t : x.profile = {
395
- ...x.profile,
393
+ function z(e, t) {
394
+ t !== void 0 ? L.profile[e] = t : L.profile = {
395
+ ...L.profile,
396
396
  ...e
397
397
  };
398
398
  }
399
- function be(e, t) {
400
- x.constants = {
401
- ...x.constants,
399
+ function Te(e, t) {
400
+ L.constants = {
401
+ ...L.constants,
402
402
  ...e
403
403
  };
404
404
  }
405
405
  function pe(e, t) {
406
- t !== void 0 ? x.main[e] = t : x.main = {
407
- ...x.main,
406
+ t !== void 0 ? L.main[e] = t : L.main = {
407
+ ...L.main,
408
408
  ...e
409
409
  };
410
410
  }
411
411
  async function ne(e) {
412
- const t = e.method || "get", i = e.headers || {}, n = e.data || {}, a = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
412
+ const t = e.method || "get", a = e.headers || {}, n = e.data || {}, i = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
413
413
  try {
414
414
  const s = {
415
415
  url: e.url,
416
416
  method: t,
417
- [a]: n,
418
- headers: i,
417
+ [i]: n,
418
+ headers: a,
419
419
  responseType: e?.responseType || "json"
420
420
  };
421
- ye(A.magenta(s.method.toUpperCase()), A.yellow(s.url), JSON.stringify(s.headers)), ye(A.gray(JSON.stringify(s[a], null, 2)));
421
+ $e(A.magenta(s.method.toUpperCase()), A.yellow(s.url), JSON.stringify(s.headers)), $e(A.gray(JSON.stringify(s[i], null, 2)));
422
422
  const o = await ue(s);
423
- return ye(A.green("Response"), A.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
423
+ return $e(A.green("Response"), A.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
424
424
  } catch (s) {
425
- return s instanceof Gt && ye(A.red("Error"), A.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
425
+ return s instanceof Wt && $e(A.red("Error"), A.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
426
426
  }
427
427
  }
428
- async function Fi() {
429
- const e = C("gitToken");
428
+ async function Ua() {
429
+ const e = I("gitToken");
430
430
  if (e)
431
431
  return e;
432
432
  {
433
433
  const { access_token: t } = await ne({
434
- url: `${fe}/oauth/token`,
434
+ url: `${ge}/oauth/token`,
435
435
  method: "post",
436
436
  data: {
437
437
  grant_type: "password",
438
- username: C("ldapAccount"),
439
- password: C("ldapPassword")
438
+ username: I("ldapAccount"),
439
+ password: I("ldapPassword")
440
440
  }
441
- }), i = `Bearer ${t}`;
442
- return F("gitToken", i), oe(), i;
441
+ }), a = `Bearer ${t}`;
442
+ return z("gitToken", a), oe(), a;
443
443
  }
444
444
  }
445
445
  async function S(e) {
446
446
  return ne({
447
447
  ...e,
448
448
  headers: {
449
- Authorization: await Fi()
449
+ Authorization: await Ua()
450
450
  }
451
451
  });
452
452
  }
453
- async function Bi() {
454
- const e = C("zenTaoToken");
453
+ async function Ga() {
454
+ const e = I("zenTaoToken");
455
455
  if (e)
456
456
  return e;
457
457
  {
458
458
  const { token: t } = await ne({
459
- url: `${U("ZenTaoDomain")}/api.php/v1/tokens`,
459
+ url: `${G("ZenTaoDomain")}/api.php/v1/tokens`,
460
460
  method: "post",
461
461
  data: {
462
- account: C("ldapAccount"),
463
- password: C("ldapPassword")
462
+ account: I("ldapAccount"),
463
+ password: I("ldapPassword")
464
464
  }
465
465
  });
466
- return F("zenTaoToken", t), oe(), t;
466
+ return z("zenTaoToken", t), oe(), t;
467
467
  }
468
468
  }
469
- async function $e(e) {
469
+ async function be(e) {
470
470
  const t = await ne({
471
471
  ...e,
472
472
  headers: {
473
- Token: await Bi()
473
+ Token: await Ga()
474
474
  }
475
475
  });
476
476
  if (e.url.includes("local")) {
477
477
  if (typeof t == "string") {
478
- const i = JSON.parse(t.slice(0, t.indexOf("<script>")));
479
- return JSON.parse(i.data);
478
+ const a = JSON.parse(t.slice(0, t.indexOf("<script>")));
479
+ return JSON.parse(a.data);
480
480
  }
481
481
  if (typeof t == "object")
482
- return t.error === "Unauthorized" || t.data.indexOf("<script>") < 0 ? (F("zenTaoToken", ""), $e({
482
+ return t.error === "Unauthorized" || t.data.indexOf("<script>") < 0 ? (z("zenTaoToken", ""), be({
483
483
  ...e
484
484
  })) : t;
485
485
  } else {
486
- const { status: i, data: n } = t;
487
- if (i === "success") {
488
- const a = JSON.parse(n);
489
- return a.title === "用户登录" ? (F("zenTaoToken", ""), $e({
486
+ const { status: a, data: n } = t;
487
+ if (a === "success") {
488
+ const i = JSON.parse(n);
489
+ return i.title === "用户登录" ? (z("zenTaoToken", ""), be({
490
490
  ...e
491
- })) : a;
491
+ })) : i;
492
492
  } else
493
493
  return {};
494
494
  }
495
495
  }
496
- async function Ui() {
497
- const e = C("k8sToken");
496
+ async function _a() {
497
+ const e = I("k8sToken");
498
498
  if (e)
499
499
  return e;
500
500
  {
501
501
  const { access_token: t } = await ne({
502
- url: `${U("K8sDomain")}/oauth/login/LDAP`,
502
+ url: `${G("K8sDomain")}/oauth/login/LDAP`,
503
503
  method: "post",
504
504
  headers: {
505
505
  "Content-Type": "application/x-www-form-urlencoded"
506
506
  },
507
507
  data: {
508
- username: C("ldapAccount"),
509
- password: C("ldapPassword")
508
+ username: I("ldapAccount"),
509
+ password: I("ldapPassword")
510
510
  }
511
- }), i = `Bearer ${t}`;
512
- return F("k8sToken", i), oe(), i;
511
+ }), a = `Bearer ${t}`;
512
+ return z("k8sToken", a), oe(), a;
513
513
  }
514
514
  }
515
- async function Gi(e, t) {
515
+ async function Va(e, t) {
516
516
  try {
517
- const i = Ot(t, { mode: 493 });
517
+ const a = Jt(t, { mode: 493 });
518
518
  return (await ue({
519
519
  method: "get",
520
520
  url: e,
@@ -522,193 +522,193 @@ async function Gi(e, t) {
522
522
  headers: {
523
523
  "Content-Type": "application/octet-stream"
524
524
  }
525
- })).data.pipe(i), new Promise((a, s) => {
526
- i.on("finish", () => a(1)), i.on("error", s);
525
+ })).data.pipe(a), new Promise((i, s) => {
526
+ a.on("finish", () => i(1)), a.on("error", s);
527
527
  });
528
- } catch (i) {
529
- throw console.error("下载失败:", i), i;
528
+ } catch (a) {
529
+ throw console.error("下载失败:", a), a;
530
530
  }
531
531
  }
532
- const J = () => `${fe}/api/v4`, z = (e) => `${J()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
533
- function _i() {
532
+ const B = () => `${ge}/api/v4`, J = (e) => `${B()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
533
+ function Wa() {
534
534
  return S({
535
- url: z("src/data/template-projects.json")
535
+ url: J("src/data/template-projects.json")
536
536
  });
537
537
  }
538
- function Vi() {
538
+ function qa() {
539
539
  return S({
540
- url: z("src/data/java-project-module.json")
540
+ url: J("src/data/java-project-module.json")
541
541
  });
542
542
  }
543
- function Wi() {
543
+ function Ha() {
544
544
  return S({
545
- url: z("src/data/java-project-api.json")
545
+ url: J("src/data/java-project-api.json")
546
546
  });
547
547
  }
548
- function Le() {
548
+ function ze() {
549
549
  return S({
550
- url: z("src/data/z-develop-config.json")
550
+ url: J("src/data/z-develop-config.json")
551
551
  });
552
552
  }
553
- function qi() {
553
+ function Za() {
554
554
  return S({
555
- url: z("src/assets/tsconfig.browser.json")
555
+ url: J("src/assets/tsconfig.browser.json")
556
556
  });
557
557
  }
558
- function Hi() {
558
+ function Ka() {
559
559
  return S({
560
- url: z("src/assets/tsconfig.node.json")
560
+ url: J("src/assets/tsconfig.node.json")
561
561
  });
562
562
  }
563
- function Zi() {
563
+ function Xa() {
564
564
  return S({
565
- url: z("src/assets/.prettierignore")
565
+ url: J("src/assets/.prettierignore")
566
566
  });
567
567
  }
568
- function Ki() {
568
+ function Ya() {
569
569
  return S({
570
- url: z("src/assets/.prettierrc.json")
570
+ url: J("src/assets/.prettierrc.json")
571
571
  });
572
572
  }
573
- function Xi() {
573
+ function Qa() {
574
574
  return S({
575
- url: z("src/assets/data.yaml")
575
+ url: J("src/assets/data.yaml")
576
576
  });
577
577
  }
578
- function Yi() {
578
+ function ei() {
579
579
  return S({
580
- url: z("src/assets/main.py")
580
+ url: J("src/assets/main.py")
581
581
  });
582
582
  }
583
- function Qi() {
583
+ function ti() {
584
584
  return S({
585
- url: z("src/assets/checkstyle.xml")
585
+ url: J("src/assets/checkstyle.xml")
586
586
  });
587
587
  }
588
- function ht() {
588
+ function vt() {
589
589
  return S({
590
- url: z("src/data/project-group-chats.json")
590
+ url: J("src/data/project-group-chats.json")
591
591
  });
592
592
  }
593
- function ea() {
593
+ function ai() {
594
594
  return S({
595
- url: `${J()}/user`
595
+ url: `${B()}/user`
596
596
  });
597
597
  }
598
- function ta() {
598
+ function ii() {
599
599
  return S({
600
- url: `${J()}/groups`
600
+ url: `${B()}/groups`
601
601
  });
602
602
  }
603
- function ia(e) {
603
+ function ni(e) {
604
604
  return S({
605
- url: `${J()}/projects`,
605
+ url: `${B()}/projects`,
606
606
  method: "post",
607
607
  data: e
608
608
  });
609
609
  }
610
- function wt(e) {
610
+ function $t(e) {
611
611
  return S({
612
- url: `${J()}/projects/${e}`
612
+ url: `${B()}/projects/${e}`
613
613
  });
614
614
  }
615
- function aa(e) {
615
+ function si(e) {
616
616
  return S({
617
- url: `${J()}/projects`,
617
+ url: `${B()}/projects`,
618
618
  data: {
619
619
  search: e,
620
620
  search_namespaces: !0
621
621
  }
622
622
  });
623
623
  }
624
- function na(e) {
624
+ function ri(e) {
625
625
  return S({
626
- url: `${J()}/projects/${e.id}/merge_requests`,
626
+ url: `${B()}/projects/${e.id}/merge_requests`,
627
627
  method: "post",
628
628
  data: e
629
629
  });
630
630
  }
631
- function sa(e) {
631
+ function oi(e) {
632
632
  return S({
633
- url: `${J()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
633
+ url: `${B()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
634
634
  method: "put"
635
635
  });
636
636
  }
637
- function ra(e) {
637
+ function ci(e) {
638
638
  return S({
639
- url: `${J()}/projects/${e.id}/merge_requests/${e.iid}`,
639
+ url: `${B()}/projects/${e.id}/merge_requests/${e.iid}`,
640
640
  method: "put",
641
641
  data: e
642
642
  });
643
643
  }
644
- function oa(e) {
644
+ function li(e) {
645
645
  return S({
646
- url: `${J()}/projects/${e.id}/merge_requests/${e.iid}`,
646
+ url: `${B()}/projects/${e.id}/merge_requests/${e.iid}`,
647
647
  method: "get"
648
648
  });
649
649
  }
650
- function ca(e) {
650
+ function ui(e) {
651
651
  return S({
652
- url: `${J()}/projects/${e.id}/repository/branches`,
652
+ url: `${B()}/projects/${e.id}/repository/branches`,
653
653
  method: "post",
654
654
  data: e
655
655
  });
656
656
  }
657
- function la(e) {
657
+ function pi(e) {
658
658
  return S({
659
- url: `${J()}/projects/${e}/repository/branches`
659
+ url: `${B()}/projects/${e}/repository/branches`
660
660
  });
661
661
  }
662
- function ua() {
663
- const e = he("fe-groups.json");
664
- return N(e) ? I.readJSONSync(e) : { groups: [] };
662
+ function mi() {
663
+ const e = we("fe-groups.json");
664
+ return N(e) ? R.readJSONSync(e) : { groups: [] };
665
665
  }
666
- async function pa() {
667
- const e = await ta(), t = li.map((i) => {
668
- const n = e.find((a) => a.name === i);
666
+ async function di() {
667
+ const e = await ii(), t = ma.map((a) => {
668
+ const n = e.find((i) => i.name === a);
669
669
  return n ? {
670
670
  name: n.name,
671
671
  id: n.id,
672
672
  description: n.description
673
673
  } : !1;
674
- }).filter((i) => !!i);
675
- I.writeJSONSync(he("fe-groups.json"), { groups: t }, { spaces: 2 });
674
+ }).filter((a) => !!a);
675
+ R.writeJSONSync(we("fe-groups.json"), { groups: t }, { spaces: 2 });
676
676
  }
677
677
  async function b(e) {
678
- const t = `${U("FEServerDomain")}/api`, i = await ne({
678
+ const t = `${G("FEServerDomain")}/api`, a = await ne({
679
679
  url: t + e.url,
680
680
  headers: {
681
681
  "the-key-one": "z-develop",
682
- "the-key-two": U("ZDevelopPassword")
682
+ "the-key-two": G("ZDevelopPassword")
683
683
  },
684
684
  data: e.data,
685
685
  method: e.method || "post"
686
686
  });
687
- return i.code !== 0 && p(`${i.code}: ${i.message}`), i.data;
687
+ return a.code !== 0 && d(`${a.code}: ${a.message}`), a.data;
688
688
  }
689
- async function ma(e) {
690
- const t = `${U("FEServerDomain")}/api`;
689
+ async function fi(e) {
690
+ const t = `${G("FEServerDomain")}/api`;
691
691
  return await ne({
692
692
  url: t + e.url,
693
693
  headers: {
694
694
  "the-key-one": "z-develop",
695
- "the-key-two": U("ZDevelopPassword")
695
+ "the-key-two": G("ZDevelopPassword")
696
696
  },
697
697
  data: e.data,
698
698
  method: e.method || "post"
699
699
  });
700
700
  }
701
- function da() {
701
+ function gi() {
702
702
  return b({
703
703
  url: "/user/list2"
704
704
  });
705
705
  }
706
- function fa() {
706
+ function hi() {
707
707
  return b({
708
708
  url: "/zen/testcase/product/list"
709
709
  });
710
710
  }
711
- function yt(e) {
711
+ function At(e) {
712
712
  return b({
713
713
  url: "/zen/testcase/product/module/list",
714
714
  data: {
@@ -716,7 +716,7 @@ function yt(e) {
716
716
  }
717
717
  });
718
718
  }
719
- function ga(e) {
719
+ function wi(e) {
720
720
  return b({
721
721
  url: "/zen/testcase/product/name",
722
722
  data: {
@@ -724,7 +724,7 @@ function ga(e) {
724
724
  }
725
725
  });
726
726
  }
727
- function ha(e, t) {
727
+ function yi(e, t) {
728
728
  return b({
729
729
  url: "/zen/testcase/product/auto-case/list",
730
730
  data: {
@@ -733,7 +733,7 @@ function ha(e, t) {
733
733
  }
734
734
  });
735
735
  }
736
- function wa(e) {
736
+ function vi(e) {
737
737
  return b({
738
738
  url: "/zen/testcase/step/list",
739
739
  data: {
@@ -741,72 +741,72 @@ function wa(e) {
741
741
  }
742
742
  });
743
743
  }
744
- function ya(e) {
744
+ function $i(e) {
745
745
  return b({
746
746
  url: "/zen/testcase/module/create",
747
747
  data: e
748
748
  });
749
749
  }
750
- function va(e) {
750
+ function Ai(e) {
751
751
  return b({
752
752
  url: "/zen/testcase/create",
753
753
  data: e
754
754
  });
755
755
  }
756
- function $a(e) {
756
+ function Ni(e) {
757
757
  return b({
758
758
  url: "/zen/testcase/step/create",
759
759
  data: e
760
760
  });
761
761
  }
762
- function Aa(e) {
762
+ function Si(e) {
763
763
  return b({
764
764
  url: "/zen/testcase/modules/remove",
765
765
  data: e
766
766
  });
767
767
  }
768
- function Na(e) {
768
+ function bi(e) {
769
769
  return b({
770
770
  url: "/zen/testcase/cases/remove",
771
771
  data: e
772
772
  });
773
773
  }
774
- function Sa(e) {
774
+ function ji(e) {
775
775
  return b({
776
776
  url: "/zen/testcase/module/update/name",
777
777
  data: e
778
778
  });
779
779
  }
780
- function ba(e) {
780
+ function ki(e) {
781
781
  return b({
782
782
  url: "/zen/testcase/case/update/name",
783
783
  data: e
784
784
  });
785
785
  }
786
- function ja(e) {
786
+ function Ti(e) {
787
787
  return b({
788
788
  url: "/zen/testcase/case/update/priority",
789
789
  data: e
790
790
  });
791
791
  }
792
- function ka(e) {
792
+ function Ei(e) {
793
793
  return b({
794
794
  url: "/zen/testcase/case/update/precondition",
795
795
  data: e
796
796
  });
797
797
  }
798
- function Ta(e) {
798
+ function Ri(e) {
799
799
  return b({
800
800
  url: "/zen/testcase/case/result/create",
801
801
  data: e
802
802
  });
803
803
  }
804
- function Ea() {
804
+ function Ii() {
805
805
  return b({
806
806
  url: "/zen/testcase/project/list"
807
807
  });
808
808
  }
809
- function Ia(e) {
809
+ function Ci(e) {
810
810
  return b({
811
811
  url: "/zen/testcase/project/execution/list",
812
812
  data: {
@@ -814,7 +814,7 @@ function Ia(e) {
814
814
  }
815
815
  });
816
816
  }
817
- function Ca(e) {
817
+ function Li(e) {
818
818
  return b({
819
819
  url: "/zen/testcase/execution/build/list",
820
820
  data: {
@@ -822,32 +822,32 @@ function Ca(e) {
822
822
  }
823
823
  });
824
824
  }
825
- function He(e) {
825
+ function Ye(e) {
826
826
  return b({
827
827
  url: "/common/ai/talk",
828
828
  data: e
829
829
  });
830
830
  }
831
- function Ra(e) {
832
- return ma({
831
+ function xi(e) {
832
+ return fi({
833
833
  url: "/common/notify/group/send",
834
834
  data: e
835
835
  });
836
836
  }
837
- function xa(e) {
837
+ function Di(e) {
838
838
  return b({
839
839
  url: "/deploy/create/chain",
840
840
  data: e
841
841
  });
842
842
  }
843
- function Pa(e, t) {
844
- const i = [];
843
+ function Pi(e, t) {
844
+ const a = [];
845
845
  t.forEach((s) => {
846
- e.includes(s.value) && i.push(s);
846
+ e.includes(s.value) && a.push(s);
847
847
  });
848
- const n = ge("weWorkListCache"), a = n.map((s) => s.value);
849
- i.forEach((s) => {
850
- const o = a.indexOf(s.value);
848
+ const n = he("weWorkListCache"), i = n.map((s) => s.value);
849
+ a.forEach((s) => {
850
+ const o = i.indexOf(s.value);
851
851
  o > -1 ? n[o].usageCount += 1 : n.push({
852
852
  ...s,
853
853
  usageCount: 1
@@ -856,53 +856,53 @@ function Pa(e, t) {
856
856
  weWorkListCache: n.sort((s, o) => o.usageCount - s.usageCount)
857
857
  }), oe();
858
858
  }
859
- async function vt() {
860
- const t = (await da()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
861
- name: `${s.nick} - ${ci[s.title]}`,
859
+ async function Nt() {
860
+ const t = (await gi()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
861
+ name: `${s.nick} - ${pa[s.title]}`,
862
862
  value: s.weWorkUserId
863
- })), i = ge("weWorkListCache"), n = i.map((s) => s.value), a = [];
863
+ })), a = he("weWorkListCache"), n = a.map((s) => s.value), i = [];
864
864
  return t.forEach((s) => {
865
865
  const o = n.indexOf(s.value);
866
- a.push({
866
+ i.push({
867
867
  ...s,
868
- usageCount: o > -1 ? i[o].usageCount : 0
868
+ usageCount: o > -1 ? a[o].usageCount : 0
869
869
  });
870
- }), a.sort((s, o) => o.usageCount - s.usageCount);
870
+ }), i.sort((s, o) => o.usageCount - s.usageCount);
871
871
  }
872
- async function $t(e, t, i) {
873
- const n = await vt();
874
- let a = await Z({
872
+ async function St(e, t, a) {
873
+ const n = await Nt();
874
+ let i = await _({
875
875
  message: e,
876
876
  loop: !0,
877
877
  pageSize: n.length || 5,
878
878
  clearInputWhenSelected: !0,
879
- multiple: i,
879
+ multiple: a,
880
880
  options: (s) => s ? n.filter((o) => o.name.includes(s)) : n,
881
881
  validate: t
882
882
  });
883
- return a = Array.isArray(a) ? a : [a], Pa(a, n), a;
883
+ return i = Array.isArray(i) ? i : [i], Pi(i, n), i;
884
884
  }
885
- async function Da(e, t, i) {
886
- const { groups: n } = await ht(), a = n.map((o) => ({
885
+ async function Oi(e, t, a) {
886
+ const { groups: n } = await vt(), i = n.map((o) => ({
887
887
  name: o.name,
888
888
  value: o.url
889
889
  }));
890
- let s = await Z({
890
+ let s = await _({
891
891
  message: e,
892
892
  loop: !0,
893
- pageSize: a.length || 5,
893
+ pageSize: i.length || 5,
894
894
  clearInputWhenSelected: !0,
895
- multiple: i,
896
- options: (o) => o ? a.filter((r) => r.name.includes(o)) : a,
895
+ multiple: a,
896
+ options: (o) => o ? i.filter((r) => r.name.includes(o)) : i,
897
897
  validate: t
898
898
  });
899
899
  return s = Array.isArray(s) ? s : [s], s;
900
900
  }
901
- async function La() {
901
+ async function Mi() {
902
902
  try {
903
- ut() && (await et({
903
+ dt() && (await Me({
904
904
  message: "系统中已存在z的配置文件,确认重新配置?"
905
- }) ? L.rm("-rf", Ne()) : process.exit(0)), await me(he(), { recursive: !0 });
905
+ }) ? P.rm("-rf", ke()) : process.exit(0)), await me(we(), { recursive: !0 });
906
906
  const t = await k({
907
907
  message: "请选择岗位类型",
908
908
  choices: [
@@ -920,63 +920,63 @@ async function La() {
920
920
  }
921
921
  ]
922
922
  });
923
- let i = await B({
923
+ let a = await F({
924
924
  message: "请输入LDAP账号:"
925
925
  });
926
- i = i.trim();
927
- let n = await Wt({
926
+ a = a.trim();
927
+ let n = await Zt({
928
928
  message: "请输入LDAP密码:",
929
929
  mask: !0
930
930
  });
931
- n = n.trim(), F("jobType", t), F("ldapAccount", i), F("ldapPassword", n);
932
- const a = await Le();
933
- be(a);
934
- const s = await vt(), o = await $t("请选择你自己(用于企微通知):", (l) => l.length > 1 ? "只能选一个" : l.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((l) => l.value === o[0]);
935
- F({
931
+ n = n.trim(), z("jobType", t), z("ldapAccount", a), z("ldapPassword", n);
932
+ const i = await ze();
933
+ Te(i);
934
+ const s = await Nt(), o = await St("请选择你自己(用于企微通知):", (l) => l.length > 1 ? "只能选一个" : l.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((l) => l.value === o[0]);
935
+ z({
936
936
  weWorkName: r,
937
937
  weWorkUserId: c
938
938
  });
939
939
  } catch (t) {
940
- p(t);
940
+ d(t);
941
941
  }
942
942
  const e = y("配置信息初始化中").start();
943
943
  try {
944
- const t = await ea();
945
- F({
944
+ const t = await ai();
945
+ z({
946
946
  gitUserId: t.id,
947
947
  gitName: t.name,
948
948
  gitEnglishName: t.username,
949
949
  gitEmail: t.email
950
- }), pe("latestCheckVersionTimestamp", Date.now()), oe(), C("jobType") === le.FRONT_END && await pa(), e.succeed("配置信息初始化完成"), process.exit(0);
950
+ }), pe("latestCheckVersionTimestamp", Date.now()), oe(), I("jobType") === le.FRONT_END && await di(), e.succeed("配置信息初始化完成"), process.exit(0);
951
951
  } catch (t) {
952
- e.fail("配置信息初始化失败"), ue.isAxiosError(t) && p("请检查你的域名及令牌配置"), p(t);
952
+ e.fail("配置信息初始化失败"), ue.isAxiosError(t) && d("请检查你的域名及令牌配置"), d(t);
953
953
  }
954
954
  }
955
- async function Oa() {
956
- await D(Ae(), "", { mode: 493 }), await D(T(".gitignore"), `.commit-msg-tpl
955
+ async function Bi() {
956
+ await D(je(), "", { mode: 493 }), await D(T(".gitignore"), `.commit-msg-tpl
957
957
  `, { mode: 493 }), await D(T("commit-msg"), `#!/usr/bin/env sh
958
958
  z run commit-msg`, { mode: 493 }), await D(T("pre-commit"), `#!/usr/bin/env sh
959
959
  z run commit-files`, { mode: 493 });
960
960
  const { language: e } = X();
961
961
  if ([w.JAVASCRIPT, w.MARKDOWN].includes(e) && (await D(
962
962
  T(".prettierrc.json"),
963
- `${JSON.stringify(await Ki(), null, 2)}
963
+ `${JSON.stringify(await Ya(), null, 2)}
964
964
  `,
965
965
  {
966
966
  mode: 493
967
967
  }
968
- ), await D(T(".prettierignore"), await Zi(), { mode: 493 }), await D(T("tsconfig.node.json"), await Hi(), { mode: 493 }), await D(T("tsconfig.browser.json"), await qi(), { mode: 493 })), e === w.JAVA) {
969
- await Gi(`${U("FECDNDomain")}/file/vgnlfbfHRF.jar`, T("checkstyle.jar")), await D(T("checkstyle.xml"), await Qi(), { mode: 493 });
970
- const t = d.join("package.json");
968
+ ), await D(T(".prettierignore"), await Xa(), { mode: 493 }), await D(T("tsconfig.node.json"), await Ka(), { mode: 493 }), await D(T("tsconfig.browser.json"), await Za(), { mode: 493 })), e === w.JAVA) {
969
+ await Va(`${G("FECDNDomain")}/file/vgnlfbfHRF.jar`, T("checkstyle.jar")), await D(T("checkstyle.xml"), await ti(), { mode: 493 });
970
+ const t = f.join("package.json");
971
971
  N(t) || await D(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
972
972
  mode: 493
973
973
  });
974
974
  }
975
- lt();
975
+ mt();
976
976
  }
977
- async function Ma(e, t) {
978
- const i = await m("git remote get-url --push origin");
979
- i || p("获取项目远程git地址失败,请配置后重试");
977
+ async function Ji(e, t) {
978
+ const a = await m("git remote get-url --push origin");
979
+ a || d("获取项目远程git地址失败,请配置后重试");
980
980
  let n = e;
981
981
  n || (n = await k({
982
982
  message: "请选择项目语言",
@@ -999,55 +999,55 @@ async function Ma(e, t) {
999
999
  }
1000
1000
  ]
1001
1001
  }));
1002
- let a = t;
1003
- if (!a) {
1004
- const s = te(i), o = await wt(s);
1002
+ let i = t;
1003
+ if (!i) {
1004
+ const s = te(a), o = await $t(s);
1005
1005
  if (!o)
1006
- return p(`未找到项目,请确认项目${i}是否存在,或者当前账号权限`);
1007
- a = o.namespace.full_path;
1006
+ return d(`未找到项目,请确认项目${a}是否存在,或者当前账号权限`);
1007
+ i = o.namespace.full_path;
1008
1008
  }
1009
- gt({
1009
+ yt({
1010
1010
  language: n,
1011
- "lint-staged": Ti[n],
1011
+ "lint-staged": Ra[n],
1012
1012
  repository: {
1013
- url: i,
1014
- group: a
1013
+ url: a,
1014
+ group: i
1015
1015
  }
1016
1016
  });
1017
1017
  }
1018
- async function Oe(e, t) {
1019
- e ? L.rm("-rf", ee) : N(T()) && (await et({
1018
+ async function Fe(e, t) {
1019
+ e ? P.rm("-rf", ee) : N(T()) && (await Me({
1020
1020
  message: `当前项目中已存在配置文件夹${ee},确认重新配置?`
1021
- }) ? L.rm("-rf", ee) : process.exit(0)), await me(T(), { recursive: !0 }), await Ma(e, t);
1022
- const i = y("项目初始化中...").start();
1023
- await Oa(), i.succeed("项目初始化完成");
1021
+ }) ? P.rm("-rf", ee) : process.exit(0)), await me(T(), { recursive: !0 }), await Ji(e, t);
1022
+ const a = y("项目初始化中...").start();
1023
+ await Bi(), a.succeed("项目初始化完成");
1024
1024
  }
1025
- async function Ja() {
1026
- N(T()) && N(Ae()) ? lt() : await Oe(), process.exit(0);
1025
+ async function zi() {
1026
+ N(T()) && N(je()) ? mt() : await Fe(), process.exit(0);
1027
1027
  }
1028
- async function za(e, t) {
1029
- t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && p("项目语言不支持"), e ? (K(), e === "." ? (await Oe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await Ja() : p("参数错误。执行 z init -h 查看帮助。")) : await La();
1028
+ async function Fi(e, t) {
1029
+ t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && d("项目语言不支持"), e ? (K(), e === "." ? (await Fe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await zi() : d("参数错误。执行 z init -h 查看帮助。")) : await Mi();
1030
1030
  }
1031
- P.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => M(za, ...e));
1032
- async function Fa(e, t) {
1031
+ x.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => M(Fi, ...e));
1032
+ async function Ui(e, t) {
1033
1033
  if (!e)
1034
1034
  return "不能为空";
1035
1035
  if (!/^[a-z0-9-]+$/.test(e))
1036
1036
  return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
1037
- if (dt().includes(e))
1037
+ if (ht().includes(e))
1038
1038
  return "当前目录下已存在同名文件夹,请先处理。";
1039
- const a = (await aa(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
1040
- return a ? `远程仓库中已存在同名项目(${a.http_url_to_repo}),请更名后重试` : !0;
1039
+ const i = (await si(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
1040
+ return i ? `远程仓库中已存在同名项目(${i.http_url_to_repo}),请更名后重试` : !0;
1041
1041
  }
1042
- function Ba(e) {
1042
+ function Gi(e) {
1043
1043
  return e ? !0 : "不能为空";
1044
1044
  }
1045
- function Ua(e) {
1045
+ function _i(e) {
1046
1046
  return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
1047
1047
  }
1048
- async function Ga(e) {
1049
- ae(), K(), await Se();
1050
- let t, i;
1048
+ async function Vi(e) {
1049
+ ie(), K(), await ye();
1050
+ let t, a;
1051
1051
  e.branchType ? t = e.branchType : t = await k({
1052
1052
  message: "请选择创建分支的类型",
1053
1053
  choices: [
@@ -1064,95 +1064,95 @@ async function Ga(e) {
1064
1064
  value: de.REFACTOR
1065
1065
  }
1066
1066
  ]
1067
- }), e.branchPurpose ? i = e.branchPurpose : (i = await B({
1067
+ }), e.branchPurpose ? a = e.branchPurpose : (a = await F({
1068
1068
  message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
1069
- validate: Ua
1070
- }), i = i.trim());
1071
- const n = `${t}_${i}_${ft()}`;
1072
- await m(`git fetch origin ${$.MASTER}`), await m(`git checkout -b ${n} origin/${$.MASTER}`), await m(`git push -u origin ${n}`), process.exit(0);
1073
- }
1074
- const At = (e) => `${U("ZenTaoDomain")}${e}`;
1075
- async function _a() {
1076
- const e = await $e({
1077
- url: At("/my-work-task.json?tid=mrrferp8"),
1069
+ validate: _i
1070
+ }), a = a.trim());
1071
+ const n = `${t}_${a}_${wt()}`;
1072
+ await m(`git fetch origin ${v.MASTER}`), await m(`git checkout -b ${n} origin/${v.MASTER}`), await m(`git push -u origin ${n}`), process.exit(0);
1073
+ }
1074
+ const bt = (e) => `${G("ZenTaoDomain")}${e}`;
1075
+ async function Wi() {
1076
+ const e = await be({
1077
+ url: bt("/my-work-task.json?tid=mrrferp8"),
1078
1078
  method: "get"
1079
1079
  });
1080
- return e?.tasks ? e.tasks.filter((t) => t.status !== "done").map(({ id: t, name: i }) => ({
1080
+ return e?.tasks ? e.tasks.filter((t) => t.status !== "done").map(({ id: t, name: a }) => ({
1081
1081
  value: {
1082
- name: i,
1082
+ name: a,
1083
1083
  value: t
1084
1084
  },
1085
- name: i
1085
+ name: a
1086
1086
  })) : [];
1087
1087
  }
1088
- async function Va() {
1089
- const e = await $e({
1090
- url: At("/my-work-bug.json?tid=mrrferp8"),
1088
+ async function qi() {
1089
+ const e = await be({
1090
+ url: bt("/my-work-bug.json?tid=mrrferp8"),
1091
1091
  method: "get"
1092
1092
  });
1093
- return e?.bugs ? Object.values(e.bugs).map(({ id: t, title: i }) => ({
1094
- name: i,
1093
+ return e?.bugs ? Object.values(e.bugs).map(({ id: t, title: a }) => ({
1094
+ name: a,
1095
1095
  value: {
1096
- name: i,
1096
+ name: a,
1097
1097
  value: t
1098
1098
  }
1099
1099
  })) : [];
1100
1100
  }
1101
- const xe = async () => (await B({
1101
+ const Pe = async () => (await F({
1102
1102
  message: "请输入commit msg:",
1103
1103
  validate: (t) => t.length === 0 ? "请输入commit msg" : !0
1104
1104
  })).trim();
1105
- async function Ze(e, t) {
1106
- const i = await m("git diff HEAD", {
1105
+ async function Qe(e, t) {
1106
+ const a = await m("git diff HEAD", {
1107
1107
  removeTailLinkBreak: !1
1108
1108
  });
1109
- if (i || p("git暂存区没有内容,请先git add添加文件到暂存区"), Buffer.byteLength(i, "utf-8") < _e) {
1110
- const l = await He({
1109
+ if (a || d("git暂存区没有内容,请先git add添加文件到暂存区"), Buffer.byteLength(a, "utf-8") < Ze) {
1110
+ const l = await Ye({
1111
1111
  type: "commit-message-v2",
1112
- input: i
1112
+ input: a
1113
1113
  // modelName: "qwen-turbo",
1114
1114
  });
1115
1115
  return e + l;
1116
1116
  }
1117
1117
  const n = await m("git diff --name-only HEAD");
1118
- n || p("git暂存区没有内容,请先git add添加文件到暂存区");
1119
- const a = n.replace(/\r\n/g, `
1118
+ n || d("git暂存区没有内容,请先git add添加文件到暂存区");
1119
+ const i = n.replace(/\r\n/g, `
1120
1120
  `).split(`
1121
1121
  `).filter(Boolean), s = [], o = [];
1122
- for (const l of a)
1122
+ for (const l of i)
1123
1123
  try {
1124
- const u = l.replace(/(["\\$`])/g, "\\$1"), f = await m(`git diff HEAD -- "${u}"`, {
1124
+ const u = l.replace(/(["\\$`])/g, "\\$1"), p = await m(`git diff HEAD -- "${u}"`, {
1125
1125
  removeTailLinkBreak: !1
1126
1126
  });
1127
- f && Buffer.byteLength(f, "utf-8") < mi && (s.push(l), o.push(f));
1127
+ p && Buffer.byteLength(p, "utf-8") < ga && (s.push(l), o.push(p));
1128
1128
  } catch {
1129
1129
  }
1130
1130
  const r = o.join(`
1131
1131
  `);
1132
- if (s.length === 0 || Buffer.byteLength(r, "utf-8") > _e)
1133
- return We("变更内容太大,无法自动生成commit msg"), t.stop(), await xe();
1132
+ if (s.length === 0 || Buffer.byteLength(r, "utf-8") > Ze)
1133
+ return fe("变更内容太大,无法自动生成commit msg"), t.stop(), await Pe();
1134
1134
  if (!r)
1135
- return We("无法获取文件差异信息"), t.stop(), await xe();
1136
- const c = await He({
1135
+ return fe("无法获取文件差异信息"), t.stop(), await Pe();
1136
+ const c = await Ye({
1137
1137
  type: "commit-message-v2",
1138
1138
  input: r
1139
1139
  // modelName: "qwen-turbo",
1140
1140
  });
1141
1141
  return e + c;
1142
1142
  }
1143
- async function Ee(e, t, i) {
1143
+ async function Ce(e, t, a) {
1144
1144
  const n = y("🤖 生成提交信息中...").start();
1145
- let a = "", s = !0;
1145
+ let i = "", s = !0;
1146
1146
  if ([j.FEAT, j.FIX, j.REFACTOR].includes(e)) {
1147
1147
  const o = t.map((r) => r.value).join(",");
1148
- if (i || (a = await Ze(`${e}(${o}): `, n)), !a) {
1148
+ if (a || (i = await Qe(`${e}(${o}): `, n)), !i) {
1149
1149
  const r = t.map((c) => c.name).join(";");
1150
- a = `${e}(${o}): ${r}`, s = !1;
1150
+ i = `${e}(${o}): ${r}`, s = !1;
1151
1151
  }
1152
1152
  }
1153
- e === j.CHORE && (t ? a = `${e}: ${t}` : a = await Ze(`${e}: `, n)), await D(Ae(), a, "utf-8"), s || i ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(A.yellow(a));
1153
+ e === j.CHORE && (t ? i = `${e}: ${t}` : i = await Qe(`${e}: `, n)), await D(je(), i, "utf-8"), s || a ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(A.yellow(i));
1154
1154
  }
1155
- async function Wa(e) {
1155
+ async function Hi(e) {
1156
1156
  const t = await k({
1157
1157
  message: "请选择你要创建的模板类型",
1158
1158
  choices: [
@@ -1175,58 +1175,58 @@ async function Wa(e) {
1175
1175
  ]
1176
1176
  });
1177
1177
  if ([j.FEAT, j.REFACTOR].includes(t)) {
1178
- const i = await _a();
1179
- if (!i.length)
1180
- return q("🤷 暂无开发任务");
1181
- const n = await ve({
1178
+ const a = await Wi();
1179
+ if (!a.length)
1180
+ return U("🤷 暂无开发任务");
1181
+ const n = await Se({
1182
1182
  message: "请关联开发任务(可多选):",
1183
- validate: (a) => a.length === 0 ? "请选择项" : !0,
1184
- choices: i.map((a) => ({
1185
- ...a,
1186
- name: `[${a.value.value}]: ${a.name}`
1183
+ validate: (i) => i.length === 0 ? "请选择项" : !0,
1184
+ choices: a.map((i) => ({
1185
+ ...i,
1186
+ name: `[${i.value.value}]: ${i.name}`
1187
1187
  })),
1188
- pageSize: i.length
1188
+ pageSize: a.length
1189
1189
  });
1190
- await Ee(j.FEAT, n, e);
1190
+ await Ce(j.FEAT, n, e);
1191
1191
  }
1192
1192
  if (t === j.FIX) {
1193
- const i = await Va();
1194
- if (!i.length)
1195
- return q("🤷 暂无BUG");
1196
- const n = await ve({
1193
+ const a = await qi();
1194
+ if (!a.length)
1195
+ return U("🤷 暂无BUG");
1196
+ const n = await Se({
1197
1197
  message: "请关联Bug(可多选):",
1198
- validate: (a) => a.length === 0 ? "请选择项" : !0,
1199
- choices: i.map((a) => ({
1200
- ...a,
1201
- name: `[${a.value.value}]: ${a.name}`
1198
+ validate: (i) => i.length === 0 ? "请选择项" : !0,
1199
+ choices: a.map((i) => ({
1200
+ ...i,
1201
+ name: `[${i.value.value}]: ${i.name}`
1202
1202
  })),
1203
- pageSize: i.length
1203
+ pageSize: a.length
1204
1204
  });
1205
- await Ee(j.FIX, n, e);
1205
+ await Ce(j.FIX, n, e);
1206
1206
  }
1207
1207
  if (t === j.CHORE) {
1208
- let i = "";
1209
- e && (i = await xe()), await Ee(j.CHORE, i);
1208
+ let a = "";
1209
+ e && (a = await Pe()), await Ce(j.CHORE, a);
1210
1210
  }
1211
1211
  process.exit(0);
1212
1212
  }
1213
- async function qa() {
1213
+ async function Zi() {
1214
1214
  try {
1215
1215
  const e = {}, t = async () => {
1216
- const O = dt(), { projects: se } = await _i(), Y = se.map((ce) => {
1217
- const Be = {
1216
+ const O = ht(), { projects: se } = await Wa(), Y = se.map((ce) => {
1217
+ const We = {
1218
1218
  name: `${ce.name} [${ce.desc}]`,
1219
1219
  value: ce.name,
1220
1220
  disabled: !1
1221
1221
  };
1222
- return O.includes(ce.name) && (Be.disabled = "目录下已存在同名文件夹"), Be;
1223
- }), xt = await k({
1222
+ return O.includes(ce.name) && (We.disabled = "目录下已存在同名文件夹"), We;
1223
+ }), Pt = await k({
1224
1224
  message: "请选择一个项目模板",
1225
1225
  choices: Y
1226
- }), Te = se.find((ce) => ce.name === xt);
1227
- e.tplName = Te.name, e.tplUrl = Te.url, e.tplLanguage = Te.language;
1228
- }, i = async () => {
1229
- const { groups: O } = ua(), se = await k({
1226
+ }), Ie = se.find((ce) => ce.name === Pt);
1227
+ e.tplName = Ie.name, e.tplUrl = Ie.url, e.tplLanguage = Ie.language;
1228
+ }, a = async () => {
1229
+ const { groups: O } = mi(), se = await k({
1230
1230
  message: "请选择一个分组",
1231
1231
  choices: O.map((Y) => ({
1232
1232
  name: `${Y.name} [${Y.description}]`,
@@ -1239,19 +1239,19 @@ async function qa() {
1239
1239
  name: O.find((Y) => Y.id === se)?.name
1240
1240
  };
1241
1241
  }, n = async () => {
1242
- e.projectName = await B({
1242
+ e.projectName = await F({
1243
1243
  message: "请输入项目名称",
1244
- validate: (O) => Fa(O, e.group?.name || "")
1245
- }), e.projectName = e.projectName.trim(), e.projectDesc = await B({
1244
+ validate: (O) => Ui(O, e.group?.name || "")
1245
+ }), e.projectName = e.projectName.trim(), e.projectDesc = await F({
1246
1246
  message: "请输入项目描述",
1247
- validate: Ba
1247
+ validate: Gi
1248
1248
  }), e.projectDesc = e.projectDesc.trim();
1249
1249
  };
1250
- await t(), await i(), await n();
1251
- const a = `${fe}/${e.group?.name}/${e.projectName}.git`, s = y("模版初始化中").start();
1252
- await m(`git clone --depth=1 ${e.tplUrl}`), await Qe(e.tplName, e.projectName), L.cd(e.projectName), L.rm("-rf", ".git"), await m(`git init --initial-branch=${$.MASTER}`), await m(`git remote add origin ${a}`), await m(`git config user.name ${C("gitName")}`), await m(`git config user.email ${C("gitEmail")}`);
1253
- const o = De();
1254
- Ji({
1250
+ await t(), await a(), await n();
1251
+ const i = `${ge}/${e.group?.name}/${e.projectName}.git`, s = y("模版初始化中").start();
1252
+ await m(`git clone --depth=1 ${e.tplUrl}`), await it(e.tplName, e.projectName), P.cd(e.projectName), P.rm("-rf", ".git"), await m(`git init --initial-branch=${v.MASTER}`), await m(`git remote add origin ${i}`), await m(`git config user.name ${I("gitName")}`), await m(`git config user.email ${I("gitEmail")}`);
1253
+ const o = Je();
1254
+ za({
1255
1255
  ...o,
1256
1256
  name: e.projectName,
1257
1257
  description: e.projectDesc,
@@ -1259,52 +1259,52 @@ async function qa() {
1259
1259
  ...o.scripts,
1260
1260
  prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
1261
1261
  }
1262
- }), await I.writeFile(d.resolve("README.md"), ki(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Oe(e.tplLanguage, e.group?.name);
1262
+ }), await R.writeFile(f.resolve("README.md"), Ea(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Fe(e.tplLanguage, e.group?.name);
1263
1263
  const r = y("依赖安装中").start();
1264
1264
  await m("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
1265
1265
  const c = y("项目推送中").start();
1266
1266
  await m('git add . && git commit -m "chore: 项目初始化"'), await m("git tag v0.0.1");
1267
- const l = await ia({
1267
+ const l = await ni({
1268
1268
  name: e.projectName,
1269
1269
  description: e.projectDesc,
1270
1270
  path: e.projectName,
1271
1271
  visibility: "private",
1272
1272
  namespace_id: e.group?.id
1273
1273
  });
1274
- await m(`git push -u origin ${$.MASTER}`), await m(`git push origin HEAD:${$.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${A.blue(a)}`);
1275
- const u = y("初始化分支中").start(), f = `feat_init_${ft()}`, h = [$.DEV, $.TEST, $.RELEASE, f], g = await Promise.allSettled(
1274
+ await m(`git push -u origin ${v.MASTER}`), await m(`git push origin HEAD:${v.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${A.blue(i)}`);
1275
+ const u = y("初始化分支中").start(), p = `feat_init_${wt()}`, h = [v.DEV, v.TEST, v.RELEASE, p], g = await Promise.allSettled(
1276
1276
  h.map(
1277
- (O) => ca({
1277
+ (O) => ui({
1278
1278
  id: l.id,
1279
1279
  branch: O,
1280
- ref: $.MASTER
1280
+ ref: v.MASTER
1281
1281
  })
1282
1282
  )
1283
- ), v = [];
1283
+ ), $ = [];
1284
1284
  g.forEach(({ status: O }, se) => {
1285
- O === "fulfilled" && v.push(h[se]);
1286
- }), await m("git pull"), v.includes(f) ? (await m(`git checkout -b ${f} origin/${f}`), u.succeed(`项目已切换到初始分支: ${A.blue(f)}`)) : u.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
1287
- const G = `cd ${e.projectName} && z start`;
1288
- console.log(`输入 ${A.green(G)} 开始开发吧~`), process.exit(0);
1285
+ O === "fulfilled" && $.push(h[se]);
1286
+ }), await m("git pull"), $.includes(p) ? (await m(`git checkout -b ${p} origin/${p}`), u.succeed(`项目已切换到初始分支: ${A.blue(p)}`)) : u.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
1287
+ const V = `cd ${e.projectName} && z start`;
1288
+ console.log(`输入 ${A.green(V)} 开始开发吧~`), process.exit(0);
1289
1289
  } catch (e) {
1290
- p(e);
1290
+ d(e);
1291
1291
  }
1292
1292
  }
1293
- async function Ha(e, t) {
1294
- let i;
1293
+ async function Ki(e, t) {
1294
+ let a;
1295
1295
  e ? [
1296
1296
  "project",
1297
1297
  "pr"
1298
1298
  /* ProjectAbbr */
1299
- ].includes(e) ? i = "project" : [
1299
+ ].includes(e) ? a = "project" : [
1300
1300
  "branch",
1301
1301
  "b"
1302
1302
  /* BranchAbbr */
1303
- ].includes(e) ? i = "branch" : [
1303
+ ].includes(e) ? a = "branch" : [
1304
1304
  "commit-msg",
1305
1305
  "cm"
1306
1306
  /* CommitMsgAbbr */
1307
- ].includes(e) ? i = "commit-msg" : p("参数输入错误") : i = await k({
1307
+ ].includes(e) ? a = "commit-msg" : d("参数输入错误") : a = await k({
1308
1308
  message: "请选择你要创建的类型",
1309
1309
  choices: [
1310
1310
  {
@@ -1323,68 +1323,68 @@ async function Ha(e, t) {
1323
1323
  /* Project */
1324
1324
  }
1325
1325
  ]
1326
- }), i === "project" ? await qa() : (ae(), K(), i === "branch" ? await Ga(t) : i === "commit-msg" && (await m("git status -s") ? await Wa(t.commitMessageCloseAi) : p("没有要变动的文件,无法生成提交信息")));
1326
+ }), a === "project" ? await Zi() : (ie(), K(), a === "branch" ? await Vi(t) : a === "commit-msg" && (await m("git status -s") ? await Hi(t.commitMessageCloseAi) : d("没有要变动的文件,无法生成提交信息")));
1327
1327
  }
1328
- P.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) => M(Ha, ...e));
1329
- const Za = async (e) => {
1330
- const t = await Ui(), i = C("weWorkUserId"), { notifyUsers: n, notifyGroups: a, ...s } = e, o = y("部署任务创建中").start(), r = await xa({
1328
+ x.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) => M(Ki, ...e));
1329
+ const Xi = async (e) => {
1330
+ const t = await _a(), a = I("weWorkUserId"), { notifyUsers: n, notifyGroups: i, ...s } = e, o = y("部署任务创建中").start(), r = await Di({
1331
1331
  ...s,
1332
1332
  userToken: t,
1333
- userWeworkId: i,
1334
- notifyUsers: [.../* @__PURE__ */ new Set([i, ...n])].join(Re),
1335
- notifyGroups: a.join(Re)
1333
+ userWeworkId: a,
1334
+ notifyUsers: [.../* @__PURE__ */ new Set([a, ...n])].join(De),
1335
+ notifyGroups: i.join(De)
1336
1336
  });
1337
1337
  s.moduleNames.length > 1 ? (o.succeed(`多模块部署任务创建完成,共 ${s.moduleNames.length} 个模块`), o.succeed(`当前已创建首个模块 ${A.blue(s.moduleNames[0])} 的 k8s 地址:`), console.log(A.blue(r)), o.info("后续模块会在前一个模块完成后依次部署,并通过企微通知下发对应地址。")) : (o.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${A.blue(r)}`));
1338
1338
  };
1339
- function Ka(e, t) {
1340
- const i = De();
1341
- if (X()?.repository?.url || p(".z/project.json中缺少repository.url"), t === W.H5) {
1342
- const a = `build:${e}`;
1343
- i?.scripts[a] || p(`项目package.json文件scripts不存在命令${a}。`);
1339
+ function Yi(e, t) {
1340
+ const a = Je();
1341
+ if (X()?.repository?.url || d(".z/project.json中缺少repository.url"), t === H.H5) {
1342
+ const i = `build:${e}`;
1343
+ a?.scripts[i] || d(`项目package.json文件scripts不存在命令${i}。`);
1344
1344
  }
1345
- t === W.NPM && (i?.scripts.build || p("项目package.json文件scripts不存在命令build。")), t === W.SERVER && (i?.scripts.build || p("项目package.json文件scripts不存在命令build。"));
1345
+ t === H.NPM && (a?.scripts.build || d("项目package.json文件scripts不存在命令build。")), t === H.SERVER && (a?.scripts.build || d("项目package.json文件scripts不存在命令build。"));
1346
1346
  }
1347
- async function Nt(e, t) {
1348
- ae(), K();
1349
- let i = e, n = t.platform;
1350
- const a = X();
1351
- if (a.language === w.JAVA && (n = W.SERVER), i && !Object.values($).includes(i) && p("仅支持发布指定环境分支"), n && !Object.values(W).includes(n) && p("发布平台错误"), n || (n = await k({
1347
+ async function jt(e, t) {
1348
+ ie(), K();
1349
+ let a = e, n = t.platform;
1350
+ const i = X();
1351
+ if (i.language === w.JAVA && (n = H.SERVER), a && !Object.values(v).includes(a) && d("仅支持发布指定环境分支"), n && !Object.values(H).includes(n) && d("发布平台错误"), n || (n = await k({
1352
1352
  message: "请选择平台",
1353
- choices: oi
1354
- })), n === W.NPM && (i = $.MASTER), !i) {
1353
+ choices: ua
1354
+ })), n === H.NPM && (a = v.MASTER), !a) {
1355
1355
  const l = await k({
1356
1356
  message: "请选择部署环境",
1357
- choices: rt
1357
+ choices: lt
1358
1358
  });
1359
- i = bi(l);
1359
+ a = ka(l);
1360
1360
  }
1361
1361
  let s = "";
1362
- a.language === w.JAVASCRIPT && (s = ui);
1362
+ i.language === w.JAVASCRIPT && (s = da);
1363
1363
  const o = [];
1364
- if (a.language === w.JAVASCRIPT) {
1364
+ if (i.language === w.JAVASCRIPT) {
1365
1365
  let l = "";
1366
- const u = De();
1366
+ const u = Je();
1367
1367
  u.name.startsWith("@") && u.name.includes("/") ? l = u.name.split("/").pop() || "" : l = u.name, l && o.push(l);
1368
1368
  }
1369
- if (a.language === w.JAVA) {
1370
- const { projects: l } = await Vi(), u = l.find(
1371
- (f) => te(f.url) === te(a.repository.url)
1369
+ if (i.language === w.JAVA) {
1370
+ const { projects: l } = await qa(), u = l.find(
1371
+ (p) => te(p.url) === te(i.repository.url)
1372
1372
  );
1373
1373
  if (!u)
1374
- p("未找到项目对应的模块信息");
1374
+ d("未找到项目对应的模块信息");
1375
1375
  else {
1376
1376
  s = u["k8s-group-name"];
1377
- const f = u.modules.map(({ name: g, desc: v }) => ({
1378
- name: `${g} (${v})`,
1377
+ const p = u.modules.map(({ name: g, desc: $ }) => ({
1378
+ name: `${g} (${$})`,
1379
1379
  value: g
1380
1380
  }));
1381
1381
  if (t.module) {
1382
- const g = new Set(t.module.split(Re));
1383
- f.forEach((v) => g.has(v.value) && o.push(v.value));
1382
+ const g = new Set(t.module.split(De));
1383
+ p.forEach(($) => g.has($.value) && o.push($.value));
1384
1384
  }
1385
- const h = await Z({
1385
+ const h = await _({
1386
1386
  message: "请选择部署模块",
1387
- options: (g) => g ? f.filter((v) => v.name.includes(g)) : f,
1387
+ options: (g) => g ? p.filter(($) => $.name.includes(g)) : p,
1388
1388
  pageSize: 20,
1389
1389
  loop: !0,
1390
1390
  clearInputWhenSelected: !0,
@@ -1393,7 +1393,7 @@ async function Nt(e, t) {
1393
1393
  filter: !0,
1394
1394
  theme: {
1395
1395
  style: {
1396
- renderSelectedOptions: (g) => g.map((v, G) => `${G + 1}.${v.value}`).join(", ")
1396
+ renderSelectedOptions: (g) => g.map(($, V) => `${V + 1}.${$.value}`).join(", ")
1397
1397
  }
1398
1398
  }
1399
1399
  });
@@ -1401,129 +1401,212 @@ async function Nt(e, t) {
1401
1401
  }
1402
1402
  }
1403
1403
  let r = [];
1404
- t.skipSelectionNotification || (r = await $t("请选择部署成功要通知的人员:", () => !0, !0));
1404
+ t.skipSelectionNotification || (r = await St("请选择部署成功要通知的人员:", () => !0, !0));
1405
1405
  let c = [];
1406
- if (t.skipGroupNotification || (c = await Da("请选择部署成功要通知的群组:", () => !0, !0)), a.language === w.JAVASCRIPT) {
1407
- const l = Si(i);
1408
- Ka(l, n);
1406
+ if (t.skipGroupNotification || (c = await Oi("请选择部署成功要通知的群组:", () => !0, !0)), i.language === w.JAVASCRIPT) {
1407
+ const l = ja(a);
1408
+ Yi(l, n);
1409
1409
  }
1410
- await Za({
1410
+ await Xi({
1411
1411
  moduleNames: o,
1412
1412
  k8sGroupName: s,
1413
- branchName: i,
1413
+ branchName: a,
1414
1414
  notifyUsers: r,
1415
1415
  notifyGroups: c
1416
1416
  });
1417
1417
  }
1418
- async function St(e, t, i, n) {
1419
- const a = y(`分支合并中,${e} -> ${t}`).start();
1418
+ async function kt(e, t, a, n) {
1419
+ const i = y(`分支合并中,${e} -> ${t}`).start();
1420
1420
  let s = 0;
1421
1421
  try {
1422
- const { iid: r } = await na({
1422
+ const { iid: r } = await ri({
1423
1423
  title: `${e} -> ${t} by z-develop`,
1424
- id: i.id,
1424
+ id: a.id,
1425
1425
  source_branch: e,
1426
1426
  target_branch: t,
1427
1427
  // 合到主分支上的分支需要在合并完成后被移除
1428
- remove_source_branch: n ? !1 : $.MASTER === t
1428
+ remove_source_branch: n ? !1 : v.MASTER === t
1429
1429
  });
1430
1430
  s = r;
1431
1431
  } catch (r) {
1432
- ue.isAxiosError(r) && r?.response?.status === 409 && p(`存在重复的合并请求,前往查看${i.mergeRequestUrl}`), p(r);
1432
+ ue.isAxiosError(r) && r?.response?.status === 409 && d(`存在重复的合并请求,前往查看${a.mergeRequestUrl}`), d(r);
1433
1433
  }
1434
1434
  const o = async () => {
1435
1435
  try {
1436
1436
  await new Promise((r) => {
1437
1437
  setTimeout(r, 5e3);
1438
- }), await sa({
1439
- id: i.id,
1438
+ }), await oi({
1439
+ id: a.id,
1440
1440
  iid: s
1441
- }), a.succeed(`分支${e}已合并到分支${t}`);
1441
+ }), i.succeed(`分支${e}已合并到分支${t}`);
1442
1442
  } catch (r) {
1443
- ue.isAxiosError(r) || p(r);
1443
+ ue.isAxiosError(r) || d(r);
1444
1444
  const c = r?.response?.status;
1445
1445
  if (c === 406)
1446
1446
  return await o();
1447
- if (await ra({
1448
- id: i.id,
1447
+ if (await ci({
1448
+ id: a.id,
1449
1449
  iid: s,
1450
1450
  state_event: "close"
1451
1451
  }), c === 405) {
1452
- const l = await oa({
1453
- id: i.id,
1452
+ const l = await li({
1453
+ id: a.id,
1454
1454
  iid: s
1455
1455
  });
1456
1456
  if (l.merge_status === "cannot_be_merged" && l.diff_refs.base_sha === l.diff_refs.head_sha) {
1457
- a.warn("MR已关闭。判定为空的合并请求(没有新内容),可继续进行部署");
1457
+ i.warn("MR已关闭。判定为空的合并请求(没有新内容),可继续进行部署");
1458
1458
  return;
1459
1459
  }
1460
1460
  }
1461
- a.fail("合并过程中出现冲突,MR已关闭。建议在本地完成合并。"), process.exit(1);
1461
+ i.fail("合并过程中出现冲突,MR已关闭。建议在本地完成合并。"), process.exit(1);
1462
1462
  }
1463
1463
  };
1464
1464
  await o();
1465
1465
  }
1466
- async function Xa(e, t) {
1467
- const i = `origin/${e.sourceBranch}`, n = await m(`git log -b origin/${$.MASTER} -1 --format=%H`), a = await m(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await m(
1468
- `git log ${n}...${a} -b ${i}`
1466
+ async function Qi(e, t) {
1467
+ const a = `origin/${e.sourceBranch}`, n = await m(`git log -b origin/${v.MASTER} -1 --format=%H`), i = await m(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await m(
1468
+ `git log ${n}...${i} -b ${a}`
1469
1469
  );
1470
- if (s || p(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await m(
1471
- `git branch --contains ${n} -r ${i}`
1472
- ) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await St($.MASTER, e.sourceBranch, e)), t === $.MASTER) {
1470
+ if (s || d(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await m(
1471
+ `git branch --contains ${n} -r ${a}`
1472
+ ) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await kt(v.MASTER, e.sourceBranch, e)), t === v.MASTER) {
1473
1473
  const r = s.split(`
1474
- `).filter((f) => f), c = await m(`git log -b origin/${R.TEST} -1 --format=%H`), u = (await m(
1475
- `git log ${n}...${c} -b origin/${R.TEST}`
1474
+ `).filter((p) => p), c = await m(`git log -b origin/${C.TEST} -1 --format=%H`), u = (await m(
1475
+ `git log ${n}...${c} -b origin/${C.TEST}`
1476
1476
  )).split(`
1477
- `).filter((f) => f);
1478
- Ni(u, r) || p("请先在测试环境发布要部署的代码");
1477
+ `).filter((p) => p);
1478
+ ba(u, r) || d("请先在测试环境发布要部署的代码");
1479
1479
  }
1480
1480
  }
1481
- async function Ya(e, t) {
1482
- ae(), K(), await Se();
1483
- const i = await zi();
1484
- Object.values($).includes(i.sourceBranch) && p(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
1485
- const a = (await la(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
1481
+ async function en(e, t) {
1482
+ ie(), K(), await ye();
1483
+ const a = await Fa();
1484
+ Object.values(v).includes(a.sourceBranch) && d(`当前分支${a.sourceBranch}不可作为源分支合并到目标分支。`);
1485
+ const i = (await pi(a.id)).filter((c) => ![a.sourceBranch].includes(c.name)).map((c) => {
1486
1486
  let l = c.name;
1487
- return Object.values($).includes(l) && (l = A.bold.blue(l)), {
1487
+ return Object.values(v).includes(l) && (l = A.bold.blue(l)), {
1488
1488
  name: l,
1489
1489
  value: c.name
1490
1490
  };
1491
1491
  });
1492
1492
  let s;
1493
- e && !a.filter((c) => c.value === e).length && p(`未找到目标分支${e}`), e ? s = e : s = await k({
1493
+ e && !i.filter((c) => c.value === e).length && d(`未找到目标分支${e}`), e ? s = e : s = await k({
1494
1494
  message: "请选择要合并到的目标分支:",
1495
- choices: a
1496
- });
1497
- const o = y(`本地分支${i.sourceBranch}检测中`).start();
1498
- if (await m(`git ls-remote --heads origin ${i.sourceBranch}`)) {
1499
- o.text = `存在远程分支origin/${i.sourceBranch}`, await m("git fetch");
1500
- const c = await m(`git rev-parse ${i.sourceBranch}`), l = await m(`git rev-parse origin/${i.sourceBranch}`);
1501
- await m(`git merge-base ${l} HEAD`) === l ? (await m(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`)) : await m(`git merge-base ${c} ${l}`) === c ? (await m("git pull"), o.succeed(`本地分支${i.sourceBranch}已更新`)) : (o.fail(
1502
- `远程分支origin/${i.sourceBranch}和本地分支${i.sourceBranch}都有新的提交,请手动合并后再试。`
1495
+ choices: i
1496
+ });
1497
+ const o = y(`本地分支${a.sourceBranch}检测中`).start();
1498
+ if (await m(`git ls-remote --heads origin ${a.sourceBranch}`)) {
1499
+ o.text = `存在远程分支origin/${a.sourceBranch}`, await m("git fetch");
1500
+ const c = await m(`git rev-parse ${a.sourceBranch}`), l = await m(`git rev-parse origin/${a.sourceBranch}`);
1501
+ await m(`git merge-base ${l} HEAD`) === l ? (await m(`git push -u origin ${a.sourceBranch}`), o.succeed(`本地分支${a.sourceBranch}已推送到远程分支origin/${a.sourceBranch}`)) : await m(`git merge-base ${c} ${l}`) === c ? (await m("git pull"), o.succeed(`本地分支${a.sourceBranch}已更新`)) : (o.fail(
1502
+ `远程分支origin/${a.sourceBranch}和本地分支${a.sourceBranch}都有新的提交,请手动合并后再试。`
1503
1503
  ), process.exit(1));
1504
1504
  } else
1505
- await m(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`);
1506
- await Xa(i, s), await St(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster), $.MASTER === s && !t.keepBranchAfterMergeMaster && (await m(`git checkout ${$.MASTER}`), await m(`git pull origin ${$.MASTER}`), await m(`git branch -d ${i.sourceBranch}`), q(
1507
- `${i.sourceBranch}分支已移除,当前已切换到最新的${$.MASTER}。如需继续开发,请检出新分支(z c b)。`
1508
- )), Object.values($).includes(s) && await Nt(s, {
1505
+ await m(`git push -u origin ${a.sourceBranch}`), o.succeed(`本地分支${a.sourceBranch}已推送到远程分支origin/${a.sourceBranch}`);
1506
+ await Qi(a, s), await kt(a.sourceBranch, s, a, t.keepBranchAfterMergeMaster), v.MASTER === s && !t.keepBranchAfterMergeMaster && (await m(`git checkout ${v.MASTER}`), await m(`git pull origin ${v.MASTER}`), await m(`git branch -d ${a.sourceBranch}`), U(
1507
+ `${a.sourceBranch}分支已移除,当前已切换到最新的${v.MASTER}。如需继续开发,请检出新分支(z c b)。`
1508
+ )), Object.values(v).includes(s) && await jt(s, {
1509
1509
  platform: t.deployPlatform,
1510
1510
  skipSelectionNotification: t.deploySkipSelectionNotification,
1511
1511
  skipGroupNotification: t.skipGroupNotification
1512
1512
  });
1513
1513
  }
1514
- P.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) => M(Ya, ...e));
1515
- P.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values($).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(W).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称,多个使用逗号分隔").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => M(Nt, ...e));
1516
- async function Qa() {
1514
+ x.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(H).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => M(en, ...e));
1515
+ x.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(v).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(H).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称,多个使用逗号分隔").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => M(jt, ...e));
1516
+ async function tn() {
1517
1517
  try {
1518
1518
  await m("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
1519
1519
  silent: !1
1520
- }), q("checkstyle执行完毕"), process.exit(0);
1520
+ }), U("checkstyle执行完毕"), process.exit(0);
1521
1521
  } catch {
1522
- p("checkstyle执行出错"), process.exit(1);
1522
+ d("checkstyle执行出错"), process.exit(1);
1523
+ }
1524
+ }
1525
+ const Ne = "origin/", an = Object.values(v).map((e) => `${Ne}${e}`), nn = Object.values(v), Ae = v.MASTER, sn = async (e) => {
1526
+ await m("git fetch --prune");
1527
+ const t = `${Ne}${e}`, a = await m(`git branch -r --merged ${t}`, {
1528
+ encoding: "utf8"
1529
+ }), n = await m(`git branch --merged ${t}`, {
1530
+ encoding: "utf8"
1531
+ }), i = /* @__PURE__ */ new Map();
1532
+ return a.split(`
1533
+ `).forEach((s) => {
1534
+ const o = s.trim();
1535
+ if (o && o !== t && !o.startsWith(`${Ne}HEAD`) && !an.includes(o)) {
1536
+ const r = o.replace(new RegExp(`^${Ne}`), "");
1537
+ i.set(r, {
1538
+ name: r,
1539
+ value: r,
1540
+ hasLocal: i.get(r)?.hasLocal ?? !1,
1541
+ hasRemote: !0
1542
+ });
1543
+ }
1544
+ }), n.split(`
1545
+ `).forEach((s) => {
1546
+ const o = s.replace(/^\*?\s*/, "").trim();
1547
+ if (o && o !== e && !nn.includes(o)) {
1548
+ const r = i.get(o);
1549
+ i.set(o, {
1550
+ name: o,
1551
+ value: o,
1552
+ hasLocal: !0,
1553
+ hasRemote: r?.hasRemote ?? !1
1554
+ });
1555
+ }
1556
+ }), [...i.values()].map((s) => ({
1557
+ ...s,
1558
+ name: `${s.value}${s.hasRemote && s.hasLocal ? "(本地/远程)" : s.hasRemote ? "(远程)" : "(本地)"}`
1559
+ })).sort((s, o) => s.value.localeCompare(o.value));
1560
+ }, rn = (e) => _({
1561
+ message: "请选择需要删除的分支",
1562
+ options: (t) => t ? e.filter((a) => a.name.includes(t)) : e,
1563
+ pageSize: 20,
1564
+ clearInputWhenSelected: !0,
1565
+ multiple: !0,
1566
+ loop: !0,
1567
+ validate: (t) => t.length ? !0 : "至少选择一个分支",
1568
+ filter: !0,
1569
+ theme: {
1570
+ style: {
1571
+ renderSelectedOptions: (t) => t.map((a) => a.value).join(", ")
1572
+ }
1523
1573
  }
1524
- }
1525
- async function en() {
1526
- N(d.resolve("node_modules", ".bin", "markdownlint")) || p("该项目未安装markdownlint,请安装后重试");
1574
+ }), on = async (e) => (await m(`git branch --list ${e}`)).trim() !== "", cn = (e) => {
1575
+ Be(`git push origin --delete ${e}`);
1576
+ }, ln = (e) => {
1577
+ Be(`git branch -d ${e}`);
1578
+ }, un = async () => {
1579
+ await ye();
1580
+ const e = y(`正在查询本地和远程已经合并到${Ae}的分支...`).start(), t = await sn(Ae);
1581
+ if (e.succeed(`查询到 ${t.length} 个已合并到 ${Ae} 的分支`), !t.length) {
1582
+ fe(`未查询到已合并到 ${Ae} 的可删除分支`);
1583
+ return;
1584
+ }
1585
+ const a = await rn(t);
1586
+ if (!await Me({
1587
+ message: `确认删除选中的 ${a.length} 个分支对应的远程分支和本地分支?`,
1588
+ default: !1
1589
+ })) {
1590
+ fe("已取消删除");
1591
+ return;
1592
+ }
1593
+ const i = await m("git branch --show-current"), s = [], o = [], r = [], c = t.filter((u) => a.includes(u.value)), l = y("正在删除分支...").start();
1594
+ try {
1595
+ for (const u of c) {
1596
+ const { value: p, hasLocal: h, hasRemote: g } = u;
1597
+ if (g && (l.text = `正在删除远程分支 ${p}...`, cn(p), o.push(p)), p === i) {
1598
+ h && s.push(p);
1599
+ continue;
1600
+ }
1601
+ !h || !await on(p) || (l.text = `正在删除本地分支 ${p}...`, ln(p), r.push(p));
1602
+ }
1603
+ } catch (u) {
1604
+ throw l.fail("删除分支失败"), u;
1605
+ }
1606
+ l.succeed("分支删除完成"), o.length && U(`远程分支删除完成:${o.join(", ")}`), r.length && U(`本地分支删除完成:${r.join(", ")}`), s.length && fe(`${s.join(", ")} 为当前分支,无法删除本地分支`);
1607
+ };
1608
+ async function pn() {
1609
+ N(f.resolve("node_modules", ".bin", "markdownlint")) || d("该项目未安装markdownlint,请安装后重试");
1527
1610
  const e = y("markdownlint执行中...").start();
1528
1611
  try {
1529
1612
  await m('npx markdownlint "**/*.md" --fix', {
@@ -1533,38 +1616,38 @@ async function en() {
1533
1616
  e.fail("markdownlint校验出错"), process.exit(1);
1534
1617
  }
1535
1618
  }
1536
- function tn() {
1619
+ function mn() {
1537
1620
  const e = X();
1538
1621
  if (e["lint-staged"])
1539
1622
  return e["lint-staged"];
1540
1623
  throw new Error("未找到lint配置");
1541
1624
  }
1542
- async function an() {
1625
+ async function dn() {
1543
1626
  const e = y("代码风格检测中...").start();
1544
- await qt({
1627
+ await Kt({
1545
1628
  concurrent: 4,
1546
1629
  debug: !1,
1547
- config: tn(),
1630
+ config: mn(),
1548
1631
  quiet: !0,
1549
1632
  relative: !0
1550
1633
  }) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
1551
1634
  }
1552
- function nn(e) {
1553
- if (e.includes("Merge") && e.includes("# Conflicts:") || Ht.valid(e))
1635
+ function fn(e) {
1636
+ if (e.includes("Merge") && e.includes("# Conflicts:") || Xt.valid(e))
1554
1637
  return !0;
1555
1638
  const t = e.split(": ");
1556
1639
  if (t.length === 1)
1557
1640
  return "body前缺少「: 」";
1558
- const i = t[0];
1559
- return /^(feat|fix|refactor)/.test(i) ? /\(\d+(?:,\d+)*\)/.test(i) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(i) ? [j.CHORE, j.CI].includes(i) ? !0 : "chore/ci类型无需填写ID。" : j.Break === i ? !0 : "不存在的提交类型。";
1641
+ const a = t[0];
1642
+ 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 : "不存在的提交类型。";
1560
1643
  }
1561
- async function sn() {
1562
- const e = await Ie(d.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), i = nn(e);
1563
- i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
1644
+ async function gn() {
1645
+ const e = await Le(f.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), a = fn(e);
1646
+ a === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${a}`), process.exit(1));
1564
1647
  }
1565
- async function rn() {
1566
- await Se();
1567
- const e = await Zt({
1648
+ async function hn() {
1649
+ await ye();
1650
+ const e = await Yt({
1568
1651
  // 分组,展示仓库链接
1569
1652
  format: ["group", "repo"],
1570
1653
  // 交互式弹窗
@@ -1575,26 +1658,26 @@ async function rn() {
1575
1658
  install: "always"
1576
1659
  });
1577
1660
  if (e && Object.keys(e).length) {
1578
- q("升级完成 🎉");
1579
- const t = Object.entries(e).map(([i, n]) => `${i}@${n}`).join("; ");
1661
+ U("升级完成 🎉");
1662
+ const t = Object.entries(e).map(([a, n]) => `${a}@${n}`).join("; ");
1580
1663
  await m(`git add . && git commit -m "chore: 依赖升级。${t}"`);
1581
1664
  }
1582
1665
  process.exit(0);
1583
1666
  }
1584
- async function on(e) {
1585
- N(d.resolve("node_modules", ".bin", "eslint")) || p("该项目未安装eslint,请安装后重试");
1667
+ async function wn(e) {
1668
+ N(f.resolve("node_modules", ".bin", "eslint")) || d("该项目未安装eslint,请安装后重试");
1586
1669
  const t = y("eslint执行中...").start();
1587
1670
  try {
1588
- let i = "npx eslint '**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}' --fix";
1589
- process.platform === "win32" && (i = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (i += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? i += ` --max-warnings ${Number(e.maxWarnings)}` : i += " --max-warnings 100", await m(i, {
1671
+ let a = "npx eslint '**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}' --fix";
1672
+ process.platform === "win32" && (a = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (a += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? a += ` --max-warnings ${Number(e.maxWarnings)}` : a += " --max-warnings 100", await m(a, {
1590
1673
  silent: !1
1591
1674
  }), t.succeed("eslint执行成功"), process.exit(0);
1592
1675
  } catch {
1593
1676
  t.fail("eslint校验出错"), process.exit(1);
1594
1677
  }
1595
1678
  }
1596
- async function cn() {
1597
- N(d.resolve("node_modules", ".bin", "prettier")) || p("该项目未安装prettier,请安装后重试");
1679
+ async function yn() {
1680
+ N(f.resolve("node_modules", ".bin", "prettier")) || d("该项目未安装prettier,请安装后重试");
1598
1681
  const e = y("prettier执行中...").start();
1599
1682
  try {
1600
1683
  await m(
@@ -1607,12 +1690,12 @@ async function cn() {
1607
1690
  e.fail("prettier校验出错"), process.exit(1);
1608
1691
  }
1609
1692
  }
1610
- function ln() {
1611
- N(d.resolve("./node_modules/.bin/vue-tsc")) || p("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), Ai("npx vue-tsc --build"), process.exit(0);
1693
+ function vn() {
1694
+ N(f.resolve("./node_modules/.bin/vue-tsc")) || d("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), Be("npx vue-tsc --build"), process.exit(0);
1612
1695
  }
1613
- async function un(e, t) {
1614
- ae(), K();
1615
- const i = X();
1696
+ async function $n(e, t) {
1697
+ ie(), K();
1698
+ const a = X();
1616
1699
  let n;
1617
1700
  if (e)
1618
1701
  [
@@ -1651,20 +1734,20 @@ async function un(e, t) {
1651
1734
  "delete-merged",
1652
1735
  "dm"
1653
1736
  /* DeleteMergedAbbr */
1654
- ].includes(e) ? n = "delete-merged" : p("参数输入错误");
1737
+ ].includes(e) ? n = "delete-merged" : d("参数输入错误");
1655
1738
  else {
1656
- const a = [
1739
+ const i = [
1657
1740
  {
1658
1741
  name: "执行 prettier",
1659
1742
  value: "prettier"
1660
1743
  /* Prettier */
1661
1744
  }
1662
1745
  ];
1663
- i.language === w.JAVA && a.push({
1746
+ a.language === w.JAVA && i.push({
1664
1747
  name: "执行 check-style",
1665
1748
  value: "checkstyle"
1666
1749
  /* CheckStyle */
1667
- }), i.language === w.JAVASCRIPT && a.push(
1750
+ }), a.language === w.JAVASCRIPT && i.push(
1668
1751
  {
1669
1752
  name: "执行 eslint",
1670
1753
  value: "eslint"
@@ -1680,7 +1763,7 @@ async function un(e, t) {
1680
1763
  value: "dependency-check"
1681
1764
  /* DependencyCheck */
1682
1765
  }
1683
- ), i.language === w.MARKDOWN && a.push(
1766
+ ), a.language === w.MARKDOWN && i.push(
1684
1767
  {
1685
1768
  name: "执行markdown-lint",
1686
1769
  value: "markdown-lint"
@@ -1703,24 +1786,24 @@ async function un(e, t) {
1703
1786
  }
1704
1787
  ), n = await k({
1705
1788
  message: "请选择你要执行的操作",
1706
- choices: a
1789
+ choices: i
1707
1790
  });
1708
1791
  }
1709
- n === "commit-msg" ? await sn() : n === "commit-files" ? await an() : n === "prettier" ? await cn() : n === "eslint" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? await on(t) : n === "type-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? ln() : n === "dependency-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? await rn() : n === "checkstyle" && i.language === w.JAVA ? await Qa() : n === "markdown-lint" && i.language === w.MARKDOWN && await en();
1792
+ n === "commit-msg" ? await gn() : n === "commit-files" ? await dn() : n === "prettier" ? await yn() : n === "eslint" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await wn(t) : n === "type-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? vn() : n === "dependency-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await hn() : n === "checkstyle" && a.language === w.JAVA ? await tn() : n === "markdown-lint" && a.language === w.MARKDOWN ? await pn() : n === "delete-merged" && await un();
1710
1793
  }
1711
- P.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint / delete-merged。").argument(
1794
+ x.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint / delete-merged。").argument(
1712
1795
  "[type]",
1713
1796
  "非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs, markdown-lint|ml, delete-merged|dm。"
1714
- ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => M(un, ...e));
1715
- async function bt(e = "latest") {
1797
+ ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => M($n, ...e));
1798
+ async function Tt(e = "latest") {
1716
1799
  const t = y("安装中...").start();
1717
1800
  await m(`npm i -g ${re.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", pe("latestCheckVersionTimestamp", Date.now()), pe("version", e);
1718
- const i = await Le();
1719
- be(i), oe(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
1801
+ const a = await ze();
1802
+ Te(a), oe(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
1720
1803
  }
1721
- P.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => M(bt, ...e));
1722
- const Me = /Thumbs\.db|\.git|DS_Store|idea/, jt = "testcase";
1723
- function kt(e) {
1804
+ x.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => M(Tt, ...e));
1805
+ const Ue = /Thumbs\.db|\.git|DS_Store|idea/, Et = "testcase";
1806
+ function Rt(e) {
1724
1807
  const t = e.match(/^(.*[^[])?\[(\d+)]$/);
1725
1808
  if (t && !e.startsWith("["))
1726
1809
  return {
@@ -1728,46 +1811,46 @@ function kt(e) {
1728
1811
  id: t[2],
1729
1812
  displayName: t[1]?.trim() || ""
1730
1813
  };
1731
- const i = e.match(/^\[(\d+)](.+)$/);
1732
- return i ? {
1814
+ const a = e.match(/^\[(\d+)](.+)$/);
1815
+ return a ? {
1733
1816
  type: "case",
1734
- id: i[1],
1735
- displayName: i[2]?.trim() || ""
1817
+ id: a[1],
1818
+ displayName: a[2]?.trim() || ""
1736
1819
  } : {
1737
1820
  type: "directory",
1738
1821
  id: void 0,
1739
1822
  displayName: e
1740
1823
  };
1741
1824
  }
1742
- async function ie(e, t = {}) {
1743
- const { exclude: i = Me } = t, n = [];
1744
- async function a(s) {
1745
- const o = d.basename(s);
1746
- if ((await zt(s)).isFile())
1825
+ async function ae(e, t = {}) {
1826
+ const { exclude: a = Ue } = t, n = [];
1827
+ async function i(s) {
1828
+ const o = f.basename(s);
1829
+ if ((await Ut(s)).isFile())
1747
1830
  return null;
1748
- const c = await Pe(s, { withFileTypes: !0 }), l = (await Promise.all(
1749
- c.filter((v) => v.isDirectory() && !i.test(v.name)).map((v) => a(d.join(s, v.name)))
1750
- )).filter(Boolean), { type: u, id: f, displayName: h } = kt(o), g = {
1831
+ const c = await Oe(s, { withFileTypes: !0 }), l = (await Promise.all(
1832
+ c.filter(($) => $.isDirectory() && !a.test($.name)).map(($) => i(f.join(s, $.name)))
1833
+ )).filter(Boolean), { type: u, id: p, displayName: h } = Rt(o), g = {
1751
1834
  name: o,
1752
- id: f,
1835
+ id: p,
1753
1836
  displayName: h,
1754
1837
  path: s,
1755
1838
  type: u,
1756
1839
  children: l
1757
1840
  };
1758
- return (t.hasRoot || d.resolve(e) !== s) && n.push(g), g;
1841
+ return (t.hasRoot || f.resolve(e) !== s) && n.push(g), g;
1759
1842
  }
1760
- return await a(d.resolve(e)), n;
1843
+ return await i(f.resolve(e)), n;
1761
1844
  }
1762
- async function Tt(e, t = {}) {
1763
- const { exclude: i = Me } = t;
1845
+ async function It(e, t = {}) {
1846
+ const { exclude: a = Ue } = t;
1764
1847
  try {
1765
- const n = await Pe(d.resolve(e), { withFileTypes: !0 });
1848
+ const n = await Oe(f.resolve(e), { withFileTypes: !0 });
1766
1849
  return await Promise.all(
1767
- n.filter((a) => a.isDirectory() && !i.test(a.name)).map((a) => {
1768
- const s = d.join(e, a.name), { type: o, id: r, displayName: c } = kt(a.name);
1850
+ n.filter((i) => i.isDirectory() && !a.test(i.name)).map((i) => {
1851
+ const s = f.join(e, i.name), { type: o, id: r, displayName: c } = Rt(i.name);
1769
1852
  return {
1770
- name: a.name,
1853
+ name: i.name,
1771
1854
  id: r,
1772
1855
  displayName: c,
1773
1856
  path: s,
@@ -1776,150 +1859,150 @@ async function Tt(e, t = {}) {
1776
1859
  })
1777
1860
  );
1778
1861
  } catch (n) {
1779
- return p(`读取目录失败: ${e} : ${n}`), [];
1862
+ return d(`读取目录失败: ${e} : ${n}`), [];
1780
1863
  }
1781
1864
  }
1782
- function H(e, t, i) {
1865
+ function Z(e, t, a) {
1783
1866
  switch (e) {
1784
1867
  case "module":
1785
- return i ? `${t}[${i}]` : t;
1868
+ return a ? `${t}[${a}]` : t;
1786
1869
  case "case":
1787
- return i ? `[${i}]${t}` : t;
1870
+ return a ? `[${a}]${t}` : t;
1788
1871
  default:
1789
1872
  return t;
1790
1873
  }
1791
1874
  }
1792
- async function we(e, t, i, n) {
1875
+ async function ve(e, t, a, n) {
1793
1876
  try {
1794
- const a = d.basename(e), s = H(i, t, n);
1795
- if (a === s)
1877
+ const i = f.basename(e), s = Z(a, t, n);
1878
+ if (i === s)
1796
1879
  return !0;
1797
- const o = d.dirname(e), r = d.join(o, s);
1798
- return await ji(e) ? await Qe(e, r) : (await m(`git mv "${e}" "${r}"`), await m("git add .")), !0;
1799
- } catch (a) {
1800
- return p(`重命名文件夹失败: ${e} -> ${t}。${a}`), !1;
1880
+ const o = f.dirname(e), r = f.join(o, s);
1881
+ return await Ta(e) ? await it(e, r) : (await m(`git mv "${e}" "${r}"`), await m("git add .")), !0;
1882
+ } catch (i) {
1883
+ return d(`重命名文件夹失败: ${e} -> ${t}。${i}`), !1;
1801
1884
  }
1802
1885
  }
1803
- async function pn(e, t, i = {}) {
1804
- const { exclude: n = Me } = i;
1805
- async function a(s, o) {
1886
+ async function An(e, t, a = {}) {
1887
+ const { exclude: n = Ue } = a;
1888
+ async function i(s, o) {
1806
1889
  if (!s || s.length === 0) return;
1807
- const r = await Tt(o, { exclude: n });
1890
+ const r = await It(o, { exclude: n });
1808
1891
  for (const c of s) {
1809
- const l = String(c.value), u = H("module", c.label, l), f = r.find((g) => g.id === l);
1810
- let h = f?.path || d.join(o, u);
1811
- f ? f.displayName !== c.label && await we(f.path, c.label, "module", l) && (h = d.join(o, u)) : (await me(h, { recursive: !0 }), await m(`git add "${h}"`)), c.children && c.children.length > 0 && await a(c.children, h);
1892
+ const l = String(c.value), u = Z("module", c.label, l), p = r.find((g) => g.id === l);
1893
+ let h = p?.path || f.join(o, u);
1894
+ p ? p.displayName !== c.label && await ve(p.path, c.label, "module", l) && (h = f.join(o, u)) : (await me(h, { recursive: !0 }), await m(`git add "${h}"`)), c.children && c.children.length > 0 && await i(c.children, h);
1812
1895
  }
1813
1896
  }
1814
- await a(e, d.resolve(t));
1897
+ await i(e, f.resolve(t));
1815
1898
  }
1816
- async function Et(e) {
1899
+ async function Ct(e) {
1817
1900
  const t = {
1818
1901
  id: 0,
1819
1902
  name: "",
1820
1903
  path: ""
1821
1904
  };
1822
1905
  if (e)
1823
- Number.isNaN(Number(e)) && p("请输入正确的产品ID"), t.id = Number(e);
1906
+ Number.isNaN(Number(e)) && d("请输入正确的产品ID"), t.id = Number(e);
1824
1907
  else {
1825
- const i = await fa();
1908
+ const a = await hi();
1826
1909
  t.id = await k({
1827
1910
  message: "请选择产品",
1828
- choices: i.map((n) => ({
1911
+ choices: a.map((n) => ({
1829
1912
  name: `${n.label}[${n.value}]`,
1830
1913
  value: n.value
1831
1914
  }))
1832
1915
  });
1833
1916
  }
1834
- return t.name = await ga(t.id), t.path = d.join(jt, H("module", t.name, String(t.id))), t;
1917
+ return t.name = await wi(t.id), t.path = f.join(Et, Z("module", t.name, String(t.id))), t;
1835
1918
  }
1836
- async function Je(e) {
1837
- return (await Tt(jt)).find((i) => Number(i.id) === e.id);
1919
+ async function Ge(e) {
1920
+ return (await It(Et)).find((a) => Number(a.id) === e.id);
1838
1921
  }
1839
- async function It(e, t) {
1840
- const i = {
1922
+ async function Lt(e, t) {
1923
+ const a = {
1841
1924
  precondition: e.precondition,
1842
1925
  priority: e.pri,
1843
1926
  steps: []
1844
1927
  };
1845
- i.steps = await wa(e.id), I.writeJSONSync(t, i, {
1928
+ a.steps = await vi(e.id), R.writeJSONSync(t, a, {
1846
1929
  spaces: 2
1847
1930
  });
1848
1931
  }
1849
- async function Ct(e, t) {
1932
+ async function xt(e, t) {
1850
1933
  await me(t, {
1851
1934
  recursive: !0
1852
- }), await It(e, d.join(t, "config.json")), I.ensureFileSync(d.join(t, "data.yaml")), await D(
1853
- d.join(t, "data.yaml"),
1854
- N(d.resolve(ee, "data.yaml")) ? await Ie(d.resolve(ee, "data.yaml")) : await Xi()
1855
- ), I.ensureFileSync(d.join(t, "main.py")), await D(
1856
- d.join(t, "main.py"),
1857
- N(d.resolve(ee, "main.py")) ? await Ie(d.resolve(ee, "main.py")) : await Yi()
1935
+ }), await Lt(e, f.join(t, "config.json")), R.ensureFileSync(f.join(t, "data.yaml")), await D(
1936
+ f.join(t, "data.yaml"),
1937
+ N(f.resolve(ee, "data.yaml")) ? await Le(f.resolve(ee, "data.yaml")) : await Qa()
1938
+ ), R.ensureFileSync(f.join(t, "main.py")), await D(
1939
+ f.join(t, "main.py"),
1940
+ N(f.resolve(ee, "main.py")) ? await Le(f.resolve(ee, "main.py")) : await ei()
1858
1941
  );
1859
1942
  }
1860
- function ze(e) {
1943
+ function _e(e) {
1861
1944
  if (e) {
1862
- const t = e.split(",").map((i) => i.trim()).filter((i) => {
1863
- const n = Number(i);
1945
+ const t = e.split(",").map((a) => a.trim()).filter((a) => {
1946
+ const n = Number(a);
1864
1947
  return Number.isInteger(n) && n > 0;
1865
- }).map((i) => Number(i));
1866
- return t.length === 0 ? (p('未找到有效的ID,请输入格式如 "1,2,3,4" 的正整数ID'), []) : t;
1948
+ }).map((a) => Number(a));
1949
+ return t.length === 0 ? (d('未找到有效的ID,请输入格式如 "1,2,3,4" 的正整数ID'), []) : t;
1867
1950
  }
1868
1951
  return [];
1869
1952
  }
1870
- async function je(e, t) {
1871
- ae(), K(), await Se();
1872
- let i;
1873
- t ? ([E.MODULE, E.CASE].includes(t) || p(`不支持的参数${t}。参数值应为 ${E.MODULE} 或者 ${E.CASE}。`), i = t) : i = await k({
1953
+ async function Ee(e, t) {
1954
+ ie(), K(), await ye();
1955
+ let a;
1956
+ t ? ([E.MODULE, E.CASE].includes(t) || d(`不支持的参数${t}。参数值应为 ${E.MODULE} 或者 ${E.CASE}。`), a = t) : a = await k({
1874
1957
  message: `请选择要${e}的数据类型`,
1875
- choices: pi
1958
+ choices: fa
1876
1959
  });
1877
- const n = i === E.MODULE ? "模块" : E.CASE === i ? "用例" : "";
1960
+ const n = a === E.MODULE ? "模块" : E.CASE === a ? "用例" : "";
1878
1961
  return {
1879
- type: i,
1962
+ type: a,
1880
1963
  typeStr: n
1881
1964
  };
1882
1965
  }
1883
- async function ke(e) {
1884
- const t = await Et(e), i = await Je(t);
1885
- return i || p(`本地未找到产品【${t.name}[${t.id}]】`), {
1966
+ async function Re(e) {
1967
+ const t = await Ct(e), a = await Ge(t);
1968
+ return a || d(`本地未找到产品【${t.name}[${t.id}]】`), {
1886
1969
  product: t,
1887
- localProduct: i
1970
+ localProduct: a
1888
1971
  };
1889
1972
  }
1890
- async function mn(e, t, i) {
1891
- e.text = "查找本地产品目录...", await Je(t) || p(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
1892
- const a = ze(i);
1893
- let s = await ie(t.path);
1973
+ async function Nn(e, t, a) {
1974
+ e.text = "查找本地产品目录...", await Ge(t) || d(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
1975
+ const i = _e(a);
1976
+ let s = await ae(t.path);
1894
1977
  e.text = "获取远程用例列表...";
1895
- const o = await ha(t.id, a);
1978
+ const o = await yi(t.id, i);
1896
1979
  e.text = "本地用例同步中...";
1897
1980
  for (const r of o) {
1898
1981
  let c;
1899
- if (r.module === 0 ? c = d.resolve(t.path) : c = s.find((u) => Number(u.id) === r.module)?.path || "", !c)
1900
- return p(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
1982
+ if (r.module === 0 ? c = f.resolve(t.path) : c = s.find((u) => Number(u.id) === r.module)?.path || "", !c)
1983
+ return d(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
1901
1984
  const l = s.find(({ id: u }) => r.id === Number(u));
1902
1985
  if (l)
1903
- l.displayName !== r.title && await we(l.path, r.title, l.type, l.id) && q(`重命名成功: ${l.displayName} -> ${r.title}`), s = await ie(t.path), r.module === 0 ? c = d.resolve(t.path) : c = s.find((u) => Number(u.id) === r.module)?.path || "", await It(
1986
+ l.displayName !== r.title && await ve(l.path, r.title, l.type, l.id) && U(`重命名成功: ${l.displayName} -> ${r.title}`), s = await ae(t.path), r.module === 0 ? c = f.resolve(t.path) : c = s.find((u) => Number(u.id) === r.module)?.path || "", await Lt(
1904
1987
  r,
1905
- d.join(c, H("case", r.title, String(r.id)), "config.json")
1988
+ f.join(c, Z("case", r.title, String(r.id)), "config.json")
1906
1989
  );
1907
1990
  else {
1908
- const u = d.join(c, H("case", r.title, String(r.id)));
1909
- await Ct(r, u);
1991
+ const u = f.join(c, Z("case", r.title, String(r.id)));
1992
+ await xt(r, u);
1910
1993
  }
1911
1994
  }
1912
1995
  }
1913
- async function dn(e, t) {
1996
+ async function Sn(e, t) {
1914
1997
  e.text = "本地产品目录查找中...";
1915
- const i = await Je(t);
1916
- i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await we(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await me(t.path, { recursive: !0 }), await m("git add .")), e.text = "获取远程模块列表...";
1917
- const n = await yt(t.id);
1918
- e.text = "本地同步模块中...", await pn(n || [], t.path);
1919
- }
1920
- async function fn(e, t) {
1921
- const { type: i, typeStr: n } = await je("拉取", e), a = await Et(t.productId), s = y(`${n}同步中...`).start();
1922
- if (E.MODULE === i && await dn(s, a), E.CASE === i && await mn(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await m("git status -s")) {
1998
+ const a = await Ge(t);
1999
+ a ? (e.text = "找到产品目录。开始重命名...", a.displayName !== t.name && await ve(a.path, t.name, a.type, a.id) && (e.text = `重命名成功: ${a.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await me(t.path, { recursive: !0 }), await m("git add .")), e.text = "获取远程模块列表...";
2000
+ const n = await At(t.id);
2001
+ e.text = "本地同步模块中...", await An(n || [], t.path);
2002
+ }
2003
+ async function bn(e, t) {
2004
+ const { type: a, typeStr: n } = await Ee("拉取", e), i = await Ct(t.productId), s = y(`${n}同步中...`).start();
2005
+ if (E.MODULE === a && await Sn(s, i), E.CASE === a && await Nn(s, i, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await m("git status -s")) {
1923
2006
  const o = y("代码提交中...").start();
1924
2007
  try {
1925
2008
  await m(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
@@ -1928,61 +2011,61 @@ async function fn(e, t) {
1928
2011
  }
1929
2012
  }
1930
2013
  }
1931
- P.command("qa-pull").alias("qp").description("将禅道中的模块或者用例同步到本地").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "type=case时,可传指定用例ID(可传N个,逗号隔开);不传则为产品下全部用例").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(fn, ...e));
1932
- async function gn(e, t, i) {
1933
- let n = await B({
2014
+ x.command("qa-pull").alias("qp").description("将禅道中的模块或者用例同步到本地").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "type=case时,可传指定用例ID(可传N个,逗号隔开);不传则为产品下全部用例").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(bn, ...e));
2015
+ async function jn(e, t, a) {
2016
+ let n = await F({
1934
2017
  message: "请输入你要创建的用例的前置条件(可不填)"
1935
2018
  });
1936
2019
  n = n.trim();
1937
- const a = y(`用例【${i}】开始创建...`).start();
1938
- a.text = "远程用例创建中...";
1939
- const s = await va({
2020
+ const i = y(`用例【${a}】开始创建...`).start();
2021
+ i.text = "远程用例创建中...";
2022
+ const s = await Ai({
1940
2023
  product: Number(e.id),
1941
2024
  // 如果父模块是产品根目录,parent=0
1942
- module: d.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
1943
- title: i,
2025
+ module: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
2026
+ title: a,
1944
2027
  type: "interface",
1945
- openedBy: C("ldapAccount"),
2028
+ openedBy: I("ldapAccount"),
1946
2029
  precondition: n || ""
1947
2030
  });
1948
- a.text = "远程用例步骤创建中...", await $a({
2031
+ i.text = "远程用例步骤创建中...", await Ni({
1949
2032
  case: s,
1950
2033
  type: "step",
1951
2034
  desc: "按照预期执行",
1952
2035
  expect: "正常执行,符合预期"
1953
- }), a.text = "本地用例创建中...";
1954
- const o = d.join(t.path, H("case", i, String(s)));
1955
- return N(o) ? q(`${o}已存在,请检查是否对应,本地不再创建。`) : (await Ct(
2036
+ }), i.text = "本地用例创建中...";
2037
+ const o = f.join(t.path, Z("case", a, String(s)));
2038
+ return N(o) ? U(`${o}已存在,请检查是否对应,本地不再创建。`) : (await xt(
1956
2039
  {
1957
2040
  id: s,
1958
2041
  pri: 3,
1959
2042
  precondition: n
1960
2043
  },
1961
2044
  o
1962
- ), a.succeed(`用例【[${o}】创建完成 🎉`), o);
2045
+ ), i.succeed(`用例【[${o}】创建完成 🎉`), o);
1963
2046
  }
1964
- async function hn(e, t, i) {
1965
- const n = y(`模块【${i}】开始创建...`).start();
2047
+ async function kn(e, t, a) {
2048
+ const n = y(`模块【${a}】开始创建...`).start();
1966
2049
  n.text = "远程模块创建中...";
1967
- const a = await ya({
2050
+ const i = await $i({
1968
2051
  root: Number(e.id),
1969
- name: i,
2052
+ name: a,
1970
2053
  // 如果父模块是产品根目录,parent=0
1971
- parent: d.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
2054
+ parent: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
1972
2055
  });
1973
2056
  n.text = "本地模块创建中...";
1974
- const s = d.join(t.path, H("module", i, String(a)));
2057
+ const s = f.join(t.path, Z("module", a, String(i)));
1975
2058
  if (N(s))
1976
- return q(`${s}已存在,请检查是否对应,本地不再创建。`);
2059
+ return U(`${s}已存在,请检查是否对应,本地不再创建。`);
1977
2060
  await me(s, {
1978
2061
  recursive: !0
1979
2062
  }), n.succeed(`模块【${s}】创建完成 🎉`);
1980
2063
  }
1981
- function wn(e) {
2064
+ function Tn(e) {
1982
2065
  function t(n) {
1983
2066
  if (!n.children || n.children.length === 0) return;
1984
- const a = n.children[0];
1985
- a && a.label === n.label && a.value === n.value && (!a.children || a.children.length === 0) || n.children.unshift({
2067
+ const i = n.children[0];
2068
+ i && i.label === n.label && i.value === n.value && (!i.children || i.children.length === 0) || n.children.unshift({
1986
2069
  value: n.value,
1987
2070
  label: n.label,
1988
2071
  type: n.type,
@@ -1990,56 +2073,56 @@ function wn(e) {
1990
2073
  tempTitle: "当前层级"
1991
2074
  });
1992
2075
  }
1993
- async function i(n, a = []) {
1994
- const s = a.length ? `请选择层级(当前:${a.join(" / ")})` : "请选择层级", o = await k({
2076
+ async function a(n, i = []) {
2077
+ const s = i.length ? `请选择层级(当前:${i.join(" / ")})` : "请选择层级", o = await k({
1995
2078
  message: s,
1996
2079
  choices: n.map((r) => ({
1997
2080
  name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
1998
2081
  value: r
1999
2082
  }))
2000
2083
  });
2001
- return o?.children?.length ? (t(o), i(o.children, [...a, o.label])) : o;
2084
+ return o?.children?.length ? (t(o), a(o.children, [...i, o.label])) : o;
2002
2085
  }
2003
- return i(e);
2086
+ return a(e);
2004
2087
  }
2005
- async function yn(e, t) {
2006
- const { type: i, typeStr: n } = await je("创建", e), { product: a, localProduct: s } = await ke(t.productId), o = await yt(a.id), r = await wn(o), c = H("module", r.label, String(r.value)), u = (await ie(a.path, { hasRoot: !0 })).find((g) => g.name === c);
2088
+ async function En(e, t) {
2089
+ const { type: a, typeStr: n } = await Ee("创建", e), { product: i, localProduct: s } = await Re(t.productId), o = await At(i.id), r = await Tn(o), c = Z("module", r.label, String(r.value)), u = (await ae(i.path, { hasRoot: !0 })).find((g) => g.name === c);
2007
2090
  if (!u?.path || !N(u.path))
2008
- return p(`本地不存在${c}模块`);
2009
- let f = await B({
2091
+ return d(`本地不存在${c}模块`);
2092
+ let p = await F({
2010
2093
  message: `请输入你要创建的${n}名称`,
2011
2094
  required: !0,
2012
2095
  validate: (g) => g.length > 0 && g.length < 255
2013
2096
  });
2014
- f = f.trim();
2097
+ p = p.trim();
2015
2098
  let h = "";
2016
- if (E.MODULE === i && await hn(s, u, f), E.CASE === i && (h = await gn(s, u, f)), !t.disableAutoCommit && E.CASE === i) {
2099
+ if (E.MODULE === a && await kn(s, u, p), E.CASE === a && (h = await jn(s, u, p)), !t.disableAutoCommit && E.CASE === a) {
2017
2100
  const g = y("代码提交中...").start();
2018
2101
  try {
2019
- await m(`git add . && git commit -m "chore: 创建了用例${d.basename(h)}"`), g.succeed("代码已提交 ✅");
2020
- } catch (v) {
2021
- g.fail(`提交失败,${v}`), process.exit(1);
2102
+ await m(`git add . && git commit -m "chore: 创建了用例${f.basename(h)}"`), g.succeed("代码已提交 ✅");
2103
+ } catch ($) {
2104
+ g.fail(`提交失败,${$}`), process.exit(1);
2022
2105
  }
2023
2106
  }
2024
2107
  }
2025
- P.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(yn, ...e));
2026
- async function vn(e, t) {
2027
- const n = (await ie(e.path)).filter((r) => r.type === "case");
2028
- let a = [];
2108
+ x.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(En, ...e));
2109
+ async function Rn(e, t) {
2110
+ const n = (await ae(e.path)).filter((r) => r.type === "case");
2111
+ let i = [];
2029
2112
  if (t.length)
2030
- a = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
2113
+ i = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
2031
2114
  id: Number(r.id),
2032
2115
  path: r.path
2033
- })), a.length || p(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
2116
+ })), i.length || d(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
2034
2117
  else {
2035
2118
  const r = n.map((c) => ({
2036
2119
  value: {
2037
2120
  id: Number(c.id),
2038
2121
  path: c.path
2039
2122
  },
2040
- name: c.path.replace(d.resolve(e.path), "")
2123
+ name: c.path.replace(f.resolve(e.path), "")
2041
2124
  }));
2042
- a = await Z({
2125
+ i = await _({
2043
2126
  message: "选择要删除的用例",
2044
2127
  pageSize: 100,
2045
2128
  loop: !1,
@@ -2049,32 +2132,32 @@ async function vn(e, t) {
2049
2132
  }
2050
2133
  });
2051
2134
  }
2052
- const s = y("远程用例删除中...").start(), o = a.map((r) => r.id);
2053
- await Na({
2135
+ const s = y("远程用例删除中...").start(), o = i.map((r) => r.id);
2136
+ await bi({
2054
2137
  product: Number(e.id),
2055
2138
  caseIds: o
2056
2139
  }), s.text = "本地用例删除中...";
2057
- for (const r of a)
2058
- N(r.path) && L.rm("-rf", r.path);
2140
+ for (const r of i)
2141
+ N(r.path) && P.rm("-rf", r.path);
2059
2142
  return s.succeed("用例删除完成"), o;
2060
2143
  }
2061
- async function $n(e, t) {
2062
- const n = (await ie(e.path)).filter((r) => r.type === "module");
2063
- let a = [];
2144
+ async function In(e, t) {
2145
+ const n = (await ae(e.path)).filter((r) => r.type === "module");
2146
+ let i = [];
2064
2147
  if (t.length)
2065
- a = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
2148
+ i = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
2066
2149
  id: Number(r.id),
2067
2150
  path: r.path
2068
- })), a.length || p(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
2151
+ })), i.length || d(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
2069
2152
  else {
2070
2153
  const r = n.map((c) => ({
2071
2154
  value: {
2072
2155
  id: Number(c.id),
2073
2156
  path: c.path
2074
2157
  },
2075
- name: c.path.replace(d.resolve(e.path), "")
2158
+ name: c.path.replace(f.resolve(e.path), "")
2076
2159
  }));
2077
- a = await Z({
2160
+ i = await _({
2078
2161
  message: "选择要删除的模块",
2079
2162
  pageSize: 100,
2080
2163
  loop: !1,
@@ -2084,20 +2167,20 @@ async function $n(e, t) {
2084
2167
  }
2085
2168
  });
2086
2169
  }
2087
- a = a.sort((r, c) => r.path.localeCompare(c.path));
2088
- const s = y("远程模块删除中...").start(), o = a.map((r) => r.id);
2089
- await Aa({
2170
+ i = i.sort((r, c) => r.path.localeCompare(c.path));
2171
+ const s = y("远程模块删除中...").start(), o = i.map((r) => r.id);
2172
+ await Si({
2090
2173
  product: Number(e.id),
2091
2174
  moduleIds: o
2092
2175
  }), s.text = "本地模块删除中...";
2093
- for (const r of a)
2094
- N(r.path) && L.rm("-rf", r.path);
2176
+ for (const r of i)
2177
+ N(r.path) && P.rm("-rf", r.path);
2095
2178
  return s.succeed("模块删除完成"), o;
2096
2179
  }
2097
- async function An(e, t) {
2098
- const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await ke(t.productId), s = ze(t.targetIds);
2180
+ async function Cn(e, t) {
2181
+ const { type: a, typeStr: n } = await Ee("删除", e), { localProduct: i } = await Re(t.productId), s = _e(t.targetIds);
2099
2182
  let o = [];
2100
- if (E.MODULE === i ? o = await $n(a, s) : E.CASE === i && (o = await vn(a, s)), !t.disableAutoCommit && await m("git status -s")) {
2183
+ if (E.MODULE === a ? o = await In(i, s) : E.CASE === a && (o = await Rn(i, s)), !t.disableAutoCommit && await m("git status -s")) {
2101
2184
  const r = y("代码提交中...").start();
2102
2185
  try {
2103
2186
  await m(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
@@ -2106,13 +2189,13 @@ async function An(e, t) {
2106
2189
  }
2107
2190
  }
2108
2191
  }
2109
- P.command("qa-remove").alias("qr").description("删除模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-ids <targetIds>", "可传指定目标(用例/模块)ID。可传N个,逗号隔开").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(An, ...e));
2110
- async function Nn(e, t) {
2111
- const n = (await ie(e.path)).filter((h) => h.type === "case");
2112
- let a;
2192
+ x.command("qa-remove").alias("qr").description("删除模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-ids <targetIds>", "可传指定目标(用例/模块)ID。可传N个,逗号隔开").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(Cn, ...e));
2193
+ async function Ln(e, t) {
2194
+ const n = (await ae(e.path)).filter((h) => h.type === "case");
2195
+ let i;
2113
2196
  if (t.targetId) {
2114
- if (a = n.find((h) => Number(h.id) === Number(t.targetId)), !a)
2115
- return p(`未找到对应用例,请确认输入的用例ID(${t.targetId})是否正确`);
2197
+ if (i = n.find((h) => Number(h.id) === Number(t.targetId)), !i)
2198
+ return d(`未找到对应用例,请确认输入的用例ID(${t.targetId})是否正确`);
2116
2199
  } else {
2117
2200
  const h = n.map((g) => ({
2118
2201
  value: {
@@ -2120,41 +2203,41 @@ async function Nn(e, t) {
2120
2203
  path: g.path,
2121
2204
  displayName: g.displayName
2122
2205
  },
2123
- name: g.path.replace(d.resolve(e.path), "")
2206
+ name: g.path.replace(f.resolve(e.path), "")
2124
2207
  }));
2125
- [a] = await Z({
2208
+ [i] = await _({
2126
2209
  message: "选择要更新的用例",
2127
2210
  pageSize: 100,
2128
2211
  loop: !1,
2129
2212
  multiple: void 0,
2130
- options: (g) => g ? h.filter((v) => v.name.includes(g)) : h,
2213
+ options: (g) => g ? h.filter(($) => $.name.includes(g)) : h,
2131
2214
  validate(g) {
2132
2215
  return g.length > 1 ? "只能选一个" : g.length < 1 ? "请选一个" : !0;
2133
2216
  }
2134
2217
  });
2135
2218
  }
2136
- let s = await B({
2219
+ let s = await F({
2137
2220
  message: "修改用例名称",
2138
- default: a.displayName,
2221
+ default: i.displayName,
2139
2222
  required: !0,
2140
2223
  validate: (h) => h.length > 0 && h.length < 255,
2141
2224
  prefill: "editable"
2142
2225
  });
2143
2226
  s = s.trim();
2144
2227
  const o = y("用例重命名中...").start();
2145
- s !== a.displayName ? (await ba({
2146
- id: Number(a.id),
2228
+ s !== i.displayName ? (await ki({
2229
+ id: Number(i.id),
2147
2230
  name: s
2148
- }), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path = d.join(d.dirname(a.path), H("case", s, String(a.id)))) : o.succeed("用例名称无变动");
2149
- let r = I.readJsonSync(d.join(a.path, "config.json")), c;
2150
- t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await Ge({
2231
+ }), await ve(i.path, s, "case", String(i.id)) && o.succeed(`用例重命名成功: ${i.displayName} -> ${s}`), i.displayName = s, i.path = f.join(f.dirname(i.path), Z("case", s, String(i.id)))) : o.succeed("用例名称无变动");
2232
+ let r = R.readJsonSync(f.join(i.path, "config.json")), c;
2233
+ t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await He({
2151
2234
  message: "修改用例优先级",
2152
2235
  min: 1,
2153
2236
  max: 5,
2154
2237
  required: !0,
2155
2238
  default: r.priority,
2156
2239
  validate: (h) => h > 0 && h < 6
2157
- }) : c = await Ge({
2240
+ }) : c = await He({
2158
2241
  message: "修改用例优先级",
2159
2242
  min: 1,
2160
2243
  max: 5,
@@ -2163,42 +2246,42 @@ async function Nn(e, t) {
2163
2246
  validate: (h) => h > 0 && h < 6
2164
2247
  });
2165
2248
  const l = y("用例优先级设置中...").start();
2166
- c !== r.priority ? (await ja({
2167
- id: Number(a.id),
2249
+ c !== r.priority ? (await Ti({
2250
+ id: Number(i.id),
2168
2251
  priority: c
2169
- }), I.writeJSONSync(
2170
- d.join(a.path, "config.json"),
2252
+ }), R.writeJSONSync(
2253
+ f.join(i.path, "config.json"),
2171
2254
  {
2172
2255
  ...r,
2173
2256
  priority: c
2174
2257
  },
2175
2258
  { spaces: 2 }
2176
- ), l.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : l.succeed("用例优先级无变动"), r = I.readJsonSync(d.join(a.path, "config.json"));
2259
+ ), l.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : l.succeed("用例优先级无变动"), r = R.readJsonSync(f.join(i.path, "config.json"));
2177
2260
  let u;
2178
- t.casePrecondition ? u = t.casePrecondition : (u = await B({
2261
+ t.casePrecondition ? u = t.casePrecondition : (u = await F({
2179
2262
  message: "修改用例前置条件",
2180
2263
  default: r.precondition,
2181
2264
  prefill: "editable"
2182
2265
  }), u = u.trim());
2183
- const f = y("用例前置条件设置中...").start();
2184
- return u !== r.precondition ? (await ka({
2185
- id: Number(a.id),
2266
+ const p = y("用例前置条件设置中...").start();
2267
+ return u !== r.precondition ? (await Ei({
2268
+ id: Number(i.id),
2186
2269
  precondition: u
2187
- }), I.writeJSONSync(
2188
- d.join(a.path, "config.json"),
2270
+ }), R.writeJSONSync(
2271
+ f.join(i.path, "config.json"),
2189
2272
  {
2190
2273
  ...r,
2191
2274
  precondition: u
2192
2275
  },
2193
2276
  { spaces: 2 }
2194
- ), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${u}`)) : f.succeed("用例前置条件无变动"), a.id;
2277
+ ), p.succeed(`用例前置条件修改成功:${r.precondition} -> ${u}`)) : p.succeed("用例前置条件无变动"), i.id;
2195
2278
  }
2196
- async function Sn(e, t) {
2197
- const n = (await ie(e.path)).filter((r) => r.type === "module");
2198
- let a;
2279
+ async function xn(e, t) {
2280
+ const n = (await ae(e.path)).filter((r) => r.type === "module");
2281
+ let i;
2199
2282
  if (t.targetId) {
2200
- if (a = n.find((r) => Number(r.id) === Number(t.targetId)), !a)
2201
- return p(`未找到对应模块,请确认输入的模块ID(${t.targetId})是否正确`);
2283
+ if (i = n.find((r) => Number(r.id) === Number(t.targetId)), !i)
2284
+ return d(`未找到对应模块,请确认输入的模块ID(${t.targetId})是否正确`);
2202
2285
  } else {
2203
2286
  const r = n.map((c) => ({
2204
2287
  value: {
@@ -2206,9 +2289,9 @@ async function Sn(e, t) {
2206
2289
  path: c.path,
2207
2290
  displayName: c.displayName
2208
2291
  },
2209
- name: c.path.replace(d.resolve(e.path), "")
2292
+ name: c.path.replace(f.resolve(e.path), "")
2210
2293
  }));
2211
- [a] = await Z({
2294
+ [i] = await _({
2212
2295
  message: "选择要更新的模块",
2213
2296
  pageSize: 100,
2214
2297
  loop: !1,
@@ -2219,24 +2302,24 @@ async function Sn(e, t) {
2219
2302
  }
2220
2303
  });
2221
2304
  }
2222
- let s = await B({
2305
+ let s = await F({
2223
2306
  message: "修改模块名称",
2224
- default: a.displayName,
2307
+ default: i.displayName,
2225
2308
  required: !0,
2226
2309
  validate: (r) => r.length > 0 && r.length < 255,
2227
2310
  prefill: "editable"
2228
2311
  });
2229
2312
  s = s.trim();
2230
2313
  const o = y("模块重命名中...").start();
2231
- return s !== a.displayName ? (await Sa({
2232
- id: Number(a.id),
2314
+ return s !== i.displayName ? (await ji({
2315
+ id: Number(i.id),
2233
2316
  name: s
2234
- }), await we(a.path, s, "module", String(a.id)) && o.succeed(`模块重命名成功: ${a.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), a.id;
2317
+ }), await ve(i.path, s, "module", String(i.id)) && o.succeed(`模块重命名成功: ${i.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), i.id;
2235
2318
  }
2236
- async function bn(e, t) {
2237
- const { type: i, typeStr: n } = await je("修改", e), { localProduct: a } = await ke(t.productId);
2319
+ async function Dn(e, t) {
2320
+ const { type: a, typeStr: n } = await Ee("修改", e), { localProduct: i } = await Re(t.productId);
2238
2321
  let s;
2239
- if (E.MODULE === i ? s = await Sn(a, t) : E.CASE === i && (s = await Nn(a, t)), !t.disableAutoCommit && await m("git status -s")) {
2322
+ if (E.MODULE === a ? s = await xn(i, t) : E.CASE === a && (s = await Ln(i, t)), !t.disableAutoCommit && await m("git status -s")) {
2240
2323
  const o = y("代码提交中...").start();
2241
2324
  try {
2242
2325
  await m(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
@@ -2245,99 +2328,99 @@ async function bn(e, t) {
2245
2328
  }
2246
2329
  }
2247
2330
  }
2248
- P.command("qa-update").alias("qu").description("修改模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-id <targetId>", "可传指定目标(用例/模块)ID").option("--target-name <targetName>", "可传指定目标(用例/模块)修改后的名称").option("--case-priority <casePriority>", "如果是用例,指定修改后的优先级").option("--case-precondition <casePrecondition>", "如果是用例,指定修改后的前置条件").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(bn, ...e));
2249
- async function jn(e, t) {
2331
+ x.command("qa-update").alias("qu").description("修改模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-id <targetId>", "可传指定目标(用例/模块)ID").option("--target-name <targetName>", "可传指定目标(用例/模块)修改后的名称").option("--case-priority <casePriority>", "如果是用例,指定修改后的优先级").option("--case-precondition <casePrecondition>", "如果是用例,指定修改后的前置条件").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(Dn, ...e));
2332
+ async function Pn(e, t) {
2250
2333
  if (!e.length)
2251
2334
  return [];
2252
- const i = Kt(20), n = e.map(
2253
- (a) => i(async () => {
2335
+ const a = Qt(20), n = e.map(
2336
+ (i) => a(async () => {
2254
2337
  try {
2255
- const s = t.env || "production", o = await m(`python ${a.path}/main.py --env ${s}`);
2338
+ const s = t.env || "production", o = await m(`python ${i.path}/main.py --env ${s}`);
2256
2339
  try {
2257
- a.result = JSON.parse(o);
2340
+ i.result = JSON.parse(o);
2258
2341
  } catch {
2259
- p(`用例${a.displayName}[${a.id}]返回格式错误:${o}`);
2342
+ d(`用例${i.displayName}[${i.id}]返回格式错误:${o}`);
2260
2343
  }
2261
2344
  } catch (s) {
2262
2345
  const o = s instanceof Error ? s.message : String(s);
2263
- p(`用例${a.displayName}[${a.id}]执行失败: ${o}`);
2346
+ d(`用例${i.displayName}[${i.id}]执行失败: ${o}`);
2264
2347
  }
2265
2348
  })
2266
2349
  );
2267
2350
  return await Promise.all(n), e;
2268
2351
  }
2269
- async function kn(e) {
2270
- ae(), K();
2271
- const { localProduct: t } = await ke(e.productId);
2272
- let i = [];
2273
- const a = (await ie(t.path)).filter((c) => c.type === "case");
2352
+ async function On(e) {
2353
+ ie(), K();
2354
+ const { localProduct: t } = await Re(e.productId);
2355
+ let a = [];
2356
+ const i = (await ae(t.path)).filter((c) => c.type === "case");
2274
2357
  if (e.all)
2275
- i = a.map((c) => ({
2358
+ a = i.map((c) => ({
2276
2359
  id: Number(c.id),
2277
2360
  path: c.path,
2278
2361
  displayName: c.displayName
2279
2362
  }));
2280
2363
  else {
2281
- const c = ze(e.caseIds);
2364
+ const c = _e(e.caseIds);
2282
2365
  if (c.length)
2283
- i = a.filter((l) => c.includes(Number(l.id))).map((l) => ({
2366
+ a = i.filter((l) => c.includes(Number(l.id))).map((l) => ({
2284
2367
  id: Number(l.id),
2285
2368
  path: l.path,
2286
2369
  displayName: l.displayName
2287
2370
  }));
2288
2371
  else {
2289
- const l = a.map((u) => ({
2372
+ const l = i.map((u) => ({
2290
2373
  value: {
2291
2374
  id: Number(u.id),
2292
2375
  path: u.path,
2293
2376
  displayName: u.displayName
2294
2377
  },
2295
- name: u.path.replace(d.resolve(t.path), "")
2378
+ name: u.path.replace(f.resolve(t.path), "")
2296
2379
  }));
2297
- i = await Z({
2380
+ a = await _({
2298
2381
  message: "选择要执行的用例",
2299
2382
  pageSize: 100,
2300
2383
  loop: !1,
2301
- options: (u) => u ? l.filter((f) => f.name.includes(u)) : l,
2384
+ options: (u) => u ? l.filter((p) => p.name.includes(u)) : l,
2302
2385
  validate(u) {
2303
2386
  return u.length === 0 ? "至少选择一项" : !0;
2304
2387
  }
2305
2388
  });
2306
2389
  }
2307
2390
  }
2308
- const s = y("用例执行中...").start(), r = (await jn(i, e)).filter((c) => c.result.length);
2391
+ const s = y("用例执行中...").start(), r = (await Pn(a, e)).filter((c) => c.result.length);
2309
2392
  if (r.length === 0)
2310
2393
  s.succeed("所有用例执行通过 🎉");
2311
2394
  else {
2312
2395
  if (e.processStep === "1")
2313
- return q("执行报告如下:"), console.log(JSON.stringify(r, null, 2)), process.exit(0);
2314
- const c = r.reduce((f, h) => f + h.result.length, 0);
2396
+ return U("执行报告如下:"), console.log(JSON.stringify(r, null, 2)), process.exit(0);
2397
+ const c = r.reduce((p, h) => p + h.result.length, 0);
2315
2398
  s.warn(`【${r.length}】个用例执行出错,【${c}】个BUG将创建。`);
2316
2399
  let l = 0;
2317
2400
  if (e.executionId)
2318
- Number.isNaN(Number(e.executionId)) && p(`executionId ${e.executionId}不是正整数`), l = Number(e.executionId);
2401
+ Number.isNaN(Number(e.executionId)) && d(`executionId ${e.executionId}不是正整数`), l = Number(e.executionId);
2319
2402
  else {
2320
- const f = await Ea(), h = await k({
2403
+ const p = await Ii(), h = await k({
2321
2404
  message: "请选择用例执行出错后,BUG所属的项目",
2322
- choices: f.map(({ id: v, name: G }) => ({ name: G, value: v }))
2323
- }), g = await Ia(h);
2405
+ choices: p.map(({ id: $, name: V }) => ({ name: V, value: $ }))
2406
+ }), g = await Ci(h);
2324
2407
  l = await k({
2325
2408
  message: "请选择用例执行出错后,BUG所属的执行",
2326
- choices: g.map(({ id: v, name: G }) => ({ name: G, value: v }))
2409
+ choices: g.map(({ id: $, name: V }) => ({ name: V, value: $ }))
2327
2410
  });
2328
2411
  }
2329
2412
  let u;
2330
2413
  if (e.buildId)
2331
2414
  u = e.buildId;
2332
2415
  else {
2333
- const f = await Ca(Number(l));
2334
- if (f.length) {
2335
- const h = await ve({
2416
+ const p = await Li(Number(l));
2417
+ if (p.length) {
2418
+ const h = await Se({
2336
2419
  message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
2337
2420
  required: !1,
2338
- choices: f.map(({ id: g, name: v, date: G, builder: O }) => ({
2421
+ choices: p.map(({ id: g, name: $, date: V, builder: O }) => ({
2339
2422
  value: g,
2340
- name: `${v} ${O} ${G}`
2423
+ name: `${$} ${O} ${V}`
2341
2424
  }))
2342
2425
  });
2343
2426
  h.length ? u = h.join(",") : u = "";
@@ -2345,26 +2428,26 @@ async function kn(e) {
2345
2428
  s.warn("当前执行下没有构建,使用默认【主干】"), u = "";
2346
2429
  }
2347
2430
  s.start("上传中...");
2348
- for (const f of r)
2349
- await Ta({
2350
- caseId: f.id,
2431
+ for (const p of r)
2432
+ await Ri({
2433
+ caseId: p.id,
2351
2434
  caseResult: "fail",
2352
- stepResults: f.result,
2353
- runner: C("ldapAccount"),
2435
+ stepResults: p.result,
2436
+ runner: I("ldapAccount"),
2354
2437
  executionId: l,
2355
2438
  openedBuild: u
2356
2439
  });
2357
2440
  s.succeed(
2358
- `用例执行完成。查看相关BUG(${U("ZenTaoDomain")}/zentao/execution-bug-${l}.html}) `
2441
+ `用例执行完成。查看相关BUG(${G("ZenTaoDomain")}/zentao/execution-bug-${l}.html}) `
2359
2442
  );
2360
2443
  }
2361
2444
  }
2362
- P.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认主干(trunk)").action((...e) => M(kn, ...e));
2363
- const Tn = async () => {
2364
- const { projects: e } = await Wi(), t = X();
2445
+ x.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认主干(trunk)").action((...e) => M(On, ...e));
2446
+ const Mn = async () => {
2447
+ const { projects: e } = await Ha(), t = X();
2365
2448
  if (t.serverProjectURL) {
2366
2449
  const n = e.find(
2367
- (a) => pt(a.url, t.serverProjectURL)
2450
+ (i) => ft(i.url, t.serverProjectURL)
2368
2451
  );
2369
2452
  if (n)
2370
2453
  return {
@@ -2372,91 +2455,91 @@ const Tn = async () => {
2372
2455
  moduleList: n.modules || []
2373
2456
  };
2374
2457
  }
2375
- const i = await k({
2458
+ const a = await k({
2376
2459
  message: "请选择本项目对应的服务端项目",
2377
2460
  choices: e.map((n) => ({
2378
2461
  name: `${n.name}(${n.url})`,
2379
2462
  value: n.url
2380
2463
  }))
2381
2464
  });
2382
- return gt({ ...t, serverProjectURL: i }), {
2383
- projectId: decodeURIComponent(te(i)),
2384
- moduleList: e.find((n) => n.url === i)?.modules || []
2465
+ return yt({ ...t, serverProjectURL: a }), {
2466
+ projectId: decodeURIComponent(te(a)),
2467
+ moduleList: e.find((n) => n.url === a)?.modules || []
2385
2468
  };
2386
- }, En = () => {
2469
+ }, Bn = () => {
2387
2470
  const e = X();
2388
- return e.language || p("未找到当前项目的语言类型,请先通过 z . 对项目进行初始化!"), e.language;
2389
- }, In = async (e, t) => {
2390
- const i = t ? t.split(",").filter((a) => e.map((s) => s.name).includes(a.trim())) : [];
2391
- if (i.length)
2392
- return i;
2393
- const n = await ve({
2471
+ return e.language || d("未找到当前项目的语言类型,请先通过 z . 对项目进行初始化!"), e.language;
2472
+ }, Jn = async (e, t) => {
2473
+ const a = t ? t.split(",").filter((i) => e.map((s) => s.name).includes(i.trim())) : [];
2474
+ if (a.length)
2475
+ return a;
2476
+ const n = await Se({
2394
2477
  message: "请选择对应的后端服务,不选默认全部",
2395
- choices: e.map((a) => ({
2396
- name: `${a.name}(${a.desc})`,
2397
- value: a.name
2478
+ choices: e.map((i) => ({
2479
+ name: `${i.name}(${i.desc})`,
2480
+ value: i.name
2398
2481
  })),
2399
2482
  required: !1,
2400
2483
  pageSize: 10,
2401
2484
  loop: !0
2402
2485
  });
2403
- return n?.length ? n : e.map((a) => a.name);
2404
- }, Ke = [R.DEV, R.TEST], Cn = async (e) => e && Ke.includes(e.trim()) ? e : await k({
2486
+ return n?.length ? n : e.map((i) => i.name);
2487
+ }, et = [C.DEV, C.TEST], zn = async (e) => e && et.includes(e.trim()) ? e : await k({
2405
2488
  message: "请选择对应的环境",
2406
- choices: rt.filter((t) => Ke.includes(t.value))
2407
- }), Fe = (e) => {
2489
+ choices: lt.filter((t) => et.includes(t.value))
2490
+ }), Ve = (e) => {
2408
2491
  const t = /^https?:\/\/[^/]+\/api\/([^/]+)\/v3\//;
2409
2492
  return e.match(t)?.[1];
2410
- }, Rn = async (e, t) => {
2493
+ }, Fn = async (e, t) => {
2411
2494
  try {
2412
- const i = await ne({
2495
+ const a = await ne({
2413
2496
  url: e,
2414
2497
  method: "get"
2415
- }), n = Fe(e);
2416
- return n && (i.paths = Object.fromEntries(
2417
- Object.entries(i.paths).map(([a, s]) => [`/${n}${a}`, s])
2418
- )), Xt(i, {
2498
+ }), n = Ve(e);
2499
+ return n && (a.paths = Object.fromEntries(
2500
+ Object.entries(a.paths).map(([i, s]) => [`/${n}${i}`, s])
2501
+ )), ea(a, {
2419
2502
  throwOnValidateError: !t
2420
2503
  });
2421
- } catch (i) {
2422
- throw p(`Error fetching Swagger JSON: ${i.message}`), i;
2504
+ } catch (a) {
2505
+ throw d(`Error fetching Swagger JSON: ${a.message}`), a;
2423
2506
  }
2424
- }, xn = (e) => {
2425
- const t = (i) => {
2426
- const { reason: n, url: a } = i;
2427
- return `## ${Fe(a)}服务接口文档校验失败
2507
+ }, Un = (e) => {
2508
+ const t = (a) => {
2509
+ const { reason: n, url: i } = a;
2510
+ return `## ${Ve(i)}服务接口文档校验失败
2428
2511
  ${n.message}`;
2429
2512
  };
2430
2513
  return `# 服务端接口文档校验失败
2431
2514
  ${e.map(t).join(`
2432
2515
  `)}`;
2433
- }, Pn = async (e, t) => {
2434
- const i = xn(e), n = X(), { groups: a } = await ht(), s = a.find(
2435
- (c) => c.projects.some((l) => pt(l, n.serverProjectURL))
2516
+ }, Gn = async (e, t) => {
2517
+ const a = Un(e), n = X(), { groups: i } = await vt(), s = i.find(
2518
+ (c) => c.projects.some((l) => ft(l, n.serverProjectURL))
2436
2519
  );
2437
- t.fail("API数据解析失败"), s || (t.fail("未找到对应的项目群聊组!"), process.stdout.write(`${A.red(i)}
2520
+ t.fail("API数据解析失败"), s || (t.fail("未找到对应的项目群聊组!"), process.stdout.write(`${A.red(a)}
2438
2521
  `), process.exit(1));
2439
- const { code: o, message: r } = await Ra({
2440
- content: i,
2522
+ const { code: o, message: r } = await xi({
2523
+ content: a,
2441
2524
  webhooks: [s.url]
2442
2525
  });
2443
- o !== 0 && t.fail(`发送消息到企微群组失败: ${A.red(r)}`), process.stdout.write(`${A.red(i)}
2526
+ o !== 0 && t.fail(`发送消息到企微群组失败: ${A.red(r)}`), process.stdout.write(`${A.red(a)}
2444
2527
  `), process.exit(1);
2445
- }, Dn = async (e) => {
2446
- const { moduleList: t, services: i, env: n, skipSwaggerValidate: a } = e, s = t.filter((u) => i.includes(u.name)).map((u) => u.swagger);
2528
+ }, _n = async (e) => {
2529
+ const { moduleList: t, services: a, env: n, skipSwaggerValidate: i } = e, s = t.filter((u) => a.includes(u.name)).map((u) => u.swagger);
2447
2530
  if (!s.length)
2448
2531
  throw new Error("Failed to fetch Swagger JSON");
2449
2532
  const o = s.flatMap((u) => {
2450
- const f = u.find((h) => h.env === n);
2451
- return f ? [f.url] : [];
2533
+ const p = u.find((h) => h.env === n);
2534
+ return p ? [p.url] : [];
2452
2535
  });
2453
2536
  if (!o.length)
2454
2537
  throw new Error("Failed to fetch Swagger JSON");
2455
- const r = y("API数据请求中...").start(), c = await Promise.allSettled(o.map((u) => Rn(u, a))), l = c.flatMap(
2456
- (u, f) => u.status === "rejected" ? [{ reason: u.reason, url: o[f] }] : []
2538
+ const r = y("API数据请求中...").start(), c = await Promise.allSettled(o.map((u) => Fn(u, i))), l = c.flatMap(
2539
+ (u, p) => u.status === "rejected" ? [{ reason: u.reason, url: o[p] }] : []
2457
2540
  );
2458
- return l.length && await Pn(l, r), r.succeed("API数据请求成功"), c.flatMap((u, f) => u.status === "fulfilled" ? [{ serverName: Fe(o[f]), swaggerJson: u.value }] : []);
2459
- }, Ln = () => k({
2541
+ return l.length && await Gn(l, r), r.succeed("API数据请求成功"), c.flatMap((u, p) => u.status === "fulfilled" ? [{ serverName: Ve(o[p]), swaggerJson: u.value }] : []);
2542
+ }, Vn = () => k({
2460
2543
  message: "请选择生成API的范围",
2461
2544
  choices: [
2462
2545
  {
@@ -2468,58 +2551,59 @@ ${e.map(t).join(`
2468
2551
  value: "single"
2469
2552
  }
2470
2553
  ]
2471
- }), Xe = (e) => {
2554
+ }), tt = (e) => {
2472
2555
  const t = e.trim();
2473
2556
  if (!t)
2474
2557
  return "请输入生成目录";
2475
2558
  if (t.includes("\0"))
2476
2559
  return "路径格式不合法";
2477
- if (Ft(t))
2560
+ if (Gt(t))
2478
2561
  return "只允许输入相对路径";
2479
- const i = Bt(t);
2480
- return !i || i === "." || i === ".." ? "请输入有效的目录路径" : i.startsWith(`..${Ut}`) ? "路径不能跳出当前项目" : !0;
2481
- }, On = (e) => {
2562
+ const a = _t(t);
2563
+ return !a || a === "." || a === ".." ? "请输入有效的目录路径" : a.startsWith(`..${Vt}`) ? "路径不能跳出当前项目" : !0;
2564
+ }, Wn = (e) => {
2482
2565
  if (e) {
2483
- const t = Xe(e);
2484
- return t !== !0 && p(t), e;
2566
+ const t = tt(e);
2567
+ return t !== !0 && d(t), e;
2485
2568
  }
2486
- return B({
2569
+ return F({
2487
2570
  message: "请输入 API 输出目录,默认为 src/services",
2488
2571
  default: "src/services",
2489
- validate: Xe
2572
+ validate: tt
2490
2573
  });
2491
2574
  };
2492
- class Rt {
2575
+ class Dt {
2493
2576
  o;
2494
2577
  options;
2495
2578
  async generateApi(t) {
2496
2579
  this.options = t;
2497
- const { scope: i } = t;
2498
- this.o = y("API 开始生成...").start(), i === "single" ? await this.startGenerateSingleApi() : await this.startGenerateAllApi(), this.o.succeed("API 生成成功");
2580
+ const { scope: a } = t;
2581
+ this.o = y("API 开始生成...").start(), a === "single" ? await this.startGenerateSingleApi() : await this.startGenerateAllApi(), this.o.succeed("API 生成成功");
2499
2582
  }
2500
2583
  async startGenerateSingleApi() {
2501
- const t = [], i = this.options.remoteSwaggerJsons.map((n) => n.swaggerJson);
2584
+ const t = [], a = this.options.remoteSwaggerJsons.map((n) => n.swaggerJson);
2502
2585
  this.o.text = "获取 API 列表...";
2503
- for (const n of i) {
2504
- const { apis: a } = await Yt(n, {
2586
+ for (const n of a) {
2587
+ const { apis: i } = await ta(n, {
2505
2588
  throwOnValidateError: !this.options.skipSwaggerValidate
2506
2589
  });
2507
- t.push(...a.map((s) => ({ name: `${s.path}${s.summary ? `(${s.summary})` : ""}`, value: s.path })));
2590
+ t.push(...i.map((s) => ({ name: `${s.path}${s.summary ? `(${s.summary})` : ""}`, value: s.path })));
2508
2591
  }
2509
2592
  this.o.stop();
2510
2593
  try {
2511
2594
  await this.generateSingleApi(
2512
- await Z({
2595
+ await _({
2513
2596
  message: "请选择需要生成的API",
2514
- options: (n) => n ? t.filter((a) => a.name.includes(n)) : t,
2597
+ options: (n) => n ? t.filter((i) => i.name.includes(n)) : t,
2515
2598
  pageSize: 20,
2516
2599
  clearInputWhenSelected: !0,
2517
2600
  multiple: !0,
2601
+ loop: !0,
2518
2602
  validate: (n) => n.length ? !0 : "至少选择一个API",
2519
2603
  filter: !0,
2520
2604
  theme: {
2521
2605
  style: {
2522
- renderSelectedOptions: (n) => n.map((a) => a.value).join(", ")
2606
+ renderSelectedOptions: (n) => n.map((i) => i.value).join(", ")
2523
2607
  }
2524
2608
  }
2525
2609
  })
@@ -2531,150 +2615,150 @@ class Rt {
2531
2615
  async startGenerateAllApi() {
2532
2616
  const t = await this.generateAllApi();
2533
2617
  this.o.stop();
2534
- const i = await On(this.options.dir), n = Ce(i);
2535
- Mt(n, { recursive: !0 });
2536
- const a = [];
2618
+ const a = await Wn(this.options.dir), n = xe(a);
2619
+ zt(n, { recursive: !0 });
2620
+ const i = [];
2537
2621
  this.o.start(), this.o.text = "API 生成中...";
2538
2622
  for (const s of t) {
2539
- const { path: o, content: r } = s, c = Ce(n, o);
2540
- a.push(c), Ye(c, r);
2623
+ const { path: o, content: r } = s, c = xe(n, o);
2624
+ i.push(c), at(c, r);
2541
2625
  }
2542
- this.o.text = "开始格式化代码", await this.formatApiContent(a), this.o.text = "代码格式化完成", this.o.succeed(`API 已生成到 ${i} 目录下`);
2626
+ this.o.text = "开始格式化代码", await this.formatApiContent(i), this.o.text = "代码格式化完成", this.o.succeed(`API 已生成到 ${a} 目录下`);
2543
2627
  }
2544
2628
  }
2545
- class Mn extends Rt {
2629
+ class qn extends Dt {
2546
2630
  formatApiContent() {
2547
2631
  return this.o.succeed("yaml 暂无格式化配置"), Promise.resolve();
2548
2632
  }
2549
2633
  generateAllApi() {
2550
- const t = this.options.remoteSwaggerJsons.map((i) => i.swaggerJson);
2551
- return Qt(
2552
- t.map((i) => ({
2553
- swaggerJson: i,
2634
+ const t = this.options.remoteSwaggerJsons.map((a) => a.swaggerJson);
2635
+ return aa(
2636
+ t.map((a) => ({
2637
+ swaggerJson: a,
2554
2638
  throwOnValidateError: !this.options.skipSwaggerValidate
2555
2639
  }))
2556
2640
  );
2557
2641
  }
2558
2642
  async generateSingleApi(t) {
2559
- const { remoteSwaggerJsons: i, skipSwaggerValidate: n } = this.options;
2560
- for (const { swaggerJson: a, serverName: s } of i) {
2643
+ const { remoteSwaggerJsons: a, skipSwaggerValidate: n } = this.options;
2644
+ for (const { swaggerJson: i, serverName: s } of a) {
2561
2645
  if (!t.some((r) => r.startsWith(`/${s}`)))
2562
2646
  continue;
2563
- const o = await ei({
2564
- swaggerJson: a,
2647
+ const o = await ia({
2648
+ swaggerJson: i,
2565
2649
  controller: t,
2566
2650
  throwOnValidateError: !n,
2567
2651
  showHeaderComment: !1
2568
2652
  });
2569
- console.log(tt(o, { language: "typescript", ignoreIllegals: !0 }));
2653
+ console.log(nt(o, { language: "typescript", ignoreIllegals: !0 }));
2570
2654
  }
2571
2655
  }
2572
2656
  }
2573
- const Jn = new it({
2657
+ const Hn = new st({
2574
2658
  fix: !0
2575
2659
  });
2576
- class zn extends Rt {
2660
+ class Zn extends Dt {
2577
2661
  async formatApiContent(t) {
2578
2662
  try {
2579
- const i = await Jn.lintFiles(t);
2580
- await it.outputFixes(i);
2663
+ const a = await Hn.lintFiles(t);
2664
+ await st.outputFixes(a);
2581
2665
  for (const n of t) {
2582
- const a = Ce(n), s = Jt(a, "utf-8"), o = await ai.format(s, {
2583
- filepath: a
2666
+ const i = xe(n), s = Ft(i, "utf-8"), o = await ra.format(s, {
2667
+ filepath: i
2584
2668
  });
2585
- Ye(a, o);
2669
+ at(i, o);
2586
2670
  }
2587
- } catch (i) {
2588
- console.error(i), this.o.stop(), p("API 格式化失败,请检查是否配置 eslint 和 prettier");
2671
+ } catch (a) {
2672
+ console.error(a), this.o.stop(), d("API 格式化失败,请检查是否配置 eslint 和 prettier");
2589
2673
  }
2590
2674
  }
2591
2675
  generateAllApi() {
2592
- const t = this.options.remoteSwaggerJsons.map((i) => i.swaggerJson);
2593
- return ti(
2594
- t.map((i) => ({
2595
- swaggerJson: i,
2676
+ const t = this.options.remoteSwaggerJsons.map((a) => a.swaggerJson);
2677
+ return na(
2678
+ t.map((a) => ({
2679
+ swaggerJson: a,
2596
2680
  throwOnValidateError: !this.options.skipSwaggerValidate
2597
2681
  }))
2598
2682
  );
2599
2683
  }
2600
2684
  async generateSingleApi(t) {
2601
- const { remoteSwaggerJsons: i, skipSwaggerValidate: n } = this.options;
2602
- for (const { swaggerJson: a, serverName: s } of i) {
2685
+ const { remoteSwaggerJsons: a, skipSwaggerValidate: n } = this.options;
2686
+ for (const { swaggerJson: i, serverName: s } of a) {
2603
2687
  if (!t.some((r) => r.startsWith(`/${s}`)))
2604
2688
  continue;
2605
- const o = await ii({
2606
- swaggerJson: a,
2689
+ const o = await sa({
2690
+ swaggerJson: i,
2607
2691
  merge: !0,
2608
2692
  controller: t,
2609
2693
  throwOnValidateError: !n,
2610
2694
  importMethods: !1
2611
2695
  });
2612
- console.log(tt(o, { language: "typescript", ignoreIllegals: !0 }));
2696
+ console.log(nt(o, { language: "typescript", ignoreIllegals: !0 }));
2613
2697
  }
2614
2698
  }
2615
2699
  }
2616
- const Fn = (e) => {
2700
+ const Kn = (e) => {
2617
2701
  switch (e) {
2618
2702
  case w.JAVASCRIPT:
2619
- return zn;
2703
+ return Zn;
2620
2704
  case w.PYTHON:
2621
- return Mn;
2705
+ return qn;
2622
2706
  }
2623
- }, Bn = async (e) => {
2624
- const { apiType: t } = e, i = Fn(t);
2625
- i ? await new i().generateApi(e) : p(`不支持 ${t} 语言`);
2707
+ }, Xn = async (e) => {
2708
+ const { apiType: t } = e, a = Kn(t);
2709
+ a ? await new a().generateApi(e) : d(`不支持 ${t} 语言`);
2626
2710
  };
2627
- async function Un(e, t) {
2628
- ae(), K();
2629
- const { moduleList: i } = await Tn(), { services: n, env: a, skipSwaggerValidate: s = !1 } = t, o = await In(i, n), r = En(), c = await Cn(a), l = await Dn({
2630
- moduleList: i,
2631
- services: o,
2632
- env: c,
2633
- skipSwaggerValidate: s
2634
- }), u = await Ln();
2635
- await Bn({
2636
- remoteSwaggerJsons: l,
2637
- ...t,
2638
- scope: u,
2639
- apiType: r
2711
+ async function Yn(e) {
2712
+ ie(), K();
2713
+ const { moduleList: t } = await Mn(), { services: a, env: n, skipSwaggerValidate: i = !1 } = e, s = await Jn(t, a), o = Bn(), r = await zn(n), c = await _n({
2714
+ moduleList: t,
2715
+ services: s,
2716
+ env: r,
2717
+ skipSwaggerValidate: i
2718
+ }), l = await Vn();
2719
+ await Xn({
2720
+ remoteSwaggerJsons: c,
2721
+ ...e,
2722
+ scope: l,
2723
+ apiType: o
2640
2724
  }), process.exit(0);
2641
2725
  }
2642
- P.command("api").alias("a").description("选择对应的服务端项目,获取接口并转成ts接口代码及类型").option("--services [services]", "指定需要生成的服务。多个使用逗号隔开").option("--env [env]", "指定环境。dev/test/release").option("--dir [dir]", "输出的目录。默认为 src/services").option("--skip-swagger-validate [skipSwaggerValidate]", "是否跳过 swagger 校验").action((...e) => M(Un, ...e));
2643
- function Gn() {
2726
+ x.command("api").alias("a").description("选择对应的服务端项目,获取接口并转成ts接口代码及类型").option("--services [services]", "指定需要生成的服务。多个使用逗号隔开").option("--env [env]", "指定环境。dev/test/release").option("--dir [dir]", "输出的目录。默认为 src/services").option("--skip-swagger-validate", "是否跳过 swagger 校验").action((...e) => M(Yn, ...e));
2727
+ function Qn() {
2644
2728
  process.on("unhandledRejection", (e) => {
2645
2729
  }), process.on("uncaughtException", (e) => {
2646
- }), L.config.fatal = !0, L.config.silent = !0, L.config.verbose = !1;
2730
+ }), P.config.fatal = !0, P.config.silent = !0, P.config.verbose = !1;
2647
2731
  }
2648
- async function _n() {
2649
- const e = ge("latestCheckVersionTimestamp"), t = ge("versionCheckDuring");
2732
+ async function es() {
2733
+ const e = he("latestCheckVersionTimestamp"), t = he("versionCheckDuring");
2650
2734
  if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
2651
- const i = await Le();
2652
- be(i);
2735
+ const a = await ze();
2736
+ Te(a);
2653
2737
  let n;
2654
2738
  try {
2655
- const a = "TIME_OUT", s = new Promise((o) => {
2656
- setTimeout(() => o(a), 3e3);
2739
+ const i = "TIME_OUT", s = new Promise((o) => {
2740
+ setTimeout(() => o(i), 3e3);
2657
2741
  });
2658
2742
  n = await Promise.race([
2659
2743
  s,
2660
2744
  m(`npm view ${re.name} version --registry https://registry.npmmirror.com/`)
2661
- ]), n !== a && n !== re.version && (console.log(`${A.blue(re.name)}本地版本为${re.version},低于线上版本${n},开始升级`), await bt(n)), pe("latestCheckVersionTimestamp", Date.now()), oe();
2662
- } catch (a) {
2663
- console.log("升级出错!请重试,或者手动升级"), p(a);
2745
+ ]), n !== i && n !== re.version && (console.log(`${A.blue(re.name)}本地版本为${re.version},低于线上版本${n},开始升级`), await Tt(n)), pe("latestCheckVersionTimestamp", Date.now()), oe();
2746
+ } catch (i) {
2747
+ console.log("升级出错!请重试,或者手动升级"), d(i);
2664
2748
  }
2665
2749
  }
2666
2750
  }
2667
- async function Vn() {
2668
- const e = ni(process.argv.slice(2));
2751
+ async function ts() {
2752
+ const e = oa(process.argv.slice(2));
2669
2753
  if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
2670
- if (ut()) {
2671
- const t = I.readJSONSync(Ne());
2672
- F(t.profile), pe(t.main), be(t.constants), await _n();
2754
+ if (dt()) {
2755
+ const t = R.readJSONSync(ke());
2756
+ z(t.profile), pe(t.main), Te(t.constants), await es();
2673
2757
  } else
2674
- p(`请先初始化z-develop(执行 z i)。更多见${ot}`);
2758
+ d(`请先初始化z-develop(执行 z i)。更多见${ut}`);
2675
2759
  }
2676
- async function Wn() {
2677
- Gn(), await Vn();
2760
+ async function as() {
2761
+ Qn(), await ts();
2678
2762
  }
2679
- P.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${A.blue(ot)}`).usage("<command> [options]").hook("preAction", Wn).version(re.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
2680
- P.parse();
2763
+ x.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${A.blue(ut)}`).usage("<command> [options]").hook("preAction", as).version(re.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
2764
+ x.parse();