cli-z-develop 0.14.5 → 0.14.7

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