cli-z-develop 0.12.2 → 0.12.3

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 +256 -247
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
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 Re, mkdir as le, writeFile as L, rename as _e, readFile as ke, stat as At } from "node:fs/promises";
5
- import m from "node:path";
4
+ import { readdir as Re, mkdir as le, writeFile as L, rename as _e, readFile as Ee, stat as At } from "node:fs/promises";
5
+ import p from "node:path";
6
6
  import ce, { AxiosError as jt } from "axios";
7
7
  import S from "chalk";
8
8
  import St from "dayjs";
9
- import P from "shelljs";
9
+ import O from "shelljs";
10
10
  import Tt from "node:os";
11
11
  import Me from "child_process";
12
- import { confirm as Ue, select as T, input as F, password as Et, checkbox as Ce, number as ze } from "@inquirer/prompts";
13
- import w from "ora";
12
+ import { confirm as Ue, select as T, input as F, password as kt, checkbox as Ce, number as ze } from "@inquirer/prompts";
13
+ import y from "ora";
14
14
  import I from "fs-extra";
15
15
  import { select as ae } from "inquirer-select-pro";
16
- import kt from "lint-staged";
16
+ import Et from "lint-staged";
17
17
  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
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 || {});
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 || {}), $ = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = Ve] = "TEST", e[e.RELEASE = We] = "RELEASE", e[e.MASTER = Lt] = "MASTER", e))($ || {}), G = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(G || {});
23
23
  const qe = [
24
24
  {
25
25
  name: `开发环境 - ${b.DEV}`,
@@ -37,7 +37,7 @@ const qe = [
37
37
  name: `正式环境 - ${b.PROD}`,
38
38
  value: b.PROD
39
39
  }
40
- ], Pt = [
40
+ ], Ot = [
41
41
  {
42
42
  name: "网页 - h5",
43
43
  value: "h5"
@@ -54,8 +54,8 @@ const qe = [
54
54
  /* SERVER */
55
55
  }
56
56
  ];
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
- const Ot = {
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 || {}), w = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e.MARKDOWN = "Markdown", e))(w || {});
58
+ const Pt = {
59
59
  1: "研发",
60
60
  2: "测试",
61
61
  3: "产品",
@@ -82,7 +82,7 @@ const Bt = [
82
82
  }
83
83
  ], Jt = ".z", Ft = "develop-config.json", K = ".z", _t = ".commit-msg-tpl", Ut = "project.json";
84
84
  function C(e = "") {
85
- return m.join(K, e);
85
+ return p.join(K, e);
86
86
  }
