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