cli-z-develop 0.14.3 → 0.14.4

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