cli-z-develop 0.14.13 → 0.15.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/.z/.prettierignore +2 -7
- package/.z/pre-push +2 -0
- package/.z/pre-rebase +2 -0
- package/.z/project.json +2 -1
- package/dist/index.js +1339 -1049
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { program as x } from "commander";
|
|
2
|
-
import
|
|
3
|
-
import { existsSync as N, readdirSync as
|
|
4
|
-
import { readdir as
|
|
5
|
-
import f, { resolve as
|
|
6
|
-
import
|
|
2
|
+
import Ht from "node:child_process";
|
|
3
|
+
import { existsSync as N, readdirSync as qt, lstatSync as Zt, createWriteStream as Kt, writeFileSync as ve, readFileSync as ut, mkdirSync as Yt, mkdtempSync as Xt, rmSync as Qt } from "node:fs";
|
|
4
|
+
import { readdir as Ge, mkdir as fe, writeFile as M, rename as pt, readFile as _e, stat as ea } from "node:fs/promises";
|
|
5
|
+
import f, { resolve as pe, isAbsolute as ta, normalize as aa, sep as sa } from "node:path";
|
|
6
|
+
import me, { AxiosError as mt } from "axios";
|
|
7
7
|
import A from "chalk";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { confirm as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { select as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { run as
|
|
19
|
-
import
|
|
20
|
-
import { validateSwagger as
|
|
21
|
-
import { highlight as
|
|
22
|
-
import { ESLint as
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
const
|
|
26
|
-
var C = /* @__PURE__ */ ((e) => (e[e.DEV =
|
|
27
|
-
const
|
|
8
|
+
import ia from "dayjs";
|
|
9
|
+
import S from "shelljs";
|
|
10
|
+
import na, { tmpdir as ra } from "node:os";
|
|
11
|
+
import Qe from "child_process";
|
|
12
|
+
import { confirm as Le, select as k, input as B, password as oa, checkbox as Re, number as et } from "@inquirer/prompts";
|
|
13
|
+
import w from "ora";
|
|
14
|
+
import I from "fs-extra";
|
|
15
|
+
import { select as V } from "inquirer-select-pro";
|
|
16
|
+
import ca from "lint-staged";
|
|
17
|
+
import la from "semver";
|
|
18
|
+
import { run as ua } from "npm-check-updates";
|
|
19
|
+
import pa from "p-limit";
|
|
20
|
+
import { validateSwagger as ma, getParsedSwagger as da, generatePythonBundleApi as fa, generatePythonApi as ga, generateTypescriptBundleApi as ha, generateTypescriptApi as wa } from "@lonely9/api-generate";
|
|
21
|
+
import { highlight as dt } from "cli-highlight";
|
|
22
|
+
import { ESLint as ft } from "eslint";
|
|
23
|
+
import ya from "prettier";
|
|
24
|
+
import $a from "minimist";
|
|
25
|
+
const gt = "dev", ht = "test", wt = "release", va = "production", Aa = "master";
|
|
26
|
+
var C = /* @__PURE__ */ ((e) => (e[e.DEV = gt] = "DEV", e[e.TEST = ht] = "TEST", e[e.RELEASE = wt] = "RELEASE", e[e.PROD = va] = "PROD", e))(C || {}), y = /* @__PURE__ */ ((e) => (e[e.DEV = gt] = "DEV", e[e.TEST = ht] = "TEST", e[e.RELEASE = wt] = "RELEASE", e[e.MASTER = Aa] = "MASTER", e))(y || {}), X = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(X || {});
|
|
27
|
+
const yt = [
|
|
28
28
|
{
|
|
29
29
|
name: `开发环境 - ${C.DEV}`,
|
|
30
30
|
value: C.DEV
|
|
@@ -41,7 +41,7 @@ const lt = [
|
|
|
41
41
|
name: `正式环境 - ${C.PROD}`,
|
|
42
42
|
value: C.PROD
|
|
43
43
|
}
|
|
44
|
-
],
|
|
44
|
+
], Sa = [
|
|
45
45
|
{
|
|
46
46
|
name: "网页 - h5",
|
|
47
47
|
value: "h5"
|
|
@@ -58,8 +58,8 @@ const lt = [
|
|
|
58
58
|
/* SERVER */
|
|
59
59
|
}
|
|
60
60
|
];
|
|
61
|
-
var
|
|
62
|
-
const
|
|
61
|
+
var $e = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))($e || {}), ue = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(ue || {}), $ = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e.MARKDOWN = "Markdown", e))($ || {});
|
|
62
|
+
const Na = {
|
|
63
63
|
1: "研发",
|
|
64
64
|
2: "测试",
|
|
65
65
|
3: "产品",
|
|
@@ -69,11 +69,11 @@ const pa = {
|
|
|
69
69
|
7: "行政",
|
|
70
70
|
8: "财务",
|
|
71
71
|
9: "其他"
|
|
72
|
-
},
|
|
73
|
-
var
|
|
74
|
-
const
|
|
72
|
+
}, Ae = "http://git.cxlqd.com", ba = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
73
|
+
var T = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(T || {});
|
|
74
|
+
const ja = "fe-biz7tvsd", $t = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
75
75
|
var E = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(E || {});
|
|
76
|
-
const
|
|
76
|
+
const Ta = [
|
|
77
77
|
{
|
|
78
78
|
name: "模块",
|
|
79
79
|
value: "module"
|
|
@@ -84,70 +84,70 @@ const fa = [
|
|
|
84
84
|
value: "case"
|
|
85
85
|
/* CASE */
|
|
86
86
|
}
|
|
87
|
-
],
|
|
88
|
-
function
|
|
89
|
-
return f.join(
|
|
87
|
+
], ka = 150 * 1024, tt = 0.8 * 1024 * 1024, Fe = ",", Ea = ".z", Ia = "develop-config.json", Y = ".z", Ra = ".commit-msg-tpl", Ca = "project.json";
|
|
88
|
+
function L(e = "") {
|
|
89
|
+
return f.join(Y, e);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
return
|
|
91
|
+
function vt() {
|
|
92
|
+
return L(Ca);
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
return
|
|
94
|
+
function Ne() {
|
|
95
|
+
return L(Ra);
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
97
|
+
function At() {
|
|
98
|
+
Qe.spawnSync("git", ["config", "core.hooksPath", L()]), Qe.spawnSync("git", ["config", "commit.template", Ne()]);
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
return f.resolve(
|
|
100
|
+
function be(e = "") {
|
|
101
|
+
return f.resolve(na.homedir(), Ea, e);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
103
|
+
function xe() {
|
|
104
|
+
return be(Ia);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
return N(
|
|
106
|
+
function La() {
|
|
107
|
+
return N(be());
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
return
|
|
109
|
+
function St() {
|
|
110
|
+
return La() && N(xe());
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function se(e, t = !0) {
|
|
113
113
|
let a = e.trim();
|
|
114
114
|
const n = a.match(/^git@([^:]+):(.+)$/);
|
|
115
115
|
if (n)
|
|
116
116
|
a = n[2];
|
|
117
117
|
else {
|
|
118
|
-
const s =
|
|
119
|
-
a = a.replace(/^https?:\/\//, ""), a.startsWith(`${s}/`) ? a = a.slice(s.length + 1) : a = a.replace(`${
|
|
118
|
+
const s = Ae.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
119
|
+
a = a.replace(/^https?:\/\//, ""), a.startsWith(`${s}/`) ? a = a.slice(s.length + 1) : a = a.replace(`${Ae.replace(/\/$/, "")}/`, "");
|
|
120
120
|
}
|
|
121
121
|
const i = a.replace(/\.git$/, "");
|
|
122
122
|
return t ? encodeURIComponent(i) : i;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
return
|
|
124
|
+
function Nt(e, t) {
|
|
125
|
+
return se(e) === se(t);
|
|
126
126
|
}
|
|
127
|
-
const { red:
|
|
128
|
-
function
|
|
127
|
+
const { red: at, green: xa, blue: cr, magenta: Da, yellow: Pa } = A;
|
|
128
|
+
function Te(...e) {
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
console.log(
|
|
130
|
+
function z(...e) {
|
|
131
|
+
console.log(Pa(...e));
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
console.log(
|
|
133
|
+
function G(...e) {
|
|
134
|
+
console.log(xa(...e));
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function bt(e) {
|
|
137
137
|
e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(A.cyan(" 👋 下次见~")), console.log(), process.exit(1));
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
139
|
+
function m(e, t = !1) {
|
|
140
|
+
bt(e);
|
|
141
141
|
let a = e;
|
|
142
|
-
e instanceof Error ? (a = e.message,
|
|
142
|
+
e instanceof Error ? (a = e.message, me.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(at(a)), console.log(Da(e.stack))) : console.log(at(e)), t || process.exit(1);
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return N(e) ?
|
|
144
|
+
function st(e) {
|
|
145
|
+
return N(e) ? Zt(e).isDirectory() : !1;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
return
|
|
147
|
+
function jt(e = process.cwd()) {
|
|
148
|
+
return st(e) ? qt(e).filter((a) => st(f.resolve(e, a))) : [];
|
|
149
149
|
}
|
|
150
|
-
async function
|
|
150
|
+
async function p(e, t = {}) {
|
|
151
151
|
const a = {
|
|
152
152
|
removeTailLinkBreak: !0,
|
|
153
153
|
silent: !0,
|
|
@@ -155,7 +155,7 @@ async function m(e, t = {}) {
|
|
|
155
155
|
};
|
|
156
156
|
let n = await new Promise((i, s) => {
|
|
157
157
|
try {
|
|
158
|
-
const o =
|
|
158
|
+
const o = S.exec(e, {
|
|
159
159
|
silent: a.silent
|
|
160
160
|
});
|
|
161
161
|
i(o);
|
|
@@ -165,46 +165,46 @@ async function m(e, t = {}) {
|
|
|
165
165
|
});
|
|
166
166
|
return n = n.toString(), a.removeTailLinkBreak && (n = n.replace(/\n$/, "")), n;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
168
|
+
function Ue(e) {
|
|
169
|
+
Ht.execSync(e, {
|
|
170
170
|
stdio: "inherit"
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
return
|
|
173
|
+
function Tt() {
|
|
174
|
+
return ia(Date.now()).format("YYMMDD");
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function Oa(e, t) {
|
|
177
177
|
for (const a of t)
|
|
178
178
|
if (!e.includes(a))
|
|
179
179
|
return !1;
|
|
180
180
|
return !0;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
N(
|
|
182
|
+
function ee() {
|
|
183
|
+
N(L()) || m("当前不在项目根目录。请切换到项目根目录");
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
N(f.resolve(".git")) ||
|
|
185
|
+
function W() {
|
|
186
|
+
N(f.resolve(".git")) || m("当前不是git项目根目录,请先执行git init,或切换到根目录");
|
|
187
187
|
}
|
|
188
|
-
async function
|
|
189
|
-
await
|
|
188
|
+
async function ge() {
|
|
189
|
+
await p("git status -s") !== "" && m("请先提交代码变动,再进行操作");
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
return e ===
|
|
191
|
+
function Ma(e) {
|
|
192
|
+
return e === y.MASTER ? C.PROD : e;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
return e === C.PROD ?
|
|
194
|
+
function Ba(e) {
|
|
195
|
+
return e === C.PROD ? y.MASTER : e;
|
|
196
196
|
}
|
|
197
|
-
async function
|
|
197
|
+
async function P(e, ...t) {
|
|
198
198
|
try {
|
|
199
199
|
await e(...t);
|
|
200
200
|
} catch (a) {
|
|
201
|
-
throw
|
|
201
|
+
throw bt(a), a;
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
async function
|
|
205
|
-
return (await
|
|
204
|
+
async function _a(e) {
|
|
205
|
+
return (await Ge(e)).length === 0;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function Fa(e = "项目中文名", t = "项目描述") {
|
|
208
208
|
return `
|
|
209
209
|
# ${e}
|
|
210
210
|
${t}
|
|
@@ -261,36 +261,36 @@ ${t}
|
|
|
261
261
|
在此处放入飞书文档链接。请在[前端团队-项目手册](https://hxhtbr8t8uy.feishu.cn/drive/folder/QfQ7favVWljQk7d63Prc8mUGnJf)中按照分类新建文档。
|
|
262
262
|
`;
|
|
263
263
|
}
|
|
264
|
-
const
|
|
265
|
-
[
|
|
264
|
+
const za = {
|
|
265
|
+
[$.JAVA]: {
|
|
266
266
|
"**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml"
|
|
267
267
|
},
|
|
268
|
-
[
|
|
268
|
+
[$.JAVASCRIPT]: {
|
|
269
269
|
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
270
270
|
"*": "prettier -wu"
|
|
271
271
|
},
|
|
272
|
-
[
|
|
272
|
+
[$.PYTHON]: {
|
|
273
273
|
// TODO: 需要优化
|
|
274
274
|
// "**/*.{py}": "python --fix",
|
|
275
275
|
"**/*.{py}": "echo 'todo'"
|
|
276
276
|
},
|
|
277
|
-
[
|
|
277
|
+
[$.MARKDOWN]: {
|
|
278
278
|
"*": "prettier -wu",
|
|
279
279
|
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
280
280
|
"**/*.md": "markdownlint --fix"
|
|
281
281
|
}
|
|
282
|
-
},
|
|
283
|
-
name:
|
|
284
|
-
version:
|
|
285
|
-
description:
|
|
286
|
-
main:
|
|
287
|
-
bin:
|
|
288
|
-
scripts:
|
|
289
|
-
type:
|
|
290
|
-
author:
|
|
291
|
-
devDependencies:
|
|
292
|
-
dependencies:
|
|
293
|
-
},
|
|
282
|
+
}, Ja = "cli-z-develop", Ga = "0.15.0", Ua = "技术团队开发流程管理工具", Va = "dist/index.js", Wa = { z: "bin/z.js", "z-develop": "bin/z.js" }, Ha = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", test: "bun src/main.ts", "test:debug": "DEBUG=true bun src/main.ts", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", "build:w": "vite build --watch", 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" }, qa = "module", Za = "z", Ka = { "@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" }, Ya = { "@inquirer/prompts": "^8.4.1", "@lonely9/api-generate": "^0.2.11", axios: "^1.15.0", chalk: "^5.6.2", "cli-highlight": "^2.1.11", commander: "^14.0.3", dayjs: "^1.11.20", eslint: "^9.39.2", "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", prettier: "^3.8.2", semver: "^7.7.4", shelljs: "^0.10.0" }, oe = {
|
|
283
|
+
name: Ja,
|
|
284
|
+
version: Ga,
|
|
285
|
+
description: Ua,
|
|
286
|
+
main: Va,
|
|
287
|
+
bin: Wa,
|
|
288
|
+
scripts: Ha,
|
|
289
|
+
type: qa,
|
|
290
|
+
author: Za,
|
|
291
|
+
devDependencies: Ka,
|
|
292
|
+
dependencies: Ya
|
|
293
|
+
}, D = {
|
|
294
294
|
// 个人数据
|
|
295
295
|
profile: {
|
|
296
296
|
ldapAccount: "",
|
|
@@ -302,13 +302,13 @@ const Ra = {
|
|
|
302
302
|
gitEmail: "",
|
|
303
303
|
weWorkName: "",
|
|
304
304
|
weWorkUserId: "",
|
|
305
|
-
jobType:
|
|
305
|
+
jobType: ue.FRONT_END,
|
|
306
306
|
zenTaoToken: "",
|
|
307
307
|
k8sToken: ""
|
|
308
308
|
},
|
|
309
309
|
// 包数据
|
|
310
310
|
main: {
|
|
311
|
-
version:
|
|
311
|
+
version: oe.version,
|
|
312
312
|
latestCheckVersionTimestamp: 0,
|
|
313
313
|
// 3天检查一次
|
|
314
314
|
versionCheckDuring: 3,
|
|
@@ -324,87 +324,87 @@ const Ra = {
|
|
|
324
324
|
FECDNDomain: ""
|
|
325
325
|
}
|
|
326
326
|
};
|
|
327
|
-
function
|
|
328
|
-
return e ?
|
|
327
|
+
function R(e) {
|
|
328
|
+
return e ? D.profile[e] : D.profile;
|
|
329
329
|
}
|
|
330
|
-
function
|
|
331
|
-
return e ?
|
|
330
|
+
function Se(e) {
|
|
331
|
+
return e ? D.main[e] : D.main;
|
|
332
332
|
}
|
|
333
|
-
function
|
|
334
|
-
return e ?
|
|
333
|
+
function U(e) {
|
|
334
|
+
return e ? D.constants[e] : D.constants;
|
|
335
335
|
}
|
|
336
|
-
let
|
|
337
|
-
function
|
|
338
|
-
if (
|
|
339
|
-
return
|
|
336
|
+
let Z = null, K = null;
|
|
337
|
+
function Ve() {
|
|
338
|
+
if (Z)
|
|
339
|
+
return Z;
|
|
340
340
|
const e = f.join("package.json");
|
|
341
|
-
return N(e) ||
|
|
342
|
-
}
|
|
343
|
-
function
|
|
344
|
-
if (
|
|
345
|
-
return
|
|
346
|
-
const e =
|
|
347
|
-
return N(e) ||
|
|
348
|
-
`当前目录(${
|
|
349
|
-
),
|
|
350
|
-
}
|
|
351
|
-
function
|
|
352
|
-
|
|
353
|
-
...
|
|
341
|
+
return N(e) || m(`当前目录(${S.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), Z = I.readJsonSync(e), Z;
|
|
342
|
+
}
|
|
343
|
+
function H() {
|
|
344
|
+
if (K)
|
|
345
|
+
return K;
|
|
346
|
+
const e = vt();
|
|
347
|
+
return N(e) || m(
|
|
348
|
+
`当前目录(${S.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
349
|
+
), K = I.readJsonSync(e), K;
|
|
350
|
+
}
|
|
351
|
+
function kt(e) {
|
|
352
|
+
K ? K = {
|
|
353
|
+
...K,
|
|
354
354
|
...e
|
|
355
|
-
} :
|
|
355
|
+
} : K = e, I.writeJSONSync(vt(), K, { spaces: 2 });
|
|
356
356
|
}
|
|
357
|
-
function
|
|
358
|
-
|
|
359
|
-
...
|
|
357
|
+
function Xa(e) {
|
|
358
|
+
Z ? Z = {
|
|
359
|
+
...Z,
|
|
360
360
|
...e
|
|
361
|
-
} :
|
|
361
|
+
} : Z = e, I.writeJSONSync(f.join("package.json"), Z, { spaces: 2 });
|
|
362
362
|
}
|
|
363
|
-
const
|
|
363
|
+
const ae = {
|
|
364
364
|
id: 0,
|
|
365
365
|
path: "",
|
|
366
366
|
group: "",
|
|
367
367
|
sourceBranch: "",
|
|
368
368
|
mergeRequestUrl: ""
|
|
369
369
|
};
|
|
370
|
-
async function
|
|
371
|
-
if (!
|
|
370
|
+
async function Qa() {
|
|
371
|
+
if (!ae.id)
|
|
372
372
|
try {
|
|
373
|
-
const e =
|
|
374
|
-
|
|
373
|
+
const e = H(), t = se(e.repository.url), a = await It(t);
|
|
374
|
+
ae.id = a.id, ae.path = t, ae.group = a.namespace.full_path, ae.mergeRequestUrl = `${a.web_url}/merge_requests`;
|
|
375
375
|
} catch (e) {
|
|
376
|
-
|
|
376
|
+
m(e);
|
|
377
377
|
}
|
|
378
|
-
return
|
|
378
|
+
return ae.sourceBranch || (ae.sourceBranch = await p("git branch --show-current")), ae;
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
|
|
382
|
-
|
|
380
|
+
function ce() {
|
|
381
|
+
I.writeJSONSync(
|
|
382
|
+
xe(),
|
|
383
383
|
{
|
|
384
|
-
main:
|
|
385
|
-
profile:
|
|
386
|
-
constants:
|
|
384
|
+
main: Se(),
|
|
385
|
+
profile: R(),
|
|
386
|
+
constants: U()
|
|
387
387
|
},
|
|
388
388
|
{
|
|
389
389
|
spaces: 2
|
|
390
390
|
}
|
|
391
391
|
);
|
|
392
392
|
}
|
|
393
|
-
function
|
|
394
|
-
t !== void 0 ?
|
|
395
|
-
...
|
|
393
|
+
function J(e, t) {
|
|
394
|
+
t !== void 0 ? D.profile[e] = t : D.profile = {
|
|
395
|
+
...D.profile,
|
|
396
396
|
...e
|
|
397
397
|
};
|
|
398
398
|
}
|
|
399
|
-
function
|
|
400
|
-
|
|
401
|
-
...
|
|
399
|
+
function De(e, t) {
|
|
400
|
+
D.constants = {
|
|
401
|
+
...D.constants,
|
|
402
402
|
...e
|
|
403
403
|
};
|
|
404
404
|
}
|
|
405
|
-
function
|
|
406
|
-
t !== void 0 ?
|
|
407
|
-
...
|
|
405
|
+
function de(e, t) {
|
|
406
|
+
t !== void 0 ? D.main[e] = t : D.main = {
|
|
407
|
+
...D.main,
|
|
408
408
|
...e
|
|
409
409
|
};
|
|
410
410
|
}
|
|
@@ -418,59 +418,61 @@ async function ne(e) {
|
|
|
418
418
|
headers: a,
|
|
419
419
|
responseType: e?.responseType || "json"
|
|
420
420
|
};
|
|
421
|
-
|
|
422
|
-
const o = await
|
|
423
|
-
return
|
|
421
|
+
Te(A.magenta(s.method.toUpperCase()), A.yellow(s.url), JSON.stringify(s.headers)), Te(A.gray(JSON.stringify(s[i], null, 2)));
|
|
422
|
+
const o = await me(s);
|
|
423
|
+
return Te(A.green("Response"), A.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
|
|
424
424
|
} catch (s) {
|
|
425
|
-
return s instanceof
|
|
425
|
+
return s instanceof mt && Te(A.red("Error"), A.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
async function
|
|
429
|
-
|
|
430
|
-
if (e)
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
428
|
+
async function es() {
|
|
429
|
+
let e = R("gitToken");
|
|
430
|
+
if (!e)
|
|
431
|
+
try {
|
|
432
|
+
const { access_token: t } = await ne({
|
|
433
|
+
url: `${Ae}/oauth/token`,
|
|
434
|
+
method: "post",
|
|
435
|
+
data: {
|
|
436
|
+
grant_type: "password",
|
|
437
|
+
username: R("ldapAccount"),
|
|
438
|
+
password: R("ldapPassword")
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
e = `Bearer ${t}`, J("gitToken", e), ce();
|
|
442
|
+
} catch (t) {
|
|
443
|
+
t instanceof mt ? m(t?.response?.data?.error_description || t || "获取 token 失败") : m(t);
|
|
444
|
+
}
|
|
445
|
+
return e;
|
|
444
446
|
}
|
|
445
|
-
async function
|
|
447
|
+
async function b(e) {
|
|
446
448
|
return ne({
|
|
447
449
|
...e,
|
|
448
450
|
headers: {
|
|
449
|
-
Authorization: await
|
|
451
|
+
Authorization: await es()
|
|
450
452
|
}
|
|
451
453
|
});
|
|
452
454
|
}
|
|
453
|
-
async function
|
|
454
|
-
const e =
|
|
455
|
+
async function ts() {
|
|
456
|
+
const e = R("zenTaoToken");
|
|
455
457
|
if (e)
|
|
456
458
|
return e;
|
|
457
459
|
{
|
|
458
460
|
const { token: t } = await ne({
|
|
459
|
-
url: `${
|
|
461
|
+
url: `${U("ZenTaoDomain")}/api.php/v1/tokens`,
|
|
460
462
|
method: "post",
|
|
461
463
|
data: {
|
|
462
|
-
account:
|
|
463
|
-
password:
|
|
464
|
+
account: R("ldapAccount"),
|
|
465
|
+
password: R("ldapPassword")
|
|
464
466
|
}
|
|
465
467
|
});
|
|
466
|
-
return
|
|
468
|
+
return J("zenTaoToken", t), ce(), t;
|
|
467
469
|
}
|
|
468
470
|
}
|
|
469
|
-
async function
|
|
471
|
+
async function Ce(e) {
|
|
470
472
|
const t = await ne({
|
|
471
473
|
...e,
|
|
472
474
|
headers: {
|
|
473
|
-
Token: await
|
|
475
|
+
Token: await ts()
|
|
474
476
|
}
|
|
475
477
|
});
|
|
476
478
|
if (e.url.includes("local")) {
|
|
@@ -479,43 +481,43 @@ async function be(e) {
|
|
|
479
481
|
return JSON.parse(a.data);
|
|
480
482
|
}
|
|
481
483
|
if (typeof t == "object")
|
|
482
|
-
return t.error === "Unauthorized" || t.data.indexOf("<script>") < 0 ? (
|
|
484
|
+
return t.error === "Unauthorized" || t.data.indexOf("<script>") < 0 ? (J("zenTaoToken", ""), Ce({
|
|
483
485
|
...e
|
|
484
486
|
})) : t;
|
|
485
487
|
} else {
|
|
486
488
|
const { status: a, data: n } = t;
|
|
487
489
|
if (a === "success") {
|
|
488
490
|
const i = JSON.parse(n);
|
|
489
|
-
return i.title === "用户登录" ? (
|
|
491
|
+
return i.title === "用户登录" ? (J("zenTaoToken", ""), Ce({
|
|
490
492
|
...e
|
|
491
493
|
})) : i;
|
|
492
494
|
} else
|
|
493
495
|
return {};
|
|
494
496
|
}
|
|
495
497
|
}
|
|
496
|
-
async function
|
|
497
|
-
const e =
|
|
498
|
+
async function as() {
|
|
499
|
+
const e = R("k8sToken");
|
|
498
500
|
if (e)
|
|
499
501
|
return e;
|
|
500
502
|
{
|
|
501
503
|
const { access_token: t } = await ne({
|
|
502
|
-
url: `${
|
|
504
|
+
url: `${U("K8sDomain")}/oauth/login/LDAP`,
|
|
503
505
|
method: "post",
|
|
504
506
|
headers: {
|
|
505
507
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
506
508
|
},
|
|
507
509
|
data: {
|
|
508
|
-
username:
|
|
509
|
-
password:
|
|
510
|
+
username: R("ldapAccount"),
|
|
511
|
+
password: R("ldapPassword")
|
|
510
512
|
}
|
|
511
513
|
}), a = `Bearer ${t}`;
|
|
512
|
-
return
|
|
514
|
+
return J("k8sToken", a), ce(), a;
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
|
-
async function
|
|
517
|
+
async function ss(e, t) {
|
|
516
518
|
try {
|
|
517
|
-
const a =
|
|
518
|
-
return (await
|
|
519
|
+
const a = Kt(t, { mode: 493 });
|
|
520
|
+
return (await me({
|
|
519
521
|
method: "get",
|
|
520
522
|
url: e,
|
|
521
523
|
responseType: "stream",
|
|
@@ -529,142 +531,142 @@ async function Va(e, t) {
|
|
|
529
531
|
throw console.error("下载失败:", a), a;
|
|
530
532
|
}
|
|
531
533
|
}
|
|
532
|
-
const
|
|
533
|
-
function
|
|
534
|
-
return
|
|
535
|
-
url:
|
|
534
|
+
const _ = () => `${Ae}/api/v4`, F = (e) => `${_()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
|
|
535
|
+
function is() {
|
|
536
|
+
return b({
|
|
537
|
+
url: F("src/data/template-projects.json")
|
|
536
538
|
});
|
|
537
539
|
}
|
|
538
|
-
function
|
|
539
|
-
return
|
|
540
|
-
url:
|
|
540
|
+
function ns() {
|
|
541
|
+
return b({
|
|
542
|
+
url: F("src/data/java-project-module.json")
|
|
541
543
|
});
|
|
542
544
|
}
|
|
543
|
-
function
|
|
544
|
-
return
|
|
545
|
-
url:
|
|
545
|
+
function rs() {
|
|
546
|
+
return b({
|
|
547
|
+
url: F("src/data/java-project-api.json")
|
|
546
548
|
});
|
|
547
549
|
}
|
|
548
|
-
function
|
|
549
|
-
return
|
|
550
|
-
url:
|
|
550
|
+
function We() {
|
|
551
|
+
return b({
|
|
552
|
+
url: F("src/data/z-develop-config.json")
|
|
551
553
|
});
|
|
552
554
|
}
|
|
553
|
-
function
|
|
554
|
-
return
|
|
555
|
-
url:
|
|
555
|
+
function os() {
|
|
556
|
+
return b({
|
|
557
|
+
url: F("src/assets/tsconfig.browser.json")
|
|
556
558
|
});
|
|
557
559
|
}
|
|
558
|
-
function
|
|
559
|
-
return
|
|
560
|
-
url:
|
|
560
|
+
function cs() {
|
|
561
|
+
return b({
|
|
562
|
+
url: F("src/assets/tsconfig.node.json")
|
|
561
563
|
});
|
|
562
564
|
}
|
|
563
|
-
function
|
|
564
|
-
return
|
|
565
|
-
url:
|
|
565
|
+
function ls() {
|
|
566
|
+
return b({
|
|
567
|
+
url: F("src/assets/.prettierignore")
|
|
566
568
|
});
|
|
567
569
|
}
|
|
568
|
-
function
|
|
569
|
-
return
|
|
570
|
-
url:
|
|
570
|
+
function us() {
|
|
571
|
+
return b({
|
|
572
|
+
url: F("src/assets/.prettierrc.json")
|
|
571
573
|
});
|
|
572
574
|
}
|
|
573
|
-
function
|
|
574
|
-
return
|
|
575
|
-
url:
|
|
575
|
+
function ps() {
|
|
576
|
+
return b({
|
|
577
|
+
url: F("src/assets/data.yaml")
|
|
576
578
|
});
|
|
577
579
|
}
|
|
578
|
-
function
|
|
579
|
-
return
|
|
580
|
-
url:
|
|
580
|
+
function ms() {
|
|
581
|
+
return b({
|
|
582
|
+
url: F("src/assets/main.py")
|
|
581
583
|
});
|
|
582
584
|
}
|
|
583
|
-
function
|
|
584
|
-
return
|
|
585
|
-
url:
|
|
585
|
+
function ds() {
|
|
586
|
+
return b({
|
|
587
|
+
url: F("src/assets/checkstyle.xml")
|
|
586
588
|
});
|
|
587
589
|
}
|
|
588
|
-
function
|
|
589
|
-
return
|
|
590
|
-
url:
|
|
590
|
+
function Et() {
|
|
591
|
+
return b({
|
|
592
|
+
url: F("src/data/project-group-chats.json")
|
|
591
593
|
});
|
|
592
594
|
}
|
|
593
|
-
function
|
|
594
|
-
return
|
|
595
|
-
url: `${
|
|
595
|
+
function fs() {
|
|
596
|
+
return b({
|
|
597
|
+
url: `${_()}/user`
|
|
596
598
|
});
|
|
597
599
|
}
|
|
598
|
-
function
|
|
599
|
-
return
|
|
600
|
-
url: `${
|
|
600
|
+
function gs() {
|
|
601
|
+
return b({
|
|
602
|
+
url: `${_()}/groups`
|
|
601
603
|
});
|
|
602
604
|
}
|
|
603
|
-
function
|
|
604
|
-
return
|
|
605
|
-
url: `${
|
|
605
|
+
function hs(e) {
|
|
606
|
+
return b({
|
|
607
|
+
url: `${_()}/projects`,
|
|
606
608
|
method: "post",
|
|
607
609
|
data: e
|
|
608
610
|
});
|
|
609
611
|
}
|
|
610
|
-
function
|
|
611
|
-
return
|
|
612
|
-
url: `${
|
|
612
|
+
function It(e) {
|
|
613
|
+
return b({
|
|
614
|
+
url: `${_()}/projects/${e}`
|
|
613
615
|
});
|
|
614
616
|
}
|
|
615
|
-
function
|
|
616
|
-
return
|
|
617
|
-
url: `${
|
|
617
|
+
function ws(e) {
|
|
618
|
+
return b({
|
|
619
|
+
url: `${_()}/projects`,
|
|
618
620
|
data: {
|
|
619
621
|
search: e,
|
|
620
622
|
search_namespaces: !0
|
|
621
623
|
}
|
|
622
624
|
});
|
|
623
625
|
}
|
|
624
|
-
function
|
|
625
|
-
return
|
|
626
|
-
url: `${
|
|
626
|
+
function ys(e) {
|
|
627
|
+
return b({
|
|
628
|
+
url: `${_()}/projects/${e.id}/merge_requests`,
|
|
627
629
|
method: "post",
|
|
628
630
|
data: e
|
|
629
631
|
});
|
|
630
632
|
}
|
|
631
|
-
function
|
|
632
|
-
return
|
|
633
|
-
url: `${
|
|
633
|
+
function $s(e) {
|
|
634
|
+
return b({
|
|
635
|
+
url: `${_()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
634
636
|
method: "put"
|
|
635
637
|
});
|
|
636
638
|
}
|
|
637
|
-
function
|
|
638
|
-
return
|
|
639
|
-
url: `${
|
|
639
|
+
function vs(e) {
|
|
640
|
+
return b({
|
|
641
|
+
url: `${_()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
640
642
|
method: "put",
|
|
641
643
|
data: e
|
|
642
644
|
});
|
|
643
645
|
}
|
|
644
|
-
function
|
|
645
|
-
return
|
|
646
|
-
url: `${
|
|
646
|
+
function As(e) {
|
|
647
|
+
return b({
|
|
648
|
+
url: `${_()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
647
649
|
method: "get"
|
|
648
650
|
});
|
|
649
651
|
}
|
|
650
|
-
function
|
|
651
|
-
return
|
|
652
|
-
url: `${
|
|
652
|
+
function Ss(e) {
|
|
653
|
+
return b({
|
|
654
|
+
url: `${_()}/projects/${e.id}/repository/branches`,
|
|
653
655
|
method: "post",
|
|
654
656
|
data: e
|
|
655
657
|
});
|
|
656
658
|
}
|
|
657
|
-
function
|
|
658
|
-
return
|
|
659
|
-
url: `${
|
|
659
|
+
function Ns(e) {
|
|
660
|
+
return b({
|
|
661
|
+
url: `${_()}/projects/${e}/repository/branches`
|
|
660
662
|
});
|
|
661
663
|
}
|
|
662
|
-
function
|
|
663
|
-
const e =
|
|
664
|
-
return N(e) ?
|
|
664
|
+
function bs() {
|
|
665
|
+
const e = be("fe-groups.json");
|
|
666
|
+
return N(e) ? I.readJSONSync(e) : { groups: [] };
|
|
665
667
|
}
|
|
666
|
-
async function
|
|
667
|
-
const e = await
|
|
668
|
+
async function js() {
|
|
669
|
+
const e = await gs(), t = ba.map((a) => {
|
|
668
670
|
const n = e.find((i) => i.name === a);
|
|
669
671
|
return n ? {
|
|
670
672
|
name: n.name,
|
|
@@ -672,60 +674,60 @@ async function di() {
|
|
|
672
674
|
description: n.description
|
|
673
675
|
} : !1;
|
|
674
676
|
}).filter((a) => !!a);
|
|
675
|
-
|
|
677
|
+
I.writeJSONSync(be("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
676
678
|
}
|
|
677
|
-
async function
|
|
678
|
-
const t = `${
|
|
679
|
+
async function j(e) {
|
|
680
|
+
const t = `${U("FEServerDomain")}/api`, a = await ne({
|
|
679
681
|
url: t + e.url,
|
|
680
682
|
headers: {
|
|
681
683
|
"the-key-one": "z-develop",
|
|
682
|
-
"the-key-two":
|
|
684
|
+
"the-key-two": U("ZDevelopPassword")
|
|
683
685
|
},
|
|
684
686
|
data: e.data,
|
|
685
687
|
method: e.method || "post"
|
|
686
688
|
});
|
|
687
|
-
return a.code !== 0 &&
|
|
689
|
+
return a.code !== 0 && m(`${a.code}: ${a.message}`), a.data;
|
|
688
690
|
}
|
|
689
|
-
async function
|
|
690
|
-
const t = `${
|
|
691
|
+
async function Ts(e) {
|
|
692
|
+
const t = `${U("FEServerDomain")}/api`;
|
|
691
693
|
return await ne({
|
|
692
694
|
url: t + e.url,
|
|
693
695
|
headers: {
|
|
694
696
|
"the-key-one": "z-develop",
|
|
695
|
-
"the-key-two":
|
|
697
|
+
"the-key-two": U("ZDevelopPassword")
|
|
696
698
|
},
|
|
697
699
|
data: e.data,
|
|
698
700
|
method: e.method || "post"
|
|
699
701
|
});
|
|
700
702
|
}
|
|
701
|
-
function
|
|
702
|
-
return
|
|
703
|
+
function ks() {
|
|
704
|
+
return j({
|
|
703
705
|
url: "/user/list2"
|
|
704
706
|
});
|
|
705
707
|
}
|
|
706
|
-
function
|
|
707
|
-
return
|
|
708
|
+
function Es() {
|
|
709
|
+
return j({
|
|
708
710
|
url: "/zen/testcase/product/list"
|
|
709
711
|
});
|
|
710
712
|
}
|
|
711
|
-
function
|
|
712
|
-
return
|
|
713
|
+
function Rt(e) {
|
|
714
|
+
return j({
|
|
713
715
|
url: "/zen/testcase/product/module/list",
|
|
714
716
|
data: {
|
|
715
717
|
product: e
|
|
716
718
|
}
|
|
717
719
|
});
|
|
718
720
|
}
|
|
719
|
-
function
|
|
720
|
-
return
|
|
721
|
+
function Is(e) {
|
|
722
|
+
return j({
|
|
721
723
|
url: "/zen/testcase/product/name",
|
|
722
724
|
data: {
|
|
723
725
|
product: e
|
|
724
726
|
}
|
|
725
727
|
});
|
|
726
728
|
}
|
|
727
|
-
function
|
|
728
|
-
return
|
|
729
|
+
function Rs(e, t) {
|
|
730
|
+
return j({
|
|
729
731
|
url: "/zen/testcase/product/auto-case/list",
|
|
730
732
|
data: {
|
|
731
733
|
product: e,
|
|
@@ -733,134 +735,134 @@ function yi(e, t) {
|
|
|
733
735
|
}
|
|
734
736
|
});
|
|
735
737
|
}
|
|
736
|
-
function
|
|
737
|
-
return
|
|
738
|
+
function Cs(e) {
|
|
739
|
+
return j({
|
|
738
740
|
url: "/zen/testcase/step/list",
|
|
739
741
|
data: {
|
|
740
742
|
id: e
|
|
741
743
|
}
|
|
742
744
|
});
|
|
743
745
|
}
|
|
744
|
-
function
|
|
745
|
-
return
|
|
746
|
+
function Ls(e) {
|
|
747
|
+
return j({
|
|
746
748
|
url: "/zen/testcase/module/create",
|
|
747
749
|
data: e
|
|
748
750
|
});
|
|
749
751
|
}
|
|
750
|
-
function
|
|
751
|
-
return
|
|
752
|
+
function xs(e) {
|
|
753
|
+
return j({
|
|
752
754
|
url: "/zen/testcase/create",
|
|
753
755
|
data: e
|
|
754
756
|
});
|
|
755
757
|
}
|
|
756
|
-
function
|
|
757
|
-
return
|
|
758
|
+
function Ds(e) {
|
|
759
|
+
return j({
|
|
758
760
|
url: "/zen/testcase/step/create",
|
|
759
761
|
data: e
|
|
760
762
|
});
|
|
761
763
|
}
|
|
762
|
-
function
|
|
763
|
-
return
|
|
764
|
+
function Ps(e) {
|
|
765
|
+
return j({
|
|
764
766
|
url: "/zen/testcase/modules/remove",
|
|
765
767
|
data: e
|
|
766
768
|
});
|
|
767
769
|
}
|
|
768
|
-
function
|
|
769
|
-
return
|
|
770
|
+
function Os(e) {
|
|
771
|
+
return j({
|
|
770
772
|
url: "/zen/testcase/cases/remove",
|
|
771
773
|
data: e
|
|
772
774
|
});
|
|
773
775
|
}
|
|
774
|
-
function
|
|
775
|
-
return
|
|
776
|
+
function Ms(e) {
|
|
777
|
+
return j({
|
|
776
778
|
url: "/zen/testcase/module/update/name",
|
|
777
779
|
data: e
|
|
778
780
|
});
|
|
779
781
|
}
|
|
780
|
-
function
|
|
781
|
-
return
|
|
782
|
+
function Bs(e) {
|
|
783
|
+
return j({
|
|
782
784
|
url: "/zen/testcase/case/update/name",
|
|
783
785
|
data: e
|
|
784
786
|
});
|
|
785
787
|
}
|
|
786
|
-
function
|
|
787
|
-
return
|
|
788
|
+
function _s(e) {
|
|
789
|
+
return j({
|
|
788
790
|
url: "/zen/testcase/case/update/priority",
|
|
789
791
|
data: e
|
|
790
792
|
});
|
|
791
793
|
}
|
|
792
|
-
function
|
|
793
|
-
return
|
|
794
|
+
function Fs(e) {
|
|
795
|
+
return j({
|
|
794
796
|
url: "/zen/testcase/case/update/precondition",
|
|
795
797
|
data: e
|
|
796
798
|
});
|
|
797
799
|
}
|
|
798
|
-
function
|
|
799
|
-
return
|
|
800
|
+
function zs(e) {
|
|
801
|
+
return j({
|
|
800
802
|
url: "/zen/testcase/case/result/create",
|
|
801
803
|
data: e
|
|
802
804
|
});
|
|
803
805
|
}
|
|
804
|
-
function
|
|
805
|
-
return
|
|
806
|
+
function Js() {
|
|
807
|
+
return j({
|
|
806
808
|
url: "/zen/testcase/project/list"
|
|
807
809
|
});
|
|
808
810
|
}
|
|
809
|
-
function
|
|
810
|
-
return
|
|
811
|
+
function Gs(e) {
|
|
812
|
+
return j({
|
|
811
813
|
url: "/zen/testcase/project/execution/list",
|
|
812
814
|
data: {
|
|
813
815
|
project: e
|
|
814
816
|
}
|
|
815
817
|
});
|
|
816
818
|
}
|
|
817
|
-
function
|
|
818
|
-
return
|
|
819
|
+
function Us(e) {
|
|
820
|
+
return j({
|
|
819
821
|
url: "/zen/testcase/execution/build/list",
|
|
820
822
|
data: {
|
|
821
823
|
id: e
|
|
822
824
|
}
|
|
823
825
|
});
|
|
824
826
|
}
|
|
825
|
-
function
|
|
826
|
-
return
|
|
827
|
+
function it(e) {
|
|
828
|
+
return j({
|
|
827
829
|
url: "/common/ai/talk",
|
|
828
830
|
data: e
|
|
829
831
|
});
|
|
830
832
|
}
|
|
831
|
-
function
|
|
832
|
-
return
|
|
833
|
+
function Vs(e) {
|
|
834
|
+
return Ts({
|
|
833
835
|
url: "/common/notify/group/send",
|
|
834
836
|
data: e
|
|
835
837
|
});
|
|
836
838
|
}
|
|
837
|
-
function
|
|
838
|
-
return
|
|
839
|
+
function Ws(e) {
|
|
840
|
+
return j({
|
|
839
841
|
url: "/deploy/create/chain",
|
|
840
842
|
data: e
|
|
841
843
|
});
|
|
842
844
|
}
|
|
843
|
-
function
|
|
845
|
+
function Hs(e, t) {
|
|
844
846
|
const a = [];
|
|
845
847
|
t.forEach((s) => {
|
|
846
848
|
e.includes(s.value) && a.push(s);
|
|
847
849
|
});
|
|
848
|
-
const n =
|
|
850
|
+
const n = Se("weWorkListCache"), i = n.map((s) => s.value);
|
|
849
851
|
a.forEach((s) => {
|
|
850
852
|
const o = i.indexOf(s.value);
|
|
851
853
|
o > -1 ? n[o].usageCount += 1 : n.push({
|
|
852
854
|
...s,
|
|
853
855
|
usageCount: 1
|
|
854
856
|
});
|
|
855
|
-
}),
|
|
857
|
+
}), de({
|
|
856
858
|
weWorkListCache: n.sort((s, o) => o.usageCount - s.usageCount)
|
|
857
|
-
}),
|
|
859
|
+
}), ce();
|
|
858
860
|
}
|
|
859
|
-
async function
|
|
860
|
-
const t = (await
|
|
861
|
-
name: `${s.nick} - ${
|
|
861
|
+
async function Ct() {
|
|
862
|
+
const t = (await ks()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
863
|
+
name: `${s.nick} - ${Na[s.title]}`,
|
|
862
864
|
value: s.weWorkUserId
|
|
863
|
-
})), a =
|
|
865
|
+
})), a = Se("weWorkListCache"), n = a.map((s) => s.value), i = [];
|
|
864
866
|
return t.forEach((s) => {
|
|
865
867
|
const o = n.indexOf(s.value);
|
|
866
868
|
i.push({
|
|
@@ -869,9 +871,9 @@ async function Nt() {
|
|
|
869
871
|
});
|
|
870
872
|
}), i.sort((s, o) => o.usageCount - s.usageCount);
|
|
871
873
|
}
|
|
872
|
-
async function
|
|
873
|
-
const n = await
|
|
874
|
-
let i = await
|
|
874
|
+
async function Lt(e, t, a) {
|
|
875
|
+
const n = await Ct();
|
|
876
|
+
let i = await V({
|
|
875
877
|
message: e,
|
|
876
878
|
loop: !0,
|
|
877
879
|
pageSize: n.length || 5,
|
|
@@ -880,14 +882,14 @@ async function St(e, t, a) {
|
|
|
880
882
|
options: (s) => s ? n.filter((o) => o.name.includes(s)) : n,
|
|
881
883
|
validate: t
|
|
882
884
|
});
|
|
883
|
-
return i = Array.isArray(i) ? i : [i],
|
|
885
|
+
return i = Array.isArray(i) ? i : [i], Hs(i, n), i;
|
|
884
886
|
}
|
|
885
|
-
async function
|
|
886
|
-
const { groups: n } = await
|
|
887
|
+
async function qs(e, t, a) {
|
|
888
|
+
const { groups: n } = await Et(), i = n.map((o) => ({
|
|
887
889
|
name: o.name,
|
|
888
890
|
value: o.url
|
|
889
891
|
}));
|
|
890
|
-
let s = await
|
|
892
|
+
let s = await V({
|
|
891
893
|
message: e,
|
|
892
894
|
loop: !0,
|
|
893
895
|
pageSize: i.length || 5,
|
|
@@ -898,183 +900,206 @@ async function Oi(e, t, a) {
|
|
|
898
900
|
});
|
|
899
901
|
return s = Array.isArray(s) ? s : [s], s;
|
|
900
902
|
}
|
|
901
|
-
async function
|
|
903
|
+
async function Zs() {
|
|
902
904
|
try {
|
|
903
|
-
|
|
905
|
+
St() && (await Le({
|
|
904
906
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
905
|
-
}) ?
|
|
907
|
+
}) ? S.rm("-rf", xe()) : process.exit(0)), await fe(be(), { recursive: !0 });
|
|
906
908
|
const t = await k({
|
|
907
909
|
message: "请选择岗位类型",
|
|
908
910
|
choices: [
|
|
909
911
|
{
|
|
910
912
|
name: "前端",
|
|
911
|
-
value:
|
|
913
|
+
value: ue.FRONT_END
|
|
912
914
|
},
|
|
913
915
|
{
|
|
914
916
|
name: "后端",
|
|
915
|
-
value:
|
|
917
|
+
value: ue.BACK_END
|
|
916
918
|
},
|
|
917
919
|
{
|
|
918
920
|
name: "测试",
|
|
919
|
-
value:
|
|
921
|
+
value: ue.QUALITY_ASSURANCE
|
|
920
922
|
}
|
|
921
923
|
]
|
|
922
924
|
});
|
|
923
|
-
let a = await
|
|
925
|
+
let a = await B({
|
|
924
926
|
message: "请输入LDAP账号:"
|
|
925
927
|
});
|
|
926
928
|
a = a.trim();
|
|
927
|
-
let n = await
|
|
929
|
+
let n = await oa({
|
|
928
930
|
message: "请输入LDAP密码:",
|
|
929
931
|
mask: !0
|
|
930
932
|
});
|
|
931
|
-
n = n.trim(),
|
|
932
|
-
const i = await
|
|
933
|
-
|
|
934
|
-
const s = await
|
|
935
|
-
|
|
933
|
+
n = n.trim(), J("jobType", t), J("ldapAccount", a), J("ldapPassword", n);
|
|
934
|
+
const i = await We();
|
|
935
|
+
De(i);
|
|
936
|
+
const s = await Ct(), o = await Lt("请选择你自己(用于企微通知):", (l) => l.length > 1 ? "只能选一个" : l.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((l) => l.value === o[0]);
|
|
937
|
+
J({
|
|
936
938
|
weWorkName: r,
|
|
937
939
|
weWorkUserId: c
|
|
938
940
|
});
|
|
939
941
|
} catch (t) {
|
|
940
|
-
|
|
942
|
+
m(t);
|
|
941
943
|
}
|
|
942
|
-
const e =
|
|
944
|
+
const e = w("配置信息初始化中").start();
|
|
943
945
|
try {
|
|
944
|
-
const t = await
|
|
945
|
-
|
|
946
|
+
const t = await fs();
|
|
947
|
+
J({
|
|
946
948
|
gitUserId: t.id,
|
|
947
949
|
gitName: t.name,
|
|
948
950
|
gitEnglishName: t.username,
|
|
949
951
|
gitEmail: t.email
|
|
950
|
-
}),
|
|
952
|
+
}), de("latestCheckVersionTimestamp", Date.now()), ce(), R("jobType") === ue.FRONT_END && await js(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
951
953
|
} catch (t) {
|
|
952
|
-
e.fail("配置信息初始化失败"),
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
954
|
+
e.fail("配置信息初始化失败"), me.isAxiosError(t) && m("请检查你的域名及令牌配置"), m(t);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
const ke = (e, t, a) => {
|
|
958
|
+
const n = [
|
|
959
|
+
"#!/usr/bin/env sh",
|
|
960
|
+
...Array.isArray(t) ? t : [t],
|
|
961
|
+
""
|
|
962
|
+
].join(`
|
|
963
|
+
`).trim();
|
|
964
|
+
ve(L(e), n, {
|
|
965
|
+
mode: 493
|
|
966
|
+
});
|
|
967
|
+
}, Ks = () => {
|
|
968
|
+
ke("commit-msg", "z run commit-msg"), ke("pre-commit", "z run commit-files"), ke("pre-rebase", "z run not-allow-rebase"), ke("pre-push", "z run detect-push");
|
|
969
|
+
};
|
|
970
|
+
async function Ys() {
|
|
971
|
+
await M(Ne(), "", { mode: 493 }), await M(L(".gitignore"), `.commit-msg-tpl
|
|
972
|
+
`, { mode: 493 }), Ks();
|
|
973
|
+
const { language: e } = H();
|
|
974
|
+
if ([$.JAVASCRIPT, $.MARKDOWN].includes(e) && (await M(
|
|
975
|
+
L(".prettierrc.json"),
|
|
976
|
+
`${JSON.stringify(await us(), null, 2)}
|
|
964
977
|
`,
|
|
965
978
|
{
|
|
966
979
|
mode: 493
|
|
967
980
|
}
|
|
968
|
-
), await
|
|
969
|
-
await
|
|
981
|
+
), await M(L(".prettierignore"), await ls(), { mode: 493 }), await M(L("tsconfig.node.json"), await cs(), { mode: 493 }), await M(L("tsconfig.browser.json"), await os(), { mode: 493 })), e === $.JAVA) {
|
|
982
|
+
await ss(`${U("FECDNDomain")}/file/vgnlfbfHRF.jar`, L("checkstyle.jar")), await M(L("checkstyle.xml"), await ds(), { mode: 493 });
|
|
970
983
|
const t = f.join("package.json");
|
|
971
|
-
N(t) || await
|
|
984
|
+
N(t) || await M(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
|
|
972
985
|
mode: 493
|
|
973
986
|
});
|
|
974
987
|
}
|
|
975
|
-
|
|
988
|
+
At(), await p(`git add ${Y}`);
|
|
976
989
|
}
|
|
977
|
-
async function
|
|
978
|
-
const a = await
|
|
979
|
-
a ||
|
|
990
|
+
async function Xs(e, t) {
|
|
991
|
+
const a = await p("git remote get-url --push origin");
|
|
992
|
+
a || m("获取项目远程git地址失败,请配置后重试");
|
|
980
993
|
let n = e;
|
|
981
994
|
n || (n = await k({
|
|
982
995
|
message: "请选择项目语言",
|
|
983
996
|
choices: [
|
|
984
997
|
{
|
|
985
|
-
name:
|
|
986
|
-
value:
|
|
998
|
+
name: $.JAVASCRIPT,
|
|
999
|
+
value: $.JAVASCRIPT
|
|
987
1000
|
},
|
|
988
1001
|
{
|
|
989
|
-
name:
|
|
990
|
-
value:
|
|
1002
|
+
name: $.JAVA,
|
|
1003
|
+
value: $.JAVA
|
|
991
1004
|
},
|
|
992
1005
|
{
|
|
993
|
-
name:
|
|
994
|
-
value:
|
|
1006
|
+
name: $.PYTHON,
|
|
1007
|
+
value: $.PYTHON
|
|
995
1008
|
},
|
|
996
1009
|
{
|
|
997
|
-
name:
|
|
998
|
-
value:
|
|
1010
|
+
name: $.MARKDOWN,
|
|
1011
|
+
value: $.MARKDOWN
|
|
999
1012
|
}
|
|
1000
1013
|
]
|
|
1001
1014
|
}));
|
|
1002
1015
|
let i = t;
|
|
1003
1016
|
if (!i) {
|
|
1004
|
-
const
|
|
1005
|
-
if (!
|
|
1006
|
-
return
|
|
1007
|
-
i =
|
|
1017
|
+
const o = se(a), r = await It(o);
|
|
1018
|
+
if (!r)
|
|
1019
|
+
return m(`未找到项目,请确认项目${a}是否存在,或者当前账号权限`);
|
|
1020
|
+
i = r.namespace.full_path;
|
|
1021
|
+
}
|
|
1022
|
+
let s = await Le({
|
|
1023
|
+
message: "是否允许直接推送代码到环境分支?默认否",
|
|
1024
|
+
default: !1
|
|
1025
|
+
});
|
|
1026
|
+
if (s) {
|
|
1027
|
+
const o = await B({
|
|
1028
|
+
message: `⚠️警告:请再次确认本项目允许直接推送代码到环境分支!!这意味着本项目可以在环境分支上进行开发,这一般用于与部署环境无关、或者单一部署环境的项目。
|
|
1029
|
+
请输入【是/yes/y/Y】以确认;输入其他或者不输入则表示不允许直接推送:`
|
|
1030
|
+
});
|
|
1031
|
+
s = ["是", "yes", "y", "Y"].includes(o), s || z("✅ 已修改为不允许直接推送代码到分支环境");
|
|
1008
1032
|
}
|
|
1009
|
-
|
|
1033
|
+
kt({
|
|
1010
1034
|
language: n,
|
|
1011
|
-
"lint-staged":
|
|
1035
|
+
"lint-staged": za[n],
|
|
1012
1036
|
repository: {
|
|
1013
1037
|
url: a,
|
|
1014
1038
|
group: i
|
|
1015
|
-
}
|
|
1039
|
+
},
|
|
1040
|
+
skipGitPushLimit: s
|
|
1016
1041
|
});
|
|
1017
1042
|
}
|
|
1018
|
-
async function
|
|
1019
|
-
e ?
|
|
1020
|
-
message: `当前项目中已存在配置文件夹${
|
|
1021
|
-
}) ?
|
|
1022
|
-
const a =
|
|
1023
|
-
await
|
|
1043
|
+
async function He(e, t) {
|
|
1044
|
+
e ? S.rm("-rf", Y) : N(L()) && (await Le({
|
|
1045
|
+
message: `当前项目中已存在配置文件夹${Y},确认重新配置?`
|
|
1046
|
+
}) ? S.rm("-rf", Y) : process.exit(0)), await fe(L(), { recursive: !0 }), await Xs(e, t);
|
|
1047
|
+
const a = w("项目初始化中...").start();
|
|
1048
|
+
await Ys(), a.succeed("项目初始化完成");
|
|
1024
1049
|
}
|
|
1025
|
-
async function
|
|
1026
|
-
N(
|
|
1050
|
+
async function Qs() {
|
|
1051
|
+
N(L()) && N(Ne()) ? At() : await He(), process.exit(0);
|
|
1027
1052
|
}
|
|
1028
|
-
async function
|
|
1029
|
-
t.projectLanguage && !Object.values(
|
|
1053
|
+
async function ei(e, t) {
|
|
1054
|
+
t.projectLanguage && !Object.values($).includes(t.projectLanguage) && m("项目语言不支持"), e ? (W(), e === "." ? (await He(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await Qs() : m("参数错误。执行 z init -h 查看帮助。")) : await Zs();
|
|
1030
1055
|
}
|
|
1031
|
-
x.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(
|
|
1032
|
-
async function
|
|
1056
|
+
x.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values($).join("/")} `).action((...e) => P(ei, ...e));
|
|
1057
|
+
async function ti(e, t) {
|
|
1033
1058
|
if (!e)
|
|
1034
1059
|
return "不能为空";
|
|
1035
1060
|
if (!/^[a-z0-9-]+$/.test(e))
|
|
1036
1061
|
return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
|
|
1037
|
-
if (
|
|
1062
|
+
if (jt().includes(e))
|
|
1038
1063
|
return "当前目录下已存在同名文件夹,请先处理。";
|
|
1039
|
-
const i = (await
|
|
1064
|
+
const i = (await ws(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
|
|
1040
1065
|
return i ? `远程仓库中已存在同名项目(${i.http_url_to_repo}),请更名后重试` : !0;
|
|
1041
1066
|
}
|
|
1042
|
-
function
|
|
1067
|
+
function ai(e) {
|
|
1043
1068
|
return e ? !0 : "不能为空";
|
|
1044
1069
|
}
|
|
1045
|
-
function
|
|
1070
|
+
function si(e) {
|
|
1046
1071
|
return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
|
|
1047
1072
|
}
|
|
1048
|
-
async function
|
|
1049
|
-
|
|
1073
|
+
async function ii(e) {
|
|
1074
|
+
ee(), W(), await ge();
|
|
1050
1075
|
let t, a;
|
|
1051
1076
|
e.branchType ? t = e.branchType : t = await k({
|
|
1052
1077
|
message: "请选择创建分支的类型",
|
|
1053
1078
|
choices: [
|
|
1054
1079
|
{
|
|
1055
1080
|
name: "开发新功能(feat)",
|
|
1056
|
-
value:
|
|
1081
|
+
value: $e.FEAT
|
|
1057
1082
|
},
|
|
1058
1083
|
{
|
|
1059
1084
|
name: "修复BUG(fix)",
|
|
1060
|
-
value:
|
|
1085
|
+
value: $e.FIX
|
|
1061
1086
|
},
|
|
1062
1087
|
{
|
|
1063
1088
|
name: "重构/优化代码(refactor)",
|
|
1064
|
-
value:
|
|
1089
|
+
value: $e.REFACTOR
|
|
1065
1090
|
}
|
|
1066
1091
|
]
|
|
1067
|
-
}), e.branchPurpose ? a = e.branchPurpose : (a = await
|
|
1092
|
+
}), e.branchPurpose ? a = e.branchPurpose : (a = await B({
|
|
1068
1093
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1069
|
-
validate:
|
|
1094
|
+
validate: si
|
|
1070
1095
|
}), a = a.trim());
|
|
1071
|
-
const n = `${t}_${a}_${
|
|
1072
|
-
await
|
|
1096
|
+
const n = `${t}_${a}_${Tt()}`;
|
|
1097
|
+
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);
|
|
1073
1098
|
}
|
|
1074
|
-
const
|
|
1075
|
-
async function
|
|
1076
|
-
const e = await
|
|
1077
|
-
url:
|
|
1099
|
+
const xt = (e) => `${U("ZenTaoDomain")}${e}`;
|
|
1100
|
+
async function ni() {
|
|
1101
|
+
const e = await Ce({
|
|
1102
|
+
url: xt("/my-work-task.json?tid=mrrferp8"),
|
|
1078
1103
|
method: "get"
|
|
1079
1104
|
});
|
|
1080
1105
|
return e?.tasks ? e.tasks.filter((t) => t.status !== "done").map(({ id: t, name: a }) => ({
|
|
@@ -1085,9 +1110,9 @@ async function Wi() {
|
|
|
1085
1110
|
name: a
|
|
1086
1111
|
})) : [];
|
|
1087
1112
|
}
|
|
1088
|
-
async function
|
|
1089
|
-
const e = await
|
|
1090
|
-
url:
|
|
1113
|
+
async function ri() {
|
|
1114
|
+
const e = await Ce({
|
|
1115
|
+
url: xt("/my-work-bug.json?tid=mrrferp8"),
|
|
1091
1116
|
method: "get"
|
|
1092
1117
|
});
|
|
1093
1118
|
return e?.bugs ? Object.values(e.bugs).map(({ id: t, title: a }) => ({
|
|
@@ -1098,160 +1123,160 @@ async function qi() {
|
|
|
1098
1123
|
}
|
|
1099
1124
|
})) : [];
|
|
1100
1125
|
}
|
|
1101
|
-
const
|
|
1126
|
+
const ze = async () => (await B({
|
|
1102
1127
|
message: "请输入commit msg:",
|
|
1103
1128
|
validate: (t) => t.length === 0 ? "请输入commit msg" : !0
|
|
1104
1129
|
})).trim();
|
|
1105
|
-
async function
|
|
1106
|
-
const a = await
|
|
1130
|
+
async function nt(e, t) {
|
|
1131
|
+
const a = await p("git diff HEAD", {
|
|
1107
1132
|
removeTailLinkBreak: !1
|
|
1108
1133
|
});
|
|
1109
|
-
if (a ||
|
|
1110
|
-
const l = await
|
|
1134
|
+
if (a || m("git暂存区没有内容,请先git add添加文件到暂存区"), Buffer.byteLength(a, "utf-8") < tt) {
|
|
1135
|
+
const l = await it({
|
|
1111
1136
|
type: "commit-message-v2",
|
|
1112
1137
|
input: a
|
|
1113
1138
|
// modelName: "qwen-turbo",
|
|
1114
1139
|
});
|
|
1115
1140
|
return e + l;
|
|
1116
1141
|
}
|
|
1117
|
-
const n = await
|
|
1118
|
-
n ||
|
|
1142
|
+
const n = await p("git diff --name-only HEAD");
|
|
1143
|
+
n || m("git暂存区没有内容,请先git add添加文件到暂存区");
|
|
1119
1144
|
const i = n.replace(/\r\n/g, `
|
|
1120
1145
|
`).split(`
|
|
1121
1146
|
`).filter(Boolean), s = [], o = [];
|
|
1122
1147
|
for (const l of i)
|
|
1123
1148
|
try {
|
|
1124
|
-
const u = l.replace(/(["\\$`])/g, "\\$1"),
|
|
1149
|
+
const u = l.replace(/(["\\$`])/g, "\\$1"), d = await p(`git diff HEAD -- "${u}"`, {
|
|
1125
1150
|
removeTailLinkBreak: !1
|
|
1126
1151
|
});
|
|
1127
|
-
|
|
1152
|
+
d && Buffer.byteLength(d, "utf-8") < ka && (s.push(l), o.push(d));
|
|
1128
1153
|
} catch {
|
|
1129
1154
|
}
|
|
1130
1155
|
const r = o.join(`
|
|
1131
1156
|
`);
|
|
1132
|
-
if (s.length === 0 || Buffer.byteLength(r, "utf-8") >
|
|
1133
|
-
return
|
|
1157
|
+
if (s.length === 0 || Buffer.byteLength(r, "utf-8") > tt)
|
|
1158
|
+
return z("变更内容太大,无法自动生成commit msg"), t.stop(), await ze();
|
|
1134
1159
|
if (!r)
|
|
1135
|
-
return
|
|
1136
|
-
const c = await
|
|
1160
|
+
return z("无法获取文件差异信息"), t.stop(), await ze();
|
|
1161
|
+
const c = await it({
|
|
1137
1162
|
type: "commit-message-v2",
|
|
1138
1163
|
input: r
|
|
1139
1164
|
// modelName: "qwen-turbo",
|
|
1140
1165
|
});
|
|
1141
1166
|
return e + c;
|
|
1142
1167
|
}
|
|
1143
|
-
async function
|
|
1144
|
-
const n =
|
|
1168
|
+
async function Be(e, t, a) {
|
|
1169
|
+
const n = w("🤖 生成提交信息中...").start();
|
|
1145
1170
|
let i = "", s = !0;
|
|
1146
|
-
if ([
|
|
1171
|
+
if ([T.FEAT, T.FIX, T.REFACTOR].includes(e)) {
|
|
1147
1172
|
const o = t.map((r) => r.value).join(",");
|
|
1148
|
-
if (a || (i = await
|
|
1173
|
+
if (a || (i = await nt(`${e}(${o}): `, n)), !i) {
|
|
1149
1174
|
const r = t.map((c) => c.name).join(";");
|
|
1150
1175
|
i = `${e}(${o}): ${r}`, s = !1;
|
|
1151
1176
|
}
|
|
1152
1177
|
}
|
|
1153
|
-
e ===
|
|
1178
|
+
e === T.CHORE && (t ? i = `${e}: ${t}` : i = await nt(`${e}: `, n)), await M(Ne(), i, "utf-8"), s || a ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(A.yellow(i));
|
|
1154
1179
|
}
|
|
1155
|
-
async function
|
|
1156
|
-
|
|
1180
|
+
async function oi({ commitMessageCloseAi: e, commitMessageUseChoreType: t }) {
|
|
1181
|
+
let a;
|
|
1182
|
+
if (t ? a = T.CHORE : a = await k({
|
|
1157
1183
|
message: "请选择你要创建的模板类型",
|
|
1158
1184
|
choices: [
|
|
1159
1185
|
{
|
|
1160
1186
|
name: "feat - 业务需求/功能开发/BUG修复",
|
|
1161
|
-
value:
|
|
1187
|
+
value: T.FEAT
|
|
1162
1188
|
},
|
|
1163
1189
|
{
|
|
1164
1190
|
name: "fix - bug修复",
|
|
1165
|
-
value:
|
|
1191
|
+
value: T.FIX
|
|
1166
1192
|
},
|
|
1167
1193
|
{
|
|
1168
1194
|
name: "refactor - 技术重构/性能优化/代码规范",
|
|
1169
|
-
value:
|
|
1195
|
+
value: T.REFACTOR
|
|
1170
1196
|
},
|
|
1171
1197
|
{
|
|
1172
1198
|
name: "chore - 其他",
|
|
1173
|
-
value:
|
|
1199
|
+
value: T.CHORE
|
|
1174
1200
|
}
|
|
1175
1201
|
]
|
|
1176
|
-
})
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
const n = await Se({
|
|
1202
|
+
}), [T.FEAT, T.REFACTOR].includes(a)) {
|
|
1203
|
+
const n = await ni();
|
|
1204
|
+
if (!n.length)
|
|
1205
|
+
return G("🤷 暂无开发任务");
|
|
1206
|
+
const i = await Re({
|
|
1182
1207
|
message: "请关联开发任务(可多选):",
|
|
1183
|
-
validate: (
|
|
1184
|
-
choices:
|
|
1185
|
-
...
|
|
1186
|
-
name: `[${
|
|
1208
|
+
validate: (s) => s.length === 0 ? "请选择项" : !0,
|
|
1209
|
+
choices: n.map((s) => ({
|
|
1210
|
+
...s,
|
|
1211
|
+
name: `[${s.value.value}]: ${s.name}`
|
|
1187
1212
|
})),
|
|
1188
|
-
pageSize:
|
|
1213
|
+
pageSize: n.length
|
|
1189
1214
|
});
|
|
1190
|
-
await
|
|
1215
|
+
await Be(T.FEAT, i, e);
|
|
1191
1216
|
}
|
|
1192
|
-
if (
|
|
1193
|
-
const
|
|
1194
|
-
if (!
|
|
1195
|
-
return
|
|
1196
|
-
const
|
|
1217
|
+
if (a === T.FIX) {
|
|
1218
|
+
const n = await ri();
|
|
1219
|
+
if (!n.length)
|
|
1220
|
+
return G("🤷 暂无BUG");
|
|
1221
|
+
const i = await Re({
|
|
1197
1222
|
message: "请关联Bug(可多选):",
|
|
1198
|
-
validate: (
|
|
1199
|
-
choices:
|
|
1200
|
-
...
|
|
1201
|
-
name: `[${
|
|
1223
|
+
validate: (s) => s.length === 0 ? "请选择项" : !0,
|
|
1224
|
+
choices: n.map((s) => ({
|
|
1225
|
+
...s,
|
|
1226
|
+
name: `[${s.value.value}]: ${s.name}`
|
|
1202
1227
|
})),
|
|
1203
|
-
pageSize:
|
|
1228
|
+
pageSize: n.length
|
|
1204
1229
|
});
|
|
1205
|
-
await
|
|
1230
|
+
await Be(T.FIX, i, e);
|
|
1206
1231
|
}
|
|
1207
|
-
if (
|
|
1208
|
-
let
|
|
1209
|
-
e && (
|
|
1232
|
+
if (a === T.CHORE) {
|
|
1233
|
+
let n = "";
|
|
1234
|
+
e && (n = await ze()), await Be(T.CHORE, n);
|
|
1210
1235
|
}
|
|
1211
1236
|
process.exit(0);
|
|
1212
1237
|
}
|
|
1213
|
-
async function
|
|
1238
|
+
async function ci() {
|
|
1214
1239
|
try {
|
|
1215
1240
|
const e = {}, t = async () => {
|
|
1216
|
-
const O =
|
|
1217
|
-
const
|
|
1218
|
-
name: `${
|
|
1219
|
-
value:
|
|
1241
|
+
const O = jt(), { projects: re } = await is(), te = re.map((le) => {
|
|
1242
|
+
const Xe = {
|
|
1243
|
+
name: `${le.name} [${le.desc}]`,
|
|
1244
|
+
value: le.name,
|
|
1220
1245
|
disabled: !1
|
|
1221
1246
|
};
|
|
1222
|
-
return O.includes(
|
|
1223
|
-
}),
|
|
1247
|
+
return O.includes(le.name) && (Xe.disabled = "目录下已存在同名文件夹"), Xe;
|
|
1248
|
+
}), Wt = await k({
|
|
1224
1249
|
message: "请选择一个项目模板",
|
|
1225
|
-
choices:
|
|
1226
|
-
}),
|
|
1227
|
-
e.tplName =
|
|
1250
|
+
choices: te
|
|
1251
|
+
}), Me = re.find((le) => le.name === Wt);
|
|
1252
|
+
e.tplName = Me.name, e.tplUrl = Me.url, e.tplLanguage = Me.language;
|
|
1228
1253
|
}, a = async () => {
|
|
1229
|
-
const { groups: O } =
|
|
1254
|
+
const { groups: O } = bs(), re = await k({
|
|
1230
1255
|
message: "请选择一个分组",
|
|
1231
|
-
choices: O.map((
|
|
1232
|
-
name: `${
|
|
1233
|
-
value:
|
|
1234
|
-
short:
|
|
1256
|
+
choices: O.map((te) => ({
|
|
1257
|
+
name: `${te.name} [${te.description}]`,
|
|
1258
|
+
value: te.id,
|
|
1259
|
+
short: te.name
|
|
1235
1260
|
}))
|
|
1236
1261
|
});
|
|
1237
1262
|
e.group = {
|
|
1238
|
-
id:
|
|
1239
|
-
name: O.find((
|
|
1263
|
+
id: re,
|
|
1264
|
+
name: O.find((te) => te.id === re)?.name
|
|
1240
1265
|
};
|
|
1241
1266
|
}, n = async () => {
|
|
1242
|
-
e.projectName = await
|
|
1267
|
+
e.projectName = await B({
|
|
1243
1268
|
message: "请输入项目名称",
|
|
1244
|
-
validate: (O) =>
|
|
1245
|
-
}), e.projectName = e.projectName.trim(), e.projectDesc = await
|
|
1269
|
+
validate: (O) => ti(O, e.group?.name || "")
|
|
1270
|
+
}), e.projectName = e.projectName.trim(), e.projectDesc = await B({
|
|
1246
1271
|
message: "请输入项目描述",
|
|
1247
|
-
validate:
|
|
1272
|
+
validate: ai
|
|
1248
1273
|
}), e.projectDesc = e.projectDesc.trim();
|
|
1249
1274
|
};
|
|
1250
1275
|
await t(), await a(), await n();
|
|
1251
|
-
const i = `${
|
|
1252
|
-
await
|
|
1253
|
-
const o =
|
|
1254
|
-
|
|
1276
|
+
const i = `${Ae}/${e.group?.name}/${e.projectName}.git`, s = w("模版初始化中").start();
|
|
1277
|
+
await p(`git clone --depth=1 ${e.tplUrl}`), await pt(e.tplName, e.projectName), S.cd(e.projectName), S.rm("-rf", ".git"), await p(`git init --initial-branch=${y.MASTER}`), await p(`git remote add origin ${i}`), await p(`git config user.name ${R("gitName")}`), await p(`git config user.email ${R("gitEmail")}`);
|
|
1278
|
+
const o = Ve();
|
|
1279
|
+
Xa({
|
|
1255
1280
|
...o,
|
|
1256
1281
|
name: e.projectName,
|
|
1257
1282
|
description: e.projectDesc,
|
|
@@ -1259,38 +1284,38 @@ async function Zi() {
|
|
|
1259
1284
|
...o.scripts,
|
|
1260
1285
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1261
1286
|
}
|
|
1262
|
-
}), await
|
|
1263
|
-
const r =
|
|
1264
|
-
await
|
|
1265
|
-
const c =
|
|
1266
|
-
await
|
|
1267
|
-
const l = await
|
|
1287
|
+
}), await I.writeFile(f.resolve("README.md"), Fa(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await He(e.tplLanguage, e.group?.name);
|
|
1288
|
+
const r = w("依赖安装中").start();
|
|
1289
|
+
await p("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1290
|
+
const c = w("项目推送中").start();
|
|
1291
|
+
await p('git add . && git commit -m "chore: 项目初始化"'), await p("git tag v0.0.1");
|
|
1292
|
+
const l = await hs({
|
|
1268
1293
|
name: e.projectName,
|
|
1269
1294
|
description: e.projectDesc,
|
|
1270
1295
|
path: e.projectName,
|
|
1271
1296
|
visibility: "private",
|
|
1272
1297
|
namespace_id: e.group?.id
|
|
1273
1298
|
});
|
|
1274
|
-
await
|
|
1275
|
-
const u =
|
|
1299
|
+
await p(`git push -u origin ${y.MASTER}`), await p(`git push origin HEAD:${y.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${A.blue(i)}`);
|
|
1300
|
+
const u = w("初始化分支中").start(), d = `feat_init_${Tt()}`, h = [y.DEV, y.TEST, y.RELEASE, d], g = await Promise.allSettled(
|
|
1276
1301
|
h.map(
|
|
1277
|
-
(O) =>
|
|
1302
|
+
(O) => Ss({
|
|
1278
1303
|
id: l.id,
|
|
1279
1304
|
branch: O,
|
|
1280
|
-
ref:
|
|
1305
|
+
ref: y.MASTER
|
|
1281
1306
|
})
|
|
1282
1307
|
)
|
|
1283
|
-
),
|
|
1284
|
-
g.forEach(({ status: O },
|
|
1285
|
-
O === "fulfilled" &&
|
|
1286
|
-
}), await
|
|
1287
|
-
const
|
|
1288
|
-
console.log(`输入 ${A.green(
|
|
1308
|
+
), v = [];
|
|
1309
|
+
g.forEach(({ status: O }, re) => {
|
|
1310
|
+
O === "fulfilled" && v.push(h[re]);
|
|
1311
|
+
}), await p("git pull"), v.includes(d) ? (await p(`git checkout -b ${d} origin/${d}`), u.succeed(`项目已切换到初始分支: ${A.blue(d)}`)) : u.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
|
|
1312
|
+
const q = `cd ${e.projectName} && z start`;
|
|
1313
|
+
console.log(`输入 ${A.green(q)} 开始开发吧~`), process.exit(0);
|
|
1289
1314
|
} catch (e) {
|
|
1290
|
-
|
|
1315
|
+
m(e);
|
|
1291
1316
|
}
|
|
1292
1317
|
}
|
|
1293
|
-
async function
|
|
1318
|
+
async function li(e, t) {
|
|
1294
1319
|
let a;
|
|
1295
1320
|
e ? [
|
|
1296
1321
|
"project",
|
|
@@ -1304,7 +1329,7 @@ async function Ki(e, t) {
|
|
|
1304
1329
|
"commit-msg",
|
|
1305
1330
|
"cm"
|
|
1306
1331
|
/* CommitMsgAbbr */
|
|
1307
|
-
].includes(e) ? a = "commit-msg" :
|
|
1332
|
+
].includes(e) ? a = "commit-msg" : m("参数输入错误") : a = await k({
|
|
1308
1333
|
message: "请选择你要创建的类型",
|
|
1309
1334
|
choices: [
|
|
1310
1335
|
{
|
|
@@ -1323,68 +1348,68 @@ async function Ki(e, t) {
|
|
|
1323
1348
|
/* Project */
|
|
1324
1349
|
}
|
|
1325
1350
|
]
|
|
1326
|
-
}), a === "project" ? await
|
|
1351
|
+
}), a === "project" ? await ci() : (ee(), W(), a === "branch" ? await ii(t) : a === "commit-msg" && (await p("git status -s") ? await oi(t) : m("没有要变动的文件,无法生成提交信息")));
|
|
1327
1352
|
}
|
|
1328
|
-
x.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(
|
|
1329
|
-
const
|
|
1330
|
-
const t = await
|
|
1353
|
+
x.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values($e).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").option("-c, --commit-message-use-chore-type", "创建提交信息时,直接使用chore类型。").action((...e) => P(li, ...e));
|
|
1354
|
+
const ui = async (e) => {
|
|
1355
|
+
const t = await as(), a = R("weWorkUserId"), { notifyUsers: n, notifyGroups: i, ...s } = e, o = w("部署任务创建中").start(), r = await Ws({
|
|
1331
1356
|
...s,
|
|
1332
1357
|
userToken: t,
|
|
1333
1358
|
userWeworkId: a,
|
|
1334
|
-
notifyUsers: [.../* @__PURE__ */ new Set([a, ...n])].join(
|
|
1335
|
-
notifyGroups: i.join(
|
|
1359
|
+
notifyUsers: [.../* @__PURE__ */ new Set([a, ...n])].join(Fe),
|
|
1360
|
+
notifyGroups: i.join(Fe)
|
|
1336
1361
|
});
|
|
1337
1362
|
s.moduleNames.length > 1 ? (o.succeed(`多模块部署任务创建完成,共 ${s.moduleNames.length} 个模块`), o.succeed(`当前已创建首个模块 ${A.blue(s.moduleNames[0])} 的 k8s 地址:`), console.log(A.blue(r)), o.info("后续模块会在前一个模块完成后依次部署,并通过企微通知下发对应地址。")) : (o.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${A.blue(r)}`));
|
|
1338
1363
|
};
|
|
1339
|
-
function
|
|
1340
|
-
const a =
|
|
1341
|
-
if (
|
|
1364
|
+
function pi(e, t) {
|
|
1365
|
+
const a = Ve();
|
|
1366
|
+
if (H()?.repository?.url || m(".z/project.json中缺少repository.url"), t === X.H5) {
|
|
1342
1367
|
const i = `build:${e}`;
|
|
1343
|
-
a?.scripts[i] ||
|
|
1368
|
+
a?.scripts[i] || m(`项目package.json文件scripts不存在命令${i}。`);
|
|
1344
1369
|
}
|
|
1345
|
-
t ===
|
|
1370
|
+
t === X.NPM && (a?.scripts.build || m("项目package.json文件scripts不存在命令build。")), t === X.SERVER && (a?.scripts.build || m("项目package.json文件scripts不存在命令build。"));
|
|
1346
1371
|
}
|
|
1347
|
-
async function
|
|
1348
|
-
|
|
1372
|
+
async function Dt(e, t) {
|
|
1373
|
+
ee(), W();
|
|
1349
1374
|
let a = e, n = t.platform;
|
|
1350
|
-
const i =
|
|
1351
|
-
if (i.language ===
|
|
1375
|
+
const i = H();
|
|
1376
|
+
if (i.language === $.JAVA && (n = X.SERVER), a && !Object.values(y).includes(a) && m("仅支持发布指定环境分支"), n && !Object.values(X).includes(n) && m("发布平台错误"), n || (n = await k({
|
|
1352
1377
|
message: "请选择平台",
|
|
1353
|
-
choices:
|
|
1354
|
-
})), n ===
|
|
1378
|
+
choices: Sa
|
|
1379
|
+
})), n === X.NPM && (a = y.MASTER), !a) {
|
|
1355
1380
|
const l = await k({
|
|
1356
1381
|
message: "请选择部署环境",
|
|
1357
|
-
choices:
|
|
1382
|
+
choices: yt
|
|
1358
1383
|
});
|
|
1359
|
-
a =
|
|
1384
|
+
a = Ba(l);
|
|
1360
1385
|
}
|
|
1361
1386
|
let s = "";
|
|
1362
|
-
i.language ===
|
|
1387
|
+
i.language === $.JAVASCRIPT && (s = ja);
|
|
1363
1388
|
const o = [];
|
|
1364
|
-
if (i.language ===
|
|
1389
|
+
if (i.language === $.JAVASCRIPT) {
|
|
1365
1390
|
let l = "";
|
|
1366
|
-
const u =
|
|
1391
|
+
const u = Ve();
|
|
1367
1392
|
u.name.startsWith("@") && u.name.includes("/") ? l = u.name.split("/").pop() || "" : l = u.name, l && o.push(l);
|
|
1368
1393
|
}
|
|
1369
|
-
if (i.language ===
|
|
1370
|
-
const { projects: l } = await
|
|
1371
|
-
(
|
|
1394
|
+
if (i.language === $.JAVA) {
|
|
1395
|
+
const { projects: l } = await ns(), u = l.find(
|
|
1396
|
+
(d) => se(d.url) === se(i.repository.url)
|
|
1372
1397
|
);
|
|
1373
1398
|
if (!u)
|
|
1374
|
-
|
|
1399
|
+
m("未找到项目对应的模块信息");
|
|
1375
1400
|
else {
|
|
1376
1401
|
s = u["k8s-group-name"];
|
|
1377
|
-
const
|
|
1378
|
-
name: `${g} (${
|
|
1402
|
+
const d = u.modules.map(({ name: g, desc: v }) => ({
|
|
1403
|
+
name: `${g} (${v})`,
|
|
1379
1404
|
value: g
|
|
1380
1405
|
}));
|
|
1381
1406
|
if (t.module) {
|
|
1382
|
-
const g = new Set(t.module.split(
|
|
1383
|
-
|
|
1407
|
+
const g = new Set(t.module.split(Fe));
|
|
1408
|
+
d.forEach((v) => g.has(v.value) && o.push(v.value));
|
|
1384
1409
|
}
|
|
1385
|
-
const h = await
|
|
1410
|
+
const h = await V({
|
|
1386
1411
|
message: "请选择部署模块",
|
|
1387
|
-
options: (g) => g ?
|
|
1412
|
+
options: (g) => g ? d.filter((v) => v.name.includes(g)) : d,
|
|
1388
1413
|
pageSize: 20,
|
|
1389
1414
|
loop: !0,
|
|
1390
1415
|
clearInputWhenSelected: !0,
|
|
@@ -1393,7 +1418,7 @@ async function jt(e, t) {
|
|
|
1393
1418
|
filter: !0,
|
|
1394
1419
|
theme: {
|
|
1395
1420
|
style: {
|
|
1396
|
-
renderSelectedOptions: (g) => g.map((
|
|
1421
|
+
renderSelectedOptions: (g) => g.map((v, q) => `${q + 1}.${v.value}`).join(", ")
|
|
1397
1422
|
}
|
|
1398
1423
|
}
|
|
1399
1424
|
});
|
|
@@ -1401,13 +1426,13 @@ async function jt(e, t) {
|
|
|
1401
1426
|
}
|
|
1402
1427
|
}
|
|
1403
1428
|
let r = [];
|
|
1404
|
-
t.skipSelectionNotification || (r = await
|
|
1429
|
+
t.skipSelectionNotification || (r = await Lt("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1405
1430
|
let c = [];
|
|
1406
|
-
if (t.skipGroupNotification || (c = await
|
|
1407
|
-
const l =
|
|
1408
|
-
|
|
1431
|
+
if (t.skipGroupNotification || (c = await qs("请选择部署成功要通知的群组:", () => !0, !0)), i.language === $.JAVASCRIPT) {
|
|
1432
|
+
const l = Ma(a);
|
|
1433
|
+
pi(l, n);
|
|
1409
1434
|
}
|
|
1410
|
-
await
|
|
1435
|
+
await ui({
|
|
1411
1436
|
moduleNames: o,
|
|
1412
1437
|
k8sGroupName: s,
|
|
1413
1438
|
branchName: a,
|
|
@@ -1415,41 +1440,41 @@ async function jt(e, t) {
|
|
|
1415
1440
|
notifyGroups: c
|
|
1416
1441
|
});
|
|
1417
1442
|
}
|
|
1418
|
-
async function
|
|
1419
|
-
const i =
|
|
1443
|
+
async function Pt(e, t, a, n) {
|
|
1444
|
+
const i = w(`分支合并中,${e} -> ${t}`).start();
|
|
1420
1445
|
let s = 0;
|
|
1421
1446
|
try {
|
|
1422
|
-
const { iid: r } = await
|
|
1447
|
+
const { iid: r } = await ys({
|
|
1423
1448
|
title: `${e} -> ${t} by z-develop`,
|
|
1424
1449
|
id: a.id,
|
|
1425
1450
|
source_branch: e,
|
|
1426
1451
|
target_branch: t,
|
|
1427
1452
|
// 合到主分支上的分支需要在合并完成后被移除
|
|
1428
|
-
remove_source_branch: n ? !1 :
|
|
1453
|
+
remove_source_branch: n ? !1 : y.MASTER === t
|
|
1429
1454
|
});
|
|
1430
1455
|
s = r;
|
|
1431
1456
|
} catch (r) {
|
|
1432
|
-
|
|
1457
|
+
me.isAxiosError(r) && r?.response?.status === 409 && m(`存在重复的合并请求,前往查看${a.mergeRequestUrl}`), m(r);
|
|
1433
1458
|
}
|
|
1434
1459
|
const o = async () => {
|
|
1435
1460
|
try {
|
|
1436
1461
|
await new Promise((r) => {
|
|
1437
1462
|
setTimeout(r, 5e3);
|
|
1438
|
-
}), await
|
|
1463
|
+
}), await $s({
|
|
1439
1464
|
id: a.id,
|
|
1440
1465
|
iid: s
|
|
1441
1466
|
}), i.succeed(`分支${e}已合并到分支${t}`);
|
|
1442
1467
|
} catch (r) {
|
|
1443
|
-
|
|
1468
|
+
me.isAxiosError(r) || m(r);
|
|
1444
1469
|
const c = r?.response?.status;
|
|
1445
1470
|
if (c === 406)
|
|
1446
1471
|
return await o();
|
|
1447
|
-
if (await
|
|
1472
|
+
if (await vs({
|
|
1448
1473
|
id: a.id,
|
|
1449
1474
|
iid: s,
|
|
1450
1475
|
state_event: "close"
|
|
1451
1476
|
}), c === 405) {
|
|
1452
|
-
const l = await
|
|
1477
|
+
const l = await As({
|
|
1453
1478
|
id: a.id,
|
|
1454
1479
|
iid: s
|
|
1455
1480
|
});
|
|
@@ -1463,77 +1488,84 @@ async function kt(e, t, a, n) {
|
|
|
1463
1488
|
};
|
|
1464
1489
|
await o();
|
|
1465
1490
|
}
|
|
1466
|
-
async function
|
|
1467
|
-
const a = `origin/${e.sourceBranch}`, n = await
|
|
1491
|
+
async function mi(e, t) {
|
|
1492
|
+
const a = `origin/${e.sourceBranch}`, n = await p(`git log -b origin/${y.MASTER} -1 --format=%H`), i = await p(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await p(
|
|
1468
1493
|
`git log ${n}...${i} -b ${a}`
|
|
1469
1494
|
);
|
|
1470
|
-
if (s ||
|
|
1495
|
+
if (s || m(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await p(
|
|
1471
1496
|
`git branch --contains ${n} -r ${a}`
|
|
1472
|
-
) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await
|
|
1497
|
+
) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await Pt(y.MASTER, e.sourceBranch, e)), t === y.MASTER) {
|
|
1473
1498
|
const r = s.split(`
|
|
1474
|
-
`).filter((
|
|
1499
|
+
`).filter((d) => d), c = await p(`git log -b origin/${C.TEST} -1 --format=%H`), u = (await p(
|
|
1475
1500
|
`git log ${n}...${c} -b origin/${C.TEST}`
|
|
1476
1501
|
)).split(`
|
|
1477
|
-
`).filter((
|
|
1478
|
-
|
|
1502
|
+
`).filter((d) => d);
|
|
1503
|
+
Oa(u, r) || m("请先在测试环境发布要部署的代码");
|
|
1479
1504
|
}
|
|
1480
1505
|
}
|
|
1481
|
-
async
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1506
|
+
const rt = async (e, t) => {
|
|
1507
|
+
try {
|
|
1508
|
+
await p(`git push -u origin ${e}`), t.succeed(`本地分支${e}已推送到远程分支origin/${e}`);
|
|
1509
|
+
} catch (a) {
|
|
1510
|
+
m(`合并到远程分支 ${e} 失败,${a}`);
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
async function di(e, t) {
|
|
1514
|
+
ee(), W(), await ge();
|
|
1515
|
+
const a = await Qa();
|
|
1516
|
+
Object.values(y).includes(a.sourceBranch) && m(`当前分支${a.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1517
|
+
const i = (await Ns(a.id)).filter((c) => ![a.sourceBranch].includes(c.name)).map((c) => {
|
|
1486
1518
|
let l = c.name;
|
|
1487
|
-
return Object.values(
|
|
1519
|
+
return Object.values(y).includes(l) && (l = A.bold.blue(l)), {
|
|
1488
1520
|
name: l,
|
|
1489
1521
|
value: c.name
|
|
1490
1522
|
};
|
|
1491
1523
|
});
|
|
1492
1524
|
let s;
|
|
1493
|
-
e && !i.filter((c) => c.value === e).length &&
|
|
1525
|
+
e && !i.filter((c) => c.value === e).length && m(`未找到目标分支${e}`), e ? s = e : s = await k({
|
|
1494
1526
|
message: "请选择要合并到的目标分支:",
|
|
1495
1527
|
choices: i
|
|
1496
1528
|
});
|
|
1497
|
-
const o =
|
|
1498
|
-
if (await
|
|
1499
|
-
o.text = `存在远程分支origin/${a.sourceBranch}`, await
|
|
1500
|
-
const c = await
|
|
1501
|
-
await
|
|
1529
|
+
const o = w(`本地分支${a.sourceBranch}检测中`).start();
|
|
1530
|
+
if (await p(`git ls-remote --heads origin ${a.sourceBranch}`)) {
|
|
1531
|
+
o.text = `存在远程分支origin/${a.sourceBranch}`, await p("git fetch");
|
|
1532
|
+
const c = await p(`git rev-parse ${a.sourceBranch}`), l = await p(`git rev-parse origin/${a.sourceBranch}`);
|
|
1533
|
+
await p(`git merge-base ${l} HEAD`) === l ? await rt(a.sourceBranch, o) : await p(`git merge-base ${c} ${l}`) === c ? (await p("git pull"), o.succeed(`本地分支${a.sourceBranch}已更新`)) : (o.fail(
|
|
1502
1534
|
`远程分支origin/${a.sourceBranch}和本地分支${a.sourceBranch}都有新的提交,请手动合并后再试。`
|
|
1503
1535
|
), process.exit(1));
|
|
1504
1536
|
} else
|
|
1505
|
-
await
|
|
1506
|
-
await
|
|
1507
|
-
`${a.sourceBranch}分支已移除,当前已切换到最新的${
|
|
1508
|
-
)), Object.values(
|
|
1537
|
+
await rt(a.sourceBranch, o);
|
|
1538
|
+
await mi(a, s), await Pt(a.sourceBranch, s, a, 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 ${a.sourceBranch}`), G(
|
|
1539
|
+
`${a.sourceBranch}分支已移除,当前已切换到最新的${y.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1540
|
+
)), Object.values(y).includes(s) && await Dt(s, {
|
|
1509
1541
|
platform: t.deployPlatform,
|
|
1510
1542
|
skipSelectionNotification: t.deploySkipSelectionNotification,
|
|
1511
1543
|
skipGroupNotification: t.skipGroupNotification
|
|
1512
1544
|
});
|
|
1513
1545
|
}
|
|
1514
|
-
x.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(
|
|
1515
|
-
x.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(
|
|
1516
|
-
async function
|
|
1546
|
+
x.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(X).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => P(di, ...e));
|
|
1547
|
+
x.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(y).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(X).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称,多个使用逗号分隔").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => P(Dt, ...e));
|
|
1548
|
+
async function fi() {
|
|
1517
1549
|
try {
|
|
1518
|
-
await
|
|
1550
|
+
await p("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
|
|
1519
1551
|
silent: !1
|
|
1520
|
-
}),
|
|
1552
|
+
}), G("checkstyle执行完毕"), process.exit(0);
|
|
1521
1553
|
} catch {
|
|
1522
|
-
|
|
1554
|
+
m("checkstyle执行出错"), process.exit(1);
|
|
1523
1555
|
}
|
|
1524
1556
|
}
|
|
1525
|
-
const
|
|
1526
|
-
await
|
|
1527
|
-
const t = `${
|
|
1557
|
+
const Ie = "origin/", gi = Object.values(y).map((e) => `${Ie}${e}`), hi = Object.values(y), Ee = y.MASTER, wi = async (e) => {
|
|
1558
|
+
await p("git fetch --prune");
|
|
1559
|
+
const t = `${Ie}${e}`, a = await p(`git branch -r --merged ${t}`, {
|
|
1528
1560
|
encoding: "utf8"
|
|
1529
|
-
}), n = await
|
|
1561
|
+
}), n = await p(`git branch --merged ${t}`, {
|
|
1530
1562
|
encoding: "utf8"
|
|
1531
1563
|
}), i = /* @__PURE__ */ new Map();
|
|
1532
1564
|
return a.split(`
|
|
1533
1565
|
`).forEach((s) => {
|
|
1534
1566
|
const o = s.trim();
|
|
1535
|
-
if (o && o !== t && !o.startsWith(`${
|
|
1536
|
-
const r = o.replace(new RegExp(`^${
|
|
1567
|
+
if (o && o !== t && !o.startsWith(`${Ie}HEAD`) && !gi.includes(o)) {
|
|
1568
|
+
const r = o.replace(new RegExp(`^${Ie}`), "");
|
|
1537
1569
|
i.set(r, {
|
|
1538
1570
|
name: r,
|
|
1539
1571
|
value: r,
|
|
@@ -1544,7 +1576,7 @@ const Ne = "origin/", an = Object.values(v).map((e) => `${Ne}${e}`), nn = Object
|
|
|
1544
1576
|
}), n.split(`
|
|
1545
1577
|
`).forEach((s) => {
|
|
1546
1578
|
const o = s.replace(/^\*?\s*/, "").trim();
|
|
1547
|
-
if (o && o !== e && !
|
|
1579
|
+
if (o && o !== e && !hi.includes(o)) {
|
|
1548
1580
|
const r = i.get(o);
|
|
1549
1581
|
i.set(o, {
|
|
1550
1582
|
name: o,
|
|
@@ -1557,7 +1589,7 @@ const Ne = "origin/", an = Object.values(v).map((e) => `${Ne}${e}`), nn = Object
|
|
|
1557
1589
|
...s,
|
|
1558
1590
|
name: `${s.value}${s.hasRemote && s.hasLocal ? "(本地/远程)" : s.hasRemote ? "(远程)" : "(本地)"}`
|
|
1559
1591
|
})).sort((s, o) => s.value.localeCompare(o.value));
|
|
1560
|
-
},
|
|
1592
|
+
}, yi = (e) => V({
|
|
1561
1593
|
message: "请选择需要删除的分支",
|
|
1562
1594
|
options: (t) => t ? e.filter((a) => a.name.includes(t)) : e,
|
|
1563
1595
|
pageSize: 20,
|
|
@@ -1571,83 +1603,123 @@ const Ne = "origin/", an = Object.values(v).map((e) => `${Ne}${e}`), nn = Object
|
|
|
1571
1603
|
renderSelectedOptions: (t) => t.map((a) => a.value).join(", ")
|
|
1572
1604
|
}
|
|
1573
1605
|
}
|
|
1574
|
-
}),
|
|
1575
|
-
|
|
1576
|
-
},
|
|
1577
|
-
|
|
1578
|
-
},
|
|
1579
|
-
await
|
|
1580
|
-
const e =
|
|
1581
|
-
if (e.succeed(`查询到 ${t.length} 个已合并到 ${
|
|
1582
|
-
|
|
1606
|
+
}), $i = async (e) => (await p(`git branch --list ${e}`)).trim() !== "", vi = (e) => {
|
|
1607
|
+
Ue(`git push origin --delete ${e}`);
|
|
1608
|
+
}, Ai = (e) => {
|
|
1609
|
+
Ue(`git branch -d ${e}`);
|
|
1610
|
+
}, Si = async () => {
|
|
1611
|
+
await ge();
|
|
1612
|
+
const e = w(`正在查询本地和远程已经合并到${Ee}的分支...`).start(), t = await wi(Ee);
|
|
1613
|
+
if (e.succeed(`查询到 ${t.length} 个已合并到 ${Ee} 的分支`), !t.length) {
|
|
1614
|
+
z(`未查询到已合并到 ${Ee} 的可删除分支`);
|
|
1583
1615
|
return;
|
|
1584
1616
|
}
|
|
1585
|
-
const a = await
|
|
1586
|
-
if (!await
|
|
1617
|
+
const a = await yi(t);
|
|
1618
|
+
if (!await Le({
|
|
1587
1619
|
message: `确认删除选中的 ${a.length} 个分支对应的远程分支和本地分支?`,
|
|
1588
1620
|
default: !1
|
|
1589
1621
|
})) {
|
|
1590
|
-
|
|
1622
|
+
z("已取消删除");
|
|
1591
1623
|
return;
|
|
1592
1624
|
}
|
|
1593
|
-
const i = await
|
|
1625
|
+
const i = await p("git branch --show-current"), s = [], o = [], r = [], c = t.filter((u) => a.includes(u.value)), l = w("正在删除分支...").start();
|
|
1594
1626
|
try {
|
|
1595
1627
|
for (const u of c) {
|
|
1596
|
-
const { value:
|
|
1597
|
-
if (g && (l.text = `正在删除远程分支 ${
|
|
1598
|
-
h && s.push(
|
|
1628
|
+
const { value: d, hasLocal: h, hasRemote: g } = u;
|
|
1629
|
+
if (g && (l.text = `正在删除远程分支 ${d}...`, vi(d), o.push(d)), d === i) {
|
|
1630
|
+
h && s.push(d);
|
|
1599
1631
|
continue;
|
|
1600
1632
|
}
|
|
1601
|
-
!h || !await
|
|
1633
|
+
!h || !await $i(d) || (l.text = `正在删除本地分支 ${d}...`, Ai(d), r.push(d));
|
|
1602
1634
|
}
|
|
1603
1635
|
} catch (u) {
|
|
1604
1636
|
throw l.fail("删除分支失败"), u;
|
|
1605
1637
|
}
|
|
1606
|
-
l.succeed("分支删除完成"), o.length &&
|
|
1638
|
+
l.succeed("分支删除完成"), o.length && G(`远程分支删除完成:${o.join(", ")}`), r.length && G(`本地分支删除完成:${r.join(", ")}`), s.length && z(`${s.join(", ")} 为当前分支,无法删除本地分支`);
|
|
1639
|
+
}, Ot = "0000000000000000000000000000000000000000", ot = "refs/heads/", Ni = async (e, t) => `${t === Ot ? await p(`git rev-parse --verify --quiet origin/${y.MASTER}`) : t}..${e}`, bi = async (e) => {
|
|
1640
|
+
try {
|
|
1641
|
+
return (await p(`git log ${e} --grep="(cherry picked from commit" --format="%H"`)).split(`
|
|
1642
|
+
`).filter(Boolean);
|
|
1643
|
+
} catch {
|
|
1644
|
+
return [];
|
|
1645
|
+
}
|
|
1646
|
+
}, ji = async (e) => {
|
|
1647
|
+
try {
|
|
1648
|
+
return (await p(`git log ${e} --format="%H %at %ct"`)).split(`
|
|
1649
|
+
`).flatMap((a) => {
|
|
1650
|
+
const [n, i, s] = a.split(" ");
|
|
1651
|
+
return n && i !== s ? [n] : [];
|
|
1652
|
+
});
|
|
1653
|
+
} catch {
|
|
1654
|
+
return [];
|
|
1655
|
+
}
|
|
1656
|
+
}, Ti = async () => {
|
|
1657
|
+
const { skipGitPushLimit: e } = H(), t = Object.values(y), a = ut(0, "utf-8");
|
|
1658
|
+
if (!a)
|
|
1659
|
+
return;
|
|
1660
|
+
const n = a.trim().split(`
|
|
1661
|
+
`), i = n.length;
|
|
1662
|
+
for (let s = 0; s < i; s++) {
|
|
1663
|
+
const [, o, r, c] = n[s].split(/\s+/);
|
|
1664
|
+
if (!r.startsWith(ot) || o === Ot)
|
|
1665
|
+
continue;
|
|
1666
|
+
const l = r.replace(ot, "");
|
|
1667
|
+
!e && t.includes(l) && m(`禁止直接 Push 到环境分支:${l}`);
|
|
1668
|
+
const u = await Ni(o, c), [d, h] = await Promise.all([
|
|
1669
|
+
bi(u),
|
|
1670
|
+
ji(u)
|
|
1671
|
+
]), g = [.../* @__PURE__ */ new Set([...d, ...h])];
|
|
1672
|
+
g.length > 0 && m(`以下提交中检测到包含 cherry-pick 特征,本次 Push 已被拒绝
|
|
1673
|
+
${g.join(`
|
|
1674
|
+
`)}`);
|
|
1675
|
+
}
|
|
1607
1676
|
};
|
|
1608
|
-
async function
|
|
1609
|
-
N(f.resolve("node_modules", ".bin", "markdownlint")) ||
|
|
1610
|
-
const e =
|
|
1677
|
+
async function ki() {
|
|
1678
|
+
N(f.resolve("node_modules", ".bin", "markdownlint")) || m("该项目未安装markdownlint,请安装后重试");
|
|
1679
|
+
const e = w("markdownlint执行中...").start();
|
|
1611
1680
|
try {
|
|
1612
|
-
await
|
|
1681
|
+
await p('npx markdownlint "**/*.md" --fix', {
|
|
1613
1682
|
silent: !1
|
|
1614
1683
|
}), e.succeed("markdownlint执行成功"), process.exit(0);
|
|
1615
1684
|
} catch {
|
|
1616
1685
|
e.fail("markdownlint校验出错"), process.exit(1);
|
|
1617
1686
|
}
|
|
1618
1687
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1688
|
+
const Ei = () => {
|
|
1689
|
+
m("禁止执行 rebase,请使用 git merge!");
|
|
1690
|
+
};
|
|
1691
|
+
function Ii() {
|
|
1692
|
+
const e = H();
|
|
1621
1693
|
if (e["lint-staged"])
|
|
1622
1694
|
return e["lint-staged"];
|
|
1623
1695
|
throw new Error("未找到lint配置");
|
|
1624
1696
|
}
|
|
1625
|
-
async function
|
|
1626
|
-
const e =
|
|
1627
|
-
await
|
|
1697
|
+
async function Ri() {
|
|
1698
|
+
const e = w("代码风格检测中...").start();
|
|
1699
|
+
await ca({
|
|
1628
1700
|
concurrent: 4,
|
|
1629
1701
|
debug: !1,
|
|
1630
|
-
config:
|
|
1702
|
+
config: Ii(),
|
|
1631
1703
|
quiet: !0,
|
|
1632
1704
|
relative: !0
|
|
1633
1705
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
1634
1706
|
}
|
|
1635
|
-
function
|
|
1636
|
-
if (e.includes("Merge") && e.includes("# Conflicts:") ||
|
|
1707
|
+
function Ci(e) {
|
|
1708
|
+
if (e.includes("Merge") && e.includes("# Conflicts:") || la.valid(e))
|
|
1637
1709
|
return !0;
|
|
1638
1710
|
const t = e.split(": ");
|
|
1639
1711
|
if (t.length === 1)
|
|
1640
1712
|
return "body前缺少「: 」";
|
|
1641
1713
|
const a = t[0];
|
|
1642
|
-
return /^(feat|fix|refactor)/.test(a) ? /\(\d+(?:,\d+)*\)/.test(a) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(a) ? [
|
|
1714
|
+
return /^(feat|fix|refactor)/.test(a) ? /\(\d+(?:,\d+)*\)/.test(a) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(a) ? [T.CHORE, T.CI].includes(a) ? !0 : "chore/ci类型无需填写ID。" : T.Break === a ? !0 : "不存在的提交类型。";
|
|
1643
1715
|
}
|
|
1644
|
-
async function
|
|
1645
|
-
const e = await
|
|
1716
|
+
async function Li() {
|
|
1717
|
+
const e = await _e(f.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = w("提交信息格式校验中...").start(), a = Ci(e);
|
|
1646
1718
|
a === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${a}`), process.exit(1));
|
|
1647
1719
|
}
|
|
1648
|
-
async function
|
|
1649
|
-
await
|
|
1650
|
-
const e = await
|
|
1720
|
+
async function xi() {
|
|
1721
|
+
await ge();
|
|
1722
|
+
const e = await ua({
|
|
1651
1723
|
// 分组,展示仓库链接
|
|
1652
1724
|
format: ["group", "repo"],
|
|
1653
1725
|
// 交互式弹窗
|
|
@@ -1658,29 +1730,29 @@ async function hn() {
|
|
|
1658
1730
|
install: "always"
|
|
1659
1731
|
});
|
|
1660
1732
|
if (e && Object.keys(e).length) {
|
|
1661
|
-
|
|
1733
|
+
G("升级完成 🎉");
|
|
1662
1734
|
const t = Object.entries(e).map(([a, n]) => `${a}@${n}`).join("; ");
|
|
1663
|
-
await
|
|
1735
|
+
await p(`git add . && git commit -m "chore: 依赖升级。${t}"`);
|
|
1664
1736
|
}
|
|
1665
1737
|
process.exit(0);
|
|
1666
1738
|
}
|
|
1667
|
-
async function
|
|
1668
|
-
N(f.resolve("node_modules", ".bin", "eslint")) ||
|
|
1669
|
-
const t =
|
|
1739
|
+
async function Di(e) {
|
|
1740
|
+
N(f.resolve("node_modules", ".bin", "eslint")) || m("该项目未安装eslint,请安装后重试");
|
|
1741
|
+
const t = w("eslint执行中...").start();
|
|
1670
1742
|
try {
|
|
1671
1743
|
let a = "npx eslint '**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}' --fix";
|
|
1672
|
-
process.platform === "win32" && (a = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (a += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? a += ` --max-warnings ${Number(e.maxWarnings)}` : a += " --max-warnings 100", await
|
|
1744
|
+
process.platform === "win32" && (a = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (a += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? a += ` --max-warnings ${Number(e.maxWarnings)}` : a += " --max-warnings 100", await p(a, {
|
|
1673
1745
|
silent: !1
|
|
1674
1746
|
}), t.succeed("eslint执行成功"), process.exit(0);
|
|
1675
1747
|
} catch {
|
|
1676
1748
|
t.fail("eslint校验出错"), process.exit(1);
|
|
1677
1749
|
}
|
|
1678
1750
|
}
|
|
1679
|
-
async function
|
|
1680
|
-
N(f.resolve("node_modules", ".bin", "prettier")) ||
|
|
1681
|
-
const e =
|
|
1751
|
+
async function Pi() {
|
|
1752
|
+
N(f.resolve("node_modules", ".bin", "prettier")) || m("该项目未安装prettier,请安装后重试");
|
|
1753
|
+
const e = w("prettier执行中...").start();
|
|
1682
1754
|
try {
|
|
1683
|
-
await
|
|
1755
|
+
await p(
|
|
1684
1756
|
"npx prettier --write . --config .z/.prettierrc.json --ignore-path .z/.prettierignore --ignore-unknown --no-error-on-unmatched-pattern",
|
|
1685
1757
|
{
|
|
1686
1758
|
silent: !1
|
|
@@ -1690,120 +1762,166 @@ async function yn() {
|
|
|
1690
1762
|
e.fail("prettier校验出错"), process.exit(1);
|
|
1691
1763
|
}
|
|
1692
1764
|
}
|
|
1693
|
-
function
|
|
1694
|
-
N(f.resolve("./node_modules/.bin/vue-tsc")) ||
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1765
|
+
function Oi() {
|
|
1766
|
+
N(f.resolve("./node_modules/.bin/vue-tsc")) || m("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), Ue("npx vue-tsc --build"), process.exit(0);
|
|
1767
|
+
}
|
|
1768
|
+
const Mi = [
|
|
1769
|
+
[
|
|
1770
|
+
"cm",
|
|
1771
|
+
"commit-msg"
|
|
1772
|
+
/* CommitMsg */
|
|
1773
|
+
],
|
|
1774
|
+
[
|
|
1775
|
+
"cf",
|
|
1776
|
+
"commit-files"
|
|
1777
|
+
/* CommitFiles */
|
|
1778
|
+
],
|
|
1779
|
+
[
|
|
1780
|
+
"p",
|
|
1781
|
+
"prettier"
|
|
1782
|
+
/* Prettier */
|
|
1783
|
+
],
|
|
1784
|
+
[
|
|
1785
|
+
"e",
|
|
1786
|
+
"eslint"
|
|
1787
|
+
/* Eslint */
|
|
1788
|
+
],
|
|
1789
|
+
[
|
|
1790
|
+
"tc",
|
|
1791
|
+
"type-check"
|
|
1792
|
+
/* TypeCheck */
|
|
1793
|
+
],
|
|
1794
|
+
[
|
|
1795
|
+
"dc",
|
|
1796
|
+
"dependency-check"
|
|
1797
|
+
/* DependencyCheck */
|
|
1798
|
+
],
|
|
1799
|
+
[
|
|
1800
|
+
"cs",
|
|
1801
|
+
"checkstyle"
|
|
1802
|
+
/* CheckStyle */
|
|
1803
|
+
],
|
|
1804
|
+
[
|
|
1805
|
+
"ml",
|
|
1806
|
+
"markdown-lint"
|
|
1807
|
+
/* MarkdownLint */
|
|
1808
|
+
],
|
|
1809
|
+
[
|
|
1810
|
+
"dm",
|
|
1811
|
+
"delete-merged"
|
|
1812
|
+
/* DeleteMerged */
|
|
1813
|
+
],
|
|
1814
|
+
[
|
|
1815
|
+
"nr",
|
|
1816
|
+
"not-allow-rebase"
|
|
1817
|
+
/* NotAllowRebase */
|
|
1818
|
+
],
|
|
1819
|
+
[
|
|
1820
|
+
"dp",
|
|
1821
|
+
"detect-push"
|
|
1822
|
+
/* DetectPush */
|
|
1823
|
+
]
|
|
1824
|
+
], Bi = {
|
|
1825
|
+
[$.JAVA]: [
|
|
1826
|
+
{
|
|
1747
1827
|
name: "执行 check-style",
|
|
1748
1828
|
value: "checkstyle"
|
|
1749
1829
|
/* CheckStyle */
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1830
|
+
}
|
|
1831
|
+
],
|
|
1832
|
+
[$.JAVASCRIPT]: [
|
|
1833
|
+
{
|
|
1834
|
+
name: "执行 eslint",
|
|
1835
|
+
value: "eslint"
|
|
1836
|
+
/* Eslint */
|
|
1837
|
+
},
|
|
1838
|
+
{
|
|
1839
|
+
name: "执行 type-check",
|
|
1840
|
+
value: "type-check"
|
|
1841
|
+
/* TypeCheck */
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
name: "执行 dependency-check",
|
|
1845
|
+
value: "dependency-check"
|
|
1846
|
+
/* DependencyCheck */
|
|
1847
|
+
}
|
|
1848
|
+
],
|
|
1849
|
+
[$.MARKDOWN]: [
|
|
1850
|
+
{
|
|
1851
|
+
name: "执行markdown-lint",
|
|
1852
|
+
value: "markdown-lint"
|
|
1853
|
+
/* MarkdownLint */
|
|
1854
|
+
},
|
|
1855
|
+
{
|
|
1856
|
+
name: "执行 eslint",
|
|
1857
|
+
value: "eslint"
|
|
1858
|
+
/* Eslint */
|
|
1859
|
+
},
|
|
1860
|
+
{
|
|
1861
|
+
name: "执行 type-check",
|
|
1862
|
+
value: "type-check"
|
|
1863
|
+
/* TypeCheck */
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
name: "执行 dependency-check",
|
|
1867
|
+
value: "dependency-check"
|
|
1868
|
+
/* DependencyCheck */
|
|
1869
|
+
}
|
|
1870
|
+
]
|
|
1871
|
+
}, _i = (e) => Reflect.get(Bi, e) ?? [], Fi = {
|
|
1872
|
+
"commit-msg": Li,
|
|
1873
|
+
"commit-files": Ri,
|
|
1874
|
+
prettier: Pi,
|
|
1875
|
+
eslint: Di,
|
|
1876
|
+
"type-check": Oi,
|
|
1877
|
+
"dependency-check": xi,
|
|
1878
|
+
checkstyle: fi,
|
|
1879
|
+
"markdown-lint": ki,
|
|
1880
|
+
"delete-merged": Si,
|
|
1881
|
+
"not-allow-rebase": Ei,
|
|
1882
|
+
"detect-push": Ti
|
|
1883
|
+
}, zi = async (e, t) => {
|
|
1884
|
+
const a = Reflect.get(Fi, e);
|
|
1885
|
+
a && typeof a == "function" && await a(t);
|
|
1886
|
+
}, Ji = (e) => {
|
|
1887
|
+
for (const [t, a] of Mi)
|
|
1888
|
+
if (e === t || e === a)
|
|
1889
|
+
return a;
|
|
1890
|
+
m("参数输入错误");
|
|
1891
|
+
};
|
|
1892
|
+
async function Gi(e, t) {
|
|
1893
|
+
ee(), W();
|
|
1894
|
+
const a = H(), n = e ? Ji(e) : await k({
|
|
1895
|
+
message: "请选择你要执行的操作",
|
|
1896
|
+
choices: [
|
|
1777
1897
|
{
|
|
1778
|
-
name: "执行
|
|
1779
|
-
value: "
|
|
1780
|
-
/*
|
|
1898
|
+
name: "执行 prettier",
|
|
1899
|
+
value: "prettier"
|
|
1900
|
+
/* Prettier */
|
|
1781
1901
|
},
|
|
1902
|
+
..._i(a.language),
|
|
1782
1903
|
{
|
|
1783
|
-
name: "执行
|
|
1784
|
-
value: "
|
|
1785
|
-
/*
|
|
1904
|
+
name: "执行 delete-merged",
|
|
1905
|
+
value: "delete-merged"
|
|
1906
|
+
/* DeleteMerged */
|
|
1786
1907
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
});
|
|
1791
|
-
}
|
|
1792
|
-
n === "commit-msg" ? await gn() : n === "commit-files" ? await dn() : n === "prettier" ? await yn() : n === "eslint" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await wn(t) : n === "type-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? vn() : n === "dependency-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await hn() : n === "checkstyle" && a.language === w.JAVA ? await tn() : n === "markdown-lint" && a.language === w.MARKDOWN ? await pn() : n === "delete-merged" && await un();
|
|
1908
|
+
]
|
|
1909
|
+
});
|
|
1910
|
+
await zi(n, t);
|
|
1793
1911
|
}
|
|
1794
1912
|
x.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint / delete-merged。").argument(
|
|
1795
1913
|
"[type]",
|
|
1796
1914
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs, markdown-lint|ml, delete-merged|dm。"
|
|
1797
|
-
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) =>
|
|
1798
|
-
async function
|
|
1799
|
-
const t =
|
|
1800
|
-
await
|
|
1801
|
-
const a = await
|
|
1802
|
-
|
|
1803
|
-
}
|
|
1804
|
-
x.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) =>
|
|
1805
|
-
const
|
|
1806
|
-
function
|
|
1915
|
+
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => P(Gi, ...e));
|
|
1916
|
+
async function Mt(e = "latest") {
|
|
1917
|
+
const t = w("安装中...").start();
|
|
1918
|
+
await p(`npm i -g ${oe.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", de("latestCheckVersionTimestamp", Date.now()), de("version", e);
|
|
1919
|
+
const a = await We();
|
|
1920
|
+
De(a), ce(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1921
|
+
}
|
|
1922
|
+
x.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => P(Mt, ...e));
|
|
1923
|
+
const qe = /Thumbs\.db|\.git|DS_Store|idea/, Bt = "testcase";
|
|
1924
|
+
function _t(e) {
|
|
1807
1925
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
1808
1926
|
if (t && !e.startsWith("["))
|
|
1809
1927
|
return {
|
|
@@ -1822,17 +1940,17 @@ function Rt(e) {
|
|
|
1822
1940
|
displayName: e
|
|
1823
1941
|
};
|
|
1824
1942
|
}
|
|
1825
|
-
async function
|
|
1826
|
-
const { exclude: a =
|
|
1943
|
+
async function ie(e, t = {}) {
|
|
1944
|
+
const { exclude: a = qe } = t, n = [];
|
|
1827
1945
|
async function i(s) {
|
|
1828
1946
|
const o = f.basename(s);
|
|
1829
|
-
if ((await
|
|
1947
|
+
if ((await ea(s)).isFile())
|
|
1830
1948
|
return null;
|
|
1831
|
-
const c = await
|
|
1832
|
-
c.filter((
|
|
1833
|
-
)).filter(Boolean), { type: u, id:
|
|
1949
|
+
const c = await Ge(s, { withFileTypes: !0 }), l = (await Promise.all(
|
|
1950
|
+
c.filter((v) => v.isDirectory() && !a.test(v.name)).map((v) => i(f.join(s, v.name)))
|
|
1951
|
+
)).filter(Boolean), { type: u, id: d, displayName: h } = _t(o), g = {
|
|
1834
1952
|
name: o,
|
|
1835
|
-
id:
|
|
1953
|
+
id: d,
|
|
1836
1954
|
displayName: h,
|
|
1837
1955
|
path: s,
|
|
1838
1956
|
type: u,
|
|
@@ -1842,13 +1960,13 @@ async function ae(e, t = {}) {
|
|
|
1842
1960
|
}
|
|
1843
1961
|
return await i(f.resolve(e)), n;
|
|
1844
1962
|
}
|
|
1845
|
-
async function
|
|
1846
|
-
const { exclude: a =
|
|
1963
|
+
async function Ft(e, t = {}) {
|
|
1964
|
+
const { exclude: a = qe } = t;
|
|
1847
1965
|
try {
|
|
1848
|
-
const n = await
|
|
1966
|
+
const n = await Ge(f.resolve(e), { withFileTypes: !0 });
|
|
1849
1967
|
return await Promise.all(
|
|
1850
1968
|
n.filter((i) => i.isDirectory() && !a.test(i.name)).map((i) => {
|
|
1851
|
-
const s = f.join(e, i.name), { type: o, id: r, displayName: c } =
|
|
1969
|
+
const s = f.join(e, i.name), { type: o, id: r, displayName: c } = _t(i.name);
|
|
1852
1970
|
return {
|
|
1853
1971
|
name: i.name,
|
|
1854
1972
|
id: r,
|
|
@@ -1859,10 +1977,10 @@ async function It(e, t = {}) {
|
|
|
1859
1977
|
})
|
|
1860
1978
|
);
|
|
1861
1979
|
} catch (n) {
|
|
1862
|
-
return
|
|
1980
|
+
return m(`读取目录失败: ${e} : ${n}`), [];
|
|
1863
1981
|
}
|
|
1864
1982
|
}
|
|
1865
|
-
function
|
|
1983
|
+
function Q(e, t, a) {
|
|
1866
1984
|
switch (e) {
|
|
1867
1985
|
case "module":
|
|
1868
1986
|
return a ? `${t}[${a}]` : t;
|
|
@@ -1872,40 +1990,40 @@ function Z(e, t, a) {
|
|
|
1872
1990
|
return t;
|
|
1873
1991
|
}
|
|
1874
1992
|
}
|
|
1875
|
-
async function
|
|
1993
|
+
async function je(e, t, a, n) {
|
|
1876
1994
|
try {
|
|
1877
|
-
const i = f.basename(e), s =
|
|
1995
|
+
const i = f.basename(e), s = Q(a, t, n);
|
|
1878
1996
|
if (i === s)
|
|
1879
1997
|
return !0;
|
|
1880
1998
|
const o = f.dirname(e), r = f.join(o, s);
|
|
1881
|
-
return await
|
|
1999
|
+
return await _a(e) ? await pt(e, r) : (await p(`git mv "${e}" "${r}"`), await p("git add .")), !0;
|
|
1882
2000
|
} catch (i) {
|
|
1883
|
-
return
|
|
2001
|
+
return m(`重命名文件夹失败: ${e} -> ${t}。${i}`), !1;
|
|
1884
2002
|
}
|
|
1885
2003
|
}
|
|
1886
|
-
async function
|
|
1887
|
-
const { exclude: n =
|
|
2004
|
+
async function Ui(e, t, a = {}) {
|
|
2005
|
+
const { exclude: n = qe } = a;
|
|
1888
2006
|
async function i(s, o) {
|
|
1889
2007
|
if (!s || s.length === 0) return;
|
|
1890
|
-
const r = await
|
|
2008
|
+
const r = await Ft(o, { exclude: n });
|
|
1891
2009
|
for (const c of s) {
|
|
1892
|
-
const l = String(c.value), u =
|
|
1893
|
-
let h =
|
|
1894
|
-
|
|
2010
|
+
const l = String(c.value), u = Q("module", c.label, l), d = r.find((g) => g.id === l);
|
|
2011
|
+
let h = d?.path || f.join(o, u);
|
|
2012
|
+
d ? d.displayName !== c.label && await je(d.path, c.label, "module", l) && (h = f.join(o, u)) : (await fe(h, { recursive: !0 }), await p(`git add "${h}"`)), c.children && c.children.length > 0 && await i(c.children, h);
|
|
1895
2013
|
}
|
|
1896
2014
|
}
|
|
1897
2015
|
await i(e, f.resolve(t));
|
|
1898
2016
|
}
|
|
1899
|
-
async function
|
|
2017
|
+
async function zt(e) {
|
|
1900
2018
|
const t = {
|
|
1901
2019
|
id: 0,
|
|
1902
2020
|
name: "",
|
|
1903
2021
|
path: ""
|
|
1904
2022
|
};
|
|
1905
2023
|
if (e)
|
|
1906
|
-
Number.isNaN(Number(e)) &&
|
|
2024
|
+
Number.isNaN(Number(e)) && m("请输入正确的产品ID"), t.id = Number(e);
|
|
1907
2025
|
else {
|
|
1908
|
-
const a = await
|
|
2026
|
+
const a = await Es();
|
|
1909
2027
|
t.id = await k({
|
|
1910
2028
|
message: "请选择产品",
|
|
1911
2029
|
choices: a.map((n) => ({
|
|
@@ -1914,48 +2032,48 @@ async function Ct(e) {
|
|
|
1914
2032
|
}))
|
|
1915
2033
|
});
|
|
1916
2034
|
}
|
|
1917
|
-
return t.name = await
|
|
2035
|
+
return t.name = await Is(t.id), t.path = f.join(Bt, Q("module", t.name, String(t.id))), t;
|
|
1918
2036
|
}
|
|
1919
|
-
async function
|
|
1920
|
-
return (await
|
|
2037
|
+
async function Ze(e) {
|
|
2038
|
+
return (await Ft(Bt)).find((a) => Number(a.id) === e.id);
|
|
1921
2039
|
}
|
|
1922
|
-
async function
|
|
2040
|
+
async function Jt(e, t) {
|
|
1923
2041
|
const a = {
|
|
1924
2042
|
precondition: e.precondition,
|
|
1925
2043
|
priority: e.pri,
|
|
1926
2044
|
steps: []
|
|
1927
2045
|
};
|
|
1928
|
-
a.steps = await
|
|
2046
|
+
a.steps = await Cs(e.id), I.writeJSONSync(t, a, {
|
|
1929
2047
|
spaces: 2
|
|
1930
2048
|
});
|
|
1931
2049
|
}
|
|
1932
|
-
async function
|
|
1933
|
-
await
|
|
2050
|
+
async function Gt(e, t) {
|
|
2051
|
+
await fe(t, {
|
|
1934
2052
|
recursive: !0
|
|
1935
|
-
}), await
|
|
2053
|
+
}), await Jt(e, f.join(t, "config.json")), I.ensureFileSync(f.join(t, "data.yaml")), await M(
|
|
1936
2054
|
f.join(t, "data.yaml"),
|
|
1937
|
-
N(f.resolve(
|
|
1938
|
-
),
|
|
2055
|
+
N(f.resolve(Y, "data.yaml")) ? await _e(f.resolve(Y, "data.yaml")) : await ps()
|
|
2056
|
+
), I.ensureFileSync(f.join(t, "main.py")), await M(
|
|
1939
2057
|
f.join(t, "main.py"),
|
|
1940
|
-
N(f.resolve(
|
|
2058
|
+
N(f.resolve(Y, "main.py")) ? await _e(f.resolve(Y, "main.py")) : await ms()
|
|
1941
2059
|
);
|
|
1942
2060
|
}
|
|
1943
|
-
function
|
|
2061
|
+
function Ke(e) {
|
|
1944
2062
|
if (e) {
|
|
1945
2063
|
const t = e.split(",").map((a) => a.trim()).filter((a) => {
|
|
1946
2064
|
const n = Number(a);
|
|
1947
2065
|
return Number.isInteger(n) && n > 0;
|
|
1948
2066
|
}).map((a) => Number(a));
|
|
1949
|
-
return t.length === 0 ? (
|
|
2067
|
+
return t.length === 0 ? (m('未找到有效的ID,请输入格式如 "1,2,3,4" 的正整数ID'), []) : t;
|
|
1950
2068
|
}
|
|
1951
2069
|
return [];
|
|
1952
2070
|
}
|
|
1953
|
-
async function
|
|
1954
|
-
|
|
2071
|
+
async function Pe(e, t) {
|
|
2072
|
+
ee(), W(), await ge();
|
|
1955
2073
|
let a;
|
|
1956
|
-
t ? ([E.MODULE, E.CASE].includes(t) ||
|
|
2074
|
+
t ? ([E.MODULE, E.CASE].includes(t) || m(`不支持的参数${t}。参数值应为 ${E.MODULE} 或者 ${E.CASE}。`), a = t) : a = await k({
|
|
1957
2075
|
message: `请选择要${e}的数据类型`,
|
|
1958
|
-
choices:
|
|
2076
|
+
choices: Ta
|
|
1959
2077
|
});
|
|
1960
2078
|
const n = a === E.MODULE ? "模块" : E.CASE === a ? "用例" : "";
|
|
1961
2079
|
return {
|
|
@@ -1963,79 +2081,79 @@ async function Ee(e, t) {
|
|
|
1963
2081
|
typeStr: n
|
|
1964
2082
|
};
|
|
1965
2083
|
}
|
|
1966
|
-
async function
|
|
1967
|
-
const t = await
|
|
1968
|
-
return a ||
|
|
2084
|
+
async function Oe(e) {
|
|
2085
|
+
const t = await zt(e), a = await Ze(t);
|
|
2086
|
+
return a || m(`本地未找到产品【${t.name}[${t.id}]】`), {
|
|
1969
2087
|
product: t,
|
|
1970
2088
|
localProduct: a
|
|
1971
2089
|
};
|
|
1972
2090
|
}
|
|
1973
|
-
async function
|
|
1974
|
-
e.text = "查找本地产品目录...", await
|
|
1975
|
-
const i =
|
|
1976
|
-
let s = await
|
|
2091
|
+
async function Vi(e, t, a) {
|
|
2092
|
+
e.text = "查找本地产品目录...", await Ze(t) || m(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
2093
|
+
const i = Ke(a);
|
|
2094
|
+
let s = await ie(t.path);
|
|
1977
2095
|
e.text = "获取远程用例列表...";
|
|
1978
|
-
const o = await
|
|
2096
|
+
const o = await Rs(t.id, i);
|
|
1979
2097
|
e.text = "本地用例同步中...";
|
|
1980
2098
|
for (const r of o) {
|
|
1981
2099
|
let c;
|
|
1982
2100
|
if (r.module === 0 ? c = f.resolve(t.path) : c = s.find((u) => Number(u.id) === r.module)?.path || "", !c)
|
|
1983
|
-
return
|
|
2101
|
+
return m(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
1984
2102
|
const l = s.find(({ id: u }) => r.id === Number(u));
|
|
1985
2103
|
if (l)
|
|
1986
|
-
l.displayName !== r.title && await
|
|
2104
|
+
l.displayName !== r.title && await je(l.path, r.title, l.type, l.id) && G(`重命名成功: ${l.displayName} -> ${r.title}`), s = await ie(t.path), r.module === 0 ? c = f.resolve(t.path) : c = s.find((u) => Number(u.id) === r.module)?.path || "", await Jt(
|
|
1987
2105
|
r,
|
|
1988
|
-
f.join(c,
|
|
2106
|
+
f.join(c, Q("case", r.title, String(r.id)), "config.json")
|
|
1989
2107
|
);
|
|
1990
2108
|
else {
|
|
1991
|
-
const u = f.join(c,
|
|
1992
|
-
await
|
|
2109
|
+
const u = f.join(c, Q("case", r.title, String(r.id)));
|
|
2110
|
+
await Gt(r, u);
|
|
1993
2111
|
}
|
|
1994
2112
|
}
|
|
1995
2113
|
}
|
|
1996
|
-
async function
|
|
2114
|
+
async function Wi(e, t) {
|
|
1997
2115
|
e.text = "本地产品目录查找中...";
|
|
1998
|
-
const a = await
|
|
1999
|
-
a ? (e.text = "找到产品目录。开始重命名...", a.displayName !== t.name && await
|
|
2000
|
-
const n = await
|
|
2001
|
-
e.text = "本地同步模块中...", await
|
|
2002
|
-
}
|
|
2003
|
-
async function
|
|
2004
|
-
const { type: a, typeStr: n } = await
|
|
2005
|
-
if (E.MODULE === a && await
|
|
2006
|
-
const o =
|
|
2116
|
+
const a = await Ze(t);
|
|
2117
|
+
a ? (e.text = "找到产品目录。开始重命名...", a.displayName !== t.name && await je(a.path, t.name, a.type, a.id) && (e.text = `重命名成功: ${a.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await fe(t.path, { recursive: !0 }), await p("git add .")), e.text = "获取远程模块列表...";
|
|
2118
|
+
const n = await Rt(t.id);
|
|
2119
|
+
e.text = "本地同步模块中...", await Ui(n || [], t.path);
|
|
2120
|
+
}
|
|
2121
|
+
async function Hi(e, t) {
|
|
2122
|
+
const { type: a, typeStr: n } = await Pe("拉取", e), i = await zt(t.productId), s = w(`${n}同步中...`).start();
|
|
2123
|
+
if (E.MODULE === a && await Wi(s, i), E.CASE === a && await Vi(s, i, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await p("git status -s")) {
|
|
2124
|
+
const o = w("代码提交中...").start();
|
|
2007
2125
|
try {
|
|
2008
|
-
await
|
|
2126
|
+
await p(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
|
|
2009
2127
|
} catch (r) {
|
|
2010
2128
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
2011
2129
|
}
|
|
2012
2130
|
}
|
|
2013
2131
|
}
|
|
2014
|
-
x.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) =>
|
|
2015
|
-
async function
|
|
2016
|
-
let n = await
|
|
2132
|
+
x.command("qa-pull").alias("qp").description("将禅道中的模块或者用例同步到本地").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "type=case时,可传指定用例ID(可传N个,逗号隔开);不传则为产品下全部用例").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => P(Hi, ...e));
|
|
2133
|
+
async function qi(e, t, a) {
|
|
2134
|
+
let n = await B({
|
|
2017
2135
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
2018
2136
|
});
|
|
2019
2137
|
n = n.trim();
|
|
2020
|
-
const i =
|
|
2138
|
+
const i = w(`用例【${a}】开始创建...`).start();
|
|
2021
2139
|
i.text = "远程用例创建中...";
|
|
2022
|
-
const s = await
|
|
2140
|
+
const s = await xs({
|
|
2023
2141
|
product: Number(e.id),
|
|
2024
2142
|
// 如果父模块是产品根目录,parent=0
|
|
2025
2143
|
module: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
2026
2144
|
title: a,
|
|
2027
2145
|
type: "interface",
|
|
2028
|
-
openedBy:
|
|
2146
|
+
openedBy: R("ldapAccount"),
|
|
2029
2147
|
precondition: n || ""
|
|
2030
2148
|
});
|
|
2031
|
-
i.text = "远程用例步骤创建中...", await
|
|
2149
|
+
i.text = "远程用例步骤创建中...", await Ds({
|
|
2032
2150
|
case: s,
|
|
2033
2151
|
type: "step",
|
|
2034
2152
|
desc: "按照预期执行",
|
|
2035
2153
|
expect: "正常执行,符合预期"
|
|
2036
2154
|
}), i.text = "本地用例创建中...";
|
|
2037
|
-
const o = f.join(t.path,
|
|
2038
|
-
return N(o) ?
|
|
2155
|
+
const o = f.join(t.path, Q("case", a, String(s)));
|
|
2156
|
+
return N(o) ? G(`${o}已存在,请检查是否对应,本地不再创建。`) : (await Gt(
|
|
2039
2157
|
{
|
|
2040
2158
|
id: s,
|
|
2041
2159
|
pri: 3,
|
|
@@ -2044,24 +2162,24 @@ async function jn(e, t, a) {
|
|
|
2044
2162
|
o
|
|
2045
2163
|
), i.succeed(`用例【[${o}】创建完成 🎉`), o);
|
|
2046
2164
|
}
|
|
2047
|
-
async function
|
|
2048
|
-
const n =
|
|
2165
|
+
async function Zi(e, t, a) {
|
|
2166
|
+
const n = w(`模块【${a}】开始创建...`).start();
|
|
2049
2167
|
n.text = "远程模块创建中...";
|
|
2050
|
-
const i = await
|
|
2168
|
+
const i = await Ls({
|
|
2051
2169
|
root: Number(e.id),
|
|
2052
2170
|
name: a,
|
|
2053
2171
|
// 如果父模块是产品根目录,parent=0
|
|
2054
2172
|
parent: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
|
|
2055
2173
|
});
|
|
2056
2174
|
n.text = "本地模块创建中...";
|
|
2057
|
-
const s = f.join(t.path,
|
|
2175
|
+
const s = f.join(t.path, Q("module", a, String(i)));
|
|
2058
2176
|
if (N(s))
|
|
2059
|
-
return
|
|
2060
|
-
await
|
|
2177
|
+
return G(`${s}已存在,请检查是否对应,本地不再创建。`);
|
|
2178
|
+
await fe(s, {
|
|
2061
2179
|
recursive: !0
|
|
2062
2180
|
}), n.succeed(`模块【${s}】创建完成 🎉`);
|
|
2063
2181
|
}
|
|
2064
|
-
function
|
|
2182
|
+
function Ki(e) {
|
|
2065
2183
|
function t(n) {
|
|
2066
2184
|
if (!n.children || n.children.length === 0) return;
|
|
2067
2185
|
const i = n.children[0];
|
|
@@ -2085,35 +2203,35 @@ function Tn(e) {
|
|
|
2085
2203
|
}
|
|
2086
2204
|
return a(e);
|
|
2087
2205
|
}
|
|
2088
|
-
async function
|
|
2089
|
-
const { type: a, typeStr: n } = await
|
|
2206
|
+
async function Yi(e, t) {
|
|
2207
|
+
const { type: a, typeStr: n } = await Pe("创建", e), { product: i, localProduct: s } = await Oe(t.productId), o = await Rt(i.id), r = await Ki(o), c = Q("module", r.label, String(r.value)), u = (await ie(i.path, { hasRoot: !0 })).find((g) => g.name === c);
|
|
2090
2208
|
if (!u?.path || !N(u.path))
|
|
2091
|
-
return
|
|
2092
|
-
let
|
|
2209
|
+
return m(`本地不存在${c}模块`);
|
|
2210
|
+
let d = await B({
|
|
2093
2211
|
message: `请输入你要创建的${n}名称`,
|
|
2094
2212
|
required: !0,
|
|
2095
2213
|
validate: (g) => g.length > 0 && g.length < 255
|
|
2096
2214
|
});
|
|
2097
|
-
|
|
2215
|
+
d = d.trim();
|
|
2098
2216
|
let h = "";
|
|
2099
|
-
if (E.MODULE === a && await
|
|
2100
|
-
const g =
|
|
2217
|
+
if (E.MODULE === a && await Zi(s, u, d), E.CASE === a && (h = await qi(s, u, d)), !t.disableAutoCommit && E.CASE === a) {
|
|
2218
|
+
const g = w("代码提交中...").start();
|
|
2101
2219
|
try {
|
|
2102
|
-
await
|
|
2103
|
-
} catch (
|
|
2104
|
-
g.fail(`提交失败,${
|
|
2220
|
+
await p(`git add . && git commit -m "chore: 创建了用例${f.basename(h)}"`), g.succeed("代码已提交 ✅");
|
|
2221
|
+
} catch (v) {
|
|
2222
|
+
g.fail(`提交失败,${v}`), process.exit(1);
|
|
2105
2223
|
}
|
|
2106
2224
|
}
|
|
2107
2225
|
}
|
|
2108
|
-
x.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) =>
|
|
2109
|
-
async function
|
|
2110
|
-
const n = (await
|
|
2226
|
+
x.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => P(Yi, ...e));
|
|
2227
|
+
async function Xi(e, t) {
|
|
2228
|
+
const n = (await ie(e.path)).filter((r) => r.type === "case");
|
|
2111
2229
|
let i = [];
|
|
2112
2230
|
if (t.length)
|
|
2113
2231
|
i = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
|
|
2114
2232
|
id: Number(r.id),
|
|
2115
2233
|
path: r.path
|
|
2116
|
-
})), i.length ||
|
|
2234
|
+
})), i.length || m(`未找到对应用例,请确认输入的用例ID(${t.join(", ")})是否正确`);
|
|
2117
2235
|
else {
|
|
2118
2236
|
const r = n.map((c) => ({
|
|
2119
2237
|
value: {
|
|
@@ -2122,7 +2240,7 @@ async function Rn(e, t) {
|
|
|
2122
2240
|
},
|
|
2123
2241
|
name: c.path.replace(f.resolve(e.path), "")
|
|
2124
2242
|
}));
|
|
2125
|
-
i = await
|
|
2243
|
+
i = await V({
|
|
2126
2244
|
message: "选择要删除的用例",
|
|
2127
2245
|
pageSize: 100,
|
|
2128
2246
|
loop: !1,
|
|
@@ -2132,23 +2250,23 @@ async function Rn(e, t) {
|
|
|
2132
2250
|
}
|
|
2133
2251
|
});
|
|
2134
2252
|
}
|
|
2135
|
-
const s =
|
|
2136
|
-
await
|
|
2253
|
+
const s = w("远程用例删除中...").start(), o = i.map((r) => r.id);
|
|
2254
|
+
await Os({
|
|
2137
2255
|
product: Number(e.id),
|
|
2138
2256
|
caseIds: o
|
|
2139
2257
|
}), s.text = "本地用例删除中...";
|
|
2140
2258
|
for (const r of i)
|
|
2141
|
-
N(r.path) &&
|
|
2259
|
+
N(r.path) && S.rm("-rf", r.path);
|
|
2142
2260
|
return s.succeed("用例删除完成"), o;
|
|
2143
2261
|
}
|
|
2144
|
-
async function
|
|
2145
|
-
const n = (await
|
|
2262
|
+
async function Qi(e, t) {
|
|
2263
|
+
const n = (await ie(e.path)).filter((r) => r.type === "module");
|
|
2146
2264
|
let i = [];
|
|
2147
2265
|
if (t.length)
|
|
2148
2266
|
i = n.filter((r) => t.includes(Number(r.id))).map((r) => ({
|
|
2149
2267
|
id: Number(r.id),
|
|
2150
2268
|
path: r.path
|
|
2151
|
-
})), i.length ||
|
|
2269
|
+
})), i.length || m(`未找到对应模块,请确认输入的模块ID(${t.join(", ")})是否正确`);
|
|
2152
2270
|
else {
|
|
2153
2271
|
const r = n.map((c) => ({
|
|
2154
2272
|
value: {
|
|
@@ -2157,7 +2275,7 @@ async function In(e, t) {
|
|
|
2157
2275
|
},
|
|
2158
2276
|
name: c.path.replace(f.resolve(e.path), "")
|
|
2159
2277
|
}));
|
|
2160
|
-
i = await
|
|
2278
|
+
i = await V({
|
|
2161
2279
|
message: "选择要删除的模块",
|
|
2162
2280
|
pageSize: 100,
|
|
2163
2281
|
loop: !1,
|
|
@@ -2168,34 +2286,34 @@ async function In(e, t) {
|
|
|
2168
2286
|
});
|
|
2169
2287
|
}
|
|
2170
2288
|
i = i.sort((r, c) => r.path.localeCompare(c.path));
|
|
2171
|
-
const s =
|
|
2172
|
-
await
|
|
2289
|
+
const s = w("远程模块删除中...").start(), o = i.map((r) => r.id);
|
|
2290
|
+
await Ps({
|
|
2173
2291
|
product: Number(e.id),
|
|
2174
2292
|
moduleIds: o
|
|
2175
2293
|
}), s.text = "本地模块删除中...";
|
|
2176
2294
|
for (const r of i)
|
|
2177
|
-
N(r.path) &&
|
|
2295
|
+
N(r.path) && S.rm("-rf", r.path);
|
|
2178
2296
|
return s.succeed("模块删除完成"), o;
|
|
2179
2297
|
}
|
|
2180
|
-
async function
|
|
2181
|
-
const { type: a, typeStr: n } = await
|
|
2298
|
+
async function en(e, t) {
|
|
2299
|
+
const { type: a, typeStr: n } = await Pe("删除", e), { localProduct: i } = await Oe(t.productId), s = Ke(t.targetIds);
|
|
2182
2300
|
let o = [];
|
|
2183
|
-
if (E.MODULE === a ? o = await
|
|
2184
|
-
const r =
|
|
2301
|
+
if (E.MODULE === a ? o = await Qi(i, s) : E.CASE === a && (o = await Xi(i, s)), !t.disableAutoCommit && await p("git status -s")) {
|
|
2302
|
+
const r = w("代码提交中...").start();
|
|
2185
2303
|
try {
|
|
2186
|
-
await
|
|
2304
|
+
await p(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
2187
2305
|
} catch (c) {
|
|
2188
2306
|
r.fail(`提交失败,${c}`), process.exit(1);
|
|
2189
2307
|
}
|
|
2190
2308
|
}
|
|
2191
2309
|
}
|
|
2192
|
-
x.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) =>
|
|
2193
|
-
async function
|
|
2194
|
-
const n = (await
|
|
2310
|
+
x.command("qa-remove").alias("qr").description("删除模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-ids <targetIds>", "可传指定目标(用例/模块)ID。可传N个,逗号隔开").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => P(en, ...e));
|
|
2311
|
+
async function tn(e, t) {
|
|
2312
|
+
const n = (await ie(e.path)).filter((h) => h.type === "case");
|
|
2195
2313
|
let i;
|
|
2196
2314
|
if (t.targetId) {
|
|
2197
2315
|
if (i = n.find((h) => Number(h.id) === Number(t.targetId)), !i)
|
|
2198
|
-
return
|
|
2316
|
+
return m(`未找到对应用例,请确认输入的用例ID(${t.targetId})是否正确`);
|
|
2199
2317
|
} else {
|
|
2200
2318
|
const h = n.map((g) => ({
|
|
2201
2319
|
value: {
|
|
@@ -2205,18 +2323,18 @@ async function Ln(e, t) {
|
|
|
2205
2323
|
},
|
|
2206
2324
|
name: g.path.replace(f.resolve(e.path), "")
|
|
2207
2325
|
}));
|
|
2208
|
-
[i] = await
|
|
2326
|
+
[i] = await V({
|
|
2209
2327
|
message: "选择要更新的用例",
|
|
2210
2328
|
pageSize: 100,
|
|
2211
2329
|
loop: !1,
|
|
2212
2330
|
multiple: void 0,
|
|
2213
|
-
options: (g) => g ? h.filter((
|
|
2331
|
+
options: (g) => g ? h.filter((v) => v.name.includes(g)) : h,
|
|
2214
2332
|
validate(g) {
|
|
2215
2333
|
return g.length > 1 ? "只能选一个" : g.length < 1 ? "请选一个" : !0;
|
|
2216
2334
|
}
|
|
2217
2335
|
});
|
|
2218
2336
|
}
|
|
2219
|
-
let s = await
|
|
2337
|
+
let s = await B({
|
|
2220
2338
|
message: "修改用例名称",
|
|
2221
2339
|
default: i.displayName,
|
|
2222
2340
|
required: !0,
|
|
@@ -2224,20 +2342,20 @@ async function Ln(e, t) {
|
|
|
2224
2342
|
prefill: "editable"
|
|
2225
2343
|
});
|
|
2226
2344
|
s = s.trim();
|
|
2227
|
-
const o =
|
|
2228
|
-
s !== i.displayName ? (await
|
|
2345
|
+
const o = w("用例重命名中...").start();
|
|
2346
|
+
s !== i.displayName ? (await Bs({
|
|
2229
2347
|
id: Number(i.id),
|
|
2230
2348
|
name: s
|
|
2231
|
-
}), await
|
|
2232
|
-
let r =
|
|
2233
|
-
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await
|
|
2349
|
+
}), await je(i.path, s, "case", String(i.id)) && o.succeed(`用例重命名成功: ${i.displayName} -> ${s}`), i.displayName = s, i.path = f.join(f.dirname(i.path), Q("case", s, String(i.id)))) : o.succeed("用例名称无变动");
|
|
2350
|
+
let r = I.readJsonSync(f.join(i.path, "config.json")), c;
|
|
2351
|
+
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await et({
|
|
2234
2352
|
message: "修改用例优先级",
|
|
2235
2353
|
min: 1,
|
|
2236
2354
|
max: 5,
|
|
2237
2355
|
required: !0,
|
|
2238
2356
|
default: r.priority,
|
|
2239
2357
|
validate: (h) => h > 0 && h < 6
|
|
2240
|
-
}) : c = await
|
|
2358
|
+
}) : c = await et({
|
|
2241
2359
|
message: "修改用例优先级",
|
|
2242
2360
|
min: 1,
|
|
2243
2361
|
max: 5,
|
|
@@ -2245,43 +2363,43 @@ async function Ln(e, t) {
|
|
|
2245
2363
|
default: r.priority,
|
|
2246
2364
|
validate: (h) => h > 0 && h < 6
|
|
2247
2365
|
});
|
|
2248
|
-
const l =
|
|
2249
|
-
c !== r.priority ? (await
|
|
2366
|
+
const l = w("用例优先级设置中...").start();
|
|
2367
|
+
c !== r.priority ? (await _s({
|
|
2250
2368
|
id: Number(i.id),
|
|
2251
2369
|
priority: c
|
|
2252
|
-
}),
|
|
2370
|
+
}), I.writeJSONSync(
|
|
2253
2371
|
f.join(i.path, "config.json"),
|
|
2254
2372
|
{
|
|
2255
2373
|
...r,
|
|
2256
2374
|
priority: c
|
|
2257
2375
|
},
|
|
2258
2376
|
{ spaces: 2 }
|
|
2259
|
-
), l.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : l.succeed("用例优先级无变动"), r =
|
|
2377
|
+
), l.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : l.succeed("用例优先级无变动"), r = I.readJsonSync(f.join(i.path, "config.json"));
|
|
2260
2378
|
let u;
|
|
2261
|
-
t.casePrecondition ? u = t.casePrecondition : (u = await
|
|
2379
|
+
t.casePrecondition ? u = t.casePrecondition : (u = await B({
|
|
2262
2380
|
message: "修改用例前置条件",
|
|
2263
2381
|
default: r.precondition,
|
|
2264
2382
|
prefill: "editable"
|
|
2265
2383
|
}), u = u.trim());
|
|
2266
|
-
const
|
|
2267
|
-
return u !== r.precondition ? (await
|
|
2384
|
+
const d = w("用例前置条件设置中...").start();
|
|
2385
|
+
return u !== r.precondition ? (await Fs({
|
|
2268
2386
|
id: Number(i.id),
|
|
2269
2387
|
precondition: u
|
|
2270
|
-
}),
|
|
2388
|
+
}), I.writeJSONSync(
|
|
2271
2389
|
f.join(i.path, "config.json"),
|
|
2272
2390
|
{
|
|
2273
2391
|
...r,
|
|
2274
2392
|
precondition: u
|
|
2275
2393
|
},
|
|
2276
2394
|
{ spaces: 2 }
|
|
2277
|
-
),
|
|
2395
|
+
), d.succeed(`用例前置条件修改成功:${r.precondition} -> ${u}`)) : d.succeed("用例前置条件无变动"), i.id;
|
|
2278
2396
|
}
|
|
2279
|
-
async function
|
|
2280
|
-
const n = (await
|
|
2397
|
+
async function an(e, t) {
|
|
2398
|
+
const n = (await ie(e.path)).filter((r) => r.type === "module");
|
|
2281
2399
|
let i;
|
|
2282
2400
|
if (t.targetId) {
|
|
2283
2401
|
if (i = n.find((r) => Number(r.id) === Number(t.targetId)), !i)
|
|
2284
|
-
return
|
|
2402
|
+
return m(`未找到对应模块,请确认输入的模块ID(${t.targetId})是否正确`);
|
|
2285
2403
|
} else {
|
|
2286
2404
|
const r = n.map((c) => ({
|
|
2287
2405
|
value: {
|
|
@@ -2291,7 +2409,7 @@ async function xn(e, t) {
|
|
|
2291
2409
|
},
|
|
2292
2410
|
name: c.path.replace(f.resolve(e.path), "")
|
|
2293
2411
|
}));
|
|
2294
|
-
[i] = await
|
|
2412
|
+
[i] = await V({
|
|
2295
2413
|
message: "选择要更新的模块",
|
|
2296
2414
|
pageSize: 100,
|
|
2297
2415
|
loop: !1,
|
|
@@ -2302,7 +2420,7 @@ async function xn(e, t) {
|
|
|
2302
2420
|
}
|
|
2303
2421
|
});
|
|
2304
2422
|
}
|
|
2305
|
-
let s = await
|
|
2423
|
+
let s = await B({
|
|
2306
2424
|
message: "修改模块名称",
|
|
2307
2425
|
default: i.displayName,
|
|
2308
2426
|
required: !0,
|
|
@@ -2310,50 +2428,50 @@ async function xn(e, t) {
|
|
|
2310
2428
|
prefill: "editable"
|
|
2311
2429
|
});
|
|
2312
2430
|
s = s.trim();
|
|
2313
|
-
const o =
|
|
2314
|
-
return s !== i.displayName ? (await
|
|
2431
|
+
const o = w("模块重命名中...").start();
|
|
2432
|
+
return s !== i.displayName ? (await Ms({
|
|
2315
2433
|
id: Number(i.id),
|
|
2316
2434
|
name: s
|
|
2317
|
-
}), await
|
|
2435
|
+
}), await je(i.path, s, "module", String(i.id)) && o.succeed(`模块重命名成功: ${i.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), i.id;
|
|
2318
2436
|
}
|
|
2319
|
-
async function
|
|
2320
|
-
const { type: a, typeStr: n } = await
|
|
2437
|
+
async function sn(e, t) {
|
|
2438
|
+
const { type: a, typeStr: n } = await Pe("修改", e), { localProduct: i } = await Oe(t.productId);
|
|
2321
2439
|
let s;
|
|
2322
|
-
if (E.MODULE === a ? s = await
|
|
2323
|
-
const o =
|
|
2440
|
+
if (E.MODULE === a ? s = await an(i, t) : E.CASE === a && (s = await tn(i, t)), !t.disableAutoCommit && await p("git status -s")) {
|
|
2441
|
+
const o = w("代码提交中...").start();
|
|
2324
2442
|
try {
|
|
2325
|
-
await
|
|
2443
|
+
await p(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
|
|
2326
2444
|
} catch (r) {
|
|
2327
2445
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
2328
2446
|
}
|
|
2329
2447
|
}
|
|
2330
2448
|
}
|
|
2331
|
-
x.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) =>
|
|
2332
|
-
async function
|
|
2449
|
+
x.command("qa-update").alias("qu").description("修改模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-id <targetId>", "可传指定目标(用例/模块)ID").option("--target-name <targetName>", "可传指定目标(用例/模块)修改后的名称").option("--case-priority <casePriority>", "如果是用例,指定修改后的优先级").option("--case-precondition <casePrecondition>", "如果是用例,指定修改后的前置条件").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => P(sn, ...e));
|
|
2450
|
+
async function nn(e, t) {
|
|
2333
2451
|
if (!e.length)
|
|
2334
2452
|
return [];
|
|
2335
|
-
const a =
|
|
2453
|
+
const a = pa(20), n = e.map(
|
|
2336
2454
|
(i) => a(async () => {
|
|
2337
2455
|
try {
|
|
2338
|
-
const s = t.env || "production", o = await
|
|
2456
|
+
const s = t.env || "production", o = await p(`python ${i.path}/main.py --env ${s}`);
|
|
2339
2457
|
try {
|
|
2340
2458
|
i.result = JSON.parse(o);
|
|
2341
2459
|
} catch {
|
|
2342
|
-
|
|
2460
|
+
m(`用例${i.displayName}[${i.id}]返回格式错误:${o}`);
|
|
2343
2461
|
}
|
|
2344
2462
|
} catch (s) {
|
|
2345
2463
|
const o = s instanceof Error ? s.message : String(s);
|
|
2346
|
-
|
|
2464
|
+
m(`用例${i.displayName}[${i.id}]执行失败: ${o}`);
|
|
2347
2465
|
}
|
|
2348
2466
|
})
|
|
2349
2467
|
);
|
|
2350
2468
|
return await Promise.all(n), e;
|
|
2351
2469
|
}
|
|
2352
|
-
async function
|
|
2353
|
-
|
|
2354
|
-
const { localProduct: t } = await
|
|
2470
|
+
async function rn(e) {
|
|
2471
|
+
ee(), W();
|
|
2472
|
+
const { localProduct: t } = await Oe(e.productId);
|
|
2355
2473
|
let a = [];
|
|
2356
|
-
const i = (await
|
|
2474
|
+
const i = (await ie(t.path)).filter((c) => c.type === "case");
|
|
2357
2475
|
if (e.all)
|
|
2358
2476
|
a = i.map((c) => ({
|
|
2359
2477
|
id: Number(c.id),
|
|
@@ -2361,7 +2479,7 @@ async function On(e) {
|
|
|
2361
2479
|
displayName: c.displayName
|
|
2362
2480
|
}));
|
|
2363
2481
|
else {
|
|
2364
|
-
const c =
|
|
2482
|
+
const c = Ke(e.caseIds);
|
|
2365
2483
|
if (c.length)
|
|
2366
2484
|
a = i.filter((l) => c.includes(Number(l.id))).map((l) => ({
|
|
2367
2485
|
id: Number(l.id),
|
|
@@ -2377,50 +2495,50 @@ async function On(e) {
|
|
|
2377
2495
|
},
|
|
2378
2496
|
name: u.path.replace(f.resolve(t.path), "")
|
|
2379
2497
|
}));
|
|
2380
|
-
a = await
|
|
2498
|
+
a = await V({
|
|
2381
2499
|
message: "选择要执行的用例",
|
|
2382
2500
|
pageSize: 100,
|
|
2383
2501
|
loop: !1,
|
|
2384
|
-
options: (u) => u ? l.filter((
|
|
2502
|
+
options: (u) => u ? l.filter((d) => d.name.includes(u)) : l,
|
|
2385
2503
|
validate(u) {
|
|
2386
2504
|
return u.length === 0 ? "至少选择一项" : !0;
|
|
2387
2505
|
}
|
|
2388
2506
|
});
|
|
2389
2507
|
}
|
|
2390
2508
|
}
|
|
2391
|
-
const s =
|
|
2509
|
+
const s = w("用例执行中...").start(), r = (await nn(a, e)).filter((c) => c.result.length);
|
|
2392
2510
|
if (r.length === 0)
|
|
2393
2511
|
s.succeed("所有用例执行通过 🎉");
|
|
2394
2512
|
else {
|
|
2395
2513
|
if (e.processStep === "1")
|
|
2396
|
-
return
|
|
2397
|
-
const c = r.reduce((
|
|
2514
|
+
return G("执行报告如下:"), console.log(JSON.stringify(r, null, 2)), process.exit(0);
|
|
2515
|
+
const c = r.reduce((d, h) => d + h.result.length, 0);
|
|
2398
2516
|
s.warn(`【${r.length}】个用例执行出错,【${c}】个BUG将创建。`);
|
|
2399
2517
|
let l = 0;
|
|
2400
2518
|
if (e.executionId)
|
|
2401
|
-
Number.isNaN(Number(e.executionId)) &&
|
|
2519
|
+
Number.isNaN(Number(e.executionId)) && m(`executionId ${e.executionId}不是正整数`), l = Number(e.executionId);
|
|
2402
2520
|
else {
|
|
2403
|
-
const
|
|
2521
|
+
const d = await Js(), h = await k({
|
|
2404
2522
|
message: "请选择用例执行出错后,BUG所属的项目",
|
|
2405
|
-
choices:
|
|
2406
|
-
}), g = await
|
|
2523
|
+
choices: d.map(({ id: v, name: q }) => ({ name: q, value: v }))
|
|
2524
|
+
}), g = await Gs(h);
|
|
2407
2525
|
l = await k({
|
|
2408
2526
|
message: "请选择用例执行出错后,BUG所属的执行",
|
|
2409
|
-
choices: g.map(({ id:
|
|
2527
|
+
choices: g.map(({ id: v, name: q }) => ({ name: q, value: v }))
|
|
2410
2528
|
});
|
|
2411
2529
|
}
|
|
2412
2530
|
let u;
|
|
2413
2531
|
if (e.buildId)
|
|
2414
2532
|
u = e.buildId;
|
|
2415
2533
|
else {
|
|
2416
|
-
const
|
|
2417
|
-
if (
|
|
2418
|
-
const h = await
|
|
2534
|
+
const d = await Us(Number(l));
|
|
2535
|
+
if (d.length) {
|
|
2536
|
+
const h = await Re({
|
|
2419
2537
|
message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
|
|
2420
2538
|
required: !1,
|
|
2421
|
-
choices:
|
|
2539
|
+
choices: d.map(({ id: g, name: v, date: q, builder: O }) => ({
|
|
2422
2540
|
value: g,
|
|
2423
|
-
name: `${
|
|
2541
|
+
name: `${v} ${O} ${q}`
|
|
2424
2542
|
}))
|
|
2425
2543
|
});
|
|
2426
2544
|
h.length ? u = h.join(",") : u = "";
|
|
@@ -2428,30 +2546,30 @@ async function On(e) {
|
|
|
2428
2546
|
s.warn("当前执行下没有构建,使用默认【主干】"), u = "";
|
|
2429
2547
|
}
|
|
2430
2548
|
s.start("上传中...");
|
|
2431
|
-
for (const
|
|
2432
|
-
await
|
|
2433
|
-
caseId:
|
|
2549
|
+
for (const d of r)
|
|
2550
|
+
await zs({
|
|
2551
|
+
caseId: d.id,
|
|
2434
2552
|
caseResult: "fail",
|
|
2435
|
-
stepResults:
|
|
2436
|
-
runner:
|
|
2553
|
+
stepResults: d.result,
|
|
2554
|
+
runner: R("ldapAccount"),
|
|
2437
2555
|
executionId: l,
|
|
2438
2556
|
openedBuild: u
|
|
2439
2557
|
});
|
|
2440
2558
|
s.succeed(
|
|
2441
|
-
`用例执行完成。查看相关BUG(${
|
|
2559
|
+
`用例执行完成。查看相关BUG(${U("ZenTaoDomain")}/zentao/execution-bug-${l}.html}) `
|
|
2442
2560
|
);
|
|
2443
2561
|
}
|
|
2444
2562
|
}
|
|
2445
|
-
x.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) =>
|
|
2446
|
-
const
|
|
2447
|
-
const { projects: e } = await
|
|
2563
|
+
x.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) => P(rn, ...e));
|
|
2564
|
+
const on = async () => {
|
|
2565
|
+
const { projects: e } = await rs(), t = H();
|
|
2448
2566
|
if (t.serverProjectURL) {
|
|
2449
2567
|
const n = e.find(
|
|
2450
|
-
(i) =>
|
|
2568
|
+
(i) => Nt(i.url, t.serverProjectURL)
|
|
2451
2569
|
);
|
|
2452
2570
|
if (n)
|
|
2453
2571
|
return {
|
|
2454
|
-
projectId: decodeURIComponent(
|
|
2572
|
+
projectId: decodeURIComponent(se(t.serverProjectURL)),
|
|
2455
2573
|
moduleList: n.modules || []
|
|
2456
2574
|
};
|
|
2457
2575
|
}
|
|
@@ -2462,18 +2580,18 @@ const Mn = async () => {
|
|
|
2462
2580
|
value: n.url
|
|
2463
2581
|
}))
|
|
2464
2582
|
});
|
|
2465
|
-
return
|
|
2466
|
-
projectId: decodeURIComponent(
|
|
2583
|
+
return kt({ ...t, serverProjectURL: a }), {
|
|
2584
|
+
projectId: decodeURIComponent(se(a)),
|
|
2467
2585
|
moduleList: e.find((n) => n.url === a)?.modules || []
|
|
2468
2586
|
};
|
|
2469
|
-
},
|
|
2470
|
-
const e =
|
|
2471
|
-
return e.language ||
|
|
2472
|
-
},
|
|
2587
|
+
}, cn = () => {
|
|
2588
|
+
const e = H();
|
|
2589
|
+
return e.language || m("未找到当前项目的语言类型,请先通过 z . 对项目进行初始化!"), e.language;
|
|
2590
|
+
}, ln = async (e, t) => {
|
|
2473
2591
|
const a = t ? t.split(",").filter((i) => e.map((s) => s.name).includes(i.trim())) : [];
|
|
2474
2592
|
if (a.length)
|
|
2475
2593
|
return a;
|
|
2476
|
-
const n = await
|
|
2594
|
+
const n = await Re({
|
|
2477
2595
|
message: "请选择对应的后端服务,不选默认全部",
|
|
2478
2596
|
choices: e.map((i) => ({
|
|
2479
2597
|
name: `${i.name}(${i.desc})`,
|
|
@@ -2484,62 +2602,62 @@ const Mn = async () => {
|
|
|
2484
2602
|
loop: !0
|
|
2485
2603
|
});
|
|
2486
2604
|
return n?.length ? n : e.map((i) => i.name);
|
|
2487
|
-
},
|
|
2605
|
+
}, ct = [C.DEV, C.TEST], un = async (e) => e && ct.includes(e.trim()) ? e : await k({
|
|
2488
2606
|
message: "请选择对应的环境",
|
|
2489
|
-
choices:
|
|
2490
|
-
}),
|
|
2607
|
+
choices: yt.filter((t) => ct.includes(t.value))
|
|
2608
|
+
}), Ye = (e) => {
|
|
2491
2609
|
const t = /^https?:\/\/[^/]+\/api\/([^/]+)\/v3\//;
|
|
2492
2610
|
return e.match(t)?.[1];
|
|
2493
|
-
},
|
|
2611
|
+
}, pn = async (e, t) => {
|
|
2494
2612
|
try {
|
|
2495
2613
|
const a = await ne({
|
|
2496
2614
|
url: e,
|
|
2497
2615
|
method: "get"
|
|
2498
|
-
}), n =
|
|
2616
|
+
}), n = Ye(e);
|
|
2499
2617
|
return n && (a.paths = Object.fromEntries(
|
|
2500
2618
|
Object.entries(a.paths).map(([i, s]) => [`/${n}${i}`, s])
|
|
2501
|
-
)),
|
|
2619
|
+
)), ma(a, {
|
|
2502
2620
|
throwOnValidateError: !t
|
|
2503
2621
|
});
|
|
2504
2622
|
} catch (a) {
|
|
2505
|
-
throw
|
|
2623
|
+
throw m(`Error fetching Swagger JSON: ${a.message}`), a;
|
|
2506
2624
|
}
|
|
2507
|
-
},
|
|
2625
|
+
}, mn = (e) => {
|
|
2508
2626
|
const t = (a) => {
|
|
2509
2627
|
const { reason: n, url: i } = a;
|
|
2510
|
-
return `## ${
|
|
2628
|
+
return `## ${Ye(i)}服务接口文档校验失败
|
|
2511
2629
|
${n.message}`;
|
|
2512
2630
|
};
|
|
2513
2631
|
return `# 服务端接口文档校验失败
|
|
2514
2632
|
${e.map(t).join(`
|
|
2515
2633
|
`)}`;
|
|
2516
|
-
},
|
|
2517
|
-
const a =
|
|
2518
|
-
(c) => c.projects.some((l) =>
|
|
2634
|
+
}, dn = async (e, t) => {
|
|
2635
|
+
const a = mn(e), n = H(), { groups: i } = await Et(), s = i.find(
|
|
2636
|
+
(c) => c.projects.some((l) => Nt(l, n.serverProjectURL))
|
|
2519
2637
|
);
|
|
2520
2638
|
t.fail("API数据解析失败"), s || (t.fail("未找到对应的项目群聊组!"), process.stdout.write(`${A.red(a)}
|
|
2521
2639
|
`), process.exit(1));
|
|
2522
|
-
const { code: o, message: r } = await
|
|
2640
|
+
const { code: o, message: r } = await Vs({
|
|
2523
2641
|
content: a,
|
|
2524
2642
|
webhooks: [s.url]
|
|
2525
2643
|
});
|
|
2526
2644
|
o !== 0 && t.fail(`发送消息到企微群组失败: ${A.red(r)}`), process.stdout.write(`${A.red(a)}
|
|
2527
2645
|
`), process.exit(1);
|
|
2528
|
-
},
|
|
2646
|
+
}, fn = async (e) => {
|
|
2529
2647
|
const { moduleList: t, services: a, env: n, skipSwaggerValidate: i } = e, s = t.filter((u) => a.includes(u.name)).map((u) => u.swagger);
|
|
2530
2648
|
if (!s.length)
|
|
2531
2649
|
throw new Error("Failed to fetch Swagger JSON");
|
|
2532
2650
|
const o = s.flatMap((u) => {
|
|
2533
|
-
const
|
|
2534
|
-
return
|
|
2651
|
+
const d = u.find((h) => h.env === n);
|
|
2652
|
+
return d ? [d.url] : [];
|
|
2535
2653
|
});
|
|
2536
2654
|
if (!o.length)
|
|
2537
2655
|
throw new Error("Failed to fetch Swagger JSON");
|
|
2538
|
-
const r =
|
|
2539
|
-
(u,
|
|
2656
|
+
const r = w("API数据请求中...").start(), c = await Promise.allSettled(o.map((u) => pn(u, i))), l = c.flatMap(
|
|
2657
|
+
(u, d) => u.status === "rejected" ? [{ reason: u.reason, url: o[d] }] : []
|
|
2540
2658
|
);
|
|
2541
|
-
return l.length && await
|
|
2542
|
-
},
|
|
2659
|
+
return l.length && await dn(l, r), r.succeed("API数据请求成功"), c.flatMap((u, d) => u.status === "fulfilled" ? [{ serverName: Ye(o[d]), swaggerJson: u.value }] : []);
|
|
2660
|
+
}, gn = () => k({
|
|
2543
2661
|
message: "请选择生成API的范围",
|
|
2544
2662
|
choices: [
|
|
2545
2663
|
{
|
|
@@ -2551,40 +2669,64 @@ ${e.map(t).join(`
|
|
|
2551
2669
|
value: "single"
|
|
2552
2670
|
}
|
|
2553
2671
|
]
|
|
2554
|
-
}),
|
|
2672
|
+
}), Je = ({
|
|
2673
|
+
message: e,
|
|
2674
|
+
options: t,
|
|
2675
|
+
emptyValidateMsg: a,
|
|
2676
|
+
pageSize: n = 20,
|
|
2677
|
+
multiple: i = !0,
|
|
2678
|
+
formatShowToValue: s
|
|
2679
|
+
}) => {
|
|
2680
|
+
const o = s ? typeof s == "function" ? s : (r) => r.map((c) => String(c.value)).join(", ") : void 0;
|
|
2681
|
+
return V({
|
|
2682
|
+
message: e,
|
|
2683
|
+
pageSize: n,
|
|
2684
|
+
clearInputWhenSelected: !0,
|
|
2685
|
+
multiple: i,
|
|
2686
|
+
loop: !0,
|
|
2687
|
+
options: (r) => r ? t.filter((c) => (c.name ?? c.label ?? c.value).includes(r)) : t,
|
|
2688
|
+
validate: a ? (r) => r.length ? !0 : a : void 0,
|
|
2689
|
+
filter: !0,
|
|
2690
|
+
theme: o ? {
|
|
2691
|
+
style: {
|
|
2692
|
+
renderSelectedOptions: o
|
|
2693
|
+
}
|
|
2694
|
+
} : void 0
|
|
2695
|
+
});
|
|
2696
|
+
}, lt = (e) => {
|
|
2555
2697
|
const t = e.trim();
|
|
2556
2698
|
if (!t)
|
|
2557
2699
|
return "请输入生成目录";
|
|
2558
2700
|
if (t.includes("\0"))
|
|
2559
2701
|
return "路径格式不合法";
|
|
2560
|
-
if (
|
|
2702
|
+
if (ta(t))
|
|
2561
2703
|
return "只允许输入相对路径";
|
|
2562
|
-
const a =
|
|
2563
|
-
return !a || a === "." || a === ".." ? "请输入有效的目录路径" : a.startsWith(`..${
|
|
2564
|
-
},
|
|
2704
|
+
const a = aa(t);
|
|
2705
|
+
return !a || a === "." || a === ".." ? "请输入有效的目录路径" : a.startsWith(`..${sa}`) ? "路径不能跳出当前项目" : !0;
|
|
2706
|
+
}, hn = (e) => {
|
|
2565
2707
|
if (e) {
|
|
2566
|
-
const t =
|
|
2567
|
-
return t !== !0 &&
|
|
2708
|
+
const t = lt(e);
|
|
2709
|
+
return t !== !0 && m(t), e;
|
|
2568
2710
|
}
|
|
2569
|
-
return
|
|
2711
|
+
return B({
|
|
2570
2712
|
message: "请输入 API 输出目录,默认为 src/services",
|
|
2571
2713
|
default: "src/services",
|
|
2572
|
-
validate:
|
|
2714
|
+
validate: lt
|
|
2573
2715
|
});
|
|
2574
2716
|
};
|
|
2575
|
-
class
|
|
2717
|
+
class Ut {
|
|
2576
2718
|
o;
|
|
2577
2719
|
options;
|
|
2578
2720
|
async generateApi(t) {
|
|
2579
2721
|
this.options = t;
|
|
2580
2722
|
const { scope: a } = t;
|
|
2581
|
-
this.o =
|
|
2723
|
+
this.o = w("API 开始生成...").start(), a === "single" ? await this.startGenerateSingleApi() : await this.startGenerateAllApi(), this.o.succeed("API 生成成功");
|
|
2582
2724
|
}
|
|
2583
2725
|
async startGenerateSingleApi() {
|
|
2584
2726
|
const t = [], a = this.options.remoteSwaggerJsons.map((n) => n.swaggerJson);
|
|
2585
2727
|
this.o.text = "获取 API 列表...";
|
|
2586
2728
|
for (const n of a) {
|
|
2587
|
-
const { apis: i } = await
|
|
2729
|
+
const { apis: i } = await da(n, {
|
|
2588
2730
|
throwOnValidateError: !this.options.skipSwaggerValidate
|
|
2589
2731
|
});
|
|
2590
2732
|
t.push(...i.map((s) => ({ name: `${s.path}${s.summary ? `(${s.summary})` : ""}`, value: s.path })));
|
|
@@ -2592,20 +2734,11 @@ class Dt {
|
|
|
2592
2734
|
this.o.stop();
|
|
2593
2735
|
try {
|
|
2594
2736
|
await this.generateSingleApi(
|
|
2595
|
-
await
|
|
2737
|
+
await Je({
|
|
2596
2738
|
message: "请选择需要生成的API",
|
|
2597
|
-
options:
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
multiple: !0,
|
|
2601
|
-
loop: !0,
|
|
2602
|
-
validate: (n) => n.length ? !0 : "至少选择一个API",
|
|
2603
|
-
filter: !0,
|
|
2604
|
-
theme: {
|
|
2605
|
-
style: {
|
|
2606
|
-
renderSelectedOptions: (n) => n.map((i) => i.value).join(", ")
|
|
2607
|
-
}
|
|
2608
|
-
}
|
|
2739
|
+
options: t,
|
|
2740
|
+
emptyValidateMsg: "至少选择一个API",
|
|
2741
|
+
formatShowToValue: !0
|
|
2609
2742
|
})
|
|
2610
2743
|
);
|
|
2611
2744
|
} catch (n) {
|
|
@@ -2615,24 +2748,24 @@ class Dt {
|
|
|
2615
2748
|
async startGenerateAllApi() {
|
|
2616
2749
|
const t = await this.generateAllApi();
|
|
2617
2750
|
this.o.stop();
|
|
2618
|
-
const a = await
|
|
2619
|
-
|
|
2751
|
+
const a = await hn(this.options.dir), n = pe(a);
|
|
2752
|
+
Yt(n, { recursive: !0 });
|
|
2620
2753
|
const i = [];
|
|
2621
2754
|
this.o.start(), this.o.text = "API 生成中...";
|
|
2622
2755
|
for (const s of t) {
|
|
2623
|
-
const { path: o, content: r } = s, c =
|
|
2624
|
-
i.push(c),
|
|
2756
|
+
const { path: o, content: r } = s, c = pe(n, o);
|
|
2757
|
+
i.push(c), ve(c, r);
|
|
2625
2758
|
}
|
|
2626
2759
|
this.o.text = "开始格式化代码", await this.formatApiContent(i), this.o.text = "代码格式化完成", this.o.succeed(`API 已生成到 ${a} 目录下`);
|
|
2627
2760
|
}
|
|
2628
2761
|
}
|
|
2629
|
-
class
|
|
2762
|
+
class wn extends Ut {
|
|
2630
2763
|
formatApiContent() {
|
|
2631
2764
|
return this.o.succeed("yaml 暂无格式化配置"), Promise.resolve();
|
|
2632
2765
|
}
|
|
2633
2766
|
generateAllApi() {
|
|
2634
2767
|
const t = this.options.remoteSwaggerJsons.map((a) => a.swaggerJson);
|
|
2635
|
-
return
|
|
2768
|
+
return fa(
|
|
2636
2769
|
t.map((a) => ({
|
|
2637
2770
|
swaggerJson: a,
|
|
2638
2771
|
throwOnValidateError: !this.options.skipSwaggerValidate
|
|
@@ -2644,37 +2777,37 @@ class qn extends Dt {
|
|
|
2644
2777
|
for (const { swaggerJson: i, serverName: s } of a) {
|
|
2645
2778
|
if (!t.some((r) => r.startsWith(`/${s}`)))
|
|
2646
2779
|
continue;
|
|
2647
|
-
const o = await
|
|
2780
|
+
const o = await ga({
|
|
2648
2781
|
swaggerJson: i,
|
|
2649
2782
|
controller: t,
|
|
2650
2783
|
throwOnValidateError: !n,
|
|
2651
2784
|
showHeaderComment: !1
|
|
2652
2785
|
});
|
|
2653
|
-
console.log(
|
|
2786
|
+
console.log(dt(o, { language: "typescript", ignoreIllegals: !0 }));
|
|
2654
2787
|
}
|
|
2655
2788
|
}
|
|
2656
2789
|
}
|
|
2657
|
-
const
|
|
2790
|
+
const yn = new ft({
|
|
2658
2791
|
fix: !0
|
|
2659
2792
|
});
|
|
2660
|
-
class
|
|
2793
|
+
class $n extends Ut {
|
|
2661
2794
|
async formatApiContent(t) {
|
|
2662
2795
|
try {
|
|
2663
|
-
const a = await
|
|
2664
|
-
await
|
|
2796
|
+
const a = await yn.lintFiles(t);
|
|
2797
|
+
await ft.outputFixes(a);
|
|
2665
2798
|
for (const n of t) {
|
|
2666
|
-
const i =
|
|
2799
|
+
const i = pe(n), s = ut(i, "utf-8"), o = await ya.format(s, {
|
|
2667
2800
|
filepath: i
|
|
2668
2801
|
});
|
|
2669
|
-
|
|
2802
|
+
ve(i, o);
|
|
2670
2803
|
}
|
|
2671
2804
|
} catch (a) {
|
|
2672
|
-
console.error(a), this.o.stop(),
|
|
2805
|
+
console.error(a), this.o.stop(), m("API 格式化失败,请检查是否配置 eslint 和 prettier");
|
|
2673
2806
|
}
|
|
2674
2807
|
}
|
|
2675
2808
|
generateAllApi() {
|
|
2676
2809
|
const t = this.options.remoteSwaggerJsons.map((a) => a.swaggerJson);
|
|
2677
|
-
return
|
|
2810
|
+
return ha(
|
|
2678
2811
|
t.map((a) => ({
|
|
2679
2812
|
swaggerJson: a,
|
|
2680
2813
|
throwOnValidateError: !this.options.skipSwaggerValidate
|
|
@@ -2686,54 +2819,211 @@ class Zn extends Dt {
|
|
|
2686
2819
|
for (const { swaggerJson: i, serverName: s } of a) {
|
|
2687
2820
|
if (!t.some((r) => r.startsWith(`/${s}`)))
|
|
2688
2821
|
continue;
|
|
2689
|
-
const o = await
|
|
2822
|
+
const o = await wa({
|
|
2690
2823
|
swaggerJson: i,
|
|
2691
2824
|
merge: !0,
|
|
2692
2825
|
controller: t,
|
|
2693
2826
|
throwOnValidateError: !n,
|
|
2694
2827
|
importMethods: !1
|
|
2695
2828
|
});
|
|
2696
|
-
console.log(
|
|
2829
|
+
console.log(dt(o, { language: "typescript", ignoreIllegals: !0 }));
|
|
2697
2830
|
}
|
|
2698
2831
|
}
|
|
2699
2832
|
}
|
|
2700
|
-
const
|
|
2833
|
+
const vn = (e) => {
|
|
2701
2834
|
switch (e) {
|
|
2702
|
-
case
|
|
2703
|
-
return
|
|
2704
|
-
case
|
|
2705
|
-
return
|
|
2706
|
-
}
|
|
2707
|
-
},
|
|
2708
|
-
const { apiType: t } = e, a =
|
|
2709
|
-
a ? await new a().generateApi(e) :
|
|
2835
|
+
case $.JAVASCRIPT:
|
|
2836
|
+
return $n;
|
|
2837
|
+
case $.PYTHON:
|
|
2838
|
+
return wn;
|
|
2839
|
+
}
|
|
2840
|
+
}, An = async (e) => {
|
|
2841
|
+
const { apiType: t } = e, a = vn(t);
|
|
2842
|
+
a ? await new a().generateApi(e) : m(`不支持 ${t} 语言`);
|
|
2710
2843
|
};
|
|
2711
|
-
async function
|
|
2712
|
-
|
|
2713
|
-
const { moduleList:
|
|
2714
|
-
moduleList:
|
|
2715
|
-
services:
|
|
2716
|
-
env:
|
|
2717
|
-
skipSwaggerValidate:
|
|
2718
|
-
}),
|
|
2719
|
-
await
|
|
2720
|
-
remoteSwaggerJsons:
|
|
2721
|
-
...
|
|
2722
|
-
scope:
|
|
2723
|
-
apiType:
|
|
2844
|
+
async function Sn(e) {
|
|
2845
|
+
ee(), W();
|
|
2846
|
+
const { moduleList: t } = await on(), { services: a, env: n, skipSwaggerValidate: i = !1 } = e, s = await ln(t, a), o = cn(), r = await un(n), c = await fn({
|
|
2847
|
+
moduleList: t,
|
|
2848
|
+
services: s,
|
|
2849
|
+
env: r,
|
|
2850
|
+
skipSwaggerValidate: i
|
|
2851
|
+
}), l = await gn();
|
|
2852
|
+
await An({
|
|
2853
|
+
remoteSwaggerJsons: c,
|
|
2854
|
+
...e,
|
|
2855
|
+
scope: l,
|
|
2856
|
+
apiType: o
|
|
2724
2857
|
}), process.exit(0);
|
|
2725
2858
|
}
|
|
2726
|
-
x.command("api").alias("a").description("选择对应的服务端项目,获取接口并转成ts接口代码及类型").option("--services [services]", "指定需要生成的服务。多个使用逗号隔开").option("--env [env]", "指定环境。dev/test/release").option("--dir [dir]", "输出的目录。默认为 src/services").option("--skip-swagger-validate
|
|
2727
|
-
|
|
2859
|
+
x.command("api").alias("a").description("选择对应的服务端项目,获取接口并转成ts接口代码及类型").option("--services [services]", "指定需要生成的服务。多个使用逗号隔开").option("--env [env]", "指定环境。dev/test/release").option("--dir [dir]", "输出的目录。默认为 src/services").option("--skip-swagger-validate", "是否跳过 swagger 校验").action((...e) => P(Sn, ...e));
|
|
2860
|
+
const Nn = 10, bn = async () => {
|
|
2861
|
+
const e = await p("git branch --show-current"), t = [
|
|
2862
|
+
y.MASTER,
|
|
2863
|
+
// 本地当前分支
|
|
2864
|
+
`* ${e}`,
|
|
2865
|
+
// 远程当前分支
|
|
2866
|
+
`remotes/origin/${e}`,
|
|
2867
|
+
// 远程 master 分支
|
|
2868
|
+
`remotes/origin/${y.MASTER}`
|
|
2869
|
+
];
|
|
2870
|
+
return (await p("git branch -a")).trim().split(`
|
|
2871
|
+
`).map((n) => n.trim()).filter((n) => n && !n.includes("HEAD")).filter((n) => !t.includes(n)).filter((n, i, s) => s.indexOf(n) === i).map((n) => ({
|
|
2872
|
+
name: n,
|
|
2873
|
+
value: n
|
|
2874
|
+
}));
|
|
2875
|
+
}, jn = async (e) => (await p(
|
|
2876
|
+
`git log ${e} -n ${Nn} --format="%H%x1f%s%x1f%an%x1f%ae%x1f%aI" --no-merges`
|
|
2877
|
+
)).trim().split(`
|
|
2878
|
+
`).filter((a) => a.trim() !== "").map((a) => {
|
|
2879
|
+
const [n = "", i = "", s = "", o = "", r = ""] = a.split("");
|
|
2880
|
+
return {
|
|
2881
|
+
hash: n,
|
|
2882
|
+
message: i,
|
|
2883
|
+
authorName: s,
|
|
2884
|
+
authorEmail: o,
|
|
2885
|
+
authorDate: r
|
|
2886
|
+
};
|
|
2887
|
+
}), Tn = (e) => p(`git show -s --format=%B ${e}`, { removeTailLinkBreak: !1 }), he = (e) => typeof e == "string" ? e : "", we = (e, t = {}) => {
|
|
2888
|
+
const a = S.config.fatal;
|
|
2889
|
+
S.config.fatal = !1;
|
|
2890
|
+
try {
|
|
2891
|
+
return S.exec(e, t);
|
|
2892
|
+
} finally {
|
|
2893
|
+
S.config.fatal = a;
|
|
2894
|
+
}
|
|
2895
|
+
}, ye = (e, t) => {
|
|
2896
|
+
e.text = t, e.render();
|
|
2897
|
+
}, kn = (e) => /with conflicts|merge conflict|CONFLICT|patch does not apply/i.test(e), En = async () => {
|
|
2898
|
+
try {
|
|
2899
|
+
return (await p("git diff --name-only --diff-filter=U")).split(`
|
|
2900
|
+
`).map((t) => t.trim()).filter(Boolean);
|
|
2901
|
+
} catch {
|
|
2902
|
+
return [];
|
|
2903
|
+
}
|
|
2904
|
+
}, In = async (e, t) => {
|
|
2905
|
+
const a = Xt(pe(ra(), "z-pick-commit-")), n = pe(a, `${e.hash}.patch`), i = pe(a, `${e.hash}.message`);
|
|
2906
|
+
try {
|
|
2907
|
+
ye(t, `正在生成 patch: ${e.hash.slice(0, 8)} ${e.message}`);
|
|
2908
|
+
const s = we(`git format-patch -1 ${e.hash} --stdout --binary --full-index`, {
|
|
2909
|
+
silent: !0
|
|
2910
|
+
});
|
|
2911
|
+
if (s.code !== 0)
|
|
2912
|
+
return {
|
|
2913
|
+
status: "failed",
|
|
2914
|
+
message: he(s.stderr) || `生成 patch 失败: ${e.hash}`
|
|
2915
|
+
};
|
|
2916
|
+
if (ve(n, he(s.stdout)), ve(i, await Tn(e.hash)), ye(t, `正在检查 patch 是否已存在: ${e.hash.slice(0, 8)} ${e.message}`), we(`git apply --reverse --check "${n}"`, {
|
|
2917
|
+
silent: !0
|
|
2918
|
+
}).code === 0)
|
|
2919
|
+
return {
|
|
2920
|
+
status: "skipped",
|
|
2921
|
+
reason: `已跳过重复 patch: ${e.hash.slice(0, 8)} ${e.message}`
|
|
2922
|
+
};
|
|
2923
|
+
ye(t, `正在应用 patch: ${e.hash.slice(0, 8)} ${e.message}`);
|
|
2924
|
+
const r = we(`git apply --3way --whitespace=nowarn "${n}"`, {
|
|
2925
|
+
silent: !0
|
|
2926
|
+
});
|
|
2927
|
+
if (r.code !== 0) {
|
|
2928
|
+
const u = he(r.stderr) || `应用 patch 失败: ${e.hash}`;
|
|
2929
|
+
return kn(u) ? {
|
|
2930
|
+
status: "conflict",
|
|
2931
|
+
message: u,
|
|
2932
|
+
conflictFiles: await En()
|
|
2933
|
+
} : {
|
|
2934
|
+
status: "failed",
|
|
2935
|
+
message: u
|
|
2936
|
+
};
|
|
2937
|
+
}
|
|
2938
|
+
ye(t, `正在暂存变更: ${e.hash.slice(0, 8)} ${e.message}`);
|
|
2939
|
+
const c = we("git add -A", {
|
|
2940
|
+
silent: !0
|
|
2941
|
+
});
|
|
2942
|
+
if (c.code !== 0)
|
|
2943
|
+
return {
|
|
2944
|
+
status: "failed",
|
|
2945
|
+
message: he(c.stderr) || `暂存 patch 失败: ${e.hash}`
|
|
2946
|
+
};
|
|
2947
|
+
S.env.GIT_AUTHOR_NAME = e.authorName, S.env.GIT_AUTHOR_EMAIL = e.authorEmail, S.env.GIT_AUTHOR_DATE = e.authorDate, ye(t, `正在提交 commit: ${e.hash.slice(0, 8)} ${e.message}`);
|
|
2948
|
+
const l = we(`git commit --file "${i}"`, {
|
|
2949
|
+
silent: !0
|
|
2950
|
+
});
|
|
2951
|
+
return l.code !== 0 ? {
|
|
2952
|
+
status: "failed",
|
|
2953
|
+
message: he(l.stderr) || `提交 patch 失败: ${e.hash}`
|
|
2954
|
+
} : {
|
|
2955
|
+
status: "success"
|
|
2956
|
+
};
|
|
2957
|
+
} finally {
|
|
2958
|
+
delete S.env.GIT_AUTHOR_NAME, delete S.env.GIT_AUTHOR_EMAIL, delete S.env.GIT_AUTHOR_DATE, Qt(a, {
|
|
2959
|
+
force: !0,
|
|
2960
|
+
recursive: !0
|
|
2961
|
+
});
|
|
2962
|
+
}
|
|
2963
|
+
}, Vt = (e) => e.slice(0, 8), Rn = (e) => e.replace("T", " ").slice(0, 16), Cn = (e) => `${Rn(e.authorDate)} ${e.authorName} ${Vt(e.hash)} ${e.message}`, Ln = (e, t) => t.map((a) => e.find((n) => n.hash === a)).filter((a) => !!a).sort((a, n) => {
|
|
2964
|
+
const i = e.indexOf(a);
|
|
2965
|
+
return e.indexOf(n) - i;
|
|
2966
|
+
});
|
|
2967
|
+
async function xn() {
|
|
2968
|
+
ee(), W(), await ge();
|
|
2969
|
+
const e = w("获取分支列表中...").start();
|
|
2970
|
+
await p("git fetch -p");
|
|
2971
|
+
const t = await bn();
|
|
2972
|
+
e.succeed("获取分支列表成功");
|
|
2973
|
+
const a = await Je({
|
|
2974
|
+
message: "选择需要pick的分支",
|
|
2975
|
+
options: t,
|
|
2976
|
+
emptyValidateMsg: "至少选择一个分支",
|
|
2977
|
+
multiple: !1
|
|
2978
|
+
});
|
|
2979
|
+
if (!a)
|
|
2980
|
+
return;
|
|
2981
|
+
const n = await jn(a), i = n.map((r) => ({
|
|
2982
|
+
name: Cn(r),
|
|
2983
|
+
value: r.hash
|
|
2984
|
+
})), s = await Je({
|
|
2985
|
+
message: "选择需要pick的commit。选中的 commit 会按照提交时间顺序执行。",
|
|
2986
|
+
options: i,
|
|
2987
|
+
emptyValidateMsg: "至少选择一个commit",
|
|
2988
|
+
formatShowToValue: (r) => r.map((c) => {
|
|
2989
|
+
const l = n.find((u) => u.hash === c.value);
|
|
2990
|
+
return l ? Vt(l.hash) : String(c.value);
|
|
2991
|
+
}).join(", ")
|
|
2992
|
+
});
|
|
2993
|
+
if (!s?.length)
|
|
2994
|
+
return;
|
|
2995
|
+
const o = Ln(n, s);
|
|
2996
|
+
e.start(`开始处理分支 ${a} 的 commit...`);
|
|
2997
|
+
for (const r of o) {
|
|
2998
|
+
const c = await In(r, e);
|
|
2999
|
+
if (c.status === "skipped")
|
|
3000
|
+
e.warn(c.reason);
|
|
3001
|
+
else if (c.status === "success")
|
|
3002
|
+
e.succeed(`已提交: ${r.hash.slice(0, 8)} ${r.message}`);
|
|
3003
|
+
else if (c.status === "conflict") {
|
|
3004
|
+
e.fail(`处理失败: ${r.hash.slice(0, 8)} ${r.message}`), z("检测到 patch 冲突,已停止后续 commit 处理。"), z(`冲突提交: ${r.hash.slice(0, 8)} ${r.message}`), c.conflictFiles.length && z(`冲突文件:
|
|
3005
|
+
${c.conflictFiles.join(`
|
|
3006
|
+
`)}`), z("请先手动解决冲突并处理当前工作区,再重新执行 pick-commit。"), await M(Ne(), r.message, "utf-8");
|
|
3007
|
+
return;
|
|
3008
|
+
} else {
|
|
3009
|
+
e.fail(`处理失败: ${r.hash.slice(0, 8)} ${r.message}`), z(c.message);
|
|
3010
|
+
return;
|
|
3011
|
+
}
|
|
3012
|
+
e.start(`继续处理分支 ${a} 的下一个 commit...`);
|
|
3013
|
+
}
|
|
3014
|
+
e.succeed(`分支 ${a} 处理完成`), e.succeed("pick commit 完成");
|
|
3015
|
+
}
|
|
3016
|
+
x.command("pick").alias("p").description("从其他分支选择并应用 Commit内容 到当前分支").action((...e) => P(xn, ...e));
|
|
3017
|
+
function Dn() {
|
|
2728
3018
|
process.on("unhandledRejection", (e) => {
|
|
2729
3019
|
}), process.on("uncaughtException", (e) => {
|
|
2730
|
-
}),
|
|
3020
|
+
}), S.config.fatal = !0, S.config.silent = !0, S.config.verbose = !1;
|
|
2731
3021
|
}
|
|
2732
|
-
async function
|
|
2733
|
-
const e =
|
|
3022
|
+
async function Pn() {
|
|
3023
|
+
const e = Se("latestCheckVersionTimestamp"), t = Se("versionCheckDuring");
|
|
2734
3024
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
2735
|
-
const a = await
|
|
2736
|
-
|
|
3025
|
+
const a = await We();
|
|
3026
|
+
De(a);
|
|
2737
3027
|
let n;
|
|
2738
3028
|
try {
|
|
2739
3029
|
const i = "TIME_OUT", s = new Promise((o) => {
|
|
@@ -2741,24 +3031,24 @@ async function es() {
|
|
|
2741
3031
|
});
|
|
2742
3032
|
n = await Promise.race([
|
|
2743
3033
|
s,
|
|
2744
|
-
|
|
2745
|
-
]), n !== i && n !==
|
|
3034
|
+
p(`npm view ${oe.name} version --registry https://registry.npmmirror.com/`)
|
|
3035
|
+
]), n !== i && n !== oe.version && (console.log(`${A.blue(oe.name)}本地版本为${oe.version},低于线上版本${n},开始升级`), await Mt(n)), de("latestCheckVersionTimestamp", Date.now()), ce();
|
|
2746
3036
|
} catch (i) {
|
|
2747
|
-
console.log("升级出错!请重试,或者手动升级"),
|
|
3037
|
+
console.log("升级出错!请重试,或者手动升级"), m(i);
|
|
2748
3038
|
}
|
|
2749
3039
|
}
|
|
2750
3040
|
}
|
|
2751
|
-
async function
|
|
2752
|
-
const e =
|
|
3041
|
+
async function On() {
|
|
3042
|
+
const e = $a(process.argv.slice(2));
|
|
2753
3043
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2754
|
-
if (
|
|
2755
|
-
const t =
|
|
2756
|
-
|
|
3044
|
+
if (St()) {
|
|
3045
|
+
const t = I.readJSONSync(xe());
|
|
3046
|
+
J(t.profile), de(t.main), De(t.constants), await Pn();
|
|
2757
3047
|
} else
|
|
2758
|
-
|
|
3048
|
+
m(`请先初始化z-develop(执行 z i)。更多见${$t}`);
|
|
2759
3049
|
}
|
|
2760
|
-
async function
|
|
2761
|
-
|
|
3050
|
+
async function Mn() {
|
|
3051
|
+
Dn(), await On();
|
|
2762
3052
|
}
|
|
2763
|
-
x.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${A.blue(
|
|
3053
|
+
x.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${A.blue($t)}`).usage("<command> [options]").hook("preAction", Mn).version(oe.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
2764
3054
|
x.parse();
|