cli-z-develop 0.16.1 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +575 -565
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { program as P } from "commander";
|
|
2
|
-
import
|
|
3
|
-
import { existsSync as
|
|
4
|
-
import { readdir as
|
|
5
|
-
import f, { resolve as pe, isAbsolute as
|
|
6
|
-
import me, { AxiosError as
|
|
2
|
+
import Yt from "node:child_process";
|
|
3
|
+
import { existsSync as j, readdirSync as Xt, lstatSync as Qt, createWriteStream as ea, writeFileSync as ve, readFileSync as dt, mkdirSync as ta, mkdtempSync as aa, rmSync as sa } from "node:fs";
|
|
4
|
+
import { readdir as Ue, mkdir as fe, writeFile as _, rename as ft, readFile as _e, stat as na } from "node:fs/promises";
|
|
5
|
+
import f, { resolve as pe, isAbsolute as ia, normalize as ra, sep as oa } from "node:path";
|
|
6
|
+
import me, { AxiosError as gt } from "axios";
|
|
7
7
|
import A from "chalk";
|
|
8
|
-
import
|
|
8
|
+
import ca from "dayjs";
|
|
9
9
|
import N from "shelljs";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { confirm as Le, select as k, input as F, password as
|
|
10
|
+
import la, { tmpdir as ua } from "node:os";
|
|
11
|
+
import tt from "child_process";
|
|
12
|
+
import { confirm as Le, select as k, input as F, password as pa, checkbox as Re, number as at } from "@inquirer/prompts";
|
|
13
13
|
import y from "ora";
|
|
14
14
|
import L from "fs-extra";
|
|
15
|
-
import
|
|
15
|
+
import ma from "open";
|
|
16
16
|
import { select as W } from "inquirer-select-pro";
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { run as
|
|
20
|
-
import
|
|
21
|
-
import { validateSwagger as
|
|
22
|
-
import { highlight as
|
|
23
|
-
import { ESLint as
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
const
|
|
27
|
-
var O = /* @__PURE__ */ ((e) => (e[e.DEV =
|
|
28
|
-
const
|
|
17
|
+
import da from "lint-staged";
|
|
18
|
+
import fa from "semver";
|
|
19
|
+
import { run as ga } from "npm-check-updates";
|
|
20
|
+
import ha from "p-limit";
|
|
21
|
+
import { validateSwagger as wa, getParsedSwagger as ya, generatePythonBundleApi as $a, generatePythonApi as va, generateTypescriptBundleApi as Aa, generateTypescriptApi as ba } from "@lonely9/api-generate";
|
|
22
|
+
import { highlight as ht } from "cli-highlight";
|
|
23
|
+
import { ESLint as wt } from "eslint";
|
|
24
|
+
import Sa from "prettier";
|
|
25
|
+
import Na from "minimist";
|
|
26
|
+
const yt = "dev", $t = "test", vt = "release", ja = "production", Ta = "master";
|
|
27
|
+
var O = /* @__PURE__ */ ((e) => (e[e.DEV = yt] = "DEV", e[e.TEST = $t] = "TEST", e[e.RELEASE = vt] = "RELEASE", e[e.PROD = ja] = "PROD", e))(O || {}), w = /* @__PURE__ */ ((e) => (e[e.DEV = yt] = "DEV", e[e.TEST = $t] = "TEST", e[e.RELEASE = vt] = "RELEASE", e[e.MASTER = Ta] = "MASTER", e))(w || {}), Y = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(Y || {});
|
|
28
|
+
const At = [
|
|
29
29
|
{
|
|
30
30
|
name: `开发环境 - ${O.DEV}`,
|
|
31
31
|
value: O.DEV
|
|
@@ -42,7 +42,7 @@ const vt = [
|
|
|
42
42
|
name: `正式环境 - ${O.PROD}`,
|
|
43
43
|
value: O.PROD
|
|
44
44
|
}
|
|
45
|
-
],
|
|
45
|
+
], ka = [
|
|
46
46
|
{
|
|
47
47
|
name: "网页 - h5",
|
|
48
48
|
value: "h5"
|
|
@@ -60,7 +60,7 @@ const vt = [
|
|
|
60
60
|
}
|
|
61
61
|
];
|
|
62
62
|
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))($ || {});
|
|
63
|
-
const
|
|
63
|
+
const Ea = {
|
|
64
64
|
1: "研发",
|
|
65
65
|
2: "测试",
|
|
66
66
|
3: "产品",
|
|
@@ -70,11 +70,11 @@ const ja = {
|
|
|
70
70
|
7: "行政",
|
|
71
71
|
8: "财务",
|
|
72
72
|
9: "其他"
|
|
73
|
-
}, Ae = "http://git.cxlqd.com",
|
|
74
|
-
var
|
|
75
|
-
const
|
|
73
|
+
}, Ae = "http://git.cxlqd.com", Ia = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
74
|
+
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 || {});
|
|
75
|
+
const Ra = "fe-biz7tvsd", bt = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
76
76
|
var C = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(C || {});
|
|
77
|
-
const
|
|
77
|
+
const Ca = [
|
|
78
78
|
{
|
|
79
79
|
name: "模块",
|
|
80
80
|
value: "module"
|
|
@@ -85,30 +85,30 @@ const Ia = [
|
|
|
85
85
|
value: "case"
|
|
86
86
|
/* CASE */
|
|
87
87
|
}
|
|
88
|
-
],
|
|
88
|
+
], La = 150 * 1024, st = 0.8 * 1024 * 1024, Fe = ",", xa = ".z", Pa = "develop-config.json", K = ".z", Da = ".commit-msg-tpl", Oa = "project.json";
|
|
89
89
|
function x(e = "") {
|
|
90
90
|
return f.join(K, e);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
return x(
|
|
92
|
+
function St() {
|
|
93
|
+
return x(Oa);
|
|
94
94
|
}
|
|
95
95
|
function Se() {
|
|
96
|
-
return x(
|
|
96
|
+
return x(Da);
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
98
|
+
function Nt() {
|
|
99
|
+
tt.spawnSync("git", ["config", "core.hooksPath", x()]), tt.spawnSync("git", ["config", "commit.template", Se()]);
|
|
100
100
|
}
|
|
101
101
|
function Ne(e = "") {
|
|
102
|
-
return f.resolve(
|
|
102
|
+
return f.resolve(la.homedir(), xa, e);
|
|
103
103
|
}
|
|
104
104
|
function xe() {
|
|
105
|
-
return Ne(
|
|
105
|
+
return Ne(Pa);
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
107
|
+
function Ma() {
|
|
108
|
+
return j(Ne());
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
return
|
|
110
|
+
function jt() {
|
|
111
|
+
return Ma() && j(xe());
|
|
112
112
|
}
|
|
113
113
|
function se(e, t = !0) {
|
|
114
114
|
let a = e.trim();
|
|
@@ -122,17 +122,17 @@ function se(e, t = !0) {
|
|
|
122
122
|
const s = a.replace(/\.git$/, "");
|
|
123
123
|
return t ? encodeURIComponent(s) : s;
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function Pe(e, t) {
|
|
126
126
|
return se(e) === se(t);
|
|
127
127
|
}
|
|
128
|
-
const { red:
|
|
129
|
-
function
|
|
128
|
+
const { red: nt, green: Ba, blue: Ar, magenta: za, yellow: _a } = A;
|
|
129
|
+
function Te(...e) {
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
console.log(
|
|
131
|
+
function J(...e) {
|
|
132
|
+
console.log(_a(...e));
|
|
133
133
|
}
|
|
134
134
|
function U(...e) {
|
|
135
|
-
console.log(
|
|
135
|
+
console.log(Ba(...e));
|
|
136
136
|
}
|
|
137
137
|
function Tt(e) {
|
|
138
138
|
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));
|
|
@@ -140,13 +140,13 @@ function Tt(e) {
|
|
|
140
140
|
function m(e, t = !1) {
|
|
141
141
|
Tt(e);
|
|
142
142
|
let a = e;
|
|
143
|
-
e instanceof Error ? (a = e.message, me.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(
|
|
143
|
+
e instanceof Error ? (a = e.message, me.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(nt(a)), console.log(za(e.stack))) : console.log(nt(e)), t || process.exit(1);
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
return
|
|
145
|
+
function it(e) {
|
|
146
|
+
return j(e) ? Qt(e).isDirectory() : !1;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
148
|
+
function kt(e = process.cwd()) {
|
|
149
|
+
return it(e) ? Xt(e).filter((a) => it(f.resolve(e, a))) : [];
|
|
150
150
|
}
|
|
151
151
|
async function p(e, t = {}) {
|
|
152
152
|
const a = {
|
|
@@ -167,26 +167,26 @@ async function p(e, t = {}) {
|
|
|
167
167
|
return n = n.toString(), a.removeTailLinkBreak && (n = n.replace(/\n$/, "")), n;
|
|
168
168
|
}
|
|
169
169
|
function Ve(e) {
|
|
170
|
-
|
|
170
|
+
Yt.execSync(e, {
|
|
171
171
|
stdio: "inherit"
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
return
|
|
174
|
+
function Et() {
|
|
175
|
+
return ca(Date.now()).format("YYMMDD");
|
|
176
176
|
}
|
|
177
177
|
function ee() {
|
|
178
|
-
|
|
178
|
+
j(x()) || m("当前不在项目根目录。请切换到项目根目录");
|
|
179
179
|
}
|
|
180
180
|
function H() {
|
|
181
|
-
|
|
181
|
+
j(f.resolve(".git")) || m("当前不是git项目根目录,请先执行git init,或切换到根目录");
|
|
182
182
|
}
|
|
183
183
|
async function ge() {
|
|
184
184
|
await p("git status -s") !== "" && m("请先提交代码变动,再进行操作");
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function Fa(e) {
|
|
187
187
|
return e === w.MASTER ? O.PROD : e;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function Ga(e) {
|
|
190
190
|
return e === O.PROD ? w.MASTER : e;
|
|
191
191
|
}
|
|
192
192
|
async function B(e, ...t) {
|
|
@@ -196,10 +196,10 @@ async function B(e, ...t) {
|
|
|
196
196
|
throw Tt(a), a;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
async function
|
|
200
|
-
return (await
|
|
199
|
+
async function Ja(e) {
|
|
200
|
+
return (await Ue(e)).length === 0;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function Ua(e = "项目中文名", t = "项目描述") {
|
|
203
203
|
return `
|
|
204
204
|
# ${e}
|
|
205
205
|
${t}
|
|
@@ -256,7 +256,7 @@ ${t}
|
|
|
256
256
|
在此处放入飞书文档链接。请在[前端团队-项目手册](https://hxhtbr8t8uy.feishu.cn/drive/folder/QfQ7favVWljQk7d63Prc8mUGnJf)中按照分类新建文档。
|
|
257
257
|
`;
|
|
258
258
|
}
|
|
259
|
-
const
|
|
259
|
+
const Va = {
|
|
260
260
|
[$.JAVA]: {
|
|
261
261
|
"**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml"
|
|
262
262
|
},
|
|
@@ -274,17 +274,17 @@ const Ga = {
|
|
|
274
274
|
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
275
275
|
"**/*.md": "markdownlint --fix"
|
|
276
276
|
}
|
|
277
|
-
},
|
|
278
|
-
name:
|
|
279
|
-
version:
|
|
280
|
-
description:
|
|
281
|
-
main:
|
|
282
|
-
bin:
|
|
283
|
-
scripts:
|
|
284
|
-
type:
|
|
285
|
-
author:
|
|
286
|
-
devDependencies:
|
|
287
|
-
dependencies:
|
|
277
|
+
}, Wa = "cli-z-develop", Ha = "0.16.2", qa = "技术团队开发流程管理工具", Za = "dist/index.js", Ka = { z: "bin/z.js", "z-develop": "bin/z.js" }, Ya = { 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" }, Xa = "module", Qa = "z", es = { "@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" }, ts = { "@inquirer/prompts": "^8.4.1", "@lonely9/api-generate": "^0.2.13", 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", open: "^11.0.2", ora: "^9.3.0", "p-limit": "^7.3.0", prettier: "^3.8.2", semver: "^7.7.4", shelljs: "^0.10.0" }, ce = {
|
|
278
|
+
name: Wa,
|
|
279
|
+
version: Ha,
|
|
280
|
+
description: qa,
|
|
281
|
+
main: Za,
|
|
282
|
+
bin: Ka,
|
|
283
|
+
scripts: Ya,
|
|
284
|
+
type: Xa,
|
|
285
|
+
author: Qa,
|
|
286
|
+
devDependencies: es,
|
|
287
|
+
dependencies: ts
|
|
288
288
|
}, M = {
|
|
289
289
|
// 个人数据
|
|
290
290
|
profile: {
|
|
@@ -333,23 +333,23 @@ function We() {
|
|
|
333
333
|
if (q)
|
|
334
334
|
return q;
|
|
335
335
|
const e = f.join("package.json");
|
|
336
|
-
return
|
|
336
|
+
return j(e) || m(`当前目录(${N.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), q = L.readJsonSync(e), q;
|
|
337
337
|
}
|
|
338
338
|
function V() {
|
|
339
339
|
if (Z)
|
|
340
340
|
return Z;
|
|
341
|
-
const e =
|
|
342
|
-
return
|
|
341
|
+
const e = St();
|
|
342
|
+
return j(e) || m(
|
|
343
343
|
`当前目录(${N.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
344
344
|
), Z = L.readJsonSync(e), Z;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function It(e) {
|
|
347
347
|
Z ? Z = {
|
|
348
348
|
...Z,
|
|
349
349
|
...e
|
|
350
|
-
} : Z = e, L.writeJSONSync(
|
|
350
|
+
} : Z = e, L.writeJSONSync(St(), Z, { spaces: 2 });
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function as(e) {
|
|
353
353
|
q ? q = {
|
|
354
354
|
...q,
|
|
355
355
|
...e
|
|
@@ -362,10 +362,10 @@ const ae = {
|
|
|
362
362
|
sourceBranch: "",
|
|
363
363
|
mergeRequestUrl: ""
|
|
364
364
|
};
|
|
365
|
-
async function
|
|
365
|
+
async function ss() {
|
|
366
366
|
if (!ae.id)
|
|
367
367
|
try {
|
|
368
|
-
const e = V(), t = se(e.repository.url), a = await
|
|
368
|
+
const e = V(), t = se(e.repository.url), a = await Lt(t);
|
|
369
369
|
ae.id = a.id, ae.path = t, ae.group = a.namespace.full_path, ae.mergeRequestUrl = `${a.web_url}/merge_requests`;
|
|
370
370
|
} catch (e) {
|
|
371
371
|
m(e);
|
|
@@ -391,7 +391,7 @@ function E(e, t) {
|
|
|
391
391
|
...e
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function De(e, t) {
|
|
395
395
|
M.constants = {
|
|
396
396
|
...M.constants,
|
|
397
397
|
...e
|
|
@@ -415,7 +415,7 @@ async function b(e) {
|
|
|
415
415
|
});
|
|
416
416
|
return t.code !== 0 && (m(`${t.code}: ${t.message}`, e.stopBubble), e.stopBubble) ? Promise.reject(t) : t.data;
|
|
417
417
|
}
|
|
418
|
-
async function
|
|
418
|
+
async function ns(e) {
|
|
419
419
|
return await ne({
|
|
420
420
|
url: "https://pai.zxfqf.com/api" + e.url,
|
|
421
421
|
headers: {
|
|
@@ -426,17 +426,17 @@ async function as(e) {
|
|
|
426
426
|
method: e.method || "post"
|
|
427
427
|
});
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function is() {
|
|
430
430
|
return b({
|
|
431
431
|
url: "/user/list2"
|
|
432
432
|
});
|
|
433
433
|
}
|
|
434
|
-
function
|
|
434
|
+
function rs() {
|
|
435
435
|
return b({
|
|
436
436
|
url: "/zen/testcase/product/list"
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
|
-
function
|
|
439
|
+
function Rt(e) {
|
|
440
440
|
return b({
|
|
441
441
|
url: "/zen/testcase/product/module/list",
|
|
442
442
|
data: {
|
|
@@ -444,7 +444,7 @@ function It(e) {
|
|
|
444
444
|
}
|
|
445
445
|
});
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function os(e) {
|
|
448
448
|
return b({
|
|
449
449
|
url: "/zen/testcase/product/name",
|
|
450
450
|
data: {
|
|
@@ -452,7 +452,7 @@ function is(e) {
|
|
|
452
452
|
}
|
|
453
453
|
});
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function cs(e, t) {
|
|
456
456
|
return b({
|
|
457
457
|
url: "/zen/testcase/product/auto-case/list",
|
|
458
458
|
data: {
|
|
@@ -461,7 +461,7 @@ function rs(e, t) {
|
|
|
461
461
|
}
|
|
462
462
|
});
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function ls(e) {
|
|
465
465
|
return b({
|
|
466
466
|
url: "/zen/testcase/step/list",
|
|
467
467
|
data: {
|
|
@@ -469,72 +469,72 @@ function os(e) {
|
|
|
469
469
|
}
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
|
-
function
|
|
472
|
+
function us(e) {
|
|
473
473
|
return b({
|
|
474
474
|
url: "/zen/testcase/module/create",
|
|
475
475
|
data: e
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function ps(e) {
|
|
479
479
|
return b({
|
|
480
480
|
url: "/zen/testcase/create",
|
|
481
481
|
data: e
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
|
-
function
|
|
484
|
+
function ms(e) {
|
|
485
485
|
return b({
|
|
486
486
|
url: "/zen/testcase/step/create",
|
|
487
487
|
data: e
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
|
-
function
|
|
490
|
+
function ds(e) {
|
|
491
491
|
return b({
|
|
492
492
|
url: "/zen/testcase/modules/remove",
|
|
493
493
|
data: e
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
|
-
function
|
|
496
|
+
function fs(e) {
|
|
497
497
|
return b({
|
|
498
498
|
url: "/zen/testcase/cases/remove",
|
|
499
499
|
data: e
|
|
500
500
|
});
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function gs(e) {
|
|
503
503
|
return b({
|
|
504
504
|
url: "/zen/testcase/module/update/name",
|
|
505
505
|
data: e
|
|
506
506
|
});
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function hs(e) {
|
|
509
509
|
return b({
|
|
510
510
|
url: "/zen/testcase/case/update/name",
|
|
511
511
|
data: e
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
|
-
function
|
|
514
|
+
function ws(e) {
|
|
515
515
|
return b({
|
|
516
516
|
url: "/zen/testcase/case/update/priority",
|
|
517
517
|
data: e
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
|
-
function
|
|
520
|
+
function ys(e) {
|
|
521
521
|
return b({
|
|
522
522
|
url: "/zen/testcase/case/update/precondition",
|
|
523
523
|
data: e
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
|
-
function
|
|
526
|
+
function $s(e) {
|
|
527
527
|
return b({
|
|
528
528
|
url: "/zen/testcase/case/result/create",
|
|
529
529
|
data: e
|
|
530
530
|
});
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function vs() {
|
|
533
533
|
return b({
|
|
534
534
|
url: "/zen/testcase/project/list"
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function As(e) {
|
|
538
538
|
return b({
|
|
539
539
|
url: "/zen/testcase/project/execution/list",
|
|
540
540
|
data: {
|
|
@@ -542,7 +542,7 @@ function $s(e) {
|
|
|
542
542
|
}
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function bs(e) {
|
|
546
546
|
return b({
|
|
547
547
|
url: "/zen/testcase/execution/build/list",
|
|
548
548
|
data: {
|
|
@@ -550,25 +550,25 @@ function vs(e) {
|
|
|
550
550
|
}
|
|
551
551
|
});
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function rt(e) {
|
|
554
554
|
return b({
|
|
555
555
|
url: "/common/ai/talk",
|
|
556
556
|
data: e
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
|
-
function
|
|
560
|
-
return
|
|
559
|
+
function Ss(e) {
|
|
560
|
+
return ns({
|
|
561
561
|
url: "/common/notify/group/send",
|
|
562
562
|
data: e
|
|
563
563
|
});
|
|
564
564
|
}
|
|
565
|
-
function
|
|
565
|
+
function Ns(e) {
|
|
566
566
|
return b({
|
|
567
567
|
url: "/deploy/create/chain",
|
|
568
568
|
data: e
|
|
569
569
|
});
|
|
570
570
|
}
|
|
571
|
-
function
|
|
571
|
+
function js(e) {
|
|
572
572
|
return b({
|
|
573
573
|
url: "/zen/product/execution/list",
|
|
574
574
|
data: {
|
|
@@ -576,18 +576,18 @@ function Ss(e) {
|
|
|
576
576
|
}
|
|
577
577
|
});
|
|
578
578
|
}
|
|
579
|
-
function
|
|
579
|
+
function Ts(e) {
|
|
580
580
|
return b({
|
|
581
581
|
url: "/zen/execution/build/createOrUpdate",
|
|
582
582
|
data: e
|
|
583
583
|
});
|
|
584
584
|
}
|
|
585
|
-
function
|
|
585
|
+
function ks() {
|
|
586
586
|
return b({
|
|
587
587
|
url: "/auth/gitlab/oauth/authorize"
|
|
588
588
|
});
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function Es(e) {
|
|
591
591
|
return b({
|
|
592
592
|
url: "/auth/gitlab/oauth/token",
|
|
593
593
|
data: {
|
|
@@ -596,7 +596,7 @@ function js(e) {
|
|
|
596
596
|
stopBubble: !0
|
|
597
597
|
});
|
|
598
598
|
}
|
|
599
|
-
function
|
|
599
|
+
function Is(e) {
|
|
600
600
|
return b({
|
|
601
601
|
url: "/auth/gitlab/oauth/token/refresh",
|
|
602
602
|
data: {
|
|
@@ -605,7 +605,7 @@ function ks(e) {
|
|
|
605
605
|
stopBubble: !0
|
|
606
606
|
});
|
|
607
607
|
}
|
|
608
|
-
class
|
|
608
|
+
class Rs {
|
|
609
609
|
/**
|
|
610
610
|
* 生成带 Bearer 前缀的 Token
|
|
611
611
|
*/
|
|
@@ -626,22 +626,22 @@ class Es {
|
|
|
626
626
|
* @private
|
|
627
627
|
*/
|
|
628
628
|
async refreshAccessToken(t) {
|
|
629
|
-
const a = await
|
|
629
|
+
const a = await Is(t);
|
|
630
630
|
return this.saveToken(a), this.generateBearerToken(a.access_token, a.token_type);
|
|
631
631
|
}
|
|
632
632
|
/**
|
|
633
633
|
* 执行完整的 OAuth 授权流程
|
|
634
634
|
*/
|
|
635
635
|
async auth() {
|
|
636
|
-
const t = await
|
|
636
|
+
const t = await ks(), a = `${Ae}/oauth/authorize?${new URLSearchParams({
|
|
637
637
|
...t
|
|
638
638
|
})}`;
|
|
639
639
|
return console.log(A.cyan("正在打开浏览器进行 GitLab 授权,如果浏览器未自动打开,请访问: ")), console.log(A.blue(a)), new Promise((n) => {
|
|
640
|
-
|
|
640
|
+
Es(t.state).then((s) => {
|
|
641
641
|
s ? (console.log(A.green("✅ GitLab 授权成功!")), this.saveToken(s), n(this.generateBearerToken(s.access_token, s.token_type))) : m("❌ GitLab 授权失败!");
|
|
642
642
|
}).catch((s) => {
|
|
643
643
|
m(`❌ GitLab 授权失败:${s.message}`);
|
|
644
|
-
}),
|
|
644
|
+
}), ma(a);
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
647
|
/**
|
|
@@ -665,7 +665,7 @@ class Es {
|
|
|
665
665
|
return await this.auth();
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
const
|
|
668
|
+
const ot = new Rs();
|
|
669
669
|
async function ne(e) {
|
|
670
670
|
const t = e.method || "get", a = e.headers || {}, n = e.data || {}, s = e.dataKey ?? (["GET", "get"].includes(t) ? "params" : "data");
|
|
671
671
|
try {
|
|
@@ -676,11 +676,11 @@ async function ne(e) {
|
|
|
676
676
|
headers: a,
|
|
677
677
|
responseType: e?.responseType || "json"
|
|
678
678
|
};
|
|
679
|
-
|
|
679
|
+
Te(A.magenta(i.method.toUpperCase()), A.yellow(i.url), JSON.stringify(i.headers)), Te(A.gray(JSON.stringify(i[s], null, 2)));
|
|
680
680
|
const o = await me(i);
|
|
681
|
-
return
|
|
681
|
+
return Te(A.green("Response"), A.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
|
|
682
682
|
} catch (i) {
|
|
683
|
-
return i instanceof
|
|
683
|
+
return i instanceof gt && Te(A.red("Error"), A.grey(JSON.stringify(i?.response?.data))), Promise.reject(i);
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
686
|
async function S(e) {
|
|
@@ -688,21 +688,21 @@ async function S(e) {
|
|
|
688
688
|
return await ne({
|
|
689
689
|
...e,
|
|
690
690
|
headers: {
|
|
691
|
-
Authorization: await
|
|
691
|
+
Authorization: await ot.getToken()
|
|
692
692
|
}
|
|
693
693
|
});
|
|
694
694
|
} catch (t) {
|
|
695
|
-
if (t instanceof
|
|
695
|
+
if (t instanceof gt && t.response?.status === 401)
|
|
696
696
|
return console.log(A.yellow("⚠️ GitLab Token 已失效,正在重新授权...")), E("gitToken", ""), E("gitLabRefreshToken", ""), E("gitTokenExpiry", ""), X(), ne({
|
|
697
697
|
...e,
|
|
698
698
|
headers: {
|
|
699
|
-
Authorization: await
|
|
699
|
+
Authorization: await ot.getToken()
|
|
700
700
|
}
|
|
701
701
|
});
|
|
702
702
|
throw t;
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
async function
|
|
705
|
+
async function Cs() {
|
|
706
706
|
const e = I("zenTaoToken");
|
|
707
707
|
if (e)
|
|
708
708
|
return e;
|
|
@@ -722,7 +722,7 @@ async function Ce(e) {
|
|
|
722
722
|
const t = await ne({
|
|
723
723
|
...e,
|
|
724
724
|
headers: {
|
|
725
|
-
Token: await
|
|
725
|
+
Token: await Cs()
|
|
726
726
|
}
|
|
727
727
|
});
|
|
728
728
|
if (e.url.includes("local")) {
|
|
@@ -745,7 +745,7 @@ async function Ce(e) {
|
|
|
745
745
|
return {};
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
|
-
async function
|
|
748
|
+
async function Ls() {
|
|
749
749
|
const e = I("k8sToken");
|
|
750
750
|
if (e)
|
|
751
751
|
return e;
|
|
@@ -764,9 +764,9 @@ async function Rs() {
|
|
|
764
764
|
return E("k8sToken", a), X(), a;
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
|
-
async function
|
|
767
|
+
async function xs(e, t) {
|
|
768
768
|
try {
|
|
769
|
-
const a =
|
|
769
|
+
const a = ea(t, { mode: 493 });
|
|
770
770
|
return (await me({
|
|
771
771
|
method: "get",
|
|
772
772
|
url: e,
|
|
@@ -781,18 +781,18 @@ async function Cs(e, t) {
|
|
|
781
781
|
throw console.error("下载失败:", a), a;
|
|
782
782
|
}
|
|
783
783
|
}
|
|
784
|
-
const
|
|
785
|
-
function
|
|
784
|
+
const G = () => `${Ae}/api/v4`, z = (e) => `${G()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
|
|
785
|
+
function Ps() {
|
|
786
786
|
return S({
|
|
787
787
|
url: z("src/data/template-projects.json")
|
|
788
788
|
});
|
|
789
789
|
}
|
|
790
|
-
function
|
|
790
|
+
function Ds() {
|
|
791
791
|
return S({
|
|
792
792
|
url: z("src/data/java-project-module.json")
|
|
793
793
|
});
|
|
794
794
|
}
|
|
795
|
-
function
|
|
795
|
+
function Os() {
|
|
796
796
|
return S({
|
|
797
797
|
url: z("src/data/java-project-api.json")
|
|
798
798
|
});
|
|
@@ -802,126 +802,126 @@ function He() {
|
|
|
802
802
|
url: z("src/data/z-develop-config.json")
|
|
803
803
|
});
|
|
804
804
|
}
|
|
805
|
-
function
|
|
805
|
+
function Ms() {
|
|
806
806
|
return S({
|
|
807
807
|
url: z("src/assets/tsconfig.browser.json")
|
|
808
808
|
});
|
|
809
809
|
}
|
|
810
|
-
function
|
|
810
|
+
function Bs() {
|
|
811
811
|
return S({
|
|
812
812
|
url: z("src/assets/tsconfig.node.json")
|
|
813
813
|
});
|
|
814
814
|
}
|
|
815
|
-
function
|
|
815
|
+
function zs() {
|
|
816
816
|
return S({
|
|
817
817
|
url: z("src/assets/.prettierignore")
|
|
818
818
|
});
|
|
819
819
|
}
|
|
820
|
-
function
|
|
820
|
+
function _s() {
|
|
821
821
|
return S({
|
|
822
822
|
url: z("src/assets/.prettierrc.json")
|
|
823
823
|
});
|
|
824
824
|
}
|
|
825
|
-
function
|
|
825
|
+
function Fs() {
|
|
826
826
|
return S({
|
|
827
827
|
url: z("src/assets/data.yaml")
|
|
828
828
|
});
|
|
829
829
|
}
|
|
830
|
-
function
|
|
830
|
+
function Gs() {
|
|
831
831
|
return S({
|
|
832
832
|
url: z("src/assets/main.py")
|
|
833
833
|
});
|
|
834
834
|
}
|
|
835
|
-
function
|
|
835
|
+
function Js() {
|
|
836
836
|
return S({
|
|
837
837
|
url: z("src/assets/checkstyle.xml")
|
|
838
838
|
});
|
|
839
839
|
}
|
|
840
|
-
function
|
|
840
|
+
function Ct() {
|
|
841
841
|
return S({
|
|
842
842
|
url: z("src/data/project-group-chats.json")
|
|
843
843
|
});
|
|
844
844
|
}
|
|
845
|
-
function
|
|
845
|
+
function Us() {
|
|
846
846
|
return S({
|
|
847
847
|
url: z("src/data/project-zen-tao-id.json")
|
|
848
848
|
});
|
|
849
849
|
}
|
|
850
|
-
function
|
|
850
|
+
function Vs() {
|
|
851
851
|
return S({
|
|
852
|
-
url: `${
|
|
852
|
+
url: `${G()}/user`
|
|
853
853
|
});
|
|
854
854
|
}
|
|
855
|
-
function
|
|
855
|
+
function Ws() {
|
|
856
856
|
return S({
|
|
857
|
-
url: `${
|
|
857
|
+
url: `${G()}/groups`
|
|
858
858
|
});
|
|
859
859
|
}
|
|
860
|
-
function
|
|
860
|
+
function Hs(e) {
|
|
861
861
|
return S({
|
|
862
|
-
url: `${
|
|
862
|
+
url: `${G()}/projects`,
|
|
863
863
|
method: "post",
|
|
864
864
|
data: e
|
|
865
865
|
});
|
|
866
866
|
}
|
|
867
|
-
function
|
|
867
|
+
function Lt(e) {
|
|
868
868
|
return S({
|
|
869
|
-
url: `${
|
|
869
|
+
url: `${G()}/projects/${e}`
|
|
870
870
|
});
|
|
871
871
|
}
|
|
872
|
-
function
|
|
872
|
+
function qs(e) {
|
|
873
873
|
return S({
|
|
874
|
-
url: `${
|
|
874
|
+
url: `${G()}/projects`,
|
|
875
875
|
data: {
|
|
876
876
|
search: e,
|
|
877
877
|
search_namespaces: !0
|
|
878
878
|
}
|
|
879
879
|
});
|
|
880
880
|
}
|
|
881
|
-
function
|
|
881
|
+
function Zs(e) {
|
|
882
882
|
return S({
|
|
883
|
-
url: `${
|
|
883
|
+
url: `${G()}/projects/${e.id}/merge_requests`,
|
|
884
884
|
method: "post",
|
|
885
885
|
data: e
|
|
886
886
|
});
|
|
887
887
|
}
|
|
888
|
-
function
|
|
888
|
+
function Ks(e) {
|
|
889
889
|
return S({
|
|
890
|
-
url: `${
|
|
890
|
+
url: `${G()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
891
891
|
method: "put"
|
|
892
892
|
});
|
|
893
893
|
}
|
|
894
|
-
function
|
|
894
|
+
function Ys(e) {
|
|
895
895
|
return S({
|
|
896
|
-
url: `${
|
|
896
|
+
url: `${G()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
897
897
|
method: "put",
|
|
898
898
|
data: e
|
|
899
899
|
});
|
|
900
900
|
}
|
|
901
|
-
function
|
|
901
|
+
function Xs(e) {
|
|
902
902
|
return S({
|
|
903
|
-
url: `${
|
|
903
|
+
url: `${G()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
904
904
|
method: "get"
|
|
905
905
|
});
|
|
906
906
|
}
|
|
907
|
-
function
|
|
907
|
+
function Qs(e) {
|
|
908
908
|
return S({
|
|
909
|
-
url: `${
|
|
909
|
+
url: `${G()}/projects/${e.id}/repository/branches`,
|
|
910
910
|
method: "post",
|
|
911
911
|
data: e
|
|
912
912
|
});
|
|
913
913
|
}
|
|
914
|
-
function
|
|
914
|
+
function en(e) {
|
|
915
915
|
return S({
|
|
916
|
-
url: `${
|
|
916
|
+
url: `${G()}/projects/${e}/repository/branches`
|
|
917
917
|
});
|
|
918
918
|
}
|
|
919
|
-
function
|
|
919
|
+
function tn() {
|
|
920
920
|
const e = Ne("fe-groups.json");
|
|
921
|
-
return
|
|
921
|
+
return j(e) ? L.readJSONSync(e) : { groups: [] };
|
|
922
922
|
}
|
|
923
|
-
async function
|
|
924
|
-
const e = await
|
|
923
|
+
async function an() {
|
|
924
|
+
const e = await Ws(), t = Ia.map((a) => {
|
|
925
925
|
const n = e.find((s) => s.name === a);
|
|
926
926
|
return n ? {
|
|
927
927
|
name: n.name,
|
|
@@ -931,7 +931,7 @@ async function en() {
|
|
|
931
931
|
}).filter((a) => !!a);
|
|
932
932
|
L.writeJSONSync(Ne("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
933
933
|
}
|
|
934
|
-
function
|
|
934
|
+
function sn(e, t) {
|
|
935
935
|
const a = [];
|
|
936
936
|
t.forEach((i) => {
|
|
937
937
|
e.includes(i.value) && a.push(i);
|
|
@@ -947,9 +947,9 @@ function tn(e, t) {
|
|
|
947
947
|
weWorkListCache: n.sort((i, o) => o.usageCount - i.usageCount)
|
|
948
948
|
}), X();
|
|
949
949
|
}
|
|
950
|
-
async function
|
|
951
|
-
const t = (await
|
|
952
|
-
name: `${i.nick} - ${
|
|
950
|
+
async function xt() {
|
|
951
|
+
const t = (await is()).filter((i) => [1, 2, 3, 4, 5].includes(i.title)).map((i) => ({
|
|
952
|
+
name: `${i.nick} - ${Ea[i.title]}`,
|
|
953
953
|
value: i.weWorkUserId
|
|
954
954
|
})), a = be("weWorkListCache"), n = a.map((i) => i.value), s = [];
|
|
955
955
|
return t.forEach((i) => {
|
|
@@ -960,8 +960,8 @@ async function Lt() {
|
|
|
960
960
|
});
|
|
961
961
|
}), s.sort((i, o) => o.usageCount - i.usageCount);
|
|
962
962
|
}
|
|
963
|
-
async function
|
|
964
|
-
const n = await
|
|
963
|
+
async function Pt(e, t, a) {
|
|
964
|
+
const n = await xt();
|
|
965
965
|
let s = await W({
|
|
966
966
|
message: e,
|
|
967
967
|
loop: !0,
|
|
@@ -971,10 +971,10 @@ async function xt(e, t, a) {
|
|
|
971
971
|
options: (i) => i ? n.filter((o) => o.name.includes(i)) : n,
|
|
972
972
|
validate: t
|
|
973
973
|
});
|
|
974
|
-
return s = Array.isArray(s) ? s : [s],
|
|
974
|
+
return s = Array.isArray(s) ? s : [s], sn(s, n), s;
|
|
975
975
|
}
|
|
976
|
-
async function
|
|
977
|
-
const { groups: n } = await
|
|
976
|
+
async function nn(e, t, a) {
|
|
977
|
+
const { groups: n } = await Ct(), s = n.map((o) => ({
|
|
978
978
|
name: o.name,
|
|
979
979
|
value: o.url
|
|
980
980
|
}));
|
|
@@ -989,9 +989,9 @@ async function an(e, t, a) {
|
|
|
989
989
|
});
|
|
990
990
|
return i = Array.isArray(i) ? i : [i], i;
|
|
991
991
|
}
|
|
992
|
-
async function
|
|
992
|
+
async function rn() {
|
|
993
993
|
try {
|
|
994
|
-
|
|
994
|
+
jt() && (await Le({
|
|
995
995
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
996
996
|
}) ? N.rm("-rf", xe()) : process.exit(0)), await fe(Ne(), { recursive: !0 });
|
|
997
997
|
const t = await k({
|
|
@@ -1015,14 +1015,14 @@ async function sn() {
|
|
|
1015
1015
|
message: "请输入LDAP账号:"
|
|
1016
1016
|
});
|
|
1017
1017
|
a = a.trim();
|
|
1018
|
-
let n = await
|
|
1018
|
+
let n = await pa({
|
|
1019
1019
|
message: "请输入LDAP密码:",
|
|
1020
1020
|
mask: !0
|
|
1021
1021
|
});
|
|
1022
1022
|
n = n.trim(), E("jobType", t), E("ldapAccount", a), E("ldapPassword", n);
|
|
1023
1023
|
const s = await He();
|
|
1024
|
-
|
|
1025
|
-
const i = await
|
|
1024
|
+
De(s);
|
|
1025
|
+
const i = await xt(), o = await Pt("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = i.find((u) => u.value === o[0]);
|
|
1026
1026
|
E({
|
|
1027
1027
|
weWorkName: r,
|
|
1028
1028
|
weWorkUserId: c
|
|
@@ -1032,13 +1032,13 @@ async function sn() {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
const e = y("配置信息初始化中").start();
|
|
1034
1034
|
try {
|
|
1035
|
-
const t = await
|
|
1035
|
+
const t = await Vs();
|
|
1036
1036
|
E({
|
|
1037
1037
|
gitUserId: t.id,
|
|
1038
1038
|
gitName: t.name,
|
|
1039
1039
|
gitEnglishName: t.username,
|
|
1040
1040
|
gitEmail: t.email
|
|
1041
|
-
}), de("latestCheckVersionTimestamp", Date.now()), X(), I("jobType") === ue.FRONT_END && await
|
|
1041
|
+
}), de("latestCheckVersionTimestamp", Date.now()), X(), I("jobType") === ue.FRONT_END && await an(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
1042
1042
|
} catch (t) {
|
|
1043
1043
|
e.fail("配置信息初始化失败"), me.isAxiosError(t) && m("请检查你的域名及令牌配置"), m(t);
|
|
1044
1044
|
}
|
|
@@ -1053,30 +1053,30 @@ const ke = (e, t, a) => {
|
|
|
1053
1053
|
ve(x(e), n, {
|
|
1054
1054
|
mode: 493
|
|
1055
1055
|
});
|
|
1056
|
-
},
|
|
1056
|
+
}, on = () => {
|
|
1057
1057
|
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");
|
|
1058
1058
|
};
|
|
1059
|
-
async function
|
|
1059
|
+
async function cn() {
|
|
1060
1060
|
await _(Se(), "", { mode: 493 }), await _(x(".gitignore"), `.commit-msg-tpl
|
|
1061
|
-
`, { mode: 493 }),
|
|
1061
|
+
`, { mode: 493 }), on();
|
|
1062
1062
|
const { language: e } = V();
|
|
1063
1063
|
if ([$.JAVASCRIPT, $.MARKDOWN].includes(e) && (await _(
|
|
1064
1064
|
x(".prettierrc.json"),
|
|
1065
|
-
`${JSON.stringify(await
|
|
1065
|
+
`${JSON.stringify(await _s(), null, 2)}
|
|
1066
1066
|
`,
|
|
1067
1067
|
{
|
|
1068
1068
|
mode: 493
|
|
1069
1069
|
}
|
|
1070
|
-
), await _(x(".prettierignore"), await
|
|
1071
|
-
await
|
|
1070
|
+
), await _(x(".prettierignore"), await zs(), { mode: 493 }), await _(x("tsconfig.node.json"), await Bs(), { mode: 493 }), await _(x("tsconfig.browser.json"), await Ms(), { mode: 493 })), e === $.JAVA) {
|
|
1071
|
+
await xs(`${re("FECDNDomain")}/file/vgnlfbfHRF.jar`, x("checkstyle.jar")), await _(x("checkstyle.xml"), await Js(), { mode: 493 });
|
|
1072
1072
|
const t = f.join("package.json");
|
|
1073
|
-
|
|
1073
|
+
j(t) || await _(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
|
|
1074
1074
|
mode: 493
|
|
1075
1075
|
});
|
|
1076
1076
|
}
|
|
1077
|
-
|
|
1077
|
+
Nt(), await p(`git add ${K}`);
|
|
1078
1078
|
}
|
|
1079
|
-
async function
|
|
1079
|
+
async function ln(e, t) {
|
|
1080
1080
|
const a = await p("git remote get-url --push origin");
|
|
1081
1081
|
a || m("获取项目远程git地址失败,请配置后重试");
|
|
1082
1082
|
let n = e;
|
|
@@ -1103,7 +1103,7 @@ async function on(e, t) {
|
|
|
1103
1103
|
}));
|
|
1104
1104
|
let s = t;
|
|
1105
1105
|
if (!s) {
|
|
1106
|
-
const o = se(a), r = await
|
|
1106
|
+
const o = se(a), r = await Lt(o);
|
|
1107
1107
|
if (!r)
|
|
1108
1108
|
return m(`未找到项目,请确认项目${a}是否存在,或者当前账号权限`);
|
|
1109
1109
|
s = r.namespace.full_path;
|
|
@@ -1117,11 +1117,11 @@ async function on(e, t) {
|
|
|
1117
1117
|
message: `⚠️警告:请再次确认本项目允许直接推送代码到环境分支!!这意味着本项目可以在环境分支上进行开发,这一般用于与部署环境无关、或者单一部署环境的项目。
|
|
1118
1118
|
请输入【是/yes/y/Y】以确认;输入其他或者不输入则表示不允许直接推送:`
|
|
1119
1119
|
});
|
|
1120
|
-
i = ["是", "yes", "y", "Y"].includes(o), i ||
|
|
1120
|
+
i = ["是", "yes", "y", "Y"].includes(o), i || J("✅ 已修改为不允许直接推送代码到分支环境");
|
|
1121
1121
|
}
|
|
1122
|
-
|
|
1122
|
+
It({
|
|
1123
1123
|
language: n,
|
|
1124
|
-
"lint-staged":
|
|
1124
|
+
"lint-staged": Va[n],
|
|
1125
1125
|
repository: {
|
|
1126
1126
|
url: a,
|
|
1127
1127
|
group: s
|
|
@@ -1130,36 +1130,36 @@ async function on(e, t) {
|
|
|
1130
1130
|
});
|
|
1131
1131
|
}
|
|
1132
1132
|
async function qe(e, t) {
|
|
1133
|
-
e ? N.rm("-rf", K) :
|
|
1133
|
+
e ? N.rm("-rf", K) : j(x()) && (await Le({
|
|
1134
1134
|
message: `当前项目中已存在配置文件夹${K},确认重新配置?`
|
|
1135
|
-
}) ? N.rm("-rf", K) : process.exit(0)), await fe(x(), { recursive: !0 }), await
|
|
1135
|
+
}) ? N.rm("-rf", K) : process.exit(0)), await fe(x(), { recursive: !0 }), await ln(e, t);
|
|
1136
1136
|
const a = y("项目初始化中...").start();
|
|
1137
|
-
await
|
|
1137
|
+
await cn(), a.succeed("项目初始化完成");
|
|
1138
1138
|
}
|
|
1139
|
-
async function
|
|
1140
|
-
|
|
1139
|
+
async function un() {
|
|
1140
|
+
j(x()) && j(Se()) ? Nt() : await qe(), process.exit(0);
|
|
1141
1141
|
}
|
|
1142
|
-
async function
|
|
1143
|
-
t.projectLanguage && !Object.values($).includes(t.projectLanguage) && m("项目语言不支持"), e ? (H(), e === "." ? (await qe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await
|
|
1142
|
+
async function pn(e, t) {
|
|
1143
|
+
t.projectLanguage && !Object.values($).includes(t.projectLanguage) && m("项目语言不支持"), e ? (H(), e === "." ? (await qe(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await un() : m("参数错误。执行 z init -h 查看帮助。")) : await rn();
|
|
1144
1144
|
}
|
|
1145
|
-
P.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values($).join("/")} `).action((...e) => B(
|
|
1146
|
-
async function
|
|
1145
|
+
P.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values($).join("/")} `).action((...e) => B(pn, ...e));
|
|
1146
|
+
async function mn(e, t) {
|
|
1147
1147
|
if (!e)
|
|
1148
1148
|
return "不能为空";
|
|
1149
1149
|
if (!/^[a-z0-9-]+$/.test(e))
|
|
1150
1150
|
return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
|
|
1151
|
-
if (
|
|
1151
|
+
if (kt().includes(e))
|
|
1152
1152
|
return "当前目录下已存在同名文件夹,请先处理。";
|
|
1153
|
-
const s = (await
|
|
1153
|
+
const s = (await qs(e)).find((i) => i.path_with_namespace === `${t}/${e}`);
|
|
1154
1154
|
return s ? `远程仓库中已存在同名项目(${s.http_url_to_repo}),请更名后重试` : !0;
|
|
1155
1155
|
}
|
|
1156
|
-
function
|
|
1156
|
+
function dn(e) {
|
|
1157
1157
|
return e ? !0 : "不能为空";
|
|
1158
1158
|
}
|
|
1159
|
-
function
|
|
1159
|
+
function fn(e) {
|
|
1160
1160
|
return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
|
|
1161
1161
|
}
|
|
1162
|
-
async function
|
|
1162
|
+
async function gn(e) {
|
|
1163
1163
|
ee(), H(), await ge();
|
|
1164
1164
|
let t, a;
|
|
1165
1165
|
e.branchType ? t = e.branchType : t = await k({
|
|
@@ -1180,15 +1180,15 @@ async function dn(e) {
|
|
|
1180
1180
|
]
|
|
1181
1181
|
}), e.branchPurpose ? a = e.branchPurpose : (a = await F({
|
|
1182
1182
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1183
|
-
validate:
|
|
1183
|
+
validate: fn
|
|
1184
1184
|
}), a = a.trim());
|
|
1185
|
-
const n = `${t}_${a}_${
|
|
1185
|
+
const n = `${t}_${a}_${Et()}`;
|
|
1186
1186
|
await p(`git fetch origin ${w.MASTER}`), await p(`git checkout -b ${n} origin/${w.MASTER}`), await p(`git push -u origin ${n}`), process.exit(0);
|
|
1187
1187
|
}
|
|
1188
|
-
const
|
|
1189
|
-
async function
|
|
1188
|
+
const Dt = (e) => `${re("ZenTaoDomain")}${e}`;
|
|
1189
|
+
async function hn() {
|
|
1190
1190
|
const e = await Ce({
|
|
1191
|
-
url:
|
|
1191
|
+
url: Dt("/my-work-task.json?tid=mrrferp8"),
|
|
1192
1192
|
method: "get"
|
|
1193
1193
|
});
|
|
1194
1194
|
return e?.tasks ? e.tasks.filter((t) => t.status !== "done").map(({ id: t, name: a }) => ({
|
|
@@ -1199,9 +1199,9 @@ async function fn() {
|
|
|
1199
1199
|
name: a
|
|
1200
1200
|
})) : [];
|
|
1201
1201
|
}
|
|
1202
|
-
async function
|
|
1202
|
+
async function wn() {
|
|
1203
1203
|
const e = await Ce({
|
|
1204
|
-
url:
|
|
1204
|
+
url: Dt("/my-work-bug.json?tid=mrrferp8"),
|
|
1205
1205
|
method: "get"
|
|
1206
1206
|
});
|
|
1207
1207
|
return e?.bugs ? Object.values(e.bugs).map(({ id: t, title: a }) => ({
|
|
@@ -1212,16 +1212,16 @@ async function gn() {
|
|
|
1212
1212
|
}
|
|
1213
1213
|
})) : [];
|
|
1214
1214
|
}
|
|
1215
|
-
const
|
|
1215
|
+
const Ge = async () => (await F({
|
|
1216
1216
|
message: "请输入commit msg:",
|
|
1217
1217
|
validate: (t) => t.length === 0 ? "请输入commit msg" : !0
|
|
1218
1218
|
})).trim();
|
|
1219
|
-
async function
|
|
1219
|
+
async function ct(e, t) {
|
|
1220
1220
|
const a = await p("git diff HEAD", {
|
|
1221
1221
|
removeTailLinkBreak: !1
|
|
1222
1222
|
});
|
|
1223
|
-
if (a || m("git暂存区没有内容,请先git add添加文件到暂存区"), Buffer.byteLength(a, "utf-8") <
|
|
1224
|
-
const u = await
|
|
1223
|
+
if (a || m("git暂存区没有内容,请先git add添加文件到暂存区"), Buffer.byteLength(a, "utf-8") < st) {
|
|
1224
|
+
const u = await rt({
|
|
1225
1225
|
type: "commit-message-v2",
|
|
1226
1226
|
input: a
|
|
1227
1227
|
// modelName: "qwen-turbo",
|
|
@@ -1238,58 +1238,58 @@ async function ot(e, t) {
|
|
|
1238
1238
|
const l = u.replace(/(["\\$`])/g, "\\$1"), d = await p(`git diff HEAD -- "${l}"`, {
|
|
1239
1239
|
removeTailLinkBreak: !1
|
|
1240
1240
|
});
|
|
1241
|
-
d && Buffer.byteLength(d, "utf-8") <
|
|
1241
|
+
d && Buffer.byteLength(d, "utf-8") < La && (i.push(u), o.push(d));
|
|
1242
1242
|
} catch {
|
|
1243
1243
|
}
|
|
1244
1244
|
const r = o.join(`
|
|
1245
1245
|
`);
|
|
1246
|
-
if (i.length === 0 || Buffer.byteLength(r, "utf-8") >
|
|
1247
|
-
return
|
|
1246
|
+
if (i.length === 0 || Buffer.byteLength(r, "utf-8") > st)
|
|
1247
|
+
return J("变更内容太大,无法自动生成commit msg"), t.stop(), await Ge();
|
|
1248
1248
|
if (!r)
|
|
1249
|
-
return
|
|
1250
|
-
const c = await
|
|
1249
|
+
return J("无法获取文件差异信息"), t.stop(), await Ge();
|
|
1250
|
+
const c = await rt({
|
|
1251
1251
|
type: "commit-message-v2",
|
|
1252
1252
|
input: r
|
|
1253
1253
|
// modelName: "qwen-turbo",
|
|
1254
1254
|
});
|
|
1255
1255
|
return e + c;
|
|
1256
1256
|
}
|
|
1257
|
-
async function
|
|
1257
|
+
async function ze(e, t, a) {
|
|
1258
1258
|
const n = y("🤖 生成提交信息中...").start();
|
|
1259
1259
|
let s = "", i = !0;
|
|
1260
|
-
if ([
|
|
1260
|
+
if ([T.FEAT, T.FIX, T.REFACTOR].includes(e)) {
|
|
1261
1261
|
const o = t.map((r) => r.value).join(",");
|
|
1262
|
-
if (a || (s = await
|
|
1262
|
+
if (a || (s = await ct(`${e}(${o}): `, n)), !s) {
|
|
1263
1263
|
const r = t.map((c) => c.name).join(";");
|
|
1264
1264
|
s = `${e}(${o}): ${r}`, i = !1;
|
|
1265
1265
|
}
|
|
1266
1266
|
}
|
|
1267
|
-
e ===
|
|
1267
|
+
e === T.CHORE && (t ? s = `${e}: ${t}` : s = await ct(`${e}: `, n)), await _(Se(), s, "utf-8"), i || a ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(A.yellow(s));
|
|
1268
1268
|
}
|
|
1269
|
-
async function
|
|
1269
|
+
async function yn({ commitMessageCloseAi: e, commitMessageUseChoreType: t }) {
|
|
1270
1270
|
let a;
|
|
1271
|
-
if (t ? a =
|
|
1271
|
+
if (t ? a = T.CHORE : a = await k({
|
|
1272
1272
|
message: "请选择你要创建的模板类型",
|
|
1273
1273
|
choices: [
|
|
1274
1274
|
{
|
|
1275
1275
|
name: "feat - 业务需求/功能开发/BUG修复",
|
|
1276
|
-
value:
|
|
1276
|
+
value: T.FEAT
|
|
1277
1277
|
},
|
|
1278
1278
|
{
|
|
1279
1279
|
name: "fix - bug修复",
|
|
1280
|
-
value:
|
|
1280
|
+
value: T.FIX
|
|
1281
1281
|
},
|
|
1282
1282
|
{
|
|
1283
1283
|
name: "refactor - 技术重构/性能优化/代码规范",
|
|
1284
|
-
value:
|
|
1284
|
+
value: T.REFACTOR
|
|
1285
1285
|
},
|
|
1286
1286
|
{
|
|
1287
1287
|
name: "chore - 其他",
|
|
1288
|
-
value:
|
|
1288
|
+
value: T.CHORE
|
|
1289
1289
|
}
|
|
1290
1290
|
]
|
|
1291
|
-
}), [
|
|
1292
|
-
const n = await
|
|
1291
|
+
}), [T.FEAT, T.REFACTOR].includes(a)) {
|
|
1292
|
+
const n = await hn();
|
|
1293
1293
|
if (!n.length)
|
|
1294
1294
|
return U("🤷 暂无开发任务");
|
|
1295
1295
|
const s = await Re({
|
|
@@ -1301,10 +1301,10 @@ async function hn({ commitMessageCloseAi: e, commitMessageUseChoreType: t }) {
|
|
|
1301
1301
|
})),
|
|
1302
1302
|
pageSize: n.length
|
|
1303
1303
|
});
|
|
1304
|
-
await
|
|
1304
|
+
await ze(T.FEAT, s, e);
|
|
1305
1305
|
}
|
|
1306
|
-
if (a ===
|
|
1307
|
-
const n = await
|
|
1306
|
+
if (a === T.FIX) {
|
|
1307
|
+
const n = await wn();
|
|
1308
1308
|
if (!n.length)
|
|
1309
1309
|
return U("🤷 暂无BUG");
|
|
1310
1310
|
const s = await Re({
|
|
@@ -1316,31 +1316,31 @@ async function hn({ commitMessageCloseAi: e, commitMessageUseChoreType: t }) {
|
|
|
1316
1316
|
})),
|
|
1317
1317
|
pageSize: n.length
|
|
1318
1318
|
});
|
|
1319
|
-
await
|
|
1319
|
+
await ze(T.FIX, s, e);
|
|
1320
1320
|
}
|
|
1321
|
-
if (a ===
|
|
1321
|
+
if (a === T.CHORE) {
|
|
1322
1322
|
let n = "";
|
|
1323
|
-
e && (n = await
|
|
1323
|
+
e && (n = await Ge()), await ze(T.CHORE, n);
|
|
1324
1324
|
}
|
|
1325
1325
|
process.exit(0);
|
|
1326
1326
|
}
|
|
1327
|
-
async function
|
|
1327
|
+
async function $n() {
|
|
1328
1328
|
try {
|
|
1329
1329
|
const e = {}, t = async () => {
|
|
1330
|
-
const D =
|
|
1331
|
-
const
|
|
1330
|
+
const D = kt(), { projects: oe } = await Ps(), te = oe.map((le) => {
|
|
1331
|
+
const et = {
|
|
1332
1332
|
name: `${le.name} [${le.desc}]`,
|
|
1333
1333
|
value: le.name,
|
|
1334
1334
|
disabled: !1
|
|
1335
1335
|
};
|
|
1336
|
-
return D.includes(le.name) && (
|
|
1337
|
-
}),
|
|
1336
|
+
return D.includes(le.name) && (et.disabled = "目录下已存在同名文件夹"), et;
|
|
1337
|
+
}), Kt = await k({
|
|
1338
1338
|
message: "请选择一个项目模板",
|
|
1339
1339
|
choices: te
|
|
1340
|
-
}),
|
|
1341
|
-
e.tplName =
|
|
1340
|
+
}), Be = oe.find((le) => le.name === Kt);
|
|
1341
|
+
e.tplName = Be.name, e.tplUrl = Be.url, e.tplLanguage = Be.language;
|
|
1342
1342
|
}, a = async () => {
|
|
1343
|
-
const { groups: D } =
|
|
1343
|
+
const { groups: D } = tn(), oe = await k({
|
|
1344
1344
|
message: "请选择一个分组",
|
|
1345
1345
|
choices: D.map((te) => ({
|
|
1346
1346
|
name: `${te.name} [${te.description}]`,
|
|
@@ -1355,17 +1355,17 @@ async function wn() {
|
|
|
1355
1355
|
}, n = async () => {
|
|
1356
1356
|
e.projectName = await F({
|
|
1357
1357
|
message: "请输入项目名称",
|
|
1358
|
-
validate: (D) =>
|
|
1358
|
+
validate: (D) => mn(D, e.group?.name || "")
|
|
1359
1359
|
}), e.projectName = e.projectName.trim(), e.projectDesc = await F({
|
|
1360
1360
|
message: "请输入项目描述",
|
|
1361
|
-
validate:
|
|
1361
|
+
validate: dn
|
|
1362
1362
|
}), e.projectDesc = e.projectDesc.trim();
|
|
1363
1363
|
};
|
|
1364
1364
|
await t(), await a(), await n();
|
|
1365
1365
|
const s = `${Ae}/${e.group?.name}/${e.projectName}.git`, i = y("模版初始化中").start();
|
|
1366
|
-
await p(`git clone --depth=1 ${e.tplUrl}`), await
|
|
1366
|
+
await p(`git clone --depth=1 ${e.tplUrl}`), await ft(e.tplName, e.projectName), N.cd(e.projectName), N.rm("-rf", ".git"), await p(`git init --initial-branch=${w.MASTER}`), await p(`git remote add origin ${s}`), await p(`git config user.name ${I("gitName")}`), await p(`git config user.email ${I("gitEmail")}`);
|
|
1367
1367
|
const o = We();
|
|
1368
|
-
|
|
1368
|
+
as({
|
|
1369
1369
|
...o,
|
|
1370
1370
|
name: e.projectName,
|
|
1371
1371
|
description: e.projectDesc,
|
|
@@ -1373,12 +1373,12 @@ async function wn() {
|
|
|
1373
1373
|
...o.scripts,
|
|
1374
1374
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1375
1375
|
}
|
|
1376
|
-
}), await L.writeFile(f.resolve("README.md"),
|
|
1376
|
+
}), await L.writeFile(f.resolve("README.md"), Ua(e.projectName, e.projectDesc)), i.succeed("模版初始化完成"), await qe(e.tplLanguage, e.group?.name);
|
|
1377
1377
|
const r = y("依赖安装中").start();
|
|
1378
1378
|
await p("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1379
1379
|
const c = y("项目推送中").start();
|
|
1380
1380
|
await p('git add . && git commit -m "chore: 项目初始化"'), await p("git tag v0.0.1");
|
|
1381
|
-
const u = await
|
|
1381
|
+
const u = await Hs({
|
|
1382
1382
|
name: e.projectName,
|
|
1383
1383
|
description: e.projectDesc,
|
|
1384
1384
|
path: e.projectName,
|
|
@@ -1386,9 +1386,9 @@ async function wn() {
|
|
|
1386
1386
|
namespace_id: e.group?.id
|
|
1387
1387
|
});
|
|
1388
1388
|
await p(`git push -u origin ${w.MASTER}`), await p(`git push origin HEAD:${w.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${A.blue(s)}`);
|
|
1389
|
-
const l = y("初始化分支中").start(), d = `feat_init_${
|
|
1389
|
+
const l = y("初始化分支中").start(), d = `feat_init_${Et()}`, g = [w.DEV, w.TEST, w.RELEASE, d], h = await Promise.allSettled(
|
|
1390
1390
|
g.map(
|
|
1391
|
-
(D) =>
|
|
1391
|
+
(D) => Qs({
|
|
1392
1392
|
id: u.id,
|
|
1393
1393
|
branch: D,
|
|
1394
1394
|
ref: w.MASTER
|
|
@@ -1404,7 +1404,7 @@ async function wn() {
|
|
|
1404
1404
|
m(e);
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
1407
|
-
async function
|
|
1407
|
+
async function vn(e, t) {
|
|
1408
1408
|
let a;
|
|
1409
1409
|
e ? [
|
|
1410
1410
|
"project",
|
|
@@ -1437,26 +1437,38 @@ async function yn(e, t) {
|
|
|
1437
1437
|
/* Project */
|
|
1438
1438
|
}
|
|
1439
1439
|
]
|
|
1440
|
-
}), a === "project" ? await
|
|
1440
|
+
}), a === "project" ? await $n() : (ee(), H(), a === "branch" ? await gn(t) : a === "commit-msg" && (await p("git status -s") ? await yn(t) : m("没有要变动的文件,无法生成提交信息")));
|
|
1441
1441
|
}
|
|
1442
|
-
P.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) => B(
|
|
1443
|
-
const
|
|
1444
|
-
const t = await
|
|
1442
|
+
P.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) => B(vn, ...e));
|
|
1443
|
+
const An = async (e) => {
|
|
1444
|
+
const t = await Ls(), a = I("weWorkUserId"), { notifyUsers: n, notifyGroups: s, ...i } = e, o = y("部署任务创建中").start(), r = await Ns({
|
|
1445
1445
|
...i,
|
|
1446
1446
|
userToken: t,
|
|
1447
1447
|
userWeworkId: a,
|
|
1448
|
-
notifyUsers: [.../* @__PURE__ */ new Set([a, ...n])].join(
|
|
1449
|
-
notifyGroups: s.join(
|
|
1448
|
+
notifyUsers: [.../* @__PURE__ */ new Set([a, ...n])].join(Fe),
|
|
1449
|
+
notifyGroups: s.join(Fe)
|
|
1450
1450
|
});
|
|
1451
1451
|
i.moduleNames.length > 1 ? (o.succeed(`多模块部署任务创建完成,共 ${i.moduleNames.length} 个模块`), o.succeed(`当前已创建首个模块 ${A.blue(i.moduleNames[0])} 的 k8s 地址:`), console.log(A.blue(r)), o.info("后续模块会在前一个模块完成后依次部署,并通过企微通知下发对应地址。")) : (o.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${A.blue(r)}`));
|
|
1452
|
-
},
|
|
1452
|
+
}, Ze = () => {
|
|
1453
1453
|
const e = V();
|
|
1454
1454
|
return e.language || m("未找到当前项目的语言类型,请先通过 z . 对项目进行初始化!"), e.language;
|
|
1455
|
-
},
|
|
1455
|
+
}, Ot = () => {
|
|
1456
1456
|
const e = V();
|
|
1457
1457
|
return e.repository?.url || m("未找到当前项目的仓库地址,请先通过 z . 对项目进行初始化"), e.repository.url;
|
|
1458
|
+
}, Mt = async () => {
|
|
1459
|
+
const e = Ot(), t = Ze(), { groups: a } = await Us();
|
|
1460
|
+
return a.find((n) => {
|
|
1461
|
+
const s = $.JAVASCRIPT === t ? n.projects?.web : $.JAVA === t ? n.projects?.server : [];
|
|
1462
|
+
return s.length && s.some((i) => Pe(i.url, e)) && n.zenTaoProductId ? n.zenTaoProductId : !1;
|
|
1463
|
+
});
|
|
1464
|
+
}, bn = async () => {
|
|
1465
|
+
const e = await Mt();
|
|
1466
|
+
if (!e)
|
|
1467
|
+
return;
|
|
1468
|
+
const t = Ot(), a = Ze(), n = $.JAVASCRIPT === a ? e.projects?.web : $.JAVA === a ? e.projects?.server : [];
|
|
1469
|
+
return n.length ? n.find((i) => Pe(i.url, t))?.chatGroupWebhook ?? e.chatGroupWebhook : void 0;
|
|
1458
1470
|
};
|
|
1459
|
-
function
|
|
1471
|
+
function Sn(e, t) {
|
|
1460
1472
|
const a = We();
|
|
1461
1473
|
if (V()?.repository?.url || m(".z/project.json中缺少repository.url"), t === Y.H5) {
|
|
1462
1474
|
const s = `build:${e}`;
|
|
@@ -1464,19 +1476,13 @@ function An(e, t) {
|
|
|
1464
1476
|
}
|
|
1465
1477
|
t === Y.NPM && (a?.scripts.build || m("项目package.json文件scripts不存在命令build。")), t === Y.SERVER && (a?.scripts.build || m("项目package.json文件scripts不存在命令build。"));
|
|
1466
1478
|
}
|
|
1467
|
-
const
|
|
1468
|
-
const e =
|
|
1469
|
-
return a.find((n) => {
|
|
1470
|
-
const s = $.JAVASCRIPT === t ? n.projects?.web : $.JAVA === t ? n.projects?.server : [];
|
|
1471
|
-
return s.length && s.some((i) => Ue(i.url, e)) && n.zenTaoProductId ? n.zenTaoProductId : !1;
|
|
1472
|
-
});
|
|
1473
|
-
}, Sn = async () => {
|
|
1474
|
-
const e = await bn();
|
|
1479
|
+
const Nn = async () => {
|
|
1480
|
+
const e = await Mt();
|
|
1475
1481
|
if (!e) {
|
|
1476
|
-
m("
|
|
1482
|
+
m("未找到关联的禅道产品,请先关联禅道产品!");
|
|
1477
1483
|
return;
|
|
1478
1484
|
}
|
|
1479
|
-
const t = y("查询禅道执行中...").start(), a = await
|
|
1485
|
+
const t = y("查询禅道执行中...").start(), a = await js(Number(e.zenTaoProductId));
|
|
1480
1486
|
a.length || (t.fail("查询禅道执行失败"), m(`${e.name} 项目在禅道中未创建执行!`)), t.stop();
|
|
1481
1487
|
const n = await k({
|
|
1482
1488
|
message: "请选择执行",
|
|
@@ -1485,29 +1491,29 @@ const bn = async () => {
|
|
|
1485
1491
|
value: s.value
|
|
1486
1492
|
}))
|
|
1487
1493
|
});
|
|
1488
|
-
t.start("创建或更新执行构建..."), await
|
|
1494
|
+
t.start("创建或更新执行构建..."), await Ts({
|
|
1489
1495
|
appName: e.name,
|
|
1490
1496
|
executionId: Number(n),
|
|
1491
1497
|
ldapAccount: I("ldapAccount")
|
|
1492
1498
|
}), t.succeed("创建或更新执行构建成功");
|
|
1493
|
-
},
|
|
1494
|
-
async function
|
|
1499
|
+
}, jn = [w.TEST, w.MASTER];
|
|
1500
|
+
async function Bt(e, t) {
|
|
1495
1501
|
ee(), H();
|
|
1496
1502
|
let a = e, n = t.platform;
|
|
1497
1503
|
const s = V();
|
|
1498
1504
|
if (s.language === $.JAVA && (n = Y.SERVER), a && !Object.values(w).includes(a) && m("仅支持发布指定环境分支"), n && !Object.values(Y).includes(n) && m("发布平台错误"), n || (n = await k({
|
|
1499
1505
|
message: "请选择平台",
|
|
1500
|
-
choices:
|
|
1506
|
+
choices: ka
|
|
1501
1507
|
})), n === Y.NPM && (a = w.MASTER), !a) {
|
|
1502
1508
|
const l = await k({
|
|
1503
1509
|
message: "请选择部署环境",
|
|
1504
|
-
choices:
|
|
1510
|
+
choices: At
|
|
1505
1511
|
});
|
|
1506
|
-
a =
|
|
1512
|
+
a = Ga(l);
|
|
1507
1513
|
}
|
|
1508
|
-
a === w.TEST && await
|
|
1514
|
+
a === w.TEST && await Nn();
|
|
1509
1515
|
let i = "";
|
|
1510
|
-
s.language === $.JAVASCRIPT && (i =
|
|
1516
|
+
s.language === $.JAVASCRIPT && (i = Ra);
|
|
1511
1517
|
const o = [];
|
|
1512
1518
|
if (s.language === $.JAVASCRIPT) {
|
|
1513
1519
|
let l = "";
|
|
@@ -1515,7 +1521,7 @@ async function Ot(e, t) {
|
|
|
1515
1521
|
d.name.startsWith("@") && d.name.includes("/") ? l = d.name.split("/").pop() || "" : l = d.name, l && o.push(l);
|
|
1516
1522
|
}
|
|
1517
1523
|
if (s.language === $.JAVA) {
|
|
1518
|
-
const { projects: l } = await
|
|
1524
|
+
const { projects: l } = await Ds(), d = l.find(
|
|
1519
1525
|
(g) => se(g.url) === se(s.repository.url)
|
|
1520
1526
|
);
|
|
1521
1527
|
if (!d)
|
|
@@ -1527,7 +1533,7 @@ async function Ot(e, t) {
|
|
|
1527
1533
|
value: v
|
|
1528
1534
|
}));
|
|
1529
1535
|
if (t.module) {
|
|
1530
|
-
const v = new Set(t.module.split(
|
|
1536
|
+
const v = new Set(t.module.split(Fe));
|
|
1531
1537
|
g.forEach((R) => v.has(R.value) && o.push(R.value));
|
|
1532
1538
|
}
|
|
1533
1539
|
const h = await W({
|
|
@@ -1549,14 +1555,18 @@ async function Ot(e, t) {
|
|
|
1549
1555
|
}
|
|
1550
1556
|
}
|
|
1551
1557
|
let r = [];
|
|
1552
|
-
const c =
|
|
1553
|
-
!t.skipSelectionNotification && !c && (r = await
|
|
1558
|
+
const c = jn.includes(a);
|
|
1559
|
+
!t.skipSelectionNotification && !c && (r = await Pt("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1554
1560
|
let u = [];
|
|
1555
|
-
if (!t.skipGroupNotification && !c && (u = await
|
|
1556
|
-
const l =
|
|
1557
|
-
|
|
1561
|
+
if (!t.skipGroupNotification && !c && (u = await nn("请选择部署成功要通知的群组:", () => !0, !0)), c && !t.skipGroupNotification && !u.length) {
|
|
1562
|
+
const l = await bn();
|
|
1563
|
+
l && u.push(l);
|
|
1564
|
+
}
|
|
1565
|
+
if (s.language === $.JAVASCRIPT) {
|
|
1566
|
+
const l = Fa(a);
|
|
1567
|
+
Sn(l, n);
|
|
1558
1568
|
}
|
|
1559
|
-
await
|
|
1569
|
+
await An({
|
|
1560
1570
|
moduleNames: o,
|
|
1561
1571
|
k8sGroupName: i,
|
|
1562
1572
|
branchName: a,
|
|
@@ -1564,11 +1574,11 @@ async function Ot(e, t) {
|
|
|
1564
1574
|
notifyGroups: u
|
|
1565
1575
|
});
|
|
1566
1576
|
}
|
|
1567
|
-
async function
|
|
1577
|
+
async function zt(e, t, a, n) {
|
|
1568
1578
|
const s = y(`分支合并中,${e} -> ${t}`).start();
|
|
1569
1579
|
let i = 0;
|
|
1570
1580
|
try {
|
|
1571
|
-
const { iid: r } = await
|
|
1581
|
+
const { iid: r } = await Zs({
|
|
1572
1582
|
title: `${e} -> ${t} by z-develop`,
|
|
1573
1583
|
id: a.id,
|
|
1574
1584
|
source_branch: e,
|
|
@@ -1584,7 +1594,7 @@ async function Mt(e, t, a, n) {
|
|
|
1584
1594
|
try {
|
|
1585
1595
|
await new Promise((r) => {
|
|
1586
1596
|
setTimeout(r, 5e3);
|
|
1587
|
-
}), await
|
|
1597
|
+
}), await Ks({
|
|
1588
1598
|
id: a.id,
|
|
1589
1599
|
iid: i
|
|
1590
1600
|
}), s.succeed(`分支${e}已合并到分支${t}`);
|
|
@@ -1593,12 +1603,12 @@ async function Mt(e, t, a, n) {
|
|
|
1593
1603
|
const c = r?.response?.status;
|
|
1594
1604
|
if (c === 406)
|
|
1595
1605
|
return await o();
|
|
1596
|
-
if (await
|
|
1606
|
+
if (await Ys({
|
|
1597
1607
|
id: a.id,
|
|
1598
1608
|
iid: i,
|
|
1599
1609
|
state_event: "close"
|
|
1600
1610
|
}), c === 405) {
|
|
1601
|
-
const u = await
|
|
1611
|
+
const u = await Xs({
|
|
1602
1612
|
id: a.id,
|
|
1603
1613
|
iid: i
|
|
1604
1614
|
});
|
|
@@ -1618,23 +1628,23 @@ async function Tn(e, t) {
|
|
|
1618
1628
|
`git log ${n}...${s} -b ${a}`
|
|
1619
1629
|
) || m(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await p(
|
|
1620
1630
|
`git branch --contains ${n} -r ${a}`
|
|
1621
|
-
) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await
|
|
1631
|
+
) || (console.log(A.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await zt(w.MASTER, e.sourceBranch, e)), t === w.MASTER && (await p(
|
|
1622
1632
|
`git cherry origin/${O.TEST} ${a} origin/${w.MASTER}`
|
|
1623
1633
|
)).split(`
|
|
1624
1634
|
`).some((c) => c.startsWith("+ ")) && m("请先在测试环境发布要部署的代码");
|
|
1625
1635
|
}
|
|
1626
|
-
const
|
|
1636
|
+
const lt = async (e, t) => {
|
|
1627
1637
|
try {
|
|
1628
1638
|
await p(`git push -u origin ${e}`), t.succeed(`本地分支${e}已推送到远程分支origin/${e}`);
|
|
1629
1639
|
} catch (a) {
|
|
1630
1640
|
m(`合并到远程分支 ${e} 失败,${a}`);
|
|
1631
1641
|
}
|
|
1632
1642
|
};
|
|
1633
|
-
async function
|
|
1643
|
+
async function kn(e, t) {
|
|
1634
1644
|
ee(), H(), await ge();
|
|
1635
|
-
const a = await
|
|
1645
|
+
const a = await ss();
|
|
1636
1646
|
Object.values(w).includes(a.sourceBranch) && m(`当前分支${a.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1637
|
-
const s = (await
|
|
1647
|
+
const s = (await en(a.id)).filter((c) => ![a.sourceBranch].includes(c.name)).map((c) => {
|
|
1638
1648
|
let u = c.name;
|
|
1639
1649
|
return Object.values(w).includes(u) && (u = A.bold.blue(u)), {
|
|
1640
1650
|
name: u,
|
|
@@ -1650,22 +1660,22 @@ async function jn(e, t) {
|
|
|
1650
1660
|
if (await p(`git ls-remote --heads origin ${a.sourceBranch}`)) {
|
|
1651
1661
|
o.text = `存在远程分支origin/${a.sourceBranch}`, await p("git fetch");
|
|
1652
1662
|
const c = await p(`git rev-parse ${a.sourceBranch}`), u = await p(`git rev-parse origin/${a.sourceBranch}`);
|
|
1653
|
-
await p(`git merge-base ${u} HEAD`) === u ? await
|
|
1663
|
+
await p(`git merge-base ${u} HEAD`) === u ? await lt(a.sourceBranch, o) : await p(`git merge-base ${c} ${u}`) === c ? (await p("git pull"), o.succeed(`本地分支${a.sourceBranch}已更新`)) : (o.fail(
|
|
1654
1664
|
`远程分支origin/${a.sourceBranch}和本地分支${a.sourceBranch}都有新的提交,请手动合并后再试。`
|
|
1655
1665
|
), process.exit(1));
|
|
1656
1666
|
} else
|
|
1657
|
-
await
|
|
1658
|
-
await Tn(a, i), await
|
|
1667
|
+
await lt(a.sourceBranch, o);
|
|
1668
|
+
await Tn(a, i), await zt(a.sourceBranch, i, a, t.keepBranchAfterMergeMaster), w.MASTER === i && !t.keepBranchAfterMergeMaster && (await p(`git checkout ${w.MASTER}`), await p(`git pull origin ${w.MASTER}`), await p(`git branch -d ${a.sourceBranch}`), U(
|
|
1659
1669
|
`${a.sourceBranch}分支已移除,当前已切换到最新的${w.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1660
|
-
)), Object.values(w).includes(i) && await
|
|
1670
|
+
)), Object.values(w).includes(i) && await Bt(i, {
|
|
1661
1671
|
platform: t.deployPlatform,
|
|
1662
1672
|
skipSelectionNotification: t.deploySkipSelectionNotification,
|
|
1663
1673
|
skipGroupNotification: t.skipGroupNotification
|
|
1664
1674
|
});
|
|
1665
1675
|
}
|
|
1666
|
-
P.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(Y).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => B(
|
|
1667
|
-
P.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(w).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(Y).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称,多个使用逗号分隔").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => B(
|
|
1668
|
-
async function
|
|
1676
|
+
P.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(Y).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => B(kn, ...e));
|
|
1677
|
+
P.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(w).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(Y).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称,多个使用逗号分隔").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => B(Bt, ...e));
|
|
1678
|
+
async function En() {
|
|
1669
1679
|
try {
|
|
1670
1680
|
await p("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
|
|
1671
1681
|
silent: !1
|
|
@@ -1674,7 +1684,7 @@ async function kn() {
|
|
|
1674
1684
|
m("checkstyle执行出错"), process.exit(1);
|
|
1675
1685
|
}
|
|
1676
1686
|
}
|
|
1677
|
-
const Ie = "origin/",
|
|
1687
|
+
const Ie = "origin/", In = Object.values(w).map((e) => `${Ie}${e}`), Rn = Object.values(w), Ee = w.MASTER, Cn = async (e) => {
|
|
1678
1688
|
await p("git fetch --prune");
|
|
1679
1689
|
const t = `${Ie}${e}`, a = await p(`git branch -r --merged ${t}`, {
|
|
1680
1690
|
encoding: "utf8"
|
|
@@ -1684,7 +1694,7 @@ const Ie = "origin/", En = Object.values(w).map((e) => `${Ie}${e}`), In = Object
|
|
|
1684
1694
|
return a.split(`
|
|
1685
1695
|
`).forEach((i) => {
|
|
1686
1696
|
const o = i.trim();
|
|
1687
|
-
if (o && o !== t && !o.startsWith(`${Ie}HEAD`) && !
|
|
1697
|
+
if (o && o !== t && !o.startsWith(`${Ie}HEAD`) && !In.includes(o)) {
|
|
1688
1698
|
const r = o.replace(new RegExp(`^${Ie}`), "");
|
|
1689
1699
|
s.set(r, {
|
|
1690
1700
|
name: r,
|
|
@@ -1696,7 +1706,7 @@ const Ie = "origin/", En = Object.values(w).map((e) => `${Ie}${e}`), In = Object
|
|
|
1696
1706
|
}), n.split(`
|
|
1697
1707
|
`).forEach((i) => {
|
|
1698
1708
|
const o = i.replace(/^\*?\s*/, "").trim();
|
|
1699
|
-
if (o && o !== e && !
|
|
1709
|
+
if (o && o !== e && !Rn.includes(o)) {
|
|
1700
1710
|
const r = s.get(o);
|
|
1701
1711
|
s.set(o, {
|
|
1702
1712
|
name: o,
|
|
@@ -1709,7 +1719,7 @@ const Ie = "origin/", En = Object.values(w).map((e) => `${Ie}${e}`), In = Object
|
|
|
1709
1719
|
...i,
|
|
1710
1720
|
name: `${i.value}${i.hasRemote && i.hasLocal ? "(本地/远程)" : i.hasRemote ? "(远程)" : "(本地)"}`
|
|
1711
1721
|
})).sort((i, o) => i.value.localeCompare(o.value));
|
|
1712
|
-
},
|
|
1722
|
+
}, Ln = (e) => W({
|
|
1713
1723
|
message: "请选择需要删除的分支",
|
|
1714
1724
|
options: (t) => t ? e.filter((a) => a.name.includes(t)) : e,
|
|
1715
1725
|
pageSize: 20,
|
|
@@ -1723,41 +1733,41 @@ const Ie = "origin/", En = Object.values(w).map((e) => `${Ie}${e}`), In = Object
|
|
|
1723
1733
|
renderSelectedOptions: (t) => t.map((a) => a.value).join(", ")
|
|
1724
1734
|
}
|
|
1725
1735
|
}
|
|
1726
|
-
}),
|
|
1736
|
+
}), xn = async (e) => (await p(`git branch --list ${e}`)).trim() !== "", Pn = (e) => {
|
|
1727
1737
|
Ve(`git push origin --delete ${e}`);
|
|
1728
|
-
},
|
|
1738
|
+
}, Dn = (e) => {
|
|
1729
1739
|
Ve(`git branch -d ${e}`);
|
|
1730
|
-
},
|
|
1740
|
+
}, On = async () => {
|
|
1731
1741
|
await ge();
|
|
1732
|
-
const e = y(`正在查询本地和远程已经合并到${Ee}的分支...`).start(), t = await
|
|
1742
|
+
const e = y(`正在查询本地和远程已经合并到${Ee}的分支...`).start(), t = await Cn(Ee);
|
|
1733
1743
|
if (e.succeed(`查询到 ${t.length} 个已合并到 ${Ee} 的分支`), !t.length) {
|
|
1734
|
-
|
|
1744
|
+
J(`未查询到已合并到 ${Ee} 的可删除分支`);
|
|
1735
1745
|
return;
|
|
1736
1746
|
}
|
|
1737
|
-
const a = await
|
|
1747
|
+
const a = await Ln(t);
|
|
1738
1748
|
if (!await Le({
|
|
1739
1749
|
message: `确认删除选中的 ${a.length} 个分支对应的远程分支和本地分支?`,
|
|
1740
1750
|
default: !1
|
|
1741
1751
|
})) {
|
|
1742
|
-
|
|
1752
|
+
J("已取消删除");
|
|
1743
1753
|
return;
|
|
1744
1754
|
}
|
|
1745
1755
|
const s = await p("git branch --show-current"), i = [], o = [], r = [], c = t.filter((l) => a.includes(l.value)), u = y("正在删除分支...").start();
|
|
1746
1756
|
try {
|
|
1747
1757
|
for (const l of c) {
|
|
1748
1758
|
const { value: d, hasLocal: g, hasRemote: h } = l;
|
|
1749
|
-
if (h && (u.text = `正在删除远程分支 ${d}...`,
|
|
1759
|
+
if (h && (u.text = `正在删除远程分支 ${d}...`, Pn(d), o.push(d)), d === s) {
|
|
1750
1760
|
g && i.push(d);
|
|
1751
1761
|
continue;
|
|
1752
1762
|
}
|
|
1753
|
-
!g || !await
|
|
1763
|
+
!g || !await xn(d) || (u.text = `正在删除本地分支 ${d}...`, Dn(d), r.push(d));
|
|
1754
1764
|
}
|
|
1755
1765
|
} catch (l) {
|
|
1756
1766
|
throw u.fail("删除分支失败"), l;
|
|
1757
1767
|
}
|
|
1758
|
-
u.succeed("分支删除完成"), o.length && U(`远程分支删除完成:${o.join(", ")}`), r.length && U(`本地分支删除完成:${r.join(", ")}`), i.length &&
|
|
1759
|
-
},
|
|
1760
|
-
if (t ===
|
|
1768
|
+
u.succeed("分支删除完成"), o.length && U(`远程分支删除完成:${o.join(", ")}`), r.length && U(`本地分支删除完成:${r.join(", ")}`), i.length && J(`${i.join(", ")} 为当前分支,无法删除本地分支`);
|
|
1769
|
+
}, _t = "0000000000000000000000000000000000000000", ut = "refs/heads/", Mn = async (e, t) => {
|
|
1770
|
+
if (t === _t) {
|
|
1761
1771
|
try {
|
|
1762
1772
|
const a = await p(`git rev-parse --verify --quiet origin/${w.MASTER}`);
|
|
1763
1773
|
if (a)
|
|
@@ -1767,14 +1777,14 @@ const Ie = "origin/", En = Object.values(w).map((e) => `${Ie}${e}`), In = Object
|
|
|
1767
1777
|
return null;
|
|
1768
1778
|
}
|
|
1769
1779
|
return `${t}..${e}`;
|
|
1770
|
-
},
|
|
1780
|
+
}, Bn = async (e) => {
|
|
1771
1781
|
try {
|
|
1772
1782
|
return (await p(`git log ${e} --grep="(cherry picked from commit" --format="%H"`)).split(`
|
|
1773
1783
|
`).filter(Boolean);
|
|
1774
1784
|
} catch {
|
|
1775
1785
|
return [];
|
|
1776
1786
|
}
|
|
1777
|
-
},
|
|
1787
|
+
}, zn = async (e) => {
|
|
1778
1788
|
try {
|
|
1779
1789
|
return (await p(`git log ${e} --format="%H %at %ct"`)).split(`
|
|
1780
1790
|
`).flatMap((a) => {
|
|
@@ -1784,32 +1794,32 @@ const Ie = "origin/", En = Object.values(w).map((e) => `${Ie}${e}`), In = Object
|
|
|
1784
1794
|
} catch {
|
|
1785
1795
|
return [];
|
|
1786
1796
|
}
|
|
1787
|
-
},
|
|
1788
|
-
const { skipGitPushLimit: e } = V(), t = Object.values(w), a =
|
|
1797
|
+
}, _n = async () => {
|
|
1798
|
+
const { skipGitPushLimit: e } = V(), t = Object.values(w), a = dt(0, "utf-8");
|
|
1789
1799
|
if (!a)
|
|
1790
1800
|
return;
|
|
1791
1801
|
const n = a.trim().split(`
|
|
1792
1802
|
`), s = n.length;
|
|
1793
1803
|
for (let i = 0; i < s; i++) {
|
|
1794
1804
|
const [, o, r, c] = n[i].split(/\s+/);
|
|
1795
|
-
if (!r.startsWith(
|
|
1805
|
+
if (!r.startsWith(ut) || o === _t)
|
|
1796
1806
|
continue;
|
|
1797
|
-
const u = r.replace(
|
|
1807
|
+
const u = r.replace(ut, "");
|
|
1798
1808
|
!e && t.includes(u) && m(`禁止直接 Push 到环境分支:${u}`);
|
|
1799
|
-
const l = await
|
|
1809
|
+
const l = await Mn(o, c);
|
|
1800
1810
|
if (!l)
|
|
1801
1811
|
continue;
|
|
1802
1812
|
const [d, g] = await Promise.all([
|
|
1803
|
-
|
|
1804
|
-
|
|
1813
|
+
Bn(l),
|
|
1814
|
+
zn(l)
|
|
1805
1815
|
]), h = [.../* @__PURE__ */ new Set([...d, ...g])];
|
|
1806
1816
|
h.length > 0 && m(`以下提交中检测到包含 cherry-pick 特征,本次 Push 已被拒绝
|
|
1807
1817
|
${h.join(`
|
|
1808
1818
|
`)}`);
|
|
1809
1819
|
}
|
|
1810
1820
|
};
|
|
1811
|
-
async function
|
|
1812
|
-
|
|
1821
|
+
async function Fn() {
|
|
1822
|
+
j(f.resolve("node_modules", ".bin", "markdownlint")) || m("该项目未安装markdownlint,请安装后重试");
|
|
1813
1823
|
const e = y("markdownlint执行中...").start();
|
|
1814
1824
|
try {
|
|
1815
1825
|
await p('npx markdownlint "**/*.md" --fix', {
|
|
@@ -1819,7 +1829,7 @@ async function _n() {
|
|
|
1819
1829
|
e.fail("markdownlint校验出错"), process.exit(1);
|
|
1820
1830
|
}
|
|
1821
1831
|
}
|
|
1822
|
-
const
|
|
1832
|
+
const Gn = () => {
|
|
1823
1833
|
m("禁止执行 rebase,请使用 git merge!");
|
|
1824
1834
|
};
|
|
1825
1835
|
function Jn() {
|
|
@@ -1828,9 +1838,9 @@ function Jn() {
|
|
|
1828
1838
|
return e["lint-staged"];
|
|
1829
1839
|
throw new Error("未找到lint配置");
|
|
1830
1840
|
}
|
|
1831
|
-
async function
|
|
1841
|
+
async function Un() {
|
|
1832
1842
|
const e = y("代码风格检测中...").start();
|
|
1833
|
-
await
|
|
1843
|
+
await da({
|
|
1834
1844
|
concurrent: 4,
|
|
1835
1845
|
debug: !1,
|
|
1836
1846
|
config: Jn(),
|
|
@@ -1838,22 +1848,22 @@ async function Gn() {
|
|
|
1838
1848
|
relative: !0
|
|
1839
1849
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
1840
1850
|
}
|
|
1841
|
-
function
|
|
1842
|
-
if (e.includes("Merge") && e.includes("# Conflicts:") ||
|
|
1851
|
+
function Vn(e) {
|
|
1852
|
+
if (e.includes("Merge") && e.includes("# Conflicts:") || fa.valid(e))
|
|
1843
1853
|
return !0;
|
|
1844
1854
|
const t = e.split(": ");
|
|
1845
1855
|
if (t.length === 1)
|
|
1846
1856
|
return "body前缺少「: 」";
|
|
1847
1857
|
const a = t[0];
|
|
1848
|
-
return /^(feat|fix|refactor)/.test(a) ? /\(\d+(?:,\d+)*\)/.test(a) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(a) ? [
|
|
1858
|
+
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 : "不存在的提交类型。";
|
|
1849
1859
|
}
|
|
1850
|
-
async function
|
|
1851
|
-
const e = await
|
|
1860
|
+
async function Wn() {
|
|
1861
|
+
const e = await _e(f.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), a = Vn(e);
|
|
1852
1862
|
a === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${a}`), process.exit(1));
|
|
1853
1863
|
}
|
|
1854
|
-
async function
|
|
1864
|
+
async function Hn() {
|
|
1855
1865
|
await ge();
|
|
1856
|
-
const e = await
|
|
1866
|
+
const e = await ga({
|
|
1857
1867
|
// 分组,展示仓库链接
|
|
1858
1868
|
format: ["group", "repo"],
|
|
1859
1869
|
// 交互式弹窗
|
|
@@ -1870,8 +1880,8 @@ async function Wn() {
|
|
|
1870
1880
|
}
|
|
1871
1881
|
process.exit(0);
|
|
1872
1882
|
}
|
|
1873
|
-
async function
|
|
1874
|
-
|
|
1883
|
+
async function qn(e) {
|
|
1884
|
+
j(f.resolve("node_modules", ".bin", "eslint")) || m("该项目未安装eslint,请安装后重试");
|
|
1875
1885
|
const t = y("eslint执行中...").start();
|
|
1876
1886
|
try {
|
|
1877
1887
|
let a = "npx eslint '**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}' --fix";
|
|
@@ -1882,8 +1892,8 @@ async function Hn(e) {
|
|
|
1882
1892
|
t.fail("eslint校验出错"), process.exit(1);
|
|
1883
1893
|
}
|
|
1884
1894
|
}
|
|
1885
|
-
async function
|
|
1886
|
-
|
|
1895
|
+
async function Zn() {
|
|
1896
|
+
j(f.resolve("node_modules", ".bin", "prettier")) || m("该项目未安装prettier,请安装后重试");
|
|
1887
1897
|
const e = y("prettier执行中...").start();
|
|
1888
1898
|
try {
|
|
1889
1899
|
await p(
|
|
@@ -1896,10 +1906,10 @@ async function qn() {
|
|
|
1896
1906
|
e.fail("prettier校验出错"), process.exit(1);
|
|
1897
1907
|
}
|
|
1898
1908
|
}
|
|
1899
|
-
function
|
|
1900
|
-
|
|
1909
|
+
function Kn() {
|
|
1910
|
+
j(f.resolve("./node_modules/.bin/vue-tsc")) || m("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), Ve("npx vue-tsc --build"), process.exit(0);
|
|
1901
1911
|
}
|
|
1902
|
-
const
|
|
1912
|
+
const Yn = [
|
|
1903
1913
|
[
|
|
1904
1914
|
"cm",
|
|
1905
1915
|
"commit-msg"
|
|
@@ -1955,7 +1965,7 @@ const Kn = [
|
|
|
1955
1965
|
"detect-push"
|
|
1956
1966
|
/* DetectPush */
|
|
1957
1967
|
]
|
|
1958
|
-
],
|
|
1968
|
+
], Xn = {
|
|
1959
1969
|
[$.JAVA]: [
|
|
1960
1970
|
{
|
|
1961
1971
|
name: "执行 check-style",
|
|
@@ -2002,30 +2012,30 @@ const Kn = [
|
|
|
2002
2012
|
/* DependencyCheck */
|
|
2003
2013
|
}
|
|
2004
2014
|
]
|
|
2005
|
-
},
|
|
2006
|
-
"commit-msg":
|
|
2007
|
-
"commit-files":
|
|
2008
|
-
prettier:
|
|
2009
|
-
eslint:
|
|
2010
|
-
"type-check":
|
|
2011
|
-
"dependency-check":
|
|
2012
|
-
checkstyle:
|
|
2013
|
-
"markdown-lint":
|
|
2014
|
-
"delete-merged":
|
|
2015
|
-
"not-allow-rebase":
|
|
2016
|
-
"detect-push":
|
|
2017
|
-
},
|
|
2018
|
-
const a = Reflect.get(
|
|
2015
|
+
}, Qn = (e) => Reflect.get(Xn, e) ?? [], ei = {
|
|
2016
|
+
"commit-msg": Wn,
|
|
2017
|
+
"commit-files": Un,
|
|
2018
|
+
prettier: Zn,
|
|
2019
|
+
eslint: qn,
|
|
2020
|
+
"type-check": Kn,
|
|
2021
|
+
"dependency-check": Hn,
|
|
2022
|
+
checkstyle: En,
|
|
2023
|
+
"markdown-lint": Fn,
|
|
2024
|
+
"delete-merged": On,
|
|
2025
|
+
"not-allow-rebase": Gn,
|
|
2026
|
+
"detect-push": _n
|
|
2027
|
+
}, ti = async (e, t) => {
|
|
2028
|
+
const a = Reflect.get(ei, e);
|
|
2019
2029
|
a && typeof a == "function" && await a(t);
|
|
2020
|
-
},
|
|
2021
|
-
for (const [t, a] of
|
|
2030
|
+
}, ai = (e) => {
|
|
2031
|
+
for (const [t, a] of Yn)
|
|
2022
2032
|
if (e === t || e === a)
|
|
2023
2033
|
return a;
|
|
2024
2034
|
m("参数输入错误");
|
|
2025
2035
|
};
|
|
2026
|
-
async function
|
|
2036
|
+
async function si(e, t) {
|
|
2027
2037
|
ee(), H();
|
|
2028
|
-
const a = V(), n = e ?
|
|
2038
|
+
const a = V(), n = e ? ai(e) : await k({
|
|
2029
2039
|
message: "请选择你要执行的操作",
|
|
2030
2040
|
choices: [
|
|
2031
2041
|
{
|
|
@@ -2033,7 +2043,7 @@ async function ai(e, t) {
|
|
|
2033
2043
|
value: "prettier"
|
|
2034
2044
|
/* Prettier */
|
|
2035
2045
|
},
|
|
2036
|
-
...
|
|
2046
|
+
...Qn(a.language),
|
|
2037
2047
|
{
|
|
2038
2048
|
name: "执行 delete-merged",
|
|
2039
2049
|
value: "delete-merged"
|
|
@@ -2041,21 +2051,21 @@ async function ai(e, t) {
|
|
|
2041
2051
|
}
|
|
2042
2052
|
]
|
|
2043
2053
|
});
|
|
2044
|
-
await
|
|
2054
|
+
await ti(n, t);
|
|
2045
2055
|
}
|
|
2046
2056
|
P.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint / delete-merged。").argument(
|
|
2047
2057
|
"[type]",
|
|
2048
2058
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs, markdown-lint|ml, delete-merged|dm。"
|
|
2049
|
-
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => B(
|
|
2050
|
-
async function
|
|
2059
|
+
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => B(si, ...e));
|
|
2060
|
+
async function Ft(e = "latest") {
|
|
2051
2061
|
const t = y("安装中...").start();
|
|
2052
2062
|
await p(`npm i -g ${ce.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", de("latestCheckVersionTimestamp", Date.now()), de("version", e);
|
|
2053
2063
|
const a = await He();
|
|
2054
|
-
|
|
2064
|
+
De(a), X(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
2055
2065
|
}
|
|
2056
|
-
P.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => B(
|
|
2057
|
-
const
|
|
2058
|
-
function
|
|
2066
|
+
P.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => B(Ft, ...e));
|
|
2067
|
+
const Ke = /Thumbs\.db|\.git|DS_Store|idea/, Gt = "testcase";
|
|
2068
|
+
function Jt(e) {
|
|
2059
2069
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
2060
2070
|
if (t && !e.startsWith("["))
|
|
2061
2071
|
return {
|
|
@@ -2075,14 +2085,14 @@ function Ft(e) {
|
|
|
2075
2085
|
};
|
|
2076
2086
|
}
|
|
2077
2087
|
async function ie(e, t = {}) {
|
|
2078
|
-
const { exclude: a =
|
|
2088
|
+
const { exclude: a = Ke } = t, n = [];
|
|
2079
2089
|
async function s(i) {
|
|
2080
2090
|
const o = f.basename(i);
|
|
2081
|
-
if ((await
|
|
2091
|
+
if ((await na(i)).isFile())
|
|
2082
2092
|
return null;
|
|
2083
|
-
const c = await
|
|
2093
|
+
const c = await Ue(i, { withFileTypes: !0 }), u = (await Promise.all(
|
|
2084
2094
|
c.filter((v) => v.isDirectory() && !a.test(v.name)).map((v) => s(f.join(i, v.name)))
|
|
2085
|
-
)).filter(Boolean), { type: l, id: d, displayName: g } =
|
|
2095
|
+
)).filter(Boolean), { type: l, id: d, displayName: g } = Jt(o), h = {
|
|
2086
2096
|
name: o,
|
|
2087
2097
|
id: d,
|
|
2088
2098
|
displayName: g,
|
|
@@ -2094,13 +2104,13 @@ async function ie(e, t = {}) {
|
|
|
2094
2104
|
}
|
|
2095
2105
|
return await s(f.resolve(e)), n;
|
|
2096
2106
|
}
|
|
2097
|
-
async function
|
|
2098
|
-
const { exclude: a =
|
|
2107
|
+
async function Ut(e, t = {}) {
|
|
2108
|
+
const { exclude: a = Ke } = t;
|
|
2099
2109
|
try {
|
|
2100
|
-
const n = await
|
|
2110
|
+
const n = await Ue(f.resolve(e), { withFileTypes: !0 });
|
|
2101
2111
|
return await Promise.all(
|
|
2102
2112
|
n.filter((s) => s.isDirectory() && !a.test(s.name)).map((s) => {
|
|
2103
|
-
const i = f.join(e, s.name), { type: o, id: r, displayName: c } =
|
|
2113
|
+
const i = f.join(e, s.name), { type: o, id: r, displayName: c } = Jt(s.name);
|
|
2104
2114
|
return {
|
|
2105
2115
|
name: s.name,
|
|
2106
2116
|
id: r,
|
|
@@ -2124,31 +2134,31 @@ function Q(e, t, a) {
|
|
|
2124
2134
|
return t;
|
|
2125
2135
|
}
|
|
2126
2136
|
}
|
|
2127
|
-
async function
|
|
2137
|
+
async function je(e, t, a, n) {
|
|
2128
2138
|
try {
|
|
2129
2139
|
const s = f.basename(e), i = Q(a, t, n);
|
|
2130
2140
|
if (s === i)
|
|
2131
2141
|
return !0;
|
|
2132
2142
|
const o = f.dirname(e), r = f.join(o, i);
|
|
2133
|
-
return await
|
|
2143
|
+
return await Ja(e) ? await ft(e, r) : (await p(`git mv "${e}" "${r}"`), await p("git add .")), !0;
|
|
2134
2144
|
} catch (s) {
|
|
2135
2145
|
return m(`重命名文件夹失败: ${e} -> ${t}。${s}`), !1;
|
|
2136
2146
|
}
|
|
2137
2147
|
}
|
|
2138
|
-
async function
|
|
2139
|
-
const { exclude: n =
|
|
2148
|
+
async function ni(e, t, a = {}) {
|
|
2149
|
+
const { exclude: n = Ke } = a;
|
|
2140
2150
|
async function s(i, o) {
|
|
2141
2151
|
if (!i || i.length === 0) return;
|
|
2142
|
-
const r = await
|
|
2152
|
+
const r = await Ut(o, { exclude: n });
|
|
2143
2153
|
for (const c of i) {
|
|
2144
2154
|
const u = String(c.value), l = Q("module", c.label, u), d = r.find((h) => h.id === u);
|
|
2145
2155
|
let g = d?.path || f.join(o, l);
|
|
2146
|
-
d ? d.displayName !== c.label && await
|
|
2156
|
+
d ? d.displayName !== c.label && await je(d.path, c.label, "module", u) && (g = f.join(o, l)) : (await fe(g, { recursive: !0 }), await p(`git add "${g}"`)), c.children && c.children.length > 0 && await s(c.children, g);
|
|
2147
2157
|
}
|
|
2148
2158
|
}
|
|
2149
2159
|
await s(e, f.resolve(t));
|
|
2150
2160
|
}
|
|
2151
|
-
async function
|
|
2161
|
+
async function Vt(e) {
|
|
2152
2162
|
const t = {
|
|
2153
2163
|
id: 0,
|
|
2154
2164
|
name: "",
|
|
@@ -2157,7 +2167,7 @@ async function Gt(e) {
|
|
|
2157
2167
|
if (e)
|
|
2158
2168
|
Number.isNaN(Number(e)) && m("请输入正确的产品ID"), t.id = Number(e);
|
|
2159
2169
|
else {
|
|
2160
|
-
const a = await
|
|
2170
|
+
const a = await rs();
|
|
2161
2171
|
t.id = await k({
|
|
2162
2172
|
message: "请选择产品",
|
|
2163
2173
|
choices: a.map((n) => ({
|
|
@@ -2166,33 +2176,33 @@ async function Gt(e) {
|
|
|
2166
2176
|
}))
|
|
2167
2177
|
});
|
|
2168
2178
|
}
|
|
2169
|
-
return t.name = await
|
|
2179
|
+
return t.name = await os(t.id), t.path = f.join(Gt, Q("module", t.name, String(t.id))), t;
|
|
2170
2180
|
}
|
|
2171
|
-
async function
|
|
2172
|
-
return (await
|
|
2181
|
+
async function Ye(e) {
|
|
2182
|
+
return (await Ut(Gt)).find((a) => Number(a.id) === e.id);
|
|
2173
2183
|
}
|
|
2174
|
-
async function
|
|
2184
|
+
async function Wt(e, t) {
|
|
2175
2185
|
const a = {
|
|
2176
2186
|
precondition: e.precondition,
|
|
2177
2187
|
priority: e.pri,
|
|
2178
2188
|
steps: []
|
|
2179
2189
|
};
|
|
2180
|
-
a.steps = await
|
|
2190
|
+
a.steps = await ls(e.id), L.writeJSONSync(t, a, {
|
|
2181
2191
|
spaces: 2
|
|
2182
2192
|
});
|
|
2183
2193
|
}
|
|
2184
|
-
async function
|
|
2194
|
+
async function Ht(e, t) {
|
|
2185
2195
|
await fe(t, {
|
|
2186
2196
|
recursive: !0
|
|
2187
|
-
}), await
|
|
2197
|
+
}), await Wt(e, f.join(t, "config.json")), L.ensureFileSync(f.join(t, "data.yaml")), await _(
|
|
2188
2198
|
f.join(t, "data.yaml"),
|
|
2189
|
-
|
|
2199
|
+
j(f.resolve(K, "data.yaml")) ? await _e(f.resolve(K, "data.yaml")) : await Fs()
|
|
2190
2200
|
), L.ensureFileSync(f.join(t, "main.py")), await _(
|
|
2191
2201
|
f.join(t, "main.py"),
|
|
2192
|
-
|
|
2202
|
+
j(f.resolve(K, "main.py")) ? await _e(f.resolve(K, "main.py")) : await Gs()
|
|
2193
2203
|
);
|
|
2194
2204
|
}
|
|
2195
|
-
function
|
|
2205
|
+
function Xe(e) {
|
|
2196
2206
|
if (e) {
|
|
2197
2207
|
const t = e.split(",").map((a) => a.trim()).filter((a) => {
|
|
2198
2208
|
const n = Number(a);
|
|
@@ -2202,12 +2212,12 @@ function Ye(e) {
|
|
|
2202
2212
|
}
|
|
2203
2213
|
return [];
|
|
2204
2214
|
}
|
|
2205
|
-
async function
|
|
2215
|
+
async function Oe(e, t) {
|
|
2206
2216
|
ee(), H(), await ge();
|
|
2207
2217
|
let a;
|
|
2208
2218
|
t ? ([C.MODULE, C.CASE].includes(t) || m(`不支持的参数${t}。参数值应为 ${C.MODULE} 或者 ${C.CASE}。`), a = t) : a = await k({
|
|
2209
2219
|
message: `请选择要${e}的数据类型`,
|
|
2210
|
-
choices:
|
|
2220
|
+
choices: Ca
|
|
2211
2221
|
});
|
|
2212
2222
|
const n = a === C.MODULE ? "模块" : C.CASE === a ? "用例" : "";
|
|
2213
2223
|
return {
|
|
@@ -2215,19 +2225,19 @@ async function De(e, t) {
|
|
|
2215
2225
|
typeStr: n
|
|
2216
2226
|
};
|
|
2217
2227
|
}
|
|
2218
|
-
async function
|
|
2219
|
-
const t = await
|
|
2228
|
+
async function Me(e) {
|
|
2229
|
+
const t = await Vt(e), a = await Ye(t);
|
|
2220
2230
|
return a || m(`本地未找到产品【${t.name}[${t.id}]】`), {
|
|
2221
2231
|
product: t,
|
|
2222
2232
|
localProduct: a
|
|
2223
2233
|
};
|
|
2224
2234
|
}
|
|
2225
|
-
async function
|
|
2226
|
-
e.text = "查找本地产品目录...", await
|
|
2227
|
-
const s =
|
|
2235
|
+
async function ii(e, t, a) {
|
|
2236
|
+
e.text = "查找本地产品目录...", await Ye(t) || m(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
2237
|
+
const s = Xe(a);
|
|
2228
2238
|
let i = await ie(t.path);
|
|
2229
2239
|
e.text = "获取远程用例列表...";
|
|
2230
|
-
const o = await
|
|
2240
|
+
const o = await cs(t.id, s);
|
|
2231
2241
|
e.text = "本地用例同步中...";
|
|
2232
2242
|
for (const r of o) {
|
|
2233
2243
|
let c;
|
|
@@ -2235,26 +2245,26 @@ async function ni(e, t, a) {
|
|
|
2235
2245
|
return m(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
2236
2246
|
const u = i.find(({ id: l }) => r.id === Number(l));
|
|
2237
2247
|
if (u)
|
|
2238
|
-
u.displayName !== r.title && await
|
|
2248
|
+
u.displayName !== r.title && await je(u.path, r.title, u.type, u.id) && U(`重命名成功: ${u.displayName} -> ${r.title}`), i = await ie(t.path), r.module === 0 ? c = f.resolve(t.path) : c = i.find((l) => Number(l.id) === r.module)?.path || "", await Wt(
|
|
2239
2249
|
r,
|
|
2240
2250
|
f.join(c, Q("case", r.title, String(r.id)), "config.json")
|
|
2241
2251
|
);
|
|
2242
2252
|
else {
|
|
2243
2253
|
const l = f.join(c, Q("case", r.title, String(r.id)));
|
|
2244
|
-
await
|
|
2254
|
+
await Ht(r, l);
|
|
2245
2255
|
}
|
|
2246
2256
|
}
|
|
2247
2257
|
}
|
|
2248
|
-
async function ii(e, t) {
|
|
2249
|
-
e.text = "本地产品目录查找中...";
|
|
2250
|
-
const a = await Ke(t);
|
|
2251
|
-
a ? (e.text = "找到产品目录。开始重命名...", a.displayName !== t.name && await Te(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 = "获取远程模块列表...";
|
|
2252
|
-
const n = await It(t.id);
|
|
2253
|
-
e.text = "本地同步模块中...", await si(n || [], t.path);
|
|
2254
|
-
}
|
|
2255
2258
|
async function ri(e, t) {
|
|
2256
|
-
|
|
2257
|
-
|
|
2259
|
+
e.text = "本地产品目录查找中...";
|
|
2260
|
+
const a = await Ye(t);
|
|
2261
|
+
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 = "获取远程模块列表...";
|
|
2262
|
+
const n = await Rt(t.id);
|
|
2263
|
+
e.text = "本地同步模块中...", await ni(n || [], t.path);
|
|
2264
|
+
}
|
|
2265
|
+
async function oi(e, t) {
|
|
2266
|
+
const { type: a, typeStr: n } = await Oe("拉取", e), s = await Vt(t.productId), i = y(`${n}同步中...`).start();
|
|
2267
|
+
if (C.MODULE === a && await ri(i, s), C.CASE === a && await ii(i, s, t.caseIds), i.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await p("git status -s")) {
|
|
2258
2268
|
const o = y("代码提交中...").start();
|
|
2259
2269
|
try {
|
|
2260
2270
|
await p(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
|
|
@@ -2263,15 +2273,15 @@ async function ri(e, t) {
|
|
|
2263
2273
|
}
|
|
2264
2274
|
}
|
|
2265
2275
|
}
|
|
2266
|
-
P.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) => B(
|
|
2267
|
-
async function
|
|
2276
|
+
P.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) => B(oi, ...e));
|
|
2277
|
+
async function ci(e, t, a) {
|
|
2268
2278
|
let n = await F({
|
|
2269
2279
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
2270
2280
|
});
|
|
2271
2281
|
n = n.trim();
|
|
2272
2282
|
const s = y(`用例【${a}】开始创建...`).start();
|
|
2273
2283
|
s.text = "远程用例创建中...";
|
|
2274
|
-
const i = await
|
|
2284
|
+
const i = await ps({
|
|
2275
2285
|
product: Number(e.id),
|
|
2276
2286
|
// 如果父模块是产品根目录,parent=0
|
|
2277
2287
|
module: f.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
@@ -2280,14 +2290,14 @@ async function oi(e, t, a) {
|
|
|
2280
2290
|
openedBy: I("ldapAccount"),
|
|
2281
2291
|
precondition: n || ""
|
|
2282
2292
|
});
|
|
2283
|
-
s.text = "远程用例步骤创建中...", await
|
|
2293
|
+
s.text = "远程用例步骤创建中...", await ms({
|
|
2284
2294
|
case: i,
|
|
2285
2295
|
type: "step",
|
|
2286
2296
|
desc: "按照预期执行",
|
|
2287
2297
|
expect: "正常执行,符合预期"
|
|
2288
2298
|
}), s.text = "本地用例创建中...";
|
|
2289
2299
|
const o = f.join(t.path, Q("case", a, String(i)));
|
|
2290
|
-
return
|
|
2300
|
+
return j(o) ? U(`${o}已存在,请检查是否对应,本地不再创建。`) : (await Ht(
|
|
2291
2301
|
{
|
|
2292
2302
|
id: i,
|
|
2293
2303
|
pri: 3,
|
|
@@ -2296,10 +2306,10 @@ async function oi(e, t, a) {
|
|
|
2296
2306
|
o
|
|
2297
2307
|
), s.succeed(`用例【[${o}】创建完成 🎉`), o);
|
|
2298
2308
|
}
|
|
2299
|
-
async function
|
|
2309
|
+
async function li(e, t, a) {
|
|
2300
2310
|
const n = y(`模块【${a}】开始创建...`).start();
|
|
2301
2311
|
n.text = "远程模块创建中...";
|
|
2302
|
-
const s = await
|
|
2312
|
+
const s = await us({
|
|
2303
2313
|
root: Number(e.id),
|
|
2304
2314
|
name: a,
|
|
2305
2315
|
// 如果父模块是产品根目录,parent=0
|
|
@@ -2307,13 +2317,13 @@ async function ci(e, t, a) {
|
|
|
2307
2317
|
});
|
|
2308
2318
|
n.text = "本地模块创建中...";
|
|
2309
2319
|
const i = f.join(t.path, Q("module", a, String(s)));
|
|
2310
|
-
if (
|
|
2320
|
+
if (j(i))
|
|
2311
2321
|
return U(`${i}已存在,请检查是否对应,本地不再创建。`);
|
|
2312
2322
|
await fe(i, {
|
|
2313
2323
|
recursive: !0
|
|
2314
2324
|
}), n.succeed(`模块【${i}】创建完成 🎉`);
|
|
2315
2325
|
}
|
|
2316
|
-
function
|
|
2326
|
+
function ui(e) {
|
|
2317
2327
|
function t(n) {
|
|
2318
2328
|
if (!n.children || n.children.length === 0) return;
|
|
2319
2329
|
const s = n.children[0];
|
|
@@ -2337,9 +2347,9 @@ function li(e) {
|
|
|
2337
2347
|
}
|
|
2338
2348
|
return a(e);
|
|
2339
2349
|
}
|
|
2340
|
-
async function
|
|
2341
|
-
const { type: a, typeStr: n } = await
|
|
2342
|
-
if (!l?.path || !
|
|
2350
|
+
async function pi(e, t) {
|
|
2351
|
+
const { type: a, typeStr: n } = await Oe("创建", e), { product: s, localProduct: i } = await Me(t.productId), o = await Rt(s.id), r = await ui(o), c = Q("module", r.label, String(r.value)), l = (await ie(s.path, { hasRoot: !0 })).find((h) => h.name === c);
|
|
2352
|
+
if (!l?.path || !j(l.path))
|
|
2343
2353
|
return m(`本地不存在${c}模块`);
|
|
2344
2354
|
let d = await F({
|
|
2345
2355
|
message: `请输入你要创建的${n}名称`,
|
|
@@ -2348,7 +2358,7 @@ async function ui(e, t) {
|
|
|
2348
2358
|
});
|
|
2349
2359
|
d = d.trim();
|
|
2350
2360
|
let g = "";
|
|
2351
|
-
if (C.MODULE === a && await
|
|
2361
|
+
if (C.MODULE === a && await li(i, l, d), C.CASE === a && (g = await ci(i, l, d)), !t.disableAutoCommit && C.CASE === a) {
|
|
2352
2362
|
const h = y("代码提交中...").start();
|
|
2353
2363
|
try {
|
|
2354
2364
|
await p(`git add . && git commit -m "chore: 创建了用例${f.basename(g)}"`), h.succeed("代码已提交 ✅");
|
|
@@ -2357,8 +2367,8 @@ async function ui(e, t) {
|
|
|
2357
2367
|
}
|
|
2358
2368
|
}
|
|
2359
2369
|
}
|
|
2360
|
-
P.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => B(
|
|
2361
|
-
async function
|
|
2370
|
+
P.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => B(pi, ...e));
|
|
2371
|
+
async function mi(e, t) {
|
|
2362
2372
|
const n = (await ie(e.path)).filter((r) => r.type === "case");
|
|
2363
2373
|
let s = [];
|
|
2364
2374
|
if (t.length)
|
|
@@ -2385,15 +2395,15 @@ async function pi(e, t) {
|
|
|
2385
2395
|
});
|
|
2386
2396
|
}
|
|
2387
2397
|
const i = y("远程用例删除中...").start(), o = s.map((r) => r.id);
|
|
2388
|
-
await
|
|
2398
|
+
await fs({
|
|
2389
2399
|
product: Number(e.id),
|
|
2390
2400
|
caseIds: o
|
|
2391
2401
|
}), i.text = "本地用例删除中...";
|
|
2392
2402
|
for (const r of s)
|
|
2393
|
-
|
|
2403
|
+
j(r.path) && N.rm("-rf", r.path);
|
|
2394
2404
|
return i.succeed("用例删除完成"), o;
|
|
2395
2405
|
}
|
|
2396
|
-
async function
|
|
2406
|
+
async function di(e, t) {
|
|
2397
2407
|
const n = (await ie(e.path)).filter((r) => r.type === "module");
|
|
2398
2408
|
let s = [];
|
|
2399
2409
|
if (t.length)
|
|
@@ -2421,18 +2431,18 @@ async function mi(e, t) {
|
|
|
2421
2431
|
}
|
|
2422
2432
|
s = s.sort((r, c) => r.path.localeCompare(c.path));
|
|
2423
2433
|
const i = y("远程模块删除中...").start(), o = s.map((r) => r.id);
|
|
2424
|
-
await
|
|
2434
|
+
await ds({
|
|
2425
2435
|
product: Number(e.id),
|
|
2426
2436
|
moduleIds: o
|
|
2427
2437
|
}), i.text = "本地模块删除中...";
|
|
2428
2438
|
for (const r of s)
|
|
2429
|
-
|
|
2439
|
+
j(r.path) && N.rm("-rf", r.path);
|
|
2430
2440
|
return i.succeed("模块删除完成"), o;
|
|
2431
2441
|
}
|
|
2432
|
-
async function
|
|
2433
|
-
const { type: a, typeStr: n } = await
|
|
2442
|
+
async function fi(e, t) {
|
|
2443
|
+
const { type: a, typeStr: n } = await Oe("删除", e), { localProduct: s } = await Me(t.productId), i = Xe(t.targetIds);
|
|
2434
2444
|
let o = [];
|
|
2435
|
-
if (C.MODULE === a ? o = await
|
|
2445
|
+
if (C.MODULE === a ? o = await di(s, i) : C.CASE === a && (o = await mi(s, i)), !t.disableAutoCommit && await p("git status -s")) {
|
|
2436
2446
|
const r = y("代码提交中...").start();
|
|
2437
2447
|
try {
|
|
2438
2448
|
await p(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
@@ -2441,8 +2451,8 @@ async function di(e, t) {
|
|
|
2441
2451
|
}
|
|
2442
2452
|
}
|
|
2443
2453
|
}
|
|
2444
|
-
P.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) => B(
|
|
2445
|
-
async function
|
|
2454
|
+
P.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) => B(fi, ...e));
|
|
2455
|
+
async function gi(e, t) {
|
|
2446
2456
|
const n = (await ie(e.path)).filter((g) => g.type === "case");
|
|
2447
2457
|
let s;
|
|
2448
2458
|
if (t.targetId) {
|
|
@@ -2477,19 +2487,19 @@ async function fi(e, t) {
|
|
|
2477
2487
|
});
|
|
2478
2488
|
i = i.trim();
|
|
2479
2489
|
const o = y("用例重命名中...").start();
|
|
2480
|
-
i !== s.displayName ? (await
|
|
2490
|
+
i !== s.displayName ? (await hs({
|
|
2481
2491
|
id: Number(s.id),
|
|
2482
2492
|
name: i
|
|
2483
|
-
}), await
|
|
2493
|
+
}), await je(s.path, i, "case", String(s.id)) && o.succeed(`用例重命名成功: ${s.displayName} -> ${i}`), s.displayName = i, s.path = f.join(f.dirname(s.path), Q("case", i, String(s.id)))) : o.succeed("用例名称无变动");
|
|
2484
2494
|
let r = L.readJsonSync(f.join(s.path, "config.json")), c;
|
|
2485
|
-
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await
|
|
2495
|
+
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await at({
|
|
2486
2496
|
message: "修改用例优先级",
|
|
2487
2497
|
min: 1,
|
|
2488
2498
|
max: 5,
|
|
2489
2499
|
required: !0,
|
|
2490
2500
|
default: r.priority,
|
|
2491
2501
|
validate: (g) => g > 0 && g < 6
|
|
2492
|
-
}) : c = await
|
|
2502
|
+
}) : c = await at({
|
|
2493
2503
|
message: "修改用例优先级",
|
|
2494
2504
|
min: 1,
|
|
2495
2505
|
max: 5,
|
|
@@ -2498,7 +2508,7 @@ async function fi(e, t) {
|
|
|
2498
2508
|
validate: (g) => g > 0 && g < 6
|
|
2499
2509
|
});
|
|
2500
2510
|
const u = y("用例优先级设置中...").start();
|
|
2501
|
-
c !== r.priority ? (await
|
|
2511
|
+
c !== r.priority ? (await ws({
|
|
2502
2512
|
id: Number(s.id),
|
|
2503
2513
|
priority: c
|
|
2504
2514
|
}), L.writeJSONSync(
|
|
@@ -2516,7 +2526,7 @@ async function fi(e, t) {
|
|
|
2516
2526
|
prefill: "editable"
|
|
2517
2527
|
}), l = l.trim());
|
|
2518
2528
|
const d = y("用例前置条件设置中...").start();
|
|
2519
|
-
return l !== r.precondition ? (await
|
|
2529
|
+
return l !== r.precondition ? (await ys({
|
|
2520
2530
|
id: Number(s.id),
|
|
2521
2531
|
precondition: l
|
|
2522
2532
|
}), L.writeJSONSync(
|
|
@@ -2528,7 +2538,7 @@ async function fi(e, t) {
|
|
|
2528
2538
|
{ spaces: 2 }
|
|
2529
2539
|
), d.succeed(`用例前置条件修改成功:${r.precondition} -> ${l}`)) : d.succeed("用例前置条件无变动"), s.id;
|
|
2530
2540
|
}
|
|
2531
|
-
async function
|
|
2541
|
+
async function hi(e, t) {
|
|
2532
2542
|
const n = (await ie(e.path)).filter((r) => r.type === "module");
|
|
2533
2543
|
let s;
|
|
2534
2544
|
if (t.targetId) {
|
|
@@ -2563,15 +2573,15 @@ async function gi(e, t) {
|
|
|
2563
2573
|
});
|
|
2564
2574
|
i = i.trim();
|
|
2565
2575
|
const o = y("模块重命名中...").start();
|
|
2566
|
-
return i !== s.displayName ? (await
|
|
2576
|
+
return i !== s.displayName ? (await gs({
|
|
2567
2577
|
id: Number(s.id),
|
|
2568
2578
|
name: i
|
|
2569
|
-
}), await
|
|
2579
|
+
}), await je(s.path, i, "module", String(s.id)) && o.succeed(`模块重命名成功: ${s.displayName} -> ${i}`)) : o.succeed("模块名称无变动"), s.id;
|
|
2570
2580
|
}
|
|
2571
|
-
async function
|
|
2572
|
-
const { type: a, typeStr: n } = await
|
|
2581
|
+
async function wi(e, t) {
|
|
2582
|
+
const { type: a, typeStr: n } = await Oe("修改", e), { localProduct: s } = await Me(t.productId);
|
|
2573
2583
|
let i;
|
|
2574
|
-
if (C.MODULE === a ? i = await
|
|
2584
|
+
if (C.MODULE === a ? i = await hi(s, t) : C.CASE === a && (i = await gi(s, t)), !t.disableAutoCommit && await p("git status -s")) {
|
|
2575
2585
|
const o = y("代码提交中...").start();
|
|
2576
2586
|
try {
|
|
2577
2587
|
await p(`git add . && git commit -m 'chore: 修改了一个${n}(${i})'`), o.succeed("代码已提交 ✅");
|
|
@@ -2580,11 +2590,11 @@ async function hi(e, t) {
|
|
|
2580
2590
|
}
|
|
2581
2591
|
}
|
|
2582
2592
|
}
|
|
2583
|
-
P.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) => B(
|
|
2584
|
-
async function
|
|
2593
|
+
P.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) => B(wi, ...e));
|
|
2594
|
+
async function yi(e, t) {
|
|
2585
2595
|
if (!e.length)
|
|
2586
2596
|
return [];
|
|
2587
|
-
const a =
|
|
2597
|
+
const a = ha(20), n = e.map(
|
|
2588
2598
|
(s) => a(async () => {
|
|
2589
2599
|
try {
|
|
2590
2600
|
const i = t.env || "production", o = await p(`python ${s.path}/main.py --env ${i}`);
|
|
@@ -2601,9 +2611,9 @@ async function wi(e, t) {
|
|
|
2601
2611
|
);
|
|
2602
2612
|
return await Promise.all(n), e;
|
|
2603
2613
|
}
|
|
2604
|
-
async function
|
|
2614
|
+
async function $i(e) {
|
|
2605
2615
|
ee(), H();
|
|
2606
|
-
const { localProduct: t } = await
|
|
2616
|
+
const { localProduct: t } = await Me(e.productId);
|
|
2607
2617
|
let a = [];
|
|
2608
2618
|
const s = (await ie(t.path)).filter((c) => c.type === "case");
|
|
2609
2619
|
if (e.all)
|
|
@@ -2613,7 +2623,7 @@ async function yi(e) {
|
|
|
2613
2623
|
displayName: c.displayName
|
|
2614
2624
|
}));
|
|
2615
2625
|
else {
|
|
2616
|
-
const c =
|
|
2626
|
+
const c = Xe(e.caseIds);
|
|
2617
2627
|
if (c.length)
|
|
2618
2628
|
a = s.filter((u) => c.includes(Number(u.id))).map((u) => ({
|
|
2619
2629
|
id: Number(u.id),
|
|
@@ -2640,7 +2650,7 @@ async function yi(e) {
|
|
|
2640
2650
|
});
|
|
2641
2651
|
}
|
|
2642
2652
|
}
|
|
2643
|
-
const i = y("用例执行中...").start(), r = (await
|
|
2653
|
+
const i = y("用例执行中...").start(), r = (await yi(a, e)).filter((c) => c.result.length);
|
|
2644
2654
|
if (r.length === 0)
|
|
2645
2655
|
i.succeed("所有用例执行通过 🎉");
|
|
2646
2656
|
else {
|
|
@@ -2652,10 +2662,10 @@ async function yi(e) {
|
|
|
2652
2662
|
if (e.executionId)
|
|
2653
2663
|
Number.isNaN(Number(e.executionId)) && m(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
|
|
2654
2664
|
else {
|
|
2655
|
-
const d = await
|
|
2665
|
+
const d = await vs(), g = await k({
|
|
2656
2666
|
message: "请选择用例执行出错后,BUG所属的项目",
|
|
2657
2667
|
choices: d.map(({ id: v, name: R }) => ({ name: R, value: v }))
|
|
2658
|
-
}), h = await
|
|
2668
|
+
}), h = await As(g);
|
|
2659
2669
|
u = await k({
|
|
2660
2670
|
message: "请选择用例执行出错后,BUG所属的执行",
|
|
2661
2671
|
choices: h.map(({ id: v, name: R }) => ({ name: R, value: v }))
|
|
@@ -2665,7 +2675,7 @@ async function yi(e) {
|
|
|
2665
2675
|
if (e.buildId)
|
|
2666
2676
|
l = e.buildId;
|
|
2667
2677
|
else {
|
|
2668
|
-
const d = await
|
|
2678
|
+
const d = await bs(Number(u));
|
|
2669
2679
|
if (d.length) {
|
|
2670
2680
|
const g = await Re({
|
|
2671
2681
|
message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
|
|
@@ -2681,7 +2691,7 @@ async function yi(e) {
|
|
|
2681
2691
|
}
|
|
2682
2692
|
i.start("上传中...");
|
|
2683
2693
|
for (const d of r)
|
|
2684
|
-
await
|
|
2694
|
+
await $s({
|
|
2685
2695
|
caseId: d.id,
|
|
2686
2696
|
caseResult: "fail",
|
|
2687
2697
|
stepResults: d.result,
|
|
@@ -2694,12 +2704,12 @@ async function yi(e) {
|
|
|
2694
2704
|
);
|
|
2695
2705
|
}
|
|
2696
2706
|
}
|
|
2697
|
-
P.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) => B(
|
|
2698
|
-
const
|
|
2699
|
-
const { projects: e } = await
|
|
2707
|
+
P.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) => B($i, ...e));
|
|
2708
|
+
const vi = async () => {
|
|
2709
|
+
const { projects: e } = await Os(), t = V();
|
|
2700
2710
|
if (t.serverProjectURL) {
|
|
2701
2711
|
const n = e.find(
|
|
2702
|
-
(s) =>
|
|
2712
|
+
(s) => Pe(s.url, t.serverProjectURL)
|
|
2703
2713
|
);
|
|
2704
2714
|
if (n)
|
|
2705
2715
|
return {
|
|
@@ -2714,11 +2724,11 @@ const $i = async () => {
|
|
|
2714
2724
|
value: n.url
|
|
2715
2725
|
}))
|
|
2716
2726
|
});
|
|
2717
|
-
return
|
|
2727
|
+
return It({ ...t, serverProjectURL: a }), {
|
|
2718
2728
|
projectId: decodeURIComponent(se(a)),
|
|
2719
2729
|
moduleList: e.find((n) => n.url === a)?.modules || []
|
|
2720
2730
|
};
|
|
2721
|
-
},
|
|
2731
|
+
}, Ai = async (e, t) => {
|
|
2722
2732
|
const a = t ? t.split(",").filter((s) => e.map((i) => i.name).includes(s.trim())) : [];
|
|
2723
2733
|
if (a.length)
|
|
2724
2734
|
return a;
|
|
@@ -2733,42 +2743,42 @@ const $i = async () => {
|
|
|
2733
2743
|
loop: !0
|
|
2734
2744
|
});
|
|
2735
2745
|
return n?.length ? n : e.map((s) => s.name);
|
|
2736
|
-
},
|
|
2746
|
+
}, pt = [O.DEV, O.TEST], bi = async (e) => e && pt.includes(e.trim()) ? e : await k({
|
|
2737
2747
|
message: "请选择对应的环境",
|
|
2738
|
-
choices:
|
|
2739
|
-
}),
|
|
2748
|
+
choices: At.filter((t) => pt.includes(t.value))
|
|
2749
|
+
}), Qe = (e) => {
|
|
2740
2750
|
const t = /^https?:\/\/[^/]+\/api\/([^/]+)\/v3\//;
|
|
2741
2751
|
return e.match(t)?.[1];
|
|
2742
|
-
},
|
|
2752
|
+
}, Si = async (e, t) => {
|
|
2743
2753
|
try {
|
|
2744
2754
|
const a = await ne({
|
|
2745
2755
|
url: e,
|
|
2746
2756
|
method: "get"
|
|
2747
|
-
}), n =
|
|
2757
|
+
}), n = Qe(e);
|
|
2748
2758
|
return n && (a.paths = Object.fromEntries(
|
|
2749
2759
|
Object.entries(a.paths).map(([s, i]) => [`/${n}${s}`, i])
|
|
2750
|
-
)),
|
|
2760
|
+
)), wa(a, {
|
|
2751
2761
|
throwOnValidateError: !t
|
|
2752
2762
|
});
|
|
2753
2763
|
} catch (a) {
|
|
2754
2764
|
throw m(`Error fetching Swagger JSON: ${a.message}`), a;
|
|
2755
2765
|
}
|
|
2756
|
-
},
|
|
2766
|
+
}, Ni = (e) => {
|
|
2757
2767
|
const t = (a) => {
|
|
2758
2768
|
const { reason: n, url: s } = a;
|
|
2759
|
-
return `## ${
|
|
2769
|
+
return `## ${Qe(s)}服务接口文档校验失败
|
|
2760
2770
|
${n.message}`;
|
|
2761
2771
|
};
|
|
2762
2772
|
return `# 服务端接口文档校验失败
|
|
2763
2773
|
${e.map(t).join(`
|
|
2764
2774
|
`)}`;
|
|
2765
|
-
},
|
|
2766
|
-
const a =
|
|
2767
|
-
(c) => c.projects.some((u) =>
|
|
2775
|
+
}, ji = async (e, t) => {
|
|
2776
|
+
const a = Ni(e), n = V(), { groups: s } = await Ct(), i = s.find(
|
|
2777
|
+
(c) => c.projects.some((u) => Pe(u, n.serverProjectURL))
|
|
2768
2778
|
);
|
|
2769
2779
|
t.fail("API数据解析失败"), i || (t.fail("未找到对应的项目群聊组!"), process.stdout.write(`${A.red(a)}
|
|
2770
2780
|
`), process.exit(1));
|
|
2771
|
-
const { code: o, message: r } = await
|
|
2781
|
+
const { code: o, message: r } = await Ss({
|
|
2772
2782
|
content: a,
|
|
2773
2783
|
webhooks: [i.url]
|
|
2774
2784
|
});
|
|
@@ -2784,11 +2794,11 @@ ${e.map(t).join(`
|
|
|
2784
2794
|
});
|
|
2785
2795
|
if (!o.length)
|
|
2786
2796
|
throw new Error("Failed to fetch Swagger JSON");
|
|
2787
|
-
const r = y("API数据请求中...").start(), c = await Promise.allSettled(o.map((l) =>
|
|
2797
|
+
const r = y("API数据请求中...").start(), c = await Promise.allSettled(o.map((l) => Si(l, s))), u = c.flatMap(
|
|
2788
2798
|
(l, d) => l.status === "rejected" ? [{ reason: l.reason, url: o[d] }] : []
|
|
2789
2799
|
);
|
|
2790
|
-
return u.length && await
|
|
2791
|
-
},
|
|
2800
|
+
return u.length && await ji(u, r), r.succeed("API数据请求成功"), c.flatMap((l, d) => l.status === "fulfilled" ? [{ serverName: Qe(o[d]), swaggerJson: l.value }] : []);
|
|
2801
|
+
}, ki = () => k({
|
|
2792
2802
|
message: "请选择生成API的范围",
|
|
2793
2803
|
choices: [
|
|
2794
2804
|
{
|
|
@@ -2824,28 +2834,28 @@ ${e.map(t).join(`
|
|
|
2824
2834
|
}
|
|
2825
2835
|
} : void 0
|
|
2826
2836
|
});
|
|
2827
|
-
},
|
|
2837
|
+
}, mt = (e) => {
|
|
2828
2838
|
const t = e.trim();
|
|
2829
2839
|
if (!t)
|
|
2830
2840
|
return "请输入生成目录";
|
|
2831
2841
|
if (t.includes("\0"))
|
|
2832
2842
|
return "路径格式不合法";
|
|
2833
|
-
if (
|
|
2843
|
+
if (ia(t))
|
|
2834
2844
|
return "只允许输入相对路径";
|
|
2835
|
-
const a =
|
|
2836
|
-
return !a || a === "." || a === ".." ? "请输入有效的目录路径" : a.startsWith(`..${
|
|
2837
|
-
},
|
|
2845
|
+
const a = ra(t);
|
|
2846
|
+
return !a || a === "." || a === ".." ? "请输入有效的目录路径" : a.startsWith(`..${oa}`) ? "路径不能跳出当前项目" : !0;
|
|
2847
|
+
}, Ei = (e) => {
|
|
2838
2848
|
if (e) {
|
|
2839
|
-
const t =
|
|
2849
|
+
const t = mt(e);
|
|
2840
2850
|
return t !== !0 && m(t), e;
|
|
2841
2851
|
}
|
|
2842
2852
|
return F({
|
|
2843
2853
|
message: "请输入 API 输出目录,默认为 src/services",
|
|
2844
2854
|
default: "src/services",
|
|
2845
|
-
validate:
|
|
2855
|
+
validate: mt
|
|
2846
2856
|
});
|
|
2847
2857
|
};
|
|
2848
|
-
class
|
|
2858
|
+
class qt {
|
|
2849
2859
|
o;
|
|
2850
2860
|
options;
|
|
2851
2861
|
async generateApi(t) {
|
|
@@ -2857,7 +2867,7 @@ class Wt {
|
|
|
2857
2867
|
const t = [], a = this.options.remoteSwaggerJsons.map((n) => n.swaggerJson);
|
|
2858
2868
|
this.o.text = "获取 API 列表...";
|
|
2859
2869
|
for (const n of a) {
|
|
2860
|
-
const { apis: s } = await
|
|
2870
|
+
const { apis: s } = await ya(n, {
|
|
2861
2871
|
throwOnValidateError: !this.options.skipSwaggerValidate
|
|
2862
2872
|
});
|
|
2863
2873
|
t.push(...s.map((i) => ({ name: `${i.path}${i.summary ? `(${i.summary})` : ""}`, value: i.path })));
|
|
@@ -2879,8 +2889,8 @@ class Wt {
|
|
|
2879
2889
|
async startGenerateAllApi() {
|
|
2880
2890
|
const t = await this.generateAllApi();
|
|
2881
2891
|
this.o.stop();
|
|
2882
|
-
const a = await
|
|
2883
|
-
|
|
2892
|
+
const a = await Ei(this.options.dir), n = pe(a);
|
|
2893
|
+
ta(n, { recursive: !0 });
|
|
2884
2894
|
const s = [];
|
|
2885
2895
|
this.o.start(), this.o.text = "API 生成中...";
|
|
2886
2896
|
for (const i of t) {
|
|
@@ -2890,13 +2900,13 @@ class Wt {
|
|
|
2890
2900
|
this.o.text = "开始格式化代码", await this.formatApiContent(s), this.o.text = "代码格式化完成", this.o.succeed(`API 已生成到 ${a} 目录下`);
|
|
2891
2901
|
}
|
|
2892
2902
|
}
|
|
2893
|
-
class
|
|
2903
|
+
class Ii extends qt {
|
|
2894
2904
|
formatApiContent() {
|
|
2895
2905
|
return this.o.succeed("yaml 暂无格式化配置"), Promise.resolve();
|
|
2896
2906
|
}
|
|
2897
2907
|
generateAllApi() {
|
|
2898
2908
|
const t = this.options.remoteSwaggerJsons.map((a) => a.swaggerJson);
|
|
2899
|
-
return
|
|
2909
|
+
return $a(
|
|
2900
2910
|
t.map((a) => ({
|
|
2901
2911
|
swaggerJson: a,
|
|
2902
2912
|
throwOnValidateError: !this.options.skipSwaggerValidate
|
|
@@ -2908,26 +2918,26 @@ class Ei extends Wt {
|
|
|
2908
2918
|
for (const { swaggerJson: s, serverName: i } of a) {
|
|
2909
2919
|
if (!t.some((r) => r.startsWith(`/${i}`)))
|
|
2910
2920
|
continue;
|
|
2911
|
-
const o = await
|
|
2921
|
+
const o = await va({
|
|
2912
2922
|
swaggerJson: s,
|
|
2913
2923
|
controller: t,
|
|
2914
2924
|
throwOnValidateError: !n,
|
|
2915
2925
|
showHeaderComment: !1
|
|
2916
2926
|
});
|
|
2917
|
-
console.log(
|
|
2927
|
+
console.log(ht(o, { language: "typescript", ignoreIllegals: !0 }));
|
|
2918
2928
|
}
|
|
2919
2929
|
}
|
|
2920
2930
|
}
|
|
2921
|
-
const
|
|
2931
|
+
const Ri = new wt({
|
|
2922
2932
|
fix: !0
|
|
2923
2933
|
});
|
|
2924
|
-
class
|
|
2934
|
+
class Ci extends qt {
|
|
2925
2935
|
async formatApiContent(t) {
|
|
2926
2936
|
try {
|
|
2927
|
-
const a = await
|
|
2928
|
-
await
|
|
2937
|
+
const a = await Ri.lintFiles(t);
|
|
2938
|
+
await wt.outputFixes(a);
|
|
2929
2939
|
for (const n of t) {
|
|
2930
|
-
const s = pe(n), i =
|
|
2940
|
+
const s = pe(n), i = dt(s, "utf-8"), o = await Sa.format(i, {
|
|
2931
2941
|
filepath: s
|
|
2932
2942
|
});
|
|
2933
2943
|
ve(s, o);
|
|
@@ -2938,7 +2948,7 @@ class Ri extends Wt {
|
|
|
2938
2948
|
}
|
|
2939
2949
|
generateAllApi() {
|
|
2940
2950
|
const t = this.options.remoteSwaggerJsons.map((a) => a.swaggerJson);
|
|
2941
|
-
return
|
|
2951
|
+
return Aa(
|
|
2942
2952
|
t.map((a) => ({
|
|
2943
2953
|
swaggerJson: a,
|
|
2944
2954
|
throwOnValidateError: !this.options.skipSwaggerValidate
|
|
@@ -2950,45 +2960,45 @@ class Ri extends Wt {
|
|
|
2950
2960
|
for (const { swaggerJson: s, serverName: i } of a) {
|
|
2951
2961
|
if (!t.some((r) => r.startsWith(`/${i}`)))
|
|
2952
2962
|
continue;
|
|
2953
|
-
const o = await
|
|
2963
|
+
const o = await ba({
|
|
2954
2964
|
swaggerJson: s,
|
|
2955
2965
|
merge: !0,
|
|
2956
2966
|
controller: t,
|
|
2957
2967
|
throwOnValidateError: !n,
|
|
2958
2968
|
importMethods: !1
|
|
2959
2969
|
});
|
|
2960
|
-
console.log(
|
|
2970
|
+
console.log(ht(o, { language: "typescript", ignoreIllegals: !0 }));
|
|
2961
2971
|
}
|
|
2962
2972
|
}
|
|
2963
2973
|
}
|
|
2964
|
-
const
|
|
2974
|
+
const Li = (e) => {
|
|
2965
2975
|
switch (e) {
|
|
2966
2976
|
case $.JAVASCRIPT:
|
|
2967
|
-
return
|
|
2977
|
+
return Ci;
|
|
2968
2978
|
case $.PYTHON:
|
|
2969
|
-
return
|
|
2979
|
+
return Ii;
|
|
2970
2980
|
}
|
|
2971
|
-
},
|
|
2972
|
-
const { apiType: t } = e, a =
|
|
2981
|
+
}, xi = async (e) => {
|
|
2982
|
+
const { apiType: t } = e, a = Li(t);
|
|
2973
2983
|
a ? await new a().generateApi(e) : m(`不支持 ${t} 语言`);
|
|
2974
2984
|
};
|
|
2975
|
-
async function
|
|
2985
|
+
async function Pi(e) {
|
|
2976
2986
|
ee(), H();
|
|
2977
|
-
const { moduleList: t } = await
|
|
2987
|
+
const { moduleList: t } = await vi(), { services: a, env: n, skipSwaggerValidate: s = !1 } = e, i = await Ai(t, a), o = Ze(), r = await bi(n), c = await Ti({
|
|
2978
2988
|
moduleList: t,
|
|
2979
2989
|
services: i,
|
|
2980
2990
|
env: r,
|
|
2981
2991
|
skipSwaggerValidate: s
|
|
2982
|
-
}), u = await
|
|
2983
|
-
await
|
|
2992
|
+
}), u = await ki();
|
|
2993
|
+
await xi({
|
|
2984
2994
|
remoteSwaggerJsons: c,
|
|
2985
2995
|
...e,
|
|
2986
2996
|
scope: u,
|
|
2987
2997
|
apiType: o
|
|
2988
2998
|
}), process.exit(0);
|
|
2989
2999
|
}
|
|
2990
|
-
P.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) => B(
|
|
2991
|
-
const
|
|
3000
|
+
P.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) => B(Pi, ...e));
|
|
3001
|
+
const Di = 10, Oi = async () => {
|
|
2992
3002
|
const e = await p("git branch --show-current"), t = [
|
|
2993
3003
|
w.MASTER,
|
|
2994
3004
|
// 本地当前分支
|
|
@@ -3003,8 +3013,8 @@ const Pi = 10, Di = async () => {
|
|
|
3003
3013
|
name: n,
|
|
3004
3014
|
value: n
|
|
3005
3015
|
}));
|
|
3006
|
-
},
|
|
3007
|
-
`git log ${e} -n ${
|
|
3016
|
+
}, Mi = async (e) => (await p(
|
|
3017
|
+
`git log ${e} -n ${Di} --format="%H%x1f%s%x1f%an%x1f%ae%x1f%aI" --no-merges`
|
|
3008
3018
|
)).trim().split(`
|
|
3009
3019
|
`).filter((a) => a.trim() !== "").map((a) => {
|
|
3010
3020
|
const [n = "", s = "", i = "", o = "", r = ""] = a.split("");
|
|
@@ -3015,7 +3025,7 @@ const Pi = 10, Di = async () => {
|
|
|
3015
3025
|
authorEmail: o,
|
|
3016
3026
|
authorDate: r
|
|
3017
3027
|
};
|
|
3018
|
-
}),
|
|
3028
|
+
}), Bi = (e) => p(`git show -s --format=%B ${e}`, { removeTailLinkBreak: !1 }), he = (e) => typeof e == "string" ? e : "", we = (e, t = {}) => {
|
|
3019
3029
|
const a = N.config.fatal;
|
|
3020
3030
|
N.config.fatal = !1;
|
|
3021
3031
|
try {
|
|
@@ -3025,15 +3035,15 @@ const Pi = 10, Di = async () => {
|
|
|
3025
3035
|
}
|
|
3026
3036
|
}, ye = (e, t) => {
|
|
3027
3037
|
e.text = t, e.render();
|
|
3028
|
-
},
|
|
3038
|
+
}, zi = (e) => /with conflicts|merge conflict|CONFLICT|patch does not apply/i.test(e), _i = async () => {
|
|
3029
3039
|
try {
|
|
3030
3040
|
return (await p("git diff --name-only --diff-filter=U")).split(`
|
|
3031
3041
|
`).map((t) => t.trim()).filter(Boolean);
|
|
3032
3042
|
} catch {
|
|
3033
3043
|
return [];
|
|
3034
3044
|
}
|
|
3035
|
-
},
|
|
3036
|
-
const a =
|
|
3045
|
+
}, Fi = async (e, t) => {
|
|
3046
|
+
const a = aa(pe(ua(), "z-pick-commit-")), n = pe(a, `${e.hash}.patch`), s = pe(a, `${e.hash}.message`);
|
|
3037
3047
|
try {
|
|
3038
3048
|
ye(t, `正在生成 patch: ${e.hash.slice(0, 8)} ${e.message}`);
|
|
3039
3049
|
const i = we(`git format-patch -1 ${e.hash} --stdout --binary --full-index`, {
|
|
@@ -3044,7 +3054,7 @@ const Pi = 10, Di = async () => {
|
|
|
3044
3054
|
status: "failed",
|
|
3045
3055
|
message: he(i.stderr) || `生成 patch 失败: ${e.hash}`
|
|
3046
3056
|
};
|
|
3047
|
-
if (ve(n, he(i.stdout)), ve(s, await
|
|
3057
|
+
if (ve(n, he(i.stdout)), ve(s, await Bi(e.hash)), ye(t, `正在检查 patch 是否已存在: ${e.hash.slice(0, 8)} ${e.message}`), we(`git apply --reverse --check "${n}"`, {
|
|
3048
3058
|
silent: !0
|
|
3049
3059
|
}).code === 0)
|
|
3050
3060
|
return {
|
|
@@ -3057,10 +3067,10 @@ const Pi = 10, Di = async () => {
|
|
|
3057
3067
|
});
|
|
3058
3068
|
if (r.code !== 0) {
|
|
3059
3069
|
const l = he(r.stderr) || `应用 patch 失败: ${e.hash}`;
|
|
3060
|
-
return
|
|
3070
|
+
return zi(l) ? {
|
|
3061
3071
|
status: "conflict",
|
|
3062
3072
|
message: l,
|
|
3063
|
-
conflictFiles: await
|
|
3073
|
+
conflictFiles: await _i()
|
|
3064
3074
|
} : {
|
|
3065
3075
|
status: "failed",
|
|
3066
3076
|
message: l
|
|
@@ -3086,20 +3096,20 @@ const Pi = 10, Di = async () => {
|
|
|
3086
3096
|
status: "success"
|
|
3087
3097
|
};
|
|
3088
3098
|
} finally {
|
|
3089
|
-
delete N.env.GIT_AUTHOR_NAME, delete N.env.GIT_AUTHOR_EMAIL, delete N.env.GIT_AUTHOR_DATE,
|
|
3099
|
+
delete N.env.GIT_AUTHOR_NAME, delete N.env.GIT_AUTHOR_EMAIL, delete N.env.GIT_AUTHOR_DATE, sa(a, {
|
|
3090
3100
|
force: !0,
|
|
3091
3101
|
recursive: !0
|
|
3092
3102
|
});
|
|
3093
3103
|
}
|
|
3094
|
-
},
|
|
3104
|
+
}, Zt = (e) => e.slice(0, 8), Gi = (e) => e.replace("T", " ").slice(0, 16), Ji = (e) => `${Gi(e.authorDate)} ${e.authorName} ${Zt(e.hash)} ${e.message}`, Ui = (e, t) => t.map((a) => e.find((n) => n.hash === a)).filter((a) => !!a).sort((a, n) => {
|
|
3095
3105
|
const s = e.indexOf(a);
|
|
3096
3106
|
return e.indexOf(n) - s;
|
|
3097
3107
|
});
|
|
3098
|
-
async function
|
|
3108
|
+
async function Vi() {
|
|
3099
3109
|
ee(), H(), await ge();
|
|
3100
3110
|
const e = y("获取分支列表中...").start();
|
|
3101
3111
|
await p("git fetch -p");
|
|
3102
|
-
const t = await
|
|
3112
|
+
const t = await Oi();
|
|
3103
3113
|
e.succeed("获取分支列表成功");
|
|
3104
3114
|
const a = await Je({
|
|
3105
3115
|
message: "选择需要pick的分支",
|
|
@@ -3109,7 +3119,7 @@ async function Ui() {
|
|
|
3109
3119
|
});
|
|
3110
3120
|
if (!a)
|
|
3111
3121
|
return;
|
|
3112
|
-
const n = await
|
|
3122
|
+
const n = await Mi(a), s = n.map((r) => ({
|
|
3113
3123
|
name: Ji(r),
|
|
3114
3124
|
value: r.hash
|
|
3115
3125
|
})), i = await Je({
|
|
@@ -3118,43 +3128,43 @@ async function Ui() {
|
|
|
3118
3128
|
emptyValidateMsg: "至少选择一个commit",
|
|
3119
3129
|
formatShowToValue: (r) => r.map((c) => {
|
|
3120
3130
|
const u = n.find((l) => l.hash === c.value);
|
|
3121
|
-
return u ?
|
|
3131
|
+
return u ? Zt(u.hash) : String(c.value);
|
|
3122
3132
|
}).join(", ")
|
|
3123
3133
|
});
|
|
3124
3134
|
if (!i?.length)
|
|
3125
3135
|
return;
|
|
3126
|
-
const o =
|
|
3136
|
+
const o = Ui(n, i);
|
|
3127
3137
|
e.start(`开始处理分支 ${a} 的 commit...`);
|
|
3128
3138
|
for (const r of o) {
|
|
3129
|
-
const c = await
|
|
3139
|
+
const c = await Fi(r, e);
|
|
3130
3140
|
if (c.status === "skipped")
|
|
3131
3141
|
e.warn(c.reason);
|
|
3132
3142
|
else if (c.status === "success")
|
|
3133
3143
|
e.succeed(`已提交: ${r.hash.slice(0, 8)} ${r.message}`);
|
|
3134
3144
|
else if (c.status === "conflict") {
|
|
3135
|
-
e.fail(`处理失败: ${r.hash.slice(0, 8)} ${r.message}`),
|
|
3145
|
+
e.fail(`处理失败: ${r.hash.slice(0, 8)} ${r.message}`), J("检测到 patch 冲突,已停止后续 commit 处理。"), J(`冲突提交: ${r.hash.slice(0, 8)} ${r.message}`), c.conflictFiles.length && J(`冲突文件:
|
|
3136
3146
|
${c.conflictFiles.join(`
|
|
3137
|
-
`)}`),
|
|
3147
|
+
`)}`), J("请先手动解决冲突并处理当前工作区,再重新执行 pick-commit。"), await _(Se(), r.message, "utf-8");
|
|
3138
3148
|
return;
|
|
3139
3149
|
} else {
|
|
3140
|
-
e.fail(`处理失败: ${r.hash.slice(0, 8)} ${r.message}`),
|
|
3150
|
+
e.fail(`处理失败: ${r.hash.slice(0, 8)} ${r.message}`), J(c.message);
|
|
3141
3151
|
return;
|
|
3142
3152
|
}
|
|
3143
3153
|
e.start(`继续处理分支 ${a} 的下一个 commit...`);
|
|
3144
3154
|
}
|
|
3145
3155
|
e.succeed(`分支 ${a} 处理完成`), e.succeed("pick commit 完成");
|
|
3146
3156
|
}
|
|
3147
|
-
P.command("pick").alias("p").description("从其他分支选择并应用 Commit内容 到当前分支").action((...e) => B(
|
|
3148
|
-
function
|
|
3157
|
+
P.command("pick").alias("p").description("从其他分支选择并应用 Commit内容 到当前分支").action((...e) => B(Vi, ...e));
|
|
3158
|
+
function Wi() {
|
|
3149
3159
|
process.on("unhandledRejection", (e) => {
|
|
3150
3160
|
}), process.on("uncaughtException", (e) => {
|
|
3151
3161
|
}), N.config.fatal = !0, N.config.silent = !0, N.config.verbose = !1;
|
|
3152
3162
|
}
|
|
3153
|
-
async function
|
|
3163
|
+
async function Hi() {
|
|
3154
3164
|
const e = be("latestCheckVersionTimestamp"), t = be("versionCheckDuring");
|
|
3155
3165
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
3156
3166
|
const a = await He();
|
|
3157
|
-
|
|
3167
|
+
De(a);
|
|
3158
3168
|
let n;
|
|
3159
3169
|
try {
|
|
3160
3170
|
const s = "TIME_OUT", i = new Promise((o) => {
|
|
@@ -3163,23 +3173,23 @@ async function Wi() {
|
|
|
3163
3173
|
n = await Promise.race([
|
|
3164
3174
|
i,
|
|
3165
3175
|
p(`npm view ${ce.name} version --registry https://registry.npmmirror.com/`)
|
|
3166
|
-
]), n !== s && n !== ce.version && (console.log(`${A.blue(ce.name)}本地版本为${ce.version},低于线上版本${n},开始升级`), await
|
|
3176
|
+
]), n !== s && n !== ce.version && (console.log(`${A.blue(ce.name)}本地版本为${ce.version},低于线上版本${n},开始升级`), await Ft(n)), de("latestCheckVersionTimestamp", Date.now()), X();
|
|
3167
3177
|
} catch (s) {
|
|
3168
3178
|
console.log("升级出错!请重试,或者手动升级"), m(s);
|
|
3169
3179
|
}
|
|
3170
3180
|
}
|
|
3171
3181
|
}
|
|
3172
|
-
async function
|
|
3173
|
-
const e =
|
|
3182
|
+
async function qi() {
|
|
3183
|
+
const e = Na(process.argv.slice(2));
|
|
3174
3184
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
3175
|
-
if (
|
|
3185
|
+
if (jt()) {
|
|
3176
3186
|
const t = L.readJSONSync(xe());
|
|
3177
|
-
E(t.profile), de(t.main),
|
|
3187
|
+
E(t.profile), de(t.main), De(t.constants), await Hi();
|
|
3178
3188
|
} else
|
|
3179
|
-
m(`请先初始化z-develop(执行 z i)。更多见${
|
|
3189
|
+
m(`请先初始化z-develop(执行 z i)。更多见${bt}`);
|
|
3180
3190
|
}
|
|
3181
|
-
async function
|
|
3182
|
-
|
|
3191
|
+
async function Zi() {
|
|
3192
|
+
Wi(), await qi();
|
|
3183
3193
|
}
|
|
3184
|
-
P.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${A.blue(
|
|
3194
|
+
P.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${A.blue(bt)}`).usage("<command> [options]").hook("preAction", Zi).version(ce.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
3185
3195
|
P.parse();
|