cli-z-develop 0.10.8 → 0.11.0

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