cli-z-develop 0.14.0 → 0.14.1

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 +101 -99
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { program as D } from "commander";
2
2
  import $t from "node:child_process";
3
3
  import { existsSync as $, readdirSync as Nt, lstatSync as bt, createWriteStream as At } from "node:fs";
4
- import { readdir as Ce, mkdir as pe, writeFile as L, rename as Fe, readFile as Ee, stat as jt } from "node:fs/promises";
4
+ import { readdir as Re, mkdir as pe, writeFile as L, rename as _e, readFile as Ce, stat as jt } from "node:fs/promises";
5
5
  import p from "node:path";
6
6
  import le, { AxiosError as St } from "axios";
7
7
  import S from "chalk";
8
8
  import kt from "dayjs";
9
9
  import P from "shelljs";
10
10
  import Tt from "node:os";
11
- import Me from "child_process";
12
- import { confirm as _e, select as b, input as B, password as Et, checkbox as ve, number as ze } from "@inquirer/prompts";
11
+ import ze from "child_process";
12
+ import { confirm as Ge, select as b, input as B, password as Et, checkbox as ve, number as Je } from "@inquirer/prompts";
13
13
  import y from "ora";
14
14
  import I from "fs-extra";
15
15
  import { select as ne } from "inquirer-select-pro";
@@ -18,9 +18,9 @@ import Rt from "semver";
18
18
  import { run as It } from "npm-check-updates";
19
19
  import xt from "p-limit";
20
20
  import Dt from "minimist";
