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