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