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