87
87
  function Ze() {
88
88
  return C(Ut);
@@ -94,7 +94,7 @@ function Ke() {
94
94
  Me.spawnSync("git", ["config", "core.hooksPath", C()]), Me.spawnSync("git", ["config", "commit.template", Ne()]);
95
95
  }
96
96
  function he(e = "") {
97
- return m.resolve(Tt.homedir(), Jt, e);
97
+ return p.resolve(Tt.homedir(), Jt, e);
98
98
  }
99
99
  function be() {
100
100
  return he(Ft);
@@ -134,15 +134,15 @@ function Je(e) {
134
134
  return v(e) ? Nt(e).isDirectory() : !1;
135
135
  }
136
136
  function Qe(e = process.cwd()) {
137
- return Je(e) ? vt(e).filter((i) => Je(m.resolve(e, i))) : [];
137
+ return Je(e) ? vt(e).filter((i) => Je(p.resolve(e, i))) : [];
138
138
  }
139
- async function p(e, t = {
139
+ async function m(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 = P.exec(e, {
145
+ const s = O.exec(e, {
146
146
  silent: t.silent
147
147
  });
148
148
  n(s);
@@ -170,16 +170,16 @@ function ne() {
170
170
  v(C()) || l("当前不在项目根目录。请切换到项目根目录");
171
171
  }
172
172
  function Q() {
173
- v(m.resolve(".git")) || l("当前不是git项目根目录,请先执行git init,或切换到根目录");
173
+ v(p.resolve(".git")) || l("当前不是git项目根目录,请先执行git init,或切换到根目录");
174
174
  }
175
- async function pe() {
176
- await p("git status -s") !== "" && l("请先提交代码变动,再进行操作");
175
+ async function me() {
176
+ await m("git status -s") !== "" && l("请先提交代码变动,再进行操作");
177
177
  }
178
178
  function Ht(e) {
179
- return e === y.MASTER ? b.PROD : e;
179
+ return e === $.MASTER ? b.PROD : e;
180
180
  }
181
181
  function Zt(e) {
182
- return e === b.PROD ? y.MASTER : e;
182
+ return e === b.PROD ? $.MASTER : e;
183
183
  }
184
184
  async function z(e, ...t) {
185
185
  try {
@@ -249,19 +249,24 @@ ${t}
249
249
  `;
250
250
  }
251
251
  const Xt = {
252
- [$.JAVA]: {
252
+ [w.JAVA]: {
253
253
  "**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml"
254
254
  },
255
- [$.JAVASCRIPT]: {
255
+ [w.JAVASCRIPT]: {
256
256
  "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
257
257
  "*": "prettier -wu"
258
258
  },
259
- [$.PYTHON]: {
259
+ [w.PYTHON]: {
260
260
  // TODO: 需要优化
261
261
  // "**/*.{py}": "python --fix",
262
262
  "**/*.{py}": "echo 'todo'"
263
+ },
264
+ [w.MARKDOWN]: {
265
+ "**/*.md": "markdownlint --fix",
266
+ "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
267
+ "*": "prettier -wu"
263
268
  }
264
- }, Qt = "cli-z-develop", ei = "0.12.2", 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 = {
269
+ }, Qt = "cli-z-develop", ei = "0.12.3", 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
270
  name: Qt,
266
271
  version: ei,
267
272
  description: ti,
@@ -306,7 +311,7 @@ const Xt = {
306
311
  FECDNDomain: ""
307
312
  }
308
313
  };
309
- function k(e) {
314
+ function E(e) {
310
315
  return e ? x.profile[e] : x.profile;
311
316
  }
312
317
  function ge(e) {
@@ -319,15 +324,15 @@ let _ = null, U = null;
319
324
  function Ae() {
320
325
  if (_)
321
326
  return _;
322
- const e = m.join("package.json");
323
- return v(e) || l(`当前目录(${P.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), _ = I.readJsonSync(e), _;
327
+ const e = p.join("package.json");
328
+ return v(e) || l(`当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), _ = I.readJsonSync(e), _;
324
329
  }
325
- function me() {
330
+ function pe() {
326
331
  if (U)
327
332
  return U;
328
333
  const e = Ze();
329
334
  return v(e) || l(
330
- `当前目录(${P.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
335
+ `当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
331
336
  ), U = I.readJsonSync(e), U;
332
337
  }
333
338
  function ui(e) {
@@ -340,7 +345,7 @@ function li(e) {
340
345
  _ ? _ = {
341
346
  ..._,
342
347
  ...e
343
- } : _ = e, I.writeJSONSync(m.join("package.json"), _, { spaces: 2 });
348
+ } : _ = e, I.writeJSONSync(p.join("package.json"), _, { spaces: 2 });
344
349
  }
345
350
  const Z = {
346
351
  id: 0,
@@ -349,22 +354,22 @@ const Z = {
349
354
  sourceBranch: "",
350
355
  mergeRequestUrl: ""
351
356
  };
352
- async function pi() {
357
+ async function mi() {
353
358
  if (!Z.id)
354
359
  try {
355
- const e = me(), t = $e(e.repository.url), i = await nt(t);
360
+ const e = pe(), t = $e(e.repository.url), i = await nt(t);
356
361
  Z.id = i.id, Z.path = t, Z.group = i.namespace.full_path, Z.mergeRequestUrl = `${i.web_url}/merge_requests`;
357
362
  } catch (e) {
358
363
  l(e);
359
364
  }
360
- return Z.sourceBranch || (Z.sourceBranch = await p("git branch --show-current")), Z;
365
+ return Z.sourceBranch || (Z.sourceBranch = await m("git branch --show-current")), Z;
361
366
  }
362
367
  function se() {
363
368
  I.writeJSONSync(
364
369
  be(),
365
370
  {
366
371
  main: ge(),
367
- profile: k(),
372
+ profile: E(),
368
373
  constants: q()
369
374
  },
370
375
  {
@@ -407,8 +412,8 @@ async function Y(e) {
407
412
  return s instanceof jt && ye(S.red("Error"), S.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
408
413
  }
409
414
  }
410
- async function mi() {
411
- const e = k("gitToken");
415
+ async function pi() {
416
+ const e = E("gitToken");
412
417
  if (e)
413
418
  return e;
414
419
  {
@@ -417,8 +422,8 @@ async function mi() {
417
422
  method: "post",
418
423
  data: {
419
424
  grant_type: "password",
420
- username: k("ldapAccount"),
421
- password: k("ldapPassword")
425
+ username: E("ldapAccount"),
426
+ password: E("ldapPassword")
422
427
  }
423
428
  }), i = `Bearer ${t}`;
424
429
  return M("gitToken", i), se(), i;
@@ -428,12 +433,12 @@ async function N(e) {
428
433
  return Y({
429
434
  ...e,
430
435
  headers: {
431
- Authorization: await mi()
436
+ Authorization: await pi()
432
437
  }
433
438
  });
434
439
  }
435
440
  async function di() {
436
- const e = k("zenTaoToken");
441
+ const e = E("zenTaoToken");
437
442
  if (e)
438
443
  return e;
439
444
  {
@@ -441,8 +446,8 @@ async function di() {
441
446
  url: `${q("ZenTaoDomain")}/api.php/v1/tokens`,
442
447
  method: "post",
443
448
  data: {
444
- account: k("ldapAccount"),
445
- password: k("ldapPassword")
449
+ account: E("ldapAccount"),
450
+ password: E("ldapPassword")
446
451
  }
447
452
  });
448
453
  return M("zenTaoToken", t), se(), t;
@@ -476,7 +481,7 @@ async function ve(e) {
476
481
  }
477
482
  }
478
483
  async function fi() {
479
- const e = k("k8sToken");
484
+ const e = E("k8sToken");
480
485
  if (e)
481
486
  return e;
482
487
  {
@@ -487,8 +492,8 @@ async function fi() {
487
492
  "Content-Type": "application/x-www-form-urlencoded"
488
493
  },
489
494
  data: {
490
- username: k("ldapAccount"),
491
- password: k("ldapPassword")
495
+ username: E("ldapAccount"),
496
+ password: E("ldapPassword")
492
497
  }
493
498
  }), i = `Bearer ${t}`;
494
499
  return M("k8sToken", i), se(), i;
@@ -583,12 +588,12 @@ function Ti() {
583
588
  url: `${B()}/user`
584
589
  });
585
590
  }
586
- function Ei() {
591
+ function ki() {
587
592
  return N({
588
593
  url: `${B()}/groups`
589
594
  });
590
595
  }
591
- function ki(e) {
596
+ function Ei(e) {
592
597
  return N({
593
598
  url: `${B()}/projects`,
594
599
  method: "post",
@@ -642,17 +647,17 @@ function Li(e) {
642
647
  data: e
643
648
  });
644
649
  }
645
- function Pi(e) {
650
+ function Oi(e) {
646
651
  return N({
647
652
  url: `${B()}/projects/${e}/repository/branches`
648
653
  });
649
654
  }
650
- function Oi() {
655
+ function Pi() {
651
656
  const e = he("fe-groups.json");
652
657
  return v(e) ? I.readJSONSync(e) : { groups: [] };
653
658
  }
654
659
  async function Mi() {
655
- const e = await Ei(), t = Mt.map((i) => {
660
+ const e = await ki(), t = Mt.map((i) => {
656
661
  const n = e.find((a) => a.name === i);
657
662
  return n ? {
658
663
  name: n.name,
@@ -824,7 +829,7 @@ function aa(e, t) {
824
829
  }
825
830
  async function rt() {
826
831
  const t = (await zi()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
827
- name: `${s.nick} - ${Ot[s.title]}`,
832
+ name: `${s.nick} - ${Pt[s.title]}`,
828
833
  value: s.weWorkUserId
829
834
  })), i = ge("weWorkListCache"), n = i.map((s) => s.value), a = [];
830
835
  return t.forEach((s) => {
@@ -868,7 +873,7 @@ async function sa() {
868
873
  try {
869
874
  Ye() && (await Ue({
870
875
  message: "系统中已存在z的配置文件,确认重新配置?"
871
- }) ? P.rm("-rf", be()) : process.exit(0)), await le(he(), { recursive: !0 });
876
+ }) ? O.rm("-rf", be()) : process.exit(0)), await le(he(), { recursive: !0 });
872
877
  const t = await T({
873
878
  message: "请选择岗位类型",
874
879
  choices: [
@@ -890,7 +895,7 @@ async function sa() {
890
895
  message: "请输入LDAP账号:"
891
896
  });
892
897
  i = i.trim();
893
- let n = await Et({
898
+ let n = await kt({
894
899
  message: "请输入LDAP密码:",
895
900
  mask: !0
896
901
  });
@@ -905,7 +910,7 @@ async function sa() {
905
910
  } catch (t) {
906
911
  l(t);
907
912
  }
908
- const e = w("配置信息初始化中").start();
913
+ const e = y("配置信息初始化中").start();
909
914
  try {
910
915
  const t = await Ti();
911
916
  M({
@@ -913,7 +918,7 @@ async function sa() {
913
918
  gitName: t.name,
914
919
  gitEnglishName: t.username,
915
920
  gitEmail: t.email
916
- }), ue("latestCheckVersionTimestamp", Date.now()), se(), k("jobType") === oe.FRONT_END && await Mi(), e.succeed("配置信息初始化完成"), process.exit(0);
921
+ }), ue("latestCheckVersionTimestamp", Date.now()), se(), E("jobType") === oe.FRONT_END && await Mi(), e.succeed("配置信息初始化完成"), process.exit(0);
917
922
  } catch (t) {
918
923
  e.fail("配置信息初始化失败"), ce.isAxiosError(t) && l("请检查你的域名及令牌配置"), l(t);
919
924
  }
@@ -923,17 +928,17 @@ async function ra() {
923
928
  `, { mode: 493 }), await L(C("commit-msg"), `#!/usr/bin/env sh
924
929
  z run commit-msg`, { mode: 493 }), await L(C("pre-commit"), `#!/usr/bin/env sh
925
930
  z run commit-files`, { mode: 493 });
926
- const { language: e } = me();
927
- if (e === $.JAVASCRIPT && (await L(
931
+ const { language: e } = pe();
932
+ if ([w.JAVASCRIPT, w.MARKDOWN].includes(e) && (await L(
928
933
  C(".prettierrc.json"),
929
934
  `${JSON.stringify(await Ni(), null, 2)}
930
935
  `,
931
936
  {
932
937
  mode: 493
933
938
  }
934
- ), 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) {
939
+ ), 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 === w.JAVA) {
935
940
  await gi(`${q("FECDNDomain")}/file/vgnlfbfHRF.jar`, C("checkstyle.jar")), await L(C("checkstyle.xml"), await ji(), { mode: 493 });
936
- const t = m.join("package.json");
941
+ const t = p.join("package.json");
937
942
  v(t) || await L(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
938
943
  mode: 493
939
944
  });
@@ -941,23 +946,27 @@ z run commit-files`, { mode: 493 });
941
946
  Ke();
942
947
  }
943
948
  async function oa(e, t) {
944
- const i = await p("git remote get-url --push origin");
949
+ const i = await m("git remote get-url --push origin");
945
950
  i || l("获取项目远程git地址失败,请配置后重试");
946
951
  let n = e;
947
952
  n || (n = await T({
948
953
  message: "请选择项目语言",
949
954
  choices: [
950
955
  {
951
- name: $.JAVASCRIPT,
952
- value: $.JAVASCRIPT
956
+ name: w.JAVASCRIPT,
957
+ value: w.JAVASCRIPT
953
958
  },
954
959
  {
955
- name: $.JAVA,
956
- value: $.JAVA
960
+ name: w.JAVA,
961
+ value: w.JAVA
957
962
  },
958
963
  {
959
- name: $.PYTHON,
960
- value: $.PYTHON
964
+ name: w.PYTHON,
965
+ value: w.PYTHON
966
+ },
967
+ {
968
+ name: w.MARKDOWN,
969
+ value: w.MARKDOWN
961
970
  }
962
971
  ]
963
972
  }));
@@ -978,19 +987,19 @@ async function oa(e, t) {
978
987
  });
979
988
  }
980
989
  async function xe(e, t) {
981
- e ? P.rm("-rf", K) : v(C()) && (await Ue({
990
+ e ? O.rm("-rf", K) : v(C()) && (await Ue({
982
991
  message: `当前项目中已存在配置文件夹${K},确认重新配置?`
983
- }) ? P.rm("-rf", K) : process.exit(0)), await le(C(), { recursive: !0 }), await oa(e, t);
984
- const i = w("项目初始化中...").start();
992
+ }) ? O.rm("-rf", K) : process.exit(0)), await le(C(), { recursive: !0 }), await oa(e, t);
993
+ const i = y("项目初始化中...").start();
985
994
  await ra(), i.succeed("项目初始化完成");
986
995
  }
987
996
  async function ca() {
988
997
  v(C()) && v(Ne()) ? Ke() : await xe(), process.exit(0);
989
998
  }
990
999
  async function ua(e, t) {
991
- 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();
1000
+ t.projectLanguage && !Object.values(w).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();
992
1001
  }
993
- D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values($).join("/")} `).action((...e) => z(ua, ...e));
1002
+ D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => z(ua, ...e));
994
1003
  async function la(e, t) {
995
1004
  if (!e)
996
1005
  return "不能为空";
@@ -1001,14 +1010,14 @@ async function la(e, t) {
1001
1010
  const a = (await Ci(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
1002
1011
  return a ? `远程仓库中已存在同名项目(${a.http_url_to_repo}),请更名后重试` : !0;
1003
1012
  }
1004
- function pa(e) {
1013
+ function ma(e) {
1005
1014
  return e ? !0 : "不能为空";
1006
1015
  }
1007
- function ma(e) {
1016
+ function pa(e) {
1008
1017
  return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
1009
1018
  }
1010
1019
  async function da(e) {
1011
- ne(), Q(), await pe();
1020
+ ne(), Q(), await me();
1012
1021
  let t, i;
1013
1022
  e.branchType ? t = e.branchType : t = await T({
1014
1023
  message: "请选择创建分支的类型",
@@ -1028,10 +1037,10 @@ async function da(e) {
1028
1037
  ]
1029
1038
  }), e.branchPurpose ? i = e.branchPurpose : (i = await F({
1030
1039
  message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
1031
- validate: ma
1040
+ validate: pa
1032
1041
  }), i = i.trim());
1033
1042
  const n = `${t}_${i}_${tt()}`;
1034
- 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);
1043
+ await m(`git fetch origin ${$.MASTER}`), await m(`git checkout -b ${n} origin/${$.MASTER}`), await m(`git push -u origin ${n}`), process.exit(0);
1035
1044
  }
1036
1045
  const ct = (e) => `${q("ZenTaoDomain")}${e}`;
1037
1046
  async function fa() {
@@ -1061,7 +1070,7 @@ async function ga() {
1061
1070
  })) : [];
1062
1071
  }
1063
1072
  async function Fe(e) {
1064
- const t = await p("git diff HEAD");
1073
+ const t = await m("git diff HEAD");
1065
1074
  t || l("git暂存区没有内容,请先git add添加文件到暂存区");
1066
1075
  const i = await ia({
1067
1076
  type: "commit-message-v2",
@@ -1070,8 +1079,8 @@ async function Fe(e) {
1070
1079
  });
1071
1080
  return e + i;
1072
1081
  }
1073
- async function Ee(e, t, i) {
1074
- const n = w("🤖 生成提交信息中...").start();
1082
+ async function ke(e, t, i) {
1083
+ const n = y("🤖 生成提交信息中...").start();
1075
1084
  let a = "", s = !0;
1076
1085
  if ([j.FEAT, j.FIX, j.REFACTOR].includes(e)) {
1077
1086
  const o = t.map((r) => r.value).join(",");
@@ -1117,7 +1126,7 @@ async function ha(e) {
1117
1126
  })),
1118
1127
  pageSize: i.length
1119
1128
  });
1120
- await Ee(j.FEAT, n, e);
1129
+ await ke(j.FEAT, n, e);
1121
1130
  }
1122
1131
  if (t === j.FIX) {
1123
1132
  const i = await ga();
@@ -1132,36 +1141,36 @@ async function ha(e) {
1132
1141
  })),
1133
1142
  pageSize: i.length
1134
1143
  });
1135
- await Ee(j.FIX, n, e);
1144
+ await ke(j.FIX, n, e);
1136
1145
  }
1137
1146
  if (t === j.CHORE) {
1138
1147
  let i = "";
1139
1148
  e && (i = await F({
1140
1149
  message: "请输入commit msg:",
1141
1150
  validate: (n) => n.length === 0 ? "请输入commit msg" : !0
1142
- }), i = i.trim()), await Ee(j.CHORE, i);
1151
+ }), i = i.trim()), await ke(j.CHORE, i);
1143
1152
  }
1144
1153
  process.exit(0);
1145
1154
  }
1146
1155
  async function wa() {
1147
1156
  try {
1148
1157
  const e = {}, t = async () => {
1149
- const O = Qe(), { projects: te } = await hi(), H = te.map((re) => {
1150
- const Oe = {
1158
+ const P = Qe(), { projects: te } = await hi(), H = te.map((re) => {
1159
+ const Pe = {
1151
1160
  name: `${re.name} [${re.desc}]`,
1152
1161
  value: re.name,
1153
1162
  disabled: !1
1154
1163
  };
1155
- return O.includes(re.name) && (Oe.disabled = "目录下已存在同名文件夹"), Oe;
1164
+ return P.includes(re.name) && (Pe.disabled = "目录下已存在同名文件夹"), Pe;
1156
1165
  }), yt = await T({
1157
1166
  message: "请选择一个项目模板",
1158
1167
  choices: H
1159
1168
  }), Te = te.find((re) => re.name === yt);
1160
1169
  e.tplName = Te.name, e.tplUrl = Te.url, e.tplLanguage = Te.language;
1161
1170
  }, i = async () => {
1162
- const { groups: O } = Oi(), te = await T({
1171
+ const { groups: P } = Pi(), te = await T({
1163
1172
  message: "请选择一个分组",
1164
- choices: O.map((H) => ({
1173
+ choices: P.map((H) => ({
1165
1174
  name: `${H.name} [${H.description}]`,
1166
1175
  value: H.id,
1167
1176
  short: H.name
@@ -1169,20 +1178,20 @@ async function wa() {
1169
1178
  });
1170
1179
  e.group = {
1171
1180
  id: te,
1172
- name: O.find((H) => H.id === te)?.name
1181
+ name: P.find((H) => H.id === te)?.name
1173
1182
  };
1174
1183
  }, n = async () => {
1175
1184
  e.projectName = await F({
1176
1185
  message: "请输入项目名称",
1177
- validate: (O) => la(O, e.group?.name || "")
1186
+ validate: (P) => la(P, e.group?.name || "")
1178
1187
  }), e.projectName = e.projectName.trim(), e.projectDesc = await F({
1179
1188
  message: "请输入项目描述",
1180
- validate: pa
1189
+ validate: ma
1181
1190
  }), e.projectDesc = e.projectDesc.trim();
1182
1191
  };
1183
1192
  await t(), await i(), await n();
1184
- const a = `${fe}/${e.group?.name}/${e.projectName}.git`, s = w("模版初始化中").start();
1185
- await p(`git clone --depth=1 ${e.tplUrl}`), await _e(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")}`);
1193
+ const a = `${fe}/${e.group?.name}/${e.projectName}.git`, s = y("模版初始化中").start();
1194
+ await m(`git clone --depth=1 ${e.tplUrl}`), await _e(e.tplName, e.projectName), O.cd(e.projectName), O.rm("-rf", ".git"), await m(`git init --initial-branch=${$.MASTER}`), await m(`git remote add origin ${a}`), await m(`git config user.name ${E("gitName")}`), await m(`git config user.email ${E("gitEmail")}`);
1186
1195
  const o = Ae();
1187
1196
  li({
1188
1197
  ...o,
@@ -1192,31 +1201,31 @@ async function wa() {
1192
1201
  ...o.scripts,
1193
1202
  prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
1194
1203
  }
1195
- }), await I.writeFile(m.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await xe(e.tplLanguage, e.group?.name);
1196
- const r = w("依赖安装中").start();
1197
- await p("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
1198
- const c = w("项目推送中").start();
1199
- await p('git add . && git commit -m "chore: 项目初始化"'), await p("git tag v0.0.1");
1200
- const u = await ki({
1204
+ }), await I.writeFile(p.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await xe(e.tplLanguage, e.group?.name);
1205
+ const r = y("依赖安装中").start();
1206
+ await m("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
1207
+ const c = y("项目推送中").start();
1208
+ await m('git add . && git commit -m "chore: 项目初始化"'), await m("git tag v0.0.1");
1209
+ const u = await Ei({
1201
1210
  name: e.projectName,
1202
1211
  description: e.projectDesc,
1203
1212
  path: e.projectName,
1204
1213
  visibility: "private",
1205
1214
  namespace_id: e.group?.id
1206
1215
  });
1207
- await p(`git push -u origin ${y.MASTER}`), await p(`git push origin HEAD:${y.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${S.blue(a)}`);
1208
- const d = w("初始化分支中").start(), f = `feat_init_${tt()}`, g = [y.DEV, y.TEST, y.RELEASE, f], h = await Promise.allSettled(
1216
+ await m(`git push -u origin ${$.MASTER}`), await m(`git push origin HEAD:${$.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${S.blue(a)}`);
1217
+ const d = y("初始化分支中").start(), f = `feat_init_${tt()}`, g = [$.DEV, $.TEST, $.RELEASE, f], h = await Promise.allSettled(
1209
1218
  g.map(
1210
- (O) => Li({
1219
+ (P) => Li({
1211
1220
  id: u.id,
1212
- branch: O,
1213
- ref: y.MASTER
1221
+ branch: P,
1222
+ ref: $.MASTER
1214
1223
  })
1215
1224
  )
1216
- ), E = [];
1217
- h.forEach(({ status: O }, te) => {
1218
- O === "fulfilled" && E.push(g[te]);
1219
- }), await p("git pull"), E.includes(f) ? (await p(`git checkout -b ${f} origin/${f}`), d.succeed(`项目已切换到初始分支: ${S.blue(f)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
1225
+ ), k = [];
1226
+ h.forEach(({ status: P }, te) => {
1227
+ P === "fulfilled" && k.push(g[te]);
1228
+ }), await m("git pull"), k.includes(f) ? (await m(`git checkout -b ${f} origin/${f}`), d.succeed(`项目已切换到初始分支: ${S.blue(f)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
1220
1229
  const ee = `cd ${e.projectName} && z start`;
1221
1230
  console.log(`输入 ${S.green(ee)} 开始开发吧~`), process.exit(0);
1222
1231
  } catch (e) {
@@ -1256,7 +1265,7 @@ async function ya(e, t) {
1256
1265
  /* Project */
1257
1266
  }
1258
1267
  ]
1259
- }), 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("没有要变动的文件,无法生成提交信息")));
1268
+ }), i === "project" ? await wa() : (ne(), Q(), i === "branch" ? (await me(), await da(t)) : i === "commit-msg" && (await m("git status -s") ? await ha(t.commitMessageCloseAi) : l("没有要变动的文件,无法生成提交信息")));
1260
1269
  }
1261
1270
  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));
1262
1271
  function $a(e) {
@@ -1267,7 +1276,7 @@ function $a(e) {
1267
1276
  });
1268
1277
  }
1269
1278
  async function va(e) {
1270
- const t = w("部署任务创建中").start(), { targetBranch: i, notify: n, projectName: a } = e, s = n ? [.../* @__PURE__ */ new Set([k("weWorkUserId"), ...n])] : [k("weWorkUserId")];
1279
+ const t = y("部署任务创建中").start(), { targetBranch: i, notify: n, projectName: a } = e, s = n ? [.../* @__PURE__ */ new Set([E("weWorkUserId"), ...n])] : [E("weWorkUserId")];
1271
1280
  try {
1272
1281
  const { metadata: o, spec: r } = await $a({
1273
1282
  projectName: a,
@@ -1293,20 +1302,20 @@ async function va(e) {
1293
1302
  }
1294
1303
  function Na(e, t) {
1295
1304
  const i = Ae();
1296
- if (me()?.repository?.url || l(".z/project.json中缺少repository.url"), t === G.H5) {
1305
+ if (pe()?.repository?.url || l(".z/project.json中缺少repository.url"), t === G.H5) {
1297
1306
  const a = `build:${e}`;
1298
1307
  i?.scripts[a] || l(`项目package.json文件scripts不存在命令${a}。`);
1299
1308
  }
1300
1309
  t === G.NPM && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。")), t === G.SERVER && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。"));
1301
1310
  }
1302
1311
  async function ut(e, t) {
1303
- ne(), Q(), await pe();
1312
+ ne(), Q(), await me();
1304
1313
  let i = e, n = t.platform;
1305
- const a = me();
1306
- 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({
1314
+ const a = pe();
1315
+ if (a.language === w.JAVA && (n = G.SERVER), i && !Object.values($).includes(i) && l("仅支持发布指定环境分支"), n && !Object.values(G).includes(n) && l("发布平台错误"), n || (n = await T({
1307
1316
  message: "请选择平台",
1308
- choices: Pt
1309
- })), n === G.NPM && (i = y.MASTER), !i) {
1317
+ choices: Ot
1318
+ })), n === G.NPM && (i = $.MASTER), !i) {
1310
1319
  const u = await T({
1311
1320
  message: "请选择部署环境",
1312
1321
  choices: qe
@@ -1314,9 +1323,9 @@ async function ut(e, t) {
1314
1323
  i = Zt(u);
1315
1324
  }
1316
1325
  let s = "";
1317
- a.language === $.JAVASCRIPT && (s = zt);
1326
+ a.language === w.JAVASCRIPT && (s = zt);
1318
1327
  let o = "";
1319
- if (a.language === $.JAVASCRIPT && (o = Ae().name), a.language === $.JAVA) {
1328
+ if (a.language === w.JAVASCRIPT && (o = Ae().name), a.language === w.JAVA) {
1320
1329
  const { projects: u } = await wi(), d = u.find(
1321
1330
  (f) => $e(f.url) === $e(a.repository.url)
1322
1331
  );
@@ -1341,7 +1350,7 @@ async function ut(e, t) {
1341
1350
  let r = [];
1342
1351
  t.skipSelectionNotification || (r = await ot("请选择部署成功要通知的人员:", () => !0, !0));
1343
1352
  let c = [];
1344
- if (t.skipGroupNotification || (c = await na("请选择部署成功要通知的群组:", () => !0, !0)), a.language === $.JAVASCRIPT) {
1353
+ if (t.skipGroupNotification || (c = await na("请选择部署成功要通知的群组:", () => !0, !0)), a.language === w.JAVASCRIPT) {
1345
1354
  const u = Ht(i);
1346
1355
  Na(u, n);
1347
1356
  }
@@ -1354,7 +1363,7 @@ async function ut(e, t) {
1354
1363
  });
1355
1364
  }
1356
1365
  async function lt(e, t, i, n) {
1357
- const a = w(`分支合并中,${e} -> ${t}`).start();
1366
+ const a = y(`分支合并中,${e} -> ${t}`).start();
1358
1367
  let s = 0;
1359
1368
  try {
1360
1369
  const { iid: r } = await Ri({
@@ -1363,7 +1372,7 @@ async function lt(e, t, i, n) {
1363
1372
  source_branch: e,
1364
1373
  target_branch: t,
1365
1374
  // 合到主分支上的分支需要在合并完成后被移除
1366
- remove_source_branch: n ? !1 : y.MASTER === t
1375
+ remove_source_branch: n ? !1 : $.MASTER === t
1367
1376
  });
1368
1377
  s = r;
1369
1378
  } catch (r) {
@@ -1402,14 +1411,14 @@ async function lt(e, t, i, n) {
1402
1411
  await o();
1403
1412
  }
1404
1413
  async function ba(e, t) {
1405
- 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(
1414
+ const i = `origin/${e.sourceBranch}`, n = await m(`git log -b origin/${$.MASTER} -1 --format=%H`), a = await m(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await m(
1406
1415
  `git log ${n}...${a} -b ${i}`
1407
1416
  );
1408
- if (s || l(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await p(
1417
+ if (s || l(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await m(
1409
1418
  `git branch --contains ${n} -r ${i}`
1410
- ) || (console.log(S.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt(y.MASTER, e.sourceBranch, e)), t === y.MASTER) {
1419
+ ) || (console.log(S.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt($.MASTER, e.sourceBranch, e)), t === $.MASTER) {
1411
1420
  const r = s.split(`
1412
- `).filter((f) => f), c = await p(`git log -b origin/${b.TEST} -1 --format=%H`), d = (await p(
1421
+ `).filter((f) => f), c = await m(`git log -b origin/${b.TEST} -1 --format=%H`), d = (await m(
1413
1422
  `git log ${n}...${c} -b origin/${b.TEST}`
1414
1423
  )).split(`
1415
1424
  `).filter((f) => f);
@@ -1417,12 +1426,12 @@ async function ba(e, t) {
1417
1426
  }
1418
1427
  }
1419
1428
  async function Aa(e, t) {
1420
- ne(), Q(), await pe();
1421
- const i = await pi();
1422
- Object.values(y).includes(i.sourceBranch) && l(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
1423
- const a = (await Pi(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
1429
+ ne(), Q(), await me();
1430
+ const i = await mi();
1431
+ Object.values($).includes(i.sourceBranch) && l(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
1432
+ const a = (await Oi(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
1424
1433
  let u = c.name;
1425
- return Object.values(y).includes(u) && (u = S.bold.blue(u)), {
1434
+ return Object.values($).includes(u) && (u = S.bold.blue(u)), {
1426
1435
  name: u,
1427
1436
  value: c.name
1428
1437
  };
@@ -1432,28 +1441,28 @@ async function Aa(e, t) {
1432
1441
  message: "请选择要合并到的目标分支:",
1433
1442
  choices: a
1434
1443
  });
1435
- const o = w(`本地分支${i.sourceBranch}检测中`).start();
1436
- if (await p(`git ls-remote --heads origin ${i.sourceBranch}`)) {
1437
- o.text = `存在远程分支origin/${i.sourceBranch}`, await p("git fetch");
1438
- const c = await p(`git rev-parse ${i.sourceBranch}`), u = await p(`git rev-parse origin/${i.sourceBranch}`);
1439
- 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(
1444
+ const o = y(`本地分支${i.sourceBranch}检测中`).start();
1445
+ if (await m(`git ls-remote --heads origin ${i.sourceBranch}`)) {
1446
+ o.text = `存在远程分支origin/${i.sourceBranch}`, await m("git fetch");
1447
+ const c = await m(`git rev-parse ${i.sourceBranch}`), u = await m(`git rev-parse origin/${i.sourceBranch}`);
1448
+ await m(`git merge-base ${u} HEAD`) === u ? (await m(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`)) : await m(`git merge-base ${c} ${u}`) === c ? (await m("git pull"), o.succeed(`本地分支${i.sourceBranch}已更新`)) : (o.fail(
1440
1449
  `远程分支origin/${i.sourceBranch}和本地分支${i.sourceBranch}都有新的提交,请手动合并后再试。`
1441
1450
  ), process.exit(1));
1442
1451
  } else
1443
- await p(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`);
1444
- 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(
1445
- `${i.sourceBranch}分支已移除,当前已切换到最新的${y.MASTER}。如需继续开发,请检出新分支(z c b)。`
1446
- )), Object.values(y).includes(s) && await ut(s, {
1452
+ await m(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`);
1453
+ await ba(i, s), await lt(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster), $.MASTER === s && !t.keepBranchAfterMergeMaster && (await m(`git checkout ${$.MASTER}`), await m(`git pull origin ${$.MASTER}`), await m(`git branch -d ${i.sourceBranch}`), V(
1454
+ `${i.sourceBranch}分支已移除,当前已切换到最新的${$.MASTER}。如需继续开发,请检出新分支(z c b)。`
1455
+ )), Object.values($).includes(s) && await ut(s, {
1447
1456
  platform: t.deployPlatform,
1448
1457
  skipSelectionNotification: t.deploySkipSelectionNotification,
1449
1458
  skipGroupNotification: t.skipGroupNotification
1450
1459
  });
1451
1460
  }
1452
1461
  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));
1453
- 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));
1462
+ D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values($).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));
1454
1463
  async function ja() {
1455
1464
  try {
1456
- await p("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
1465
+ await m("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
1457
1466
  silent: !1
1458
1467
  }), V("checkstyle执行完毕"), process.exit(0);
1459
1468
  } catch {
@@ -1461,14 +1470,14 @@ async function ja() {
1461
1470
  }
1462
1471
  }
1463
1472
  function Sa() {
1464
- const e = me();
1473
+ const e = pe();
1465
1474
  if (e["lint-staged"])
1466
1475
  return e["lint-staged"];
1467
1476
  throw new Error("未找到lint配置");
1468
1477
  }
1469
1478
  async function Ta() {
1470
- const e = w("代码风格检测中...").start();
1471
- await kt({
1479
+ const e = y("代码风格检测中...").start();
1480
+ await Et({
1472
1481
  concurrent: 4,
1473
1482
  debug: !1,
1474
1483
  config: Sa(),
@@ -1476,7 +1485,7 @@ async function Ta() {
1476
1485
  relative: !0
1477
1486
  }) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
1478
1487
  }
1479
- function Ea(e) {
1488
+ function ka(e) {
1480
1489
  if (e.includes("Merge") && e.includes("# Conflicts:") || Ct.valid(e))
1481
1490
  return !0;
1482
1491
  const t = e.split(": ");
@@ -1485,12 +1494,12 @@ function Ea(e) {
1485
1494
  const i = t[0];
1486
1495
  return /^(feat|fix|refactor)/.test(i) ? /\(\d+(?:,\d+)*\)/.test(i) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(i) ? [j.CHORE, j.CI].includes(i) ? !0 : "chore/ci类型无需填写ID。" : j.Break === i ? !0 : "不存在的提交类型。";
1487
1496
  }
1488
- async function ka() {
1489
- const e = await ke(m.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = w("提交信息格式校验中...").start(), i = Ea(e);
1497
+ async function Ea() {
1498
+ const e = await Ee(p.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), i = ka(e);
1490
1499
  i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
1491
1500
  }
1492
1501
  async function Ca() {
1493
- await pe();
1502
+ await me();
1494
1503
  const e = await Rt({
1495
1504
  // 分组,展示仓库链接
1496
1505
  format: ["group", "repo"],
@@ -1504,16 +1513,16 @@ async function Ca() {
1504
1513
  if (e && Object.keys(e).length) {
1505
1514
  V("升级完成 🎉");
1506
1515
  const t = Object.entries(e).map(([i, n]) => `${i}@${n}`).join("; ");
1507
- await p(`git add . && git commit -m "chore: 依赖升级。${t}"`);
1516
+ await m(`git add . && git commit -m "chore: 依赖升级。${t}"`);
1508
1517
  }
1509
1518
  process.exit(0);
1510
1519
  }
1511
1520
  async function Ra(e) {
1512
- v(m.resolve("node_modules", ".bin", "eslint")) || l("该项目未安装eslint,请安装后重试");
1513
- const t = w("eslint执行中...").start();
1521
+ v(p.resolve("node_modules", ".bin", "eslint")) || l("该项目未安装eslint,请安装后重试");
1522
+ const t = y("eslint执行中...").start();
1514
1523
  try {
1515
1524
  let i = "npx eslint '**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}' --fix";
1516
- 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, {
1525
+ 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 m(i, {
1517
1526
  silent: !1
1518
1527
  }), t.succeed("eslint执行成功"), process.exit(0);
1519
1528
  } catch {
@@ -1521,10 +1530,10 @@ async function Ra(e) {
1521
1530
  }
1522
1531
  }
1523
1532
  async function Ia() {
1524
- v(m.resolve("node_modules", ".bin", "prettier")) || l("该项目未安装prettier,请安装后重试");
1525
- const e = w("prettier执行中...").start();
1533
+ v(p.resolve("node_modules", ".bin", "prettier")) || l("该项目未安装prettier,请安装后重试");
1534
+ const e = y("prettier执行中...").start();
1526
1535
  try {
1527
- await p(
1536
+ await m(
1528
1537
  "npx prettier --write . --config .z/.prettierrc.json --ignore-path .z/.prettierignore --ignore-unknown --no-error-on-unmatched-pattern",
1529
1538
  {
1530
1539
  silent: !1
@@ -1535,11 +1544,11 @@ async function Ia() {
1535
1544
  }
1536
1545
  }
1537
1546
  function xa() {
1538
- v(m.resolve("./node_modules/.bin/vue-tsc")) || l("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), et("npx vue-tsc --build"), process.exit(0);
1547
+ v(p.resolve("./node_modules/.bin/vue-tsc")) || l("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), et("npx vue-tsc --build"), process.exit(0);
1539
1548
  }
1540
1549
  async function Da(e, t) {
1541
1550
  ne(), Q();
1542
- const i = me();
1551
+ const i = pe();
1543
1552
  let n;
1544
1553
  if (e)
1545
1554
  [
@@ -1579,11 +1588,11 @@ async function Da(e, t) {
1579
1588
  /* Prettier */
1580
1589
  }
1581
1590
  ];
1582
- i.language === $.JAVA && a.push({
1591
+ i.language === w.JAVA && a.push({
1583
1592
  name: "执行 check-style",
1584
1593
  value: "checkstyle"
1585
1594
  /* CheckStyle */
1586
- }), i.language === $.JAVASCRIPT && a.push(
1595
+ }), i.language === w.JAVASCRIPT && a.push(
1587
1596
  {
1588
1597
  name: "执行 eslint",
1589
1598
  value: "eslint"
@@ -1604,17 +1613,17 @@ async function Da(e, t) {
1604
1613
  choices: a
1605
1614
  });
1606
1615
  }
1607
- 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 ja();
1616
+ n === "commit-msg" ? await Ea() : n === "commit-files" ? await Ta() : n === "prettier" ? await Ia() : n === "eslint" && i.language === w.JAVASCRIPT ? await Ra(t) : n === "type-check" && i.language === w.JAVASCRIPT ? xa() : n === "dependency-check" && i.language === w.JAVASCRIPT ? await Ca() : n === "checkstyle" && i.language === w.JAVA && await ja();
1608
1617
  }
1609
1618
  D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle。").argument(
1610
1619
  "[type]",
1611
1620
  "非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs。"
1612
1621
  ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(Da, ...e));
1613
- async function pt(e = "latest") {
1614
- const t = w("安装中...").start();
1615
- 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);
1622
+ async function mt(e = "latest") {
1623
+ const t = y("安装中...").start();
1624
+ await m(`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);
1616
1625
  }
1617
- D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(pt, ...e));
1626
+ D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(mt, ...e));
1618
1627
  async function La(e) {
1619
1628
  let t = e;
1620
1629
  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({
@@ -1625,7 +1634,7 @@ async function La(e) {
1625
1634
  i.scripts[n] ? et(`npm run ${n}`) : l(`项目中(package.json > scripts)不存在命令${n},请先添加!`);
1626
1635
  }
1627
1636
  D.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(La, ...e));
1628
- const De = /Thumbs\.db|\.git|DS_Store|idea/, mt = "testcase";
1637
+ const De = /Thumbs\.db|\.git|DS_Store|idea/, pt = "testcase";
1629
1638
  function dt(e) {
1630
1639
  const t = e.match(/^(.*[^[])?\[(\d+)]$/);
1631
1640
  if (t && !e.startsWith("["))
@@ -1648,11 +1657,11 @@ function dt(e) {
1648
1657
  async function X(e, t = {}) {
1649
1658
  const { exclude: i = De } = t, n = [];
1650
1659
  async function a(s) {
1651
- const o = m.basename(s);
1660
+ const o = p.basename(s);
1652
1661
  if ((await At(s)).isFile())
1653
1662
  return null;
1654
1663
  const c = await Re(s, { withFileTypes: !0 }), u = (await Promise.all(
1655
- c.filter((E) => E.isDirectory() && !i.test(E.name)).map((E) => a(m.join(s, E.name)))
1664
+ c.filter((k) => k.isDirectory() && !i.test(k.name)).map((k) => a(p.join(s, k.name)))
1656
1665
  )).filter(Boolean), { type: d, id: f, displayName: g } = dt(o), h = {
1657
1666
  name: o,
1658
1667
  id: f,
@@ -1661,17 +1670,17 @@ async function X(e, t = {}) {
1661
1670
  type: d,
1662
1671
  children: u
1663
1672
  };
1664
- return (t.hasRoot || m.resolve(e) !== s) && n.push(h), h;
1673
+ return (t.hasRoot || p.resolve(e) !== s) && n.push(h), h;
1665
1674
  }
1666
- return await a(m.resolve(e)), n;
1675
+ return await a(p.resolve(e)), n;
1667
1676
  }
1668
1677
  async function ft(e, t = {}) {
1669
1678
  const { exclude: i = De } = t;
1670
1679
  try {
1671
- const n = await Re(m.resolve(e), { withFileTypes: !0 });
1680
+ const n = await Re(p.resolve(e), { withFileTypes: !0 });
1672
1681
  return await Promise.all(
1673
1682
  n.filter((a) => a.isDirectory() && !i.test(a.name)).map((a) => {
1674
- const s = m.join(e, a.name), { type: o, id: r, displayName: c } = dt(a.name);
1683
+ const s = p.join(e, a.name), { type: o, id: r, displayName: c } = dt(a.name);
1675
1684
  return {
1676
1685
  name: a.name,
1677
1686
  id: r,
@@ -1697,27 +1706,27 @@ function W(e, t, i) {
1697
1706
  }
1698
1707
  async function we(e, t, i, n) {
1699
1708
  try {
1700
- const a = m.basename(e), s = W(i, t, n);
1709
+ const a = p.basename(e), s = W(i, t, n);
1701
1710
  if (a === s)
1702
1711
  return !0;
1703
- const o = m.dirname(e), r = m.join(o, s);
1704
- return await Kt(e) ? await _e(e, r) : (await p(`git mv "${e}" "${r}"`), await p("git add .")), !0;
1712
+ const o = p.dirname(e), r = p.join(o, s);
1713
+ return await Kt(e) ? await _e(e, r) : (await m(`git mv "${e}" "${r}"`), await m("git add .")), !0;
1705
1714
  } catch (a) {
1706
1715
  return l(`重命名文件夹失败: ${e} -> ${t}。${a}`), !1;
1707
1716
  }
1708
1717
  }
1709
- async function Pa(e, t, i = {}) {
1718
+ async function Oa(e, t, i = {}) {
1710
1719
  const { exclude: n = De } = i;
1711
1720
  async function a(s, o) {
1712
1721
  if (!s || s.length === 0) return;
1713
1722
  const r = await ft(o, { exclude: n });
1714
1723
  for (const c of s) {
1715
1724
  const u = String(c.value), d = W("module", c.label, u), f = r.find((h) => h.id === u);
1716
- let g = f?.path || m.join(o, d);
1717
- 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);
1725
+ let g = f?.path || p.join(o, d);
1726
+ f ? f.displayName !== c.label && await we(f.path, c.label, "module", u) && (g = p.join(o, d)) : (await le(g, { recursive: !0 }), await m(`git add "${g}"`)), c.children && c.children.length > 0 && await a(c.children, g);
1718
1727
  }
1719
1728
  }
1720
- await a(e, m.resolve(t));
1729
+ await a(e, p.resolve(t));
1721
1730
  }
1722
1731
  async function gt(e) {
1723
1732
  const t = {
@@ -1737,10 +1746,10 @@ async function gt(e) {
1737
1746
  }))
1738
1747
  });
1739
1748
  }
1740
- return t.name = await Ji(t.id), t.path = m.join(mt, W("module", t.name, String(t.id))), t;
1749
+ return t.name = await Ji(t.id), t.path = p.join(pt, W("module", t.name, String(t.id))), t;
1741
1750
  }
1742
1751
  async function Le(e) {
1743
- return (await ft(mt)).find((i) => Number(i.id) === e.id);
1752
+ return (await ft(pt)).find((i) => Number(i.id) === e.id);
1744
1753
  }
1745
1754
  async function ht(e, t) {
1746
1755
  const i = {
@@ -1755,15 +1764,15 @@ async function ht(e, t) {
1755
1764
  async function wt(e, t) {
1756
1765
  await le(t, {
1757
1766
  recursive: !0
1758
- }), await ht(e, m.join(t, "config.json")), I.ensureFileSync(m.join(t, "data.yaml")), await L(
1759
- m.join(t, "data.yaml"),
1760
- v(m.resolve(K, "data.yaml")) ? await ke(m.resolve(K, "data.yaml")) : await bi()
1761
- ), I.ensureFileSync(m.join(t, "main.py")), await L(
1762
- m.join(t, "main.py"),
1763
- v(m.resolve(K, "main.py")) ? await ke(m.resolve(K, "main.py")) : await Ai()
1767
+ }), await ht(e, p.join(t, "config.json")), I.ensureFileSync(p.join(t, "data.yaml")), await L(
1768
+ p.join(t, "data.yaml"),
1769
+ v(p.resolve(K, "data.yaml")) ? await Ee(p.resolve(K, "data.yaml")) : await bi()
1770
+ ), I.ensureFileSync(p.join(t, "main.py")), await L(
1771
+ p.join(t, "main.py"),
1772
+ v(p.resolve(K, "main.py")) ? await Ee(p.resolve(K, "main.py")) : await Ai()
1764
1773
  );
1765
1774
  }
1766
- function Pe(e) {
1775
+ function Oe(e) {
1767
1776
  if (e) {
1768
1777
  const t = e.split(",").map((i) => i.trim()).filter((i) => {
1769
1778
  const n = Number(i);
@@ -1774,7 +1783,7 @@ function Pe(e) {
1774
1783
  return [];
1775
1784
  }
1776
1785
  async function je(e, t) {
1777
- ne(), Q(), await pe();
1786
+ ne(), Q(), await me();
1778
1787
  let i;
1779
1788
  t ? ([R.MODULE, R.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${R.MODULE} 或者 ${R.CASE}。`), i = t) : i = await T({
1780
1789
  message: `请选择要${e}的数据类型`,
@@ -1793,25 +1802,25 @@ async function Se(e) {
1793
1802
  localProduct: i
1794
1803
  };
1795
1804
  }
1796
- async function Oa(e, t, i) {
1805
+ async function Pa(e, t, i) {
1797
1806
  e.text = "查找本地产品目录...", await Le(t) || l(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
1798
- const a = Pe(i);
1807
+ const a = Oe(i);
1799
1808
  let s = await X(t.path);
1800
1809
  e.text = "获取远程用例列表...";
1801
1810
  const o = await Fi(t.id, a);
1802
1811
  e.text = "本地用例同步中...";
1803
1812
  for (const r of o) {
1804
1813
  let c;
1805
- if (r.module === 0 ? c = m.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", !c)
1814
+ if (r.module === 0 ? c = p.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", !c)
1806
1815
  return l(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
1807
1816
  const u = s.find(({ id: d }) => r.id === Number(d));
1808
1817
  if (u)
1809
- 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(
1818
+ 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 = p.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await ht(
1810
1819
  r,
1811
- m.join(c, W("case", r.title, String(r.id)), "config.json")
1820
+ p.join(c, W("case", r.title, String(r.id)), "config.json")
1812
1821
  );
1813
1822
  else {
1814
- const d = m.join(c, W("case", r.title, String(r.id)));
1823
+ const d = p.join(c, W("case", r.title, String(r.id)));
1815
1824
  await wt(r, d);
1816
1825
  }
1817
1826
  }
@@ -1819,16 +1828,16 @@ async function Oa(e, t, i) {
1819
1828
  async function Ma(e, t) {
1820
1829
  e.text = "本地产品目录查找中...";
1821
1830
  const i = await Le(t);
1822
- 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 = "获取远程模块列表...";
1831
+ 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 m("git add .")), e.text = "获取远程模块列表...";
1823
1832
  const n = await st(t.id);
1824
- e.text = "本地同步模块中...", await Pa(n || [], t.path);
1833
+ e.text = "本地同步模块中...", await Oa(n || [], t.path);
1825
1834
  }
1826
1835
  async function za(e, t) {
1827
- const { type: i, typeStr: n } = await je("拉取", e), a = await gt(t.productId), s = w(`${n}同步中...`).start();
1828
- 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")) {
1829
- const o = w("代码提交中...").start();
1836
+ const { type: i, typeStr: n } = await je("拉取", e), a = await gt(t.productId), s = y(`${n}同步中...`).start();
1837
+ if (R.MODULE === i && await Ma(s, a), R.CASE === i && await Pa(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await m("git status -s")) {
1838
+ const o = y("代码提交中...").start();
1830
1839
  try {
1831
- await p(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
1840
+ await m(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
1832
1841
  } catch (r) {
1833
1842
  o.fail(`提交失败,${r}`), process.exit(1);
1834
1843
  }
@@ -1840,15 +1849,15 @@ async function Ba(e, t, i) {
1840
1849
  message: "请输入你要创建的用例的前置条件(可不填)"
1841
1850
  });
1842
1851
  n = n.trim();
1843
- const a = w(`用例【${i}】开始创建...`).start();
1852
+ const a = y(`用例【${i}】开始创建...`).start();
1844
1853
  a.text = "远程用例创建中...";
1845
1854
  const s = await Gi({
1846
1855
  product: Number(e.id),
1847
1856
  // 如果父模块是产品根目录,parent=0
1848
- module: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
1857
+ module: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
1849
1858
  title: i,
1850
1859
  type: "interface",
1851
- openedBy: k("ldapAccount"),
1860
+ openedBy: E("ldapAccount"),
1852
1861
  precondition: n || ""
1853
1862
  });
1854
1863
  a.text = "远程用例步骤创建中...", await Vi({
@@ -1857,7 +1866,7 @@ async function Ba(e, t, i) {
1857
1866
  desc: "按照预期执行",
1858
1867
  expect: "正常执行,符合预期"
1859
1868
  }), a.text = "本地用例创建中...";
1860
- const o = m.join(t.path, W("case", i, String(s)));
1869
+ const o = p.join(t.path, W("case", i, String(s)));
1861
1870
  return v(o) ? V(`${o}已存在,请检查是否对应,本地不再创建。`) : (await wt(
1862
1871
  {
1863
1872
  id: s,
@@ -1868,16 +1877,16 @@ async function Ba(e, t, i) {
1868
1877
  ), a.succeed(`用例【[${o}】创建完成 🎉`), o);
1869
1878
  }
1870
1879
  async function Ja(e, t, i) {
1871
- const n = w(`模块【${i}】开始创建...`).start();
1880
+ const n = y(`模块【${i}】开始创建...`).start();
1872
1881
  n.text = "远程模块创建中...";
1873
1882
  const a = await Ui({
1874
1883
  root: Number(e.id),
1875
1884
  name: i,
1876
1885
  // 如果父模块是产品根目录,parent=0
1877
- parent: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
1886
+ parent: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
1878
1887
  });
1879
1888
  n.text = "本地模块创建中...";
1880
- const s = m.join(t.path, W("module", i, String(a)));
1889
+ const s = p.join(t.path, W("module", i, String(a)));
1881
1890
  if (v(s))
1882
1891
  return V(`${s}已存在,请检查是否对应,本地不再创建。`);
1883
1892
  await le(s, {
@@ -1920,11 +1929,11 @@ async function _a(e, t) {
1920
1929
  f = f.trim();
1921
1930
  let g = "";
1922
1931
  if (R.MODULE === i && await Ja(s, d, f), R.CASE === i && (g = await Ba(s, d, f)), !t.disableAutoCommit && R.CASE === i) {
1923
- const h = w("代码提交中...").start();
1932
+ const h = y("代码提交中...").start();
1924
1933
  try {
1925
- await p(`git add . && git commit -m "chore: 创建了用例${m.basename(g)}"`), h.succeed("代码已提交 ✅");
1926
- } catch (E) {
1927
- h.fail(`提交失败,${E}`), process.exit(1);
1934
+ await m(`git add . && git commit -m "chore: 创建了用例${p.basename(g)}"`), h.succeed("代码已提交 ✅");
1935
+ } catch (k) {
1936
+ h.fail(`提交失败,${k}`), process.exit(1);
1928
1937
  }
1929
1938
  }
1930
1939
  }
@@ -1943,7 +1952,7 @@ async function Ua(e, t) {
1943
1952
  id: Number(c.id),
1944
1953
  path: c.path
1945
1954
  },
1946
- name: c.path.replace(m.resolve(e.path), "")
1955
+ name: c.path.replace(p.resolve(e.path), "")
1947
1956
  }));
1948
1957
  a = await ae({
1949
1958
  message: "选择要删除的用例",
@@ -1955,13 +1964,13 @@ async function Ua(e, t) {
1955
1964
  }
1956
1965
  });
1957
1966
  }
1958
- const s = w("远程用例删除中...").start(), o = a.map((r) => r.id);
1967
+ const s = y("远程用例删除中...").start(), o = a.map((r) => r.id);
1959
1968
  await qi({
1960
1969
  product: Number(e.id),
1961
1970
  caseIds: o
1962
1971
  }), s.text = "本地用例删除中...";
1963
1972
  for (const r of a)
1964
- v(r.path) && P.rm("-rf", r.path);
1973
+ v(r.path) && O.rm("-rf", r.path);
1965
1974
  return s.succeed("用例删除完成"), o;
1966
1975
  }
1967
1976
  async function Ga(e, t) {
@@ -1978,7 +1987,7 @@ async function Ga(e, t) {
1978
1987
  id: Number(c.id),
1979
1988
  path: c.path
1980
1989
  },
1981
- name: c.path.replace(m.resolve(e.path), "")
1990
+ name: c.path.replace(p.resolve(e.path), "")
1982
1991
  }));
1983
1992
  a = await ae({
1984
1993
  message: "选择要删除的模块",
@@ -1991,22 +2000,22 @@ async function Ga(e, t) {
1991
2000
  });
1992
2001
  }
1993
2002
  a = a.sort((r, c) => r.path.localeCompare(c.path));
1994
- const s = w("远程模块删除中...").start(), o = a.map((r) => r.id);
2003
+ const s = y("远程模块删除中...").start(), o = a.map((r) => r.id);
1995
2004
  await Wi({
1996
2005
  product: Number(e.id),
1997
2006
  moduleIds: o
1998
2007
  }), s.text = "本地模块删除中...";
1999
2008
  for (const r of a)
2000
- v(r.path) && P.rm("-rf", r.path);
2009
+ v(r.path) && O.rm("-rf", r.path);
2001
2010
  return s.succeed("模块删除完成"), o;
2002
2011
  }
2003
2012
  async function Va(e, t) {
2004
- const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await Se(t.productId), s = Pe(t.targetIds);
2013
+ const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await Se(t.productId), s = Oe(t.targetIds);
2005
2014
  let o = [];
2006
- if (R.MODULE === i ? o = await Ga(a, s) : R.CASE === i && (o = await Ua(a, s)), !t.disableAutoCommit && await p("git status -s")) {
2007
- const r = w("代码提交中...").start();
2015
+ if (R.MODULE === i ? o = await Ga(a, s) : R.CASE === i && (o = await Ua(a, s)), !t.disableAutoCommit && await m("git status -s")) {
2016
+ const r = y("代码提交中...").start();
2008
2017
  try {
2009
- await p(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
2018
+ await m(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
2010
2019
  } catch (c) {
2011
2020
  r.fail(`提交失败,${c}`), process.exit(1);
2012
2021
  }
@@ -2026,14 +2035,14 @@ async function Wa(e, t) {
2026
2035
  path: h.path,
2027
2036
  displayName: h.displayName
2028
2037
  },
2029
- name: h.path.replace(m.resolve(e.path), "")
2038
+ name: h.path.replace(p.resolve(e.path), "")
2030
2039
  }));
2031
2040
  [a] = await ae({
2032
2041
  message: "选择要更新的用例",
2033
2042
  pageSize: 100,
2034
2043
  loop: !1,
2035
2044
  multiple: void 0,
2036
- options: (h) => h ? g.filter((E) => E.name.includes(h)) : g,
2045
+ options: (h) => h ? g.filter((k) => k.name.includes(h)) : g,
2037
2046
  validate(h) {
2038
2047
  return h.length > 1 ? "只能选一个" : h.length < 1 ? "请选一个" : !0;
2039
2048
  }
@@ -2047,12 +2056,12 @@ async function Wa(e, t) {
2047
2056
  prefill: "editable"
2048
2057
  });
2049
2058
  s = s.trim();
2050
- const o = w("用例重命名中...").start();
2059
+ const o = y("用例重命名中...").start();
2051
2060
  s !== a.displayName ? (await Zi({
2052
2061
  id: Number(a.id),
2053
2062
  name: s
2054
- }), 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("用例名称无变动");
2055
- let r = I.readJsonSync(m.join(a.path, "config.json")), c;
2063
+ }), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path = p.join(p.dirname(a.path), W("case", s, String(a.id)))) : o.succeed("用例名称无变动");
2064
+ let r = I.readJsonSync(p.join(a.path, "config.json")), c;
2056
2065
  t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await ze({
2057
2066
  message: "修改用例优先级",
2058
2067
  min: 1,
@@ -2068,30 +2077,30 @@ async function Wa(e, t) {
2068
2077
  default: r.priority,
2069
2078
  validate: (g) => g > 0 && g < 6
2070
2079
  });
2071
- const u = w("用例优先级设置中...").start();
2080
+ const u = y("用例优先级设置中...").start();
2072
2081
  c !== r.priority ? (await Ki({
2073
2082
  id: Number(a.id),
2074
2083
  priority: c
2075
2084
  }), I.writeJSONSync(
2076
- m.join(a.path, "config.json"),
2085
+ p.join(a.path, "config.json"),
2077
2086
  {
2078
2087
  ...r,
2079
2088
  priority: c
2080
2089
  },
2081
2090
  { spaces: 2 }
2082
- ), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = I.readJsonSync(m.join(a.path, "config.json"));
2091
+ ), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = I.readJsonSync(p.join(a.path, "config.json"));
2083
2092
  let d;
2084
2093
  t.casePrecondition ? d = t.casePrecondition : (d = await F({
2085
2094
  message: "修改用例前置条件",
2086
2095
  default: r.precondition,
2087
2096
  prefill: "editable"
2088
2097
  }), d = d.trim());
2089
- const f = w("用例前置条件设置中...").start();
2098
+ const f = y("用例前置条件设置中...").start();
2090
2099
  return d !== r.precondition ? (await Yi({
2091
2100
  id: Number(a.id),
2092
2101
  precondition: d
2093
2102
  }), I.writeJSONSync(
2094
- m.join(a.path, "config.json"),
2103
+ p.join(a.path, "config.json"),
2095
2104
  {
2096
2105
  ...r,
2097
2106
  precondition: d
@@ -2112,7 +2121,7 @@ async function qa(e, t) {
2112
2121
  path: c.path,
2113
2122
  displayName: c.displayName
2114
2123
  },
2115
- name: c.path.replace(m.resolve(e.path), "")
2124
+ name: c.path.replace(p.resolve(e.path), "")
2116
2125
  }));
2117
2126
  [a] = await ae({
2118
2127
  message: "选择要更新的模块",
@@ -2133,7 +2142,7 @@ async function qa(e, t) {
2133
2142
  prefill: "editable"
2134
2143
  });
2135
2144
  s = s.trim();
2136
- const o = w("模块重命名中...").start();
2145
+ const o = y("模块重命名中...").start();
2137
2146
  return s !== a.displayName ? (await Hi({
2138
2147
  id: Number(a.id),
2139
2148
  name: s
@@ -2142,10 +2151,10 @@ async function qa(e, t) {
2142
2151
  async function Ha(e, t) {
2143
2152
  const { type: i, typeStr: n } = await je("修改", e), { localProduct: a } = await Se(t.productId);
2144
2153
  let s;
2145
- if (R.MODULE === i ? s = await qa(a, t) : R.CASE === i && (s = await Wa(a, t)), !t.disableAutoCommit && await p("git status -s")) {
2146
- const o = w("代码提交中...").start();
2154
+ if (R.MODULE === i ? s = await qa(a, t) : R.CASE === i && (s = await Wa(a, t)), !t.disableAutoCommit && await m("git status -s")) {
2155
+ const o = y("代码提交中...").start();
2147
2156
  try {
2148
- await p(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
2157
+ await m(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
2149
2158
  } catch (r) {
2150
2159
  o.fail(`提交失败,${r}`), process.exit(1);
2151
2160
  }
@@ -2158,7 +2167,7 @@ async function Za(e, t) {
2158
2167
  const i = It(20), n = e.map(
2159
2168
  (a) => i(async () => {
2160
2169
  try {
2161
- const s = t.env || "production", o = await p(`python ${a.path}/main.py --env ${s}`);
2170
+ const s = t.env || "production", o = await m(`python ${a.path}/main.py --env ${s}`);
2162
2171
  try {
2163
2172
  a.result = JSON.parse(o);
2164
2173
  } catch {
@@ -2184,7 +2193,7 @@ async function Ka(e) {
2184
2193
  displayName: c.displayName
2185
2194
  }));
2186
2195
  else {
2187
- const c = Pe(e.caseIds);
2196
+ const c = Oe(e.caseIds);
2188
2197
  if (c.length)
2189
2198
  i = a.filter((u) => c.includes(Number(u.id))).map((u) => ({
2190
2199
  id: Number(u.id),
@@ -2198,7 +2207,7 @@ async function Ka(e) {
2198
2207
  path: d.path,
2199
2208
  displayName: d.displayName
2200
2209
  },
2201
- name: d.path.replace(m.resolve(t.path), "")
2210
+ name: d.path.replace(p.resolve(t.path), "")
2202
2211
  }));
2203
2212
  i = await ae({
2204
2213
  message: "选择要执行的用例",
@@ -2211,7 +2220,7 @@ async function Ka(e) {
2211
2220
  });
2212
2221
  }
2213
2222
  }
2214
- const s = w("用例执行中...").start(), r = (await Za(i, e)).filter((c) => c.result.length);
2223
+ const s = y("用例执行中...").start(), r = (await Za(i, e)).filter((c) => c.result.length);
2215
2224
  if (r.length === 0)
2216
2225
  s.succeed("所有用例执行通过 🎉");
2217
2226
  else {
@@ -2225,11 +2234,11 @@ async function Ka(e) {
2225
2234
  else {
2226
2235
  const f = await Qi(), g = await T({
2227
2236
  message: "请选择用例执行出错后,BUG所属的项目",
2228
- choices: f.map(({ id: E, name: ee }) => ({ name: ee, value: E }))
2237
+ choices: f.map(({ id: k, name: ee }) => ({ name: ee, value: k }))
2229
2238
  }), h = await ea(g);
2230
2239
  u = await T({
2231
2240
  message: "请选择用例执行出错后,BUG所属的执行",
2232
- choices: h.map(({ id: E, name: ee }) => ({ name: ee, value: E }))
2241
+ choices: h.map(({ id: k, name: ee }) => ({ name: ee, value: k }))
2233
2242
  });
2234
2243
  }
2235
2244
  let d;
@@ -2241,9 +2250,9 @@ async function Ka(e) {
2241
2250
  const g = await Ce({
2242
2251
  message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
2243
2252
  required: !1,
2244
- choices: f.map(({ id: h, name: E, date: ee, builder: O }) => ({
2253
+ choices: f.map(({ id: h, name: k, date: ee, builder: P }) => ({
2245
2254
  value: h,
2246
- name: `${E} ${O} ${ee}`
2255
+ name: `${k} ${P} ${ee}`
2247
2256
  }))
2248
2257
  });
2249
2258
  g.length ? d = g.join(",") : d = "";
@@ -2256,7 +2265,7 @@ async function Ka(e) {
2256
2265
  caseId: f.id,
2257
2266
  caseResult: "fail",
2258
2267
  stepResults: f.result,
2259
- runner: k("ldapAccount"),
2268
+ runner: E("ldapAccount"),
2260
2269
  executionId: u,
2261
2270
  openedBuild: d
2262
2271
  });
@@ -2269,7 +2278,7 @@ D.command("qa-exec").alias("qe").description("执行用例").option("--product-i
2269
2278
  function Ya() {
2270
2279
  process.on("unhandledRejection", (e) => {
2271
2280
  }), process.on("uncaughtException", (e) => {
2272
- }), P.config.fatal = !0, P.config.silent = !0, P.config.verbose = !1;
2281
+ }), O.config.fatal = !0, O.config.silent = !0, O.config.verbose = !1;
2273
2282
  }
2274
2283
  async function Xa() {
2275
2284
  const e = ge("latestCheckVersionTimestamp"), t = ge("versionCheckDuring");
@@ -2283,8 +2292,8 @@ async function Xa() {
2283
2292
  });
2284
2293
  n = await Promise.race([
2285
2294
  s,
2286
- p(`npm view ${ie.name} version --registry https://registry.npmmirror.com/`)
2287
- ]), n !== a && n !== ie.version && (console.log(`${S.blue(ie.name)}本地版本为${ie.version},低于线上版本${n},开始升级`), await pt(n)), ue("latestCheckVersionTimestamp", Date.now()), se();
2295
+ m(`npm view ${ie.name} version --registry https://registry.npmmirror.com/`)
2296
+ ]), n !== a && n !== ie.version && (console.log(`${S.blue(ie.name)}本地版本为${ie.version},低于线上版本${n},开始升级`), await mt(n)), ue("latestCheckVersionTimestamp", Date.now()), se();
2288
2297
  } catch (a) {
2289
2298
  console.log("升级出错!请重试,或者手动升级"), l(a);
2290
2299
  }