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