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