cli-z-develop 0.14.11 → 0.14.12

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