cli-z-develop 0.10.2 → 0.10.4

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