21
- const Ge = "dev", We = "test", Ve = "release", Lt = "production", Pt = "master";
22
- var C = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = We] = "TEST", e[e.RELEASE = Ve] = "RELEASE", e[e.PROD = Lt] = "PROD", e))(C || {}), v = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = We] = "TEST", e[e.RELEASE = Ve] = "RELEASE", e[e.MASTER = Pt] = "MASTER", e))(v || {}), W = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(W || {});
23
- const qe = [
21
+ const We = "dev", Ve = "test", qe = "release", Lt = "production", Pt = "master";
22
+ var C = /* @__PURE__ */ ((e) => (e[e.DEV = We] = "DEV", e[e.TEST = Ve] = "TEST", e[e.RELEASE = qe] = "RELEASE", e[e.PROD = Lt] = "PROD", e))(C || {}), v = /* @__PURE__ */ ((e) => (e[e.DEV = We] = "DEV", e[e.TEST = Ve] = "TEST", e[e.RELEASE = qe] = "RELEASE", e[e.MASTER = Pt] = "MASTER", e))(v || {}), W = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(W || {});
23
+ const He = [
24
24
  {
25
25
  name: `开发环境 - ${C.DEV}`,
26
26
  value: C.DEV
@@ -67,7 +67,7 @@ const Mt = {
67
67
  9: "其他"
68
68
  }, fe = "http://git.cxlqd.com", zt = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
69
69
  var j = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(j || {});
70
- const Jt = "fe-biz7tvsd", He = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
70
+ const Jt = "fe-biz7tvsd", Ke = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
71
71
  var R = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(R || {});
72
72
  const Ut = [
73
73
  {
@@ -84,14 +84,14 @@ const Ut = [
84
84
  function E(e = "") {
85
85
  return p.join(Y, e);
86
86
  }
87
- function Ke() {
87
+ function Ze() {
88
88
  return E(Gt);
89
89
  }
90
90
  function Ne() {
91
91
  return E(_t);
92
92
  }
93
- function Ze() {
94
- Me.spawnSync("git", ["config", "core.hooksPath", E()]), Me.spawnSync("git", ["config", "commit.template", Ne()]);
93
+ function Ye() {
94
+ ze.spawnSync("git", ["config", "core.hooksPath", E()]), ze.spawnSync("git", ["config", "commit.template", Ne()]);
95
95
  }
96
96
  function he(e = "") {
97
97
  return p.resolve(Tt.homedir(), Bt, e);
@@ -102,7 +102,7 @@ function be() {
102
102
  function Wt() {
103
103
  return $(he());
104
104
  }
105
- function Ye() {
105
+ function Xe() {
106
106
  return Wt() && $(be());
107
107
  }
108
108
  function X(e) {
@@ -116,25 +116,25 @@ function X(e) {
116
116
  }
117
117
  return encodeURIComponent(t.replace(/\.git$/, ""));
118
118
  }
119
- const { red: Je, green: Vt, blue: Tn, magenta: qt, yellow: En } = S;
119
+ const { red: Ue, green: Vt, blue: Tn, magenta: qt, yellow: En } = S;
120
120
  function ye(...e) {
121
121
  }
122
122
  function V(...e) {
123
123
  console.log(Vt(...e));
124
124
  }
125
- function Xe(e) {
125
+ function Qe(e) {
126
126
  e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(S.cyan(" 👋 下次见~")), console.log(), process.exit(1));
127
127
  }
128
128
  function l(e, t = !1) {
129
- Xe(e);
129
+ Qe(e);
130
130
  let i = e;
131
- e instanceof Error ? (i = e.message, le.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(Je(i)), console.log(qt(e.stack))) : console.log(Je(e)), t || process.exit(1);
131
+ e instanceof Error ? (i = e.message, le.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(Ue(i)), console.log(qt(e.stack))) : console.log(Ue(e)), t || process.exit(1);
132
132
  }
133
- function Ue(e) {
133
+ function Be(e) {
134
134
  return $(e) ? bt(e).isDirectory() : !1;
135
135
  }
136
- function Qe(e = process.cwd()) {
137
- return Ue(e) ? Nt(e).filter((i) => Ue(p.resolve(e, i))) : [];
136
+ function et(e = process.cwd()) {
137
+ return Be(e) ? Nt(e).filter((i) => Be(p.resolve(e, i))) : [];
138
138
  }
139
139
  async function m(e, t = {
140
140
  removeTailLinkBreak: !0,
@@ -157,7 +157,7 @@ function Ht(e) {
157
157
  stdio: "inherit"
158
158
  });
159
159
  }
160
- function et() {
160
+ function tt() {
161
161
  return kt(Date.now()).format("YYMMDD");
162
162
  }
163
163
  function Kt(e, t) {
@@ -185,11 +185,11 @@ async function z(e, ...t) {
185
185
  try {
186
186
  await e(...t);
187
187
  } catch (i) {
188
- throw Xe(i), i;
188
+ throw Qe(i), i;
189
189
  }
190
190
  }
191
191
  async function Xt(e) {
192
- return (await Ce(e)).length === 0;
192
+ return (await Re(e)).length === 0;
193
193
  }
194
194
  function Qt(e = "项目中文名", t = "项目描述") {
195
195
  return `
@@ -266,7 +266,7 @@ const ei = {
266
266
  "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
267
267
  "**/*.md": "markdownlint --fix"
268
268
  }
269
- }, ti = "cli-z-develop", ii = "0.14.0", ai = "技术团队开发流程管理工具", ni = "dist/index.js", si = { z: "bin/z.js", "z-develop": "bin/z.js" }, ri = { 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" }, oi = "module", ci = "z", ui = { "@lonely9/eslint-config-team": "^1.3.8", "@tsconfig/node22": "^22.0.5", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.9", "@types/minimist": "^1.2.5", "@types/node": "^22.15.29", "@types/semver": "^7.7.1", "@types/shelljs": "^0.10.0", "@typescript-eslint/eslint-plugin": "^8.58.2", "@typescript-eslint/parser": "^8.58.2", eslint: "^9.39.2", jiti: "^2.6.1", prettier: "^3.8.2", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.2.6" }, li = { "@inquirer/prompts": "^8.4.1", axios: "^1.15.0", chalk: "^5.6.2", commander: "^14.0.3", dayjs: "^1.11.20", "fs-extra": "^11.3.4", "inquirer-select-pro": "^1.0.0-alpha.9", "lint-staged": "^16.4.0", minimist: "^1.2.8", "npm-check-updates": "^19.3.1", ora: "^9.3.0", "p-limit": "^7.3.0", semver: "^7.7.4", shelljs: "^0.10.0" }, ae = {
269
+ }, ti = "cli-z-develop", ii = "0.14.1", ai = "技术团队开发流程管理工具", ni = "dist/index.js", si = { z: "bin/z.js", "z-develop": "bin/z.js" }, ri = { 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" }, oi = "module", ci = "z", ui = { "@lonely9/eslint-config-team": "^1.3.8", "@tsconfig/node22": "^22.0.5", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.9", "@types/minimist": "^1.2.5", "@types/node": "^22.15.29", "@types/semver": "^7.7.1", "@types/shelljs": "^0.10.0", "@typescript-eslint/eslint-plugin": "^8.58.2", "@typescript-eslint/parser": "^8.58.2", eslint: "^9.39.2", jiti: "^2.6.1", prettier: "^3.8.2", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.2.6" }, li = { "@inquirer/prompts": "^8.4.1", axios: "^1.15.0", chalk: "^5.6.2", commander: "^14.0.3", dayjs: "^1.11.20", "fs-extra": "^11.3.4", "inquirer-select-pro": "^1.0.0-alpha.9", "lint-staged": "^16.4.0", minimist: "^1.2.8", "npm-check-updates": "^19.3.1", ora: "^9.3.0", "p-limit": "^7.3.0", semver: "^7.7.4", shelljs: "^0.10.0" }, ae = {
270
270
  name: ti,
271
271
  version: ii,
272
272
  description: ai,
@@ -321,7 +321,7 @@ function F(e) {
321
321
  return e ? x.constants[e] : x.constants;
322
322
  }
323
323
  let _ = null, G = null;
324
- function Re() {
324
+ function Ie() {
325
325
  if (_)
326
326
  return _;
327
327
  const e = p.join("package.json");
@@ -330,16 +330,16 @@ function Re() {
330
330
  function se() {
331
331
  if (G)
332
332
  return G;
333
- const e = Ke();
333
+ const e = Ze();
334
334
  return $(e) || l(
335
335
  `当前目录(${P.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
336
336
  ), G = I.readJsonSync(e), G;
337
337
  }
338
- function tt(e) {
338
+ function it(e) {
339
339
  G ? G = {
340
340
  ...G,
341
341
  ...e
342
- } : G = e, I.writeJSONSync(Ke(), G, { spaces: 2 });
342
+ } : G = e, I.writeJSONSync(Ze(), G, { spaces: 2 });
343
343
  }
344
344
  function mi(e) {
345
345
  _ ? _ = {
@@ -383,7 +383,7 @@ function M(e, t) {
383
383
  ...e
384
384
  };
385
385
  }
386
- function Ie(e, t) {
386
+ function je(e, t) {
387
387
  x.constants = {
388
388
  ...x.constants,
389
389
  ...e
@@ -499,14 +499,14 @@ async function gi() {
499
499
  return M("k8sToken", i), re(), i;
500
500
  }
501
501
  }
502
- async function it(e) {
502
+ async function at(e) {
503
503
  const t = await oe({
504
504
  ...e,
505
505
  headers: {
506
506
  Authorization: await gi()
507
507
  }
508
508
  });
509
- return t.code === 401 ? (M("k8sToken", ""), it({
509
+ return t.code === 401 ? (M("k8sToken", ""), at({
510
510
  ...e
511
511
  })) : t;
512
512
  }
@@ -533,12 +533,12 @@ function wi() {
533
533
  url: U("src/data/template-projects.json")
534
534
  });
535
535
  }
536
- function at() {
536
+ function nt() {
537
537
  return N({
538
538
  url: U("src/data/java-project-module.json")
539
539
  });
540
540
  }
541
- function nt() {
541
+ function xe() {
542
542
  return N({
543
543
  url: U("src/data/z-develop-config.json")
544
544
  });
@@ -869,7 +869,7 @@ async function na(e, t, i) {
869
869
  }
870
870
  async function sa() {
871
871
  try {
872
- Ye() && (await _e({
872
+ Xe() && (await Ge({
873
873
  message: "系统中已存在z的配置文件,确认重新配置?"
874
874
  }) ? P.rm("-rf", be()) : process.exit(0)), await pe(he(), { recursive: !0 });
875
875
  const t = await b({
@@ -898,8 +898,8 @@ async function sa() {
898
898
  mask: !0
899
899
  });
900
900
  n = n.trim(), M("jobType", t), M("ldapAccount", i), M("ldapPassword", n);
901
- const a = await nt();
902
- Ie(a);
901
+ const a = await xe();
902
+ je(a);
903
903
  const s = await ot(), o = await ct("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((u) => u.value === o[0]);
904
904
  M({
905
905
  weWorkName: r,
@@ -941,7 +941,7 @@ z run commit-files`, { mode: 493 });
941
941
  mode: 493
942
942
  });
943
943
  }
944
- Ze();
944
+ Ye();
945
945
  }
946
946
  async function oa(e, t) {
947
947
  const i = await m("git remote get-url --push origin");
@@ -975,7 +975,7 @@ async function oa(e, t) {
975
975
  return l(`未找到项目,请确认项目${i}是否存在,或者当前账号权限`);
976
976
  a = o.namespace.full_path;
977
977
  }
978
- tt({
978
+ it({
979
979
  language: n,
980
980
  "lint-staged": ei[n],
981
981
  repository: {
@@ -984,18 +984,18 @@ async function oa(e, t) {
984
984
  }
985
985
  });
986
986
  }
987
- async function xe(e, t) {
988
- e ? P.rm("-rf", Y) : $(E()) && (await _e({
987
+ async function De(e, t) {
988
+ e ? P.rm("-rf", Y) : $(E()) && (await Ge({
989
989
  message: `当前项目中已存在配置文件夹${Y},确认重新配置?`
990
990
  }) ? P.rm("-rf", Y) : process.exit(0)), await pe(E(), { recursive: !0 }), await oa(e, t);
991
991
  const i = y("项目初始化中...").start();
992
992
  await ra(), i.succeed("项目初始化完成");
993
993
  }
994
994
  async function ca() {
995
- $(E()) && $(Ne()) ? Ze() : await xe(), process.exit(0);
995
+ $(E()) && $(Ne()) ? Ye() : await De(), process.exit(0);
996
996
  }
997
997
  async function ua(e, t) {
998
- t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && l("项目语言不支持"), e ? (H(), e === "." ? (await xe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await ca() : l("参数错误。执行 z init -h 查看帮助。")) : await sa();
998
+ t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && l("项目语言不支持"), e ? (H(), e === "." ? (await De(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await ca() : l("参数错误。执行 z init -h 查看帮助。")) : await sa();
999
999
  }
1000
1000
  D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => z(ua, ...e));
1001
1001
  async function la(e, t) {
@@ -1003,7 +1003,7 @@ async function la(e, t) {
1003
1003
  return "不能为空";
1004
1004
  if (!/^[a-z0-9-]+$/.test(e))
1005
1005
  return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
1006
- if (Qe().includes(e))
1006
+ if (et().includes(e))
1007
1007
  return "当前目录下已存在同名文件夹,请先处理。";
1008
1008
  const a = (await Ci(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
1009
1009
  return a ? `远程仓库中已存在同名项目(${a.http_url_to_repo}),请更名后重试` : !0;
@@ -1037,7 +1037,7 @@ async function da(e) {
1037
1037
  message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
1038
1038
  validate: pa
1039
1039
  }), i = i.trim());
1040
- const n = `${t}_${i}_${et()}`;
1040
+ const n = `${t}_${i}_${tt()}`;
1041
1041
  await m(`git fetch origin ${v.MASTER}`), await m(`git checkout -b ${n} origin/${v.MASTER}`), await m(`git push -u origin ${n}`), process.exit(0);
1042
1042
  }
1043
1043
  const ut = (e) => `${F("ZenTaoDomain")}${e}`;
@@ -1067,7 +1067,7 @@ async function ga() {
1067
1067
  }
1068
1068
  })) : [];
1069
1069
  }
1070
- async function Be(e) {
1070
+ async function Fe(e) {
1071
1071
  const t = await m("git diff HEAD");
1072
1072
  t || l("git暂存区没有内容,请先git add添加文件到暂存区");
1073
1073
  const i = await ia({
@@ -1077,17 +1077,17 @@ async function Be(e) {
1077
1077
  });
1078
1078
  return e + i;
1079
1079
  }
1080
- async function Te(e, t, i) {
1080
+ async function Ee(e, t, i) {
1081
1081
  const n = y("🤖 生成提交信息中...").start();
1082
1082
  let a = "", s = !0;
1083
1083
  if ([j.FEAT, j.FIX, j.REFACTOR].includes(e)) {
1084
1084
  const o = t.map((r) => r.value).join(",");
1085
- if (i || (a = await Be(`${e}(${o}): `)), !a) {
1085
+ if (i || (a = await Fe(`${e}(${o}): `)), !a) {
1086
1086
  const r = t.map((c) => c.name).join(";");
1087
1087
  a = `${e}(${o}): ${r}`, s = !1;
1088
1088
  }
1089
1089
  }
1090
- e === j.CHORE && (t ? a = `${e}: ${t}` : a = await Be(`${e}: `)), await L(Ne(), a, "utf-8"), s || i ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(S.yellow(a));
1090
+ e === j.CHORE && (t ? a = `${e}: ${t}` : a = await Fe(`${e}: `)), await L(Ne(), a, "utf-8"), s || i ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(S.yellow(a));
1091
1091
  }
1092
1092
  async function ha(e) {
1093
1093
  const t = await b({
@@ -1124,7 +1124,7 @@ async function ha(e) {
1124
1124
  })),
1125
1125
  pageSize: i.length
1126
1126
  });
1127
- await Te(j.FEAT, n, e);
1127
+ await Ee(j.FEAT, n, e);
1128
1128
  }
1129
1129
  if (t === j.FIX) {
1130
1130
  const i = await ga();
@@ -1139,32 +1139,32 @@ async function ha(e) {
1139
1139
  })),
1140
1140
  pageSize: i.length
1141
1141
  });
1142
- await Te(j.FIX, n, e);
1142
+ await Ee(j.FIX, n, e);
1143
1143
  }
1144
1144
  if (t === j.CHORE) {
1145
1145
  let i = "";
1146
1146
  e && (i = await B({
1147
1147
  message: "请输入commit msg:",
1148
1148
  validate: (n) => n.length === 0 ? "请输入commit msg" : !0
1149
- }), i = i.trim()), await Te(j.CHORE, i);
1149
+ }), i = i.trim()), await Ee(j.CHORE, i);
1150
1150
  }
1151
1151
  process.exit(0);
1152
1152
  }
1153
1153
  async function wa() {
1154
1154
  try {
1155
1155
  const e = {}, t = async () => {
1156
- const O = Qe(), { projects: ie } = await wi(), K = ie.map((ce) => {
1157
- const Oe = {
1156
+ const O = et(), { projects: ie } = await wi(), K = ie.map((ce) => {
1157
+ const Me = {
1158
1158
  name: `${ce.name} [${ce.desc}]`,
1159
1159
  value: ce.name,
1160
1160
  disabled: !1
1161
1161
  };
1162
- return O.includes(ce.name) && (Oe.disabled = "目录下已存在同名文件夹"), Oe;
1162
+ return O.includes(ce.name) && (Me.disabled = "目录下已存在同名文件夹"), Me;
1163
1163
  }), vt = await b({
1164
1164
  message: "请选择一个项目模板",
1165
1165
  choices: K
1166
- }), ke = ie.find((ce) => ce.name === vt);
1167
- e.tplName = ke.name, e.tplUrl = ke.url, e.tplLanguage = ke.language;
1166
+ }), Te = ie.find((ce) => ce.name === vt);
1167
+ e.tplName = Te.name, e.tplUrl = Te.url, e.tplLanguage = Te.language;
1168
1168
  }, i = async () => {
1169
1169
  const { groups: O } = Oi(), ie = await b({
1170
1170
  message: "请选择一个分组",
@@ -1189,8 +1189,8 @@ async function wa() {
1189
1189
  };
1190
1190
  await t(), await i(), await n();
1191
1191
  const a = `${fe}/${e.group?.name}/${e.projectName}.git`, s = y("模版初始化中").start();
1192
- await m(`git clone --depth=1 ${e.tplUrl}`), await Fe(e.tplName, e.projectName), P.cd(e.projectName), P.rm("-rf", ".git"), await m(`git init --initial-branch=${v.MASTER}`), await m(`git remote add origin ${a}`), await m(`git config user.name ${T("gitName")}`), await m(`git config user.email ${T("gitEmail")}`);
1193
- const o = Re();
1192
+ await m(`git clone --depth=1 ${e.tplUrl}`), await _e(e.tplName, e.projectName), P.cd(e.projectName), P.rm("-rf", ".git"), await m(`git init --initial-branch=${v.MASTER}`), await m(`git remote add origin ${a}`), await m(`git config user.name ${T("gitName")}`), await m(`git config user.email ${T("gitEmail")}`);
1193
+ const o = Ie();
1194
1194
  mi({
1195
1195
  ...o,
1196
1196
  name: e.projectName,
@@ -1199,7 +1199,7 @@ async function wa() {
1199
1199
  ...o.scripts,
1200
1200
  prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
1201
1201
  }
1202
- }), await I.writeFile(p.resolve("README.md"), Qt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await xe(e.tplLanguage, e.group?.name);
1202
+ }), await I.writeFile(p.resolve("README.md"), Qt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await De(e.tplLanguage, e.group?.name);
1203
1203
  const r = y("依赖安装中").start();
1204
1204
  await m("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
1205
1205
  const c = y("项目推送中").start();
@@ -1212,7 +1212,7 @@ async function wa() {
1212
1212
  namespace_id: e.group?.id
1213
1213
  });
1214
1214
  await m(`git push -u origin ${v.MASTER}`), await m(`git push origin HEAD:${v.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${S.blue(a)}`);
1215
- const d = y("初始化分支中").start(), f = `feat_init_${et()}`, g = [v.DEV, v.TEST, v.RELEASE, f], h = await Promise.allSettled(
1215
+ const d = y("初始化分支中").start(), f = `feat_init_${tt()}`, g = [v.DEV, v.TEST, v.RELEASE, f], h = await Promise.allSettled(
1216
1216
  g.map(
1217
1217
  (O) => Li({
1218
1218
  id: u.id,
@@ -1267,7 +1267,7 @@ async function ya(e, t) {
1267
1267
  }
1268
1268
  D.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(de).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").action((...e) => z(ya, ...e));
1269
1269
  function va(e) {
1270
- return it({
1270
+ return at({
1271
1271
  url: `${F("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${e.groupName}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
1272
1272
  method: "post",
1273
1273
  data: e.params
@@ -1299,7 +1299,7 @@ async function $a(e) {
1299
1299
  }
1300
1300
  }
1301
1301
  function Na(e, t) {
1302
- const i = Re();
1302
+ const i = Ie();
1303
1303
  if (se()?.repository?.url || l(".z/project.json中缺少repository.url"), t === W.H5) {
1304
1304
  const a = `build:${e}`;
1305
1305
  i?.scripts[a] || l(`项目package.json文件scripts不存在命令${a}。`);
@@ -1316,7 +1316,7 @@ async function lt(e, t) {
1316
1316
  })), n === W.NPM && (i = v.MASTER), !i) {
1317
1317
  const u = await b({
1318
1318
  message: "请选择部署环境",
1319
- choices: qe
1319
+ choices: He
1320
1320
  });
1321
1321
  i = Yt(u);
1322
1322
  }
@@ -1324,11 +1324,11 @@ async function lt(e, t) {
1324
1324
  a.language === w.JAVASCRIPT && (s = Jt);
1325
1325
  let o = "";
1326
1326
  if (a.language === w.JAVASCRIPT) {
1327
- const u = Re();
1327
+ const u = Ie();
1328
1328
  u.name.startsWith("@") && u.name.includes("/") ? o = u.name.split("/").pop() || "" : o = u.name;
1329
1329
  }
1330
1330
  if (a.language === w.JAVA) {
1331
- const { projects: u } = await at(), d = u.find(
1331
+ const { projects: u } = await nt(), d = u.find(
1332
1332
  (f) => X(f.url) === X(a.repository.url)
1333
1333
  );
1334
1334
  if (!d)
@@ -1508,7 +1508,7 @@ function Ea(e) {
1508
1508
  return /^(feat|fix|refactor)/.test(i) ? /\(\d+(?:,\d+)*\)/.test(i) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(i) ? [j.CHORE, j.CI].includes(i) ? !0 : "chore/ci类型无需填写ID。" : j.Break === i ? !0 : "不存在的提交类型。";
1509
1509
  }
1510
1510
  async function Ca() {
1511
- const e = await Ee(p.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), i = Ea(e);
1511
+ const e = await Ce(p.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), i = Ea(e);
1512
1512
  i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
1513
1513
  }
1514
1514
  async function Ra() {
@@ -1659,10 +1659,12 @@ D.command("run").alias("r").description("执行 eslint / prettier / type-check /
1659
1659
  ).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(La, ...e));
1660
1660
  async function pt(e = "latest") {
1661
1661
  const t = y("安装中...").start();
1662
- await m(`npm i -g ${ae.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", me("latestCheckVersionTimestamp", Date.now()), me("version", e), re(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
1662
+ await m(`npm i -g ${ae.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", me("latestCheckVersionTimestamp", Date.now()), me("version", e);
1663
+ const i = await xe();
1664
+ je(i), re(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
1663
1665
  }
1664
1666
  D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(pt, ...e));
1665
- const De = /Thumbs\.db|\.git|DS_Store|idea/, dt = "testcase";
1667
+ const Le = /Thumbs\.db|\.git|DS_Store|idea/, dt = "testcase";
1666
1668
  function ft(e) {
1667
1669
  const t = e.match(/^(.*[^[])?\[(\d+)]$/);
1668
1670
  if (t && !e.startsWith("["))
@@ -1683,12 +1685,12 @@ function ft(e) {
1683
1685
  };
1684
1686
  }
1685
1687
  async function Q(e, t = {}) {
1686
- const { exclude: i = De } = t, n = [];
1688
+ const { exclude: i = Le } = t, n = [];
1687
1689
  async function a(s) {
1688
1690
  const o = p.basename(s);
1689
1691
  if ((await jt(s)).isFile())
1690
1692
  return null;
1691
- const c = await Ce(s, { withFileTypes: !0 }), u = (await Promise.all(
1693
+ const c = await Re(s, { withFileTypes: !0 }), u = (await Promise.all(
1692
1694
  c.filter((k) => k.isDirectory() && !i.test(k.name)).map((k) => a(p.join(s, k.name)))
1693
1695
  )).filter(Boolean), { type: d, id: f, displayName: g } = ft(o), h = {
1694
1696
  name: o,
@@ -1703,9 +1705,9 @@ async function Q(e, t = {}) {
1703
1705
  return await a(p.resolve(e)), n;
1704
1706
  }
1705
1707
  async function gt(e, t = {}) {
1706
- const { exclude: i = De } = t;
1708
+ const { exclude: i = Le } = t;
1707
1709
  try {
1708
- const n = await Ce(p.resolve(e), { withFileTypes: !0 });
1710
+ const n = await Re(p.resolve(e), { withFileTypes: !0 });
1709
1711
  return await Promise.all(
1710
1712
  n.filter((a) => a.isDirectory() && !i.test(a.name)).map((a) => {
1711
1713
  const s = p.join(e, a.name), { type: o, id: r, displayName: c } = ft(a.name);
@@ -1738,13 +1740,13 @@ async function we(e, t, i, n) {
1738
1740
  if (a === s)
1739
1741
  return !0;
1740
1742
  const o = p.dirname(e), r = p.join(o, s);
1741
- return await Xt(e) ? await Fe(e, r) : (await m(`git mv "${e}" "${r}"`), await m("git add .")), !0;
1743
+ return await Xt(e) ? await _e(e, r) : (await m(`git mv "${e}" "${r}"`), await m("git add .")), !0;
1742
1744
  } catch (a) {
1743
1745
  return l(`重命名文件夹失败: ${e} -> ${t}。${a}`), !1;
1744
1746
  }
1745
1747
  }
1746
1748
  async function Pa(e, t, i = {}) {
1747
- const { exclude: n = De } = i;
1749
+ const { exclude: n = Le } = i;
1748
1750
  async function a(s, o) {
1749
1751
  if (!s || s.length === 0) return;
1750
1752
  const r = await gt(o, { exclude: n });
@@ -1776,7 +1778,7 @@ async function ht(e) {
1776
1778
  }
1777
1779
  return t.name = await Ui(t.id), t.path = p.join(dt, q("module", t.name, String(t.id))), t;
1778
1780
  }
1779
- async function Le(e) {
1781
+ async function Pe(e) {
1780
1782
  return (await gt(dt)).find((i) => Number(i.id) === e.id);
1781
1783
  }
1782
1784
  async function wt(e, t) {
@@ -1794,13 +1796,13 @@ async function yt(e, t) {
1794
1796
  recursive: !0
1795
1797
  }), await wt(e, p.join(t, "config.json")), I.ensureFileSync(p.join(t, "data.yaml")), await L(
1796
1798
  p.join(t, "data.yaml"),
1797
- $(p.resolve(Y, "data.yaml")) ? await Ee(p.resolve(Y, "data.yaml")) : await bi()
1799
+ $(p.resolve(Y, "data.yaml")) ? await Ce(p.resolve(Y, "data.yaml")) : await bi()
1798
1800
  ), I.ensureFileSync(p.join(t, "main.py")), await L(
1799
1801
  p.join(t, "main.py"),
1800
- $(p.resolve(Y, "main.py")) ? await Ee(p.resolve(Y, "main.py")) : await Ai()
1802
+ $(p.resolve(Y, "main.py")) ? await Ce(p.resolve(Y, "main.py")) : await Ai()
1801
1803
  );
1802
1804
  }
1803
- function Pe(e) {
1805
+ function Oe(e) {
1804
1806
  if (e) {
1805
1807
  const t = e.split(",").map((i) => i.trim()).filter((i) => {
1806
1808
  const n = Number(i);
@@ -1810,7 +1812,7 @@ function Pe(e) {
1810
1812
  }
1811
1813
  return [];
1812
1814
  }
1813
- async function je(e, t) {
1815
+ async function Se(e, t) {
1814
1816
  ee(), H(), await Ae();
1815
1817
  let i;
1816
1818
  t ? ([R.MODULE, R.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${R.MODULE} 或者 ${R.CASE}。`), i = t) : i = await b({
@@ -1823,16 +1825,16 @@ async function je(e, t) {
1823
1825
  typeStr: n
1824
1826
  };
1825
1827
  }
1826
- async function Se(e) {
1827
- const t = await ht(e), i = await Le(t);
1828
+ async function ke(e) {
1829
+ const t = await ht(e), i = await Pe(t);
1828
1830
  return i || l(`本地未找到产品【${t.name}[${t.id}]】`), {
1829
1831
  product: t,
1830
1832
  localProduct: i
1831
1833
  };
1832
1834
  }
1833
1835
  async function Oa(e, t, i) {
1834
- e.text = "查找本地产品目录...", await Le(t) || l(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
1835
- const a = Pe(i);
1836
+ e.text = "查找本地产品目录...", await Pe(t) || l(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
1837
+ const a = Oe(i);
1836
1838
  let s = await Q(t.path);
1837
1839
  e.text = "获取远程用例列表...";
1838
1840
  const o = await Bi(t.id, a);
@@ -1855,13 +1857,13 @@ async function Oa(e, t, i) {
1855
1857
  }
1856
1858
  async function Ma(e, t) {
1857
1859
  e.text = "本地产品目录查找中...";
1858
- const i = await Le(t);
1860
+ const i = await Pe(t);
1859
1861
  i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await we(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await pe(t.path, { recursive: !0 }), await m("git add .")), e.text = "获取远程模块列表...";
1860
1862
  const n = await rt(t.id);
1861
1863
  e.text = "本地同步模块中...", await Pa(n || [], t.path);
1862
1864
  }
1863
1865
  async function za(e, t) {
1864
- const { type: i, typeStr: n } = await je("拉取", e), a = await ht(t.productId), s = y(`${n}同步中...`).start();
1866
+ const { type: i, typeStr: n } = await Se("拉取", e), a = await ht(t.productId), s = y(`${n}同步中...`).start();
1865
1867
  if (R.MODULE === i && await Ma(s, a), R.CASE === i && await Oa(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await m("git status -s")) {
1866
1868
  const o = y("代码提交中...").start();
1867
1869
  try {
@@ -1946,7 +1948,7 @@ function Ba(e) {
1946
1948
  return i(e);
1947
1949
  }
1948
1950
  async function Fa(e, t) {
1949
- const { type: i, typeStr: n } = await je("创建", e), { product: a, localProduct: s } = await Se(t.productId), o = await rt(a.id), r = await Ba(o), c = q("module", r.label, String(r.value)), d = (await Q(a.path, { hasRoot: !0 })).find((h) => h.name === c);
1951
+ const { type: i, typeStr: n } = await Se("创建", e), { product: a, localProduct: s } = await ke(t.productId), o = await rt(a.id), r = await Ba(o), c = q("module", r.label, String(r.value)), d = (await Q(a.path, { hasRoot: !0 })).find((h) => h.name === c);
1950
1952
  if (!d?.path || !$(d.path))
1951
1953
  return l(`本地不存在${c}模块`);
1952
1954
  let f = await B({
@@ -2038,7 +2040,7 @@ async function Ga(e, t) {
2038
2040
  return s.succeed("模块删除完成"), o;
2039
2041
  }
2040
2042
  async function Wa(e, t) {
2041
- const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await Se(t.productId), s = Pe(t.targetIds);
2043
+ const { type: i, typeStr: n } = await Se("删除", e), { localProduct: a } = await ke(t.productId), s = Oe(t.targetIds);
2042
2044
  let o = [];
2043
2045
  if (R.MODULE === i ? o = await Ga(a, s) : R.CASE === i && (o = await _a(a, s)), !t.disableAutoCommit && await m("git status -s")) {
2044
2046
  const r = y("代码提交中...").start();
@@ -2090,14 +2092,14 @@ async function Va(e, t) {
2090
2092
  name: s
2091
2093
  }), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path = p.join(p.dirname(a.path), q("case", s, String(a.id)))) : o.succeed("用例名称无变动");
2092
2094
  let r = I.readJsonSync(p.join(a.path, "config.json")), c;
2093
- t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await ze({
2095
+ t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await Je({
2094
2096
  message: "修改用例优先级",
2095
2097
  min: 1,
2096
2098
  max: 5,
2097
2099
  required: !0,
2098
2100
  default: r.priority,
2099
2101
  validate: (g) => g > 0 && g < 6
2100
- }) : c = await ze({
2102
+ }) : c = await Je({
2101
2103
  message: "修改用例优先级",
2102
2104
  min: 1,
2103
2105
  max: 5,
@@ -2177,7 +2179,7 @@ async function qa(e, t) {
2177
2179
  }), await we(a.path, s, "module", String(a.id)) && o.succeed(`模块重命名成功: ${a.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), a.id;
2178
2180
  }
2179
2181
  async function Ha(e, t) {
2180
- const { type: i, typeStr: n } = await je("修改", e), { localProduct: a } = await Se(t.productId);
2182
+ const { type: i, typeStr: n } = await Se("修改", e), { localProduct: a } = await ke(t.productId);
2181
2183
  let s;
2182
2184
  if (R.MODULE === i ? s = await qa(a, t) : R.CASE === i && (s = await Va(a, t)), !t.disableAutoCommit && await m("git status -s")) {
2183
2185
  const o = y("代码提交中...").start();
@@ -2211,7 +2213,7 @@ async function Ka(e, t) {
2211
2213
  }
2212
2214
  async function Za(e) {
2213
2215
  ee(), H();
2214
- const { localProduct: t } = await Se(e.productId);
2216
+ const { localProduct: t } = await ke(e.productId);
2215
2217
  let i = [];
2216
2218
  const a = (await Q(t.path)).filter((c) => c.type === "case");
2217
2219
  if (e.all)
@@ -2221,7 +2223,7 @@ async function Za(e) {
2221
2223
  displayName: c.displayName
2222
2224
  }));
2223
2225
  else {
2224
- const c = Pe(e.caseIds);
2226
+ const c = Oe(e.caseIds);
2225
2227
  if (c.length)
2226
2228
  i = a.filter((u) => c.includes(Number(u.id))).map((u) => ({
2227
2229
  id: Number(u.id),
@@ -2304,7 +2306,7 @@ async function Za(e) {
2304
2306
  }
2305
2307
  D.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认主干(trunk)").action((...e) => z(Za, ...e));
2306
2308
  async function Ya() {
2307
- const { projects: e } = await at(), t = se();
2309
+ const { projects: e } = await nt(), t = se();
2308
2310
  if (t.serverProjectURL) {
2309
2311
  const n = e.find(
2310
2312
  (a) => X(a.url) === X(t.serverProjectURL)
@@ -2322,7 +2324,7 @@ async function Ya() {
2322
2324
  value: n.url
2323
2325
  }))
2324
2326
  });
2325
- return tt({ ...t, serverProjectURL: i }), {
2327
+ return it({ ...t, serverProjectURL: i }), {
2326
2328
  projectId: decodeURIComponent(X(i)),
2327
2329
  moduleList: e.find((n) => n.url === i)?.modules || []
2328
2330
  };
@@ -2366,7 +2368,7 @@ async function Qa(e, t) {
2366
2368
  async function en(e) {
2367
2369
  return [C.DEV, C.TEST, C.RELEASE].includes(e.trim()) ? e : await b({
2368
2370
  message: "请选择对应的环境,不选默认全部",
2369
- choices: qe
2371
+ choices: He
2370
2372
  });
2371
2373
  }
2372
2374
  async function tn(e, t) {
@@ -2383,8 +2385,8 @@ function an() {
2383
2385
  async function nn() {
2384
2386
  const e = ge("latestCheckVersionTimestamp"), t = ge("versionCheckDuring");
2385
2387
  if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
2386
- const i = await nt();
2387
- Ie(i);
2388
+ const i = await xe();
2389
+ je(i);
2388
2390
  let n;
2389
2391
  try {
2390
2392
  const a = "TIME_OUT", s = new Promise((o) => {
@@ -2402,14 +2404,14 @@ async function nn() {
2402
2404
  async function sn() {
2403
2405
  const e = Dt(process.argv.slice(2));
2404
2406
  if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
2405
- if (Ye()) {
2407
+ if (Xe()) {
2406
2408
  const t = I.readJSONSync(be());
2407
- M(t.profile), me(t.main), Ie(t.constants), await nn();
2409
+ M(t.profile), me(t.main), je(t.constants), await nn();
2408
2410
  } else
2409
- l(`请先初始化z-develop(执行 z i)。更多见${He}`);
2411
+ l(`请先初始化z-develop(执行 z i)。更多见${Ke}`);
2410
2412
  }
2411
2413
  async function rn() {
2412
2414
  an(), await sn();
2413
2415
  }
2414
- D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(He)}`).usage("<command> [options]").hook("preAction", rn).version(ae.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
2416
+ D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(Ke)}`).usage("<command> [options]").hook("preAction", rn).version(ae.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
2415
2417
  D.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-z-develop",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "技术团队开发流程管理工具",
5
5
  "main": "dist/index.js",
6
6
  "bin": {