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