cli-z-develop 0.14.5 → 0.14.6

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