cli-z-develop 0.11.0 → 0.11.1
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 +264 -264
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { program as D } from "commander";
|
|
2
|
-
import
|
|
3
|
-
import { existsSync as v, readdirSync as
|
|
4
|
-
import { readdir as Ce, mkdir as le, writeFile as O, rename as
|
|
2
|
+
import $t from "node:child_process";
|
|
3
|
+
import { existsSync as v, readdirSync as vt, lstatSync as Nt, createWriteStream as bt } from "node:fs";
|
|
4
|
+
import { readdir as Ce, mkdir as le, writeFile as O, rename as Fe, readFile as Ee, stat as At } from "node:fs/promises";
|
|
5
5
|
import m from "node:path";
|
|
6
|
-
import ce, { AxiosError as
|
|
6
|
+
import ce, { AxiosError as St } from "axios";
|
|
7
7
|
import j from "chalk";
|
|
8
|
-
import
|
|
8
|
+
import jt from "dayjs";
|
|
9
9
|
import L from "shelljs";
|
|
10
|
-
import
|
|
10
|
+
import Tt from "node:os";
|
|
11
11
|
import Oe from "child_process";
|
|
12
|
-
import { confirm as
|
|
12
|
+
import { confirm as Ue, select as k, input as B, password as Et, checkbox as ke, number as Me } from "@inquirer/prompts";
|
|
13
13
|
import w from "ora";
|
|
14
14
|
import I from "fs-extra";
|
|
15
15
|
import { select as ae } from "inquirer-select-pro";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { run as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
const
|
|
22
|
-
var $ = /* @__PURE__ */ ((e) => (e[e.DEV =
|
|
23
|
-
const
|
|
16
|
+
import kt from "lint-staged";
|
|
17
|
+
import Ct from "semver";
|
|
18
|
+
import { run as Rt } from "npm-check-updates";
|
|
19
|
+
import It from "p-limit";
|
|
20
|
+
import xt from "minimist";
|
|
21
|
+
const Je = "dev", Ge = "test", Ve = "release", Dt = "production", Lt = "master";
|
|
22
|
+
var $ = /* @__PURE__ */ ((e) => (e[e.DEV = Je] = "DEV", e[e.TEST = Ge] = "TEST", e[e.RELEASE = Ve] = "RELEASE", e[e.PROD = Dt] = "PROD", e))($ || {}), y = /* @__PURE__ */ ((e) => (e[e.DEV = Je] = "DEV", e[e.TEST = Ge] = "TEST", e[e.RELEASE = Ve] = "RELEASE", e[e.MASTER = Lt] = "MASTER", e))(y || {}), K = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(K || {});
|
|
23
|
+
const We = [
|
|
24
24
|
{
|
|
25
25
|
name: `开发环境 - ${$.DEV}`,
|
|
26
26
|
value: $.DEV
|
|
@@ -37,7 +37,7 @@ const Ve = [
|
|
|
37
37
|
name: `正式环境 - ${$.PROD}`,
|
|
38
38
|
value: $.PROD
|
|
39
39
|
}
|
|
40
|
-
],
|
|
40
|
+
], Pt = [
|
|
41
41
|
{
|
|
42
42
|
name: "网页 - h5",
|
|
43
43
|
value: "h5"
|
|
@@ -55,7 +55,7 @@ const Ve = [
|
|
|
55
55
|
}
|
|
56
56
|
];
|
|
57
57
|
var me = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(me || {}), oe = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(oe || {}), b = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e))(b || {});
|
|
58
|
-
const
|
|
58
|
+
const Ot = {
|
|
59
59
|
1: "研发",
|
|
60
60
|
2: "测试",
|
|
61
61
|
3: "产品",
|
|
@@ -65,11 +65,11 @@ const Pt = {
|
|
|
65
65
|
7: "行政",
|
|
66
66
|
8: "财务",
|
|
67
67
|
9: "其他"
|
|
68
|
-
}, de = "http://git.cxlqd.com",
|
|
68
|
+
}, de = "http://git.cxlqd.com", Mt = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
69
69
|
var S = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(S || {});
|
|
70
|
-
const
|
|
70
|
+
const zt = "fe-biz7tvsd", qe = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
71
71
|
var R = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(R || {});
|
|
72
|
-
const
|
|
72
|
+
const _t = [
|
|
73
73
|
{
|
|
74
74
|
name: "模块",
|
|
75
75
|
value: "module"
|
|
@@ -80,32 +80,32 @@ const zt = [
|
|
|
80
80
|
value: "case"
|
|
81
81
|
/* CASE */
|
|
82
82
|
}
|
|
83
|
-
],
|
|
83
|
+
], Bt = ".z", Ft = "develop-config.json", Z = ".z", Ut = ".commit-msg-tpl", Jt = "project.json";
|
|
84
84
|
function C(e = "") {
|
|
85
85
|
return m.join(Z, e);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
return C(
|
|
87
|
+
function He() {
|
|
88
|
+
return C(Jt);
|
|
89
89
|
}
|
|
90
90
|
function ve() {
|
|
91
|
-
return C(
|
|
91
|
+
return C(Ut);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function Ze() {
|
|
94
94
|
Oe.spawnSync("git", ["config", "core.hooksPath", C()]), Oe.spawnSync("git", ["config", "commit.template", ve()]);
|
|
95
95
|
}
|
|
96
96
|
function ge(e = "") {
|
|
97
|
-
return m.resolve(
|
|
97
|
+
return m.resolve(Tt.homedir(), Bt, e);
|
|
98
98
|
}
|
|
99
99
|
function Ne() {
|
|
100
|
-
return ge(
|
|
100
|
+
return ge(Ft);
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Gt() {
|
|
103
103
|
return v(ge());
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
105
|
+
function Ke() {
|
|
106
|
+
return Gt() && v(Ne());
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function Ye(e) {
|
|
109
109
|
let t = e.trim();
|
|
110
110
|
const i = t.match(/^git@([^:]+):(.+)$/);
|
|
111
111
|
if (i)
|
|
@@ -116,25 +116,25 @@ function Ke(e) {
|
|
|
116
116
|
}
|
|
117
117
|
return encodeURIComponent(t.replace(/\.git$/, ""));
|
|
118
118
|
}
|
|
119
|
-
const { red: ze, green:
|
|
119
|
+
const { red: ze, green: Vt, blue: Nn, magenta: Wt, yellow: bn } = j;
|
|
120
120
|
function ye(...e) {
|
|
121
121
|
}
|
|
122
122
|
function G(...e) {
|
|
123
|
-
console.log(
|
|
123
|
+
console.log(Vt(...e));
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function Xe(e) {
|
|
126
126
|
e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(j.cyan(" 👋 下次见~")), console.log(), process.exit(1));
|
|
127
127
|
}
|
|
128
128
|
function p(e, t = !1) {
|
|
129
|
-
|
|
129
|
+
Xe(e);
|
|
130
130
|
let i = e;
|
|
131
|
-
e instanceof Error ? (i = e.message, ce.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(ze(i)), console.log(
|
|
131
|
+
e instanceof Error ? (i = e.message, ce.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(ze(i)), console.log(Wt(e.stack))) : console.log(ze(e)), t || process.exit(1);
|
|
132
132
|
}
|
|
133
133
|
function _e(e) {
|
|
134
|
-
return v(e) ?
|
|
134
|
+
return v(e) ? Nt(e).isDirectory() : !1;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
return _e(e) ?
|
|
136
|
+
function Qe(e = process.cwd()) {
|
|
137
|
+
return _e(e) ? vt(e).filter((i) => _e(m.resolve(e, i))) : [];
|
|
138
138
|
}
|
|
139
139
|
async function l(e, t = {
|
|
140
140
|
removeTailLinkBreak: !0,
|
|
@@ -152,15 +152,15 @@ async function l(e, t = {
|
|
|
152
152
|
});
|
|
153
153
|
return i = i.toString(), t.removeTailLinkBreak && (i = i.replace(/\n$/, "")), i;
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
|
|
155
|
+
function et(e) {
|
|
156
|
+
$t.execSync(e, {
|
|
157
157
|
stdio: "inherit"
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
function
|
|
161
|
-
return
|
|
160
|
+
function tt() {
|
|
161
|
+
return jt(Date.now()).format("YYMMDD");
|
|
162
162
|
}
|
|
163
|
-
function
|
|
163
|
+
function qt(e, t) {
|
|
164
164
|
for (const i of t)
|
|
165
165
|
if (!e.includes(i))
|
|
166
166
|
return !1;
|
|
@@ -175,23 +175,23 @@ function Q() {
|
|
|
175
175
|
async function pe() {
|
|
176
176
|
await l("git status -s") !== "" && p("请先提交代码变动,再进行操作");
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function Ht(e) {
|
|
179
179
|
return e === y.MASTER ? $.PROD : e;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function Zt(e) {
|
|
182
182
|
return e === $.PROD ? y.MASTER : e;
|
|
183
183
|
}
|
|
184
184
|
async function z(e, ...t) {
|
|
185
185
|
try {
|
|
186
186
|
await e(...t);
|
|
187
187
|
} catch (i) {
|
|
188
|
-
throw
|
|
188
|
+
throw Xe(i), i;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
async function
|
|
191
|
+
async function Kt(e) {
|
|
192
192
|
return (await Ce(e)).length === 0;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function Yt(e = "项目中文名", t = "项目描述") {
|
|
195
195
|
return `
|
|
196
196
|
# ${e}
|
|
197
197
|
${t}
|
|
@@ -248,7 +248,7 @@ ${t}
|
|
|
248
248
|
在此处放入飞书文档链接。请在[前端团队-项目手册](https://hxhtbr8t8uy.feishu.cn/drive/folder/QfQ7favVWljQk7d63Prc8mUGnJf)中按照分类新建文档。
|
|
249
249
|
`;
|
|
250
250
|
}
|
|
251
|
-
const
|
|
251
|
+
const Xt = {
|
|
252
252
|
[b.JAVA]: {
|
|
253
253
|
"**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml"
|
|
254
254
|
},
|
|
@@ -261,17 +261,17 @@ const Yt = {
|
|
|
261
261
|
// "**/*.{py}": "python --fix",
|
|
262
262
|
"**/*.{py}": "echo 'todo'"
|
|
263
263
|
}
|
|
264
|
-
},
|
|
265
|
-
name:
|
|
266
|
-
version:
|
|
267
|
-
description:
|
|
268
|
-
main:
|
|
269
|
-
bin:
|
|
270
|
-
scripts:
|
|
271
|
-
type:
|
|
272
|
-
author:
|
|
273
|
-
devDependencies:
|
|
274
|
-
dependencies:
|
|
264
|
+
}, Qt = "cli-z-develop", ei = "0.11.1", ti = "技术团队开发流程管理工具", ii = "dist/index.js", ai = { z: "bin/z.js", "z-develop": "bin/z.js" }, ni = { 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" }, si = "module", ri = "z", oi = { "@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" }, ci = { "@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" }, ie = {
|
|
265
|
+
name: Qt,
|
|
266
|
+
version: ei,
|
|
267
|
+
description: ti,
|
|
268
|
+
main: ii,
|
|
269
|
+
bin: ai,
|
|
270
|
+
scripts: ni,
|
|
271
|
+
type: si,
|
|
272
|
+
author: ri,
|
|
273
|
+
devDependencies: oi,
|
|
274
|
+
dependencies: ci
|
|
275
275
|
}, x = {
|
|
276
276
|
// 个人数据
|
|
277
277
|
profile: {
|
|
@@ -324,18 +324,18 @@ function be() {
|
|
|
324
324
|
function he() {
|
|
325
325
|
if (J)
|
|
326
326
|
return J;
|
|
327
|
-
const e =
|
|
327
|
+
const e = He();
|
|
328
328
|
return v(e) || p(
|
|
329
329
|
`当前目录(${L.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
330
330
|
), J = I.readJsonSync(e), J;
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function ui(e) {
|
|
333
333
|
J ? J = {
|
|
334
334
|
...J,
|
|
335
335
|
...e
|
|
336
|
-
} : J = e, I.writeJSONSync(
|
|
336
|
+
} : J = e, I.writeJSONSync(He(), J, { spaces: 2 });
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function li(e) {
|
|
339
339
|
U ? U = {
|
|
340
340
|
...U,
|
|
341
341
|
...e
|
|
@@ -348,10 +348,10 @@ const H = {
|
|
|
348
348
|
sourceBranch: "",
|
|
349
349
|
mergeRequestUrl: ""
|
|
350
350
|
};
|
|
351
|
-
async function
|
|
351
|
+
async function pi() {
|
|
352
352
|
if (!H.id)
|
|
353
353
|
try {
|
|
354
|
-
const e = he(), t =
|
|
354
|
+
const e = he(), t = Ye(e.repository.url), i = await nt(t);
|
|
355
355
|
H.id = i.id, H.path = t, H.group = i.namespace.full_path, H.mergeRequestUrl = `${i.web_url}/merge_requests`;
|
|
356
356
|
} catch (e) {
|
|
357
357
|
p(e);
|
|
@@ -403,10 +403,10 @@ async function Y(e) {
|
|
|
403
403
|
const o = await ce(s);
|
|
404
404
|
return ye(j.green("Response"), j.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
|
|
405
405
|
} catch (s) {
|
|
406
|
-
return s instanceof
|
|
406
|
+
return s instanceof St && ye(j.red("Error"), j.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
async function
|
|
409
|
+
async function mi() {
|
|
410
410
|
const e = E("gitToken");
|
|
411
411
|
if (e)
|
|
412
412
|
return e;
|
|
@@ -427,11 +427,11 @@ async function N(e) {
|
|
|
427
427
|
return Y({
|
|
428
428
|
...e,
|
|
429
429
|
headers: {
|
|
430
|
-
Authorization: await
|
|
430
|
+
Authorization: await mi()
|
|
431
431
|
}
|
|
432
432
|
});
|
|
433
433
|
}
|
|
434
|
-
async function
|
|
434
|
+
async function di() {
|
|
435
435
|
const e = E("zenTaoToken");
|
|
436
436
|
if (e)
|
|
437
437
|
return e;
|
|
@@ -451,7 +451,7 @@ async function $e(e) {
|
|
|
451
451
|
const t = await Y({
|
|
452
452
|
...e,
|
|
453
453
|
headers: {
|
|
454
|
-
Token: await
|
|
454
|
+
Token: await di()
|
|
455
455
|
}
|
|
456
456
|
});
|
|
457
457
|
if (e.url.includes("local")) {
|
|
@@ -474,7 +474,7 @@ async function $e(e) {
|
|
|
474
474
|
return {};
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
async function
|
|
477
|
+
async function fi() {
|
|
478
478
|
const e = E("k8sToken");
|
|
479
479
|
if (e)
|
|
480
480
|
return e;
|
|
@@ -493,20 +493,20 @@ async function di() {
|
|
|
493
493
|
return M("k8sToken", i), se(), i;
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
async function
|
|
496
|
+
async function it(e) {
|
|
497
497
|
const t = await Y({
|
|
498
498
|
...e,
|
|
499
499
|
headers: {
|
|
500
|
-
Authorization: await
|
|
500
|
+
Authorization: await fi()
|
|
501
501
|
}
|
|
502
502
|
});
|
|
503
|
-
return t.code === 401 ? (M("k8sToken", ""),
|
|
503
|
+
return t.code === 401 ? (M("k8sToken", ""), it({
|
|
504
504
|
...e
|
|
505
505
|
})) : t;
|
|
506
506
|
}
|
|
507
|
-
async function
|
|
507
|
+
async function gi(e, t) {
|
|
508
508
|
try {
|
|
509
|
-
const i =
|
|
509
|
+
const i = bt(t, { mode: 493 });
|
|
510
510
|
return (await ce({
|
|
511
511
|
method: "get",
|
|
512
512
|
url: e,
|
|
@@ -522,79 +522,79 @@ async function fi(e, t) {
|
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
const _ = () => `${de}/api/v4`, F = (e) => `${_()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
|
|
525
|
-
function
|
|
525
|
+
function hi() {
|
|
526
526
|
return N({
|
|
527
527
|
url: F("src/data/template-projects.json")
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
|
-
function
|
|
530
|
+
function at() {
|
|
531
531
|
return N({
|
|
532
532
|
url: F("src/data/z-develop-config.json")
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function wi() {
|
|
536
536
|
return N({
|
|
537
537
|
url: F("src/assets/tsconfig.browser.json")
|
|
538
538
|
});
|
|
539
539
|
}
|
|
540
|
-
function
|
|
540
|
+
function yi() {
|
|
541
541
|
return N({
|
|
542
542
|
url: F("src/assets/tsconfig.node.json")
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function $i() {
|
|
546
546
|
return N({
|
|
547
547
|
url: F("src/assets/.prettierignore")
|
|
548
548
|
});
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function vi() {
|
|
551
551
|
return N({
|
|
552
552
|
url: F("src/assets/.prettierrc.json")
|
|
553
553
|
});
|
|
554
554
|
}
|
|
555
|
-
function
|
|
555
|
+
function Ni() {
|
|
556
556
|
return N({
|
|
557
557
|
url: F("src/assets/data.yaml")
|
|
558
558
|
});
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function bi() {
|
|
561
561
|
return N({
|
|
562
562
|
url: F("src/assets/main.py")
|
|
563
563
|
});
|
|
564
564
|
}
|
|
565
|
-
function
|
|
565
|
+
function Ai() {
|
|
566
566
|
return N({
|
|
567
567
|
url: F("src/assets/checkstyle.xml")
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function Si() {
|
|
571
571
|
return N({
|
|
572
572
|
url: F("src/data/project-group-chats.json")
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
|
-
function
|
|
575
|
+
function ji() {
|
|
576
576
|
return N({
|
|
577
577
|
url: `${_()}/user`
|
|
578
578
|
});
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function Ti() {
|
|
581
581
|
return N({
|
|
582
582
|
url: `${_()}/groups`
|
|
583
583
|
});
|
|
584
584
|
}
|
|
585
|
-
function
|
|
585
|
+
function Ei(e) {
|
|
586
586
|
return N({
|
|
587
587
|
url: `${_()}/projects`,
|
|
588
588
|
method: "post",
|
|
589
589
|
data: e
|
|
590
590
|
});
|
|
591
591
|
}
|
|
592
|
-
function
|
|
592
|
+
function nt(e) {
|
|
593
593
|
return N({
|
|
594
594
|
url: `${_()}/projects/${e}`
|
|
595
595
|
});
|
|
596
596
|
}
|
|
597
|
-
function
|
|
597
|
+
function ki(e) {
|
|
598
598
|
return N({
|
|
599
599
|
url: `${_()}/projects`,
|
|
600
600
|
data: {
|
|
@@ -603,50 +603,50 @@ function Ei(e) {
|
|
|
603
603
|
}
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function Ci(e) {
|
|
607
607
|
return N({
|
|
608
608
|
url: `${_()}/projects/${e.id}/merge_requests`,
|
|
609
609
|
method: "post",
|
|
610
610
|
data: e
|
|
611
611
|
});
|
|
612
612
|
}
|
|
613
|
-
function
|
|
613
|
+
function Ri(e) {
|
|
614
614
|
return N({
|
|
615
615
|
url: `${_()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
616
616
|
method: "put"
|
|
617
617
|
});
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function Ii(e) {
|
|
620
620
|
return N({
|
|
621
621
|
url: `${_()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
622
622
|
method: "put",
|
|
623
623
|
data: e
|
|
624
624
|
});
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function xi(e) {
|
|
627
627
|
return N({
|
|
628
628
|
url: `${_()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
629
629
|
method: "get"
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
|
-
function
|
|
632
|
+
function Di(e) {
|
|
633
633
|
return N({
|
|
634
634
|
url: `${_()}/projects/${e.id}/repository/branches`,
|
|
635
635
|
method: "post",
|
|
636
636
|
data: e
|
|
637
637
|
});
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Li(e) {
|
|
640
640
|
return N({
|
|
641
641
|
url: `${_()}/projects/${e}/repository/branches`
|
|
642
642
|
});
|
|
643
643
|
}
|
|
644
|
-
function
|
|
644
|
+
function Pi() {
|
|
645
645
|
const e = ge("fe-groups.json");
|
|
646
646
|
return v(e) ? I.readJSONSync(e) : { groups: [] };
|
|
647
647
|
}
|
|
648
|
-
async function
|
|
649
|
-
const e = await
|
|
648
|
+
async function Oi() {
|
|
649
|
+
const e = await Ti(), t = Mt.map((i) => {
|
|
650
650
|
const n = e.find((a) => a.name === i);
|
|
651
651
|
return n ? {
|
|
652
652
|
name: n.name,
|
|
@@ -670,17 +670,17 @@ async function A(e) {
|
|
|
670
670
|
});
|
|
671
671
|
return n.code !== 0 && p(`${n.code}: ${n.message}`), n.data;
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function Mi() {
|
|
674
674
|
return A({
|
|
675
675
|
url: "/user/list2"
|
|
676
676
|
});
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function zi() {
|
|
679
679
|
return A({
|
|
680
680
|
url: "/zen/testcase/product/list"
|
|
681
681
|
});
|
|
682
682
|
}
|
|
683
|
-
function
|
|
683
|
+
function st(e) {
|
|
684
684
|
return A({
|
|
685
685
|
url: "/zen/testcase/product/module/list",
|
|
686
686
|
data: {
|
|
@@ -688,7 +688,7 @@ function nt(e) {
|
|
|
688
688
|
}
|
|
689
689
|
});
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function _i(e) {
|
|
692
692
|
return A({
|
|
693
693
|
url: "/zen/testcase/product/name",
|
|
694
694
|
data: {
|
|
@@ -696,7 +696,7 @@ function zi(e) {
|
|
|
696
696
|
}
|
|
697
697
|
});
|
|
698
698
|
}
|
|
699
|
-
function
|
|
699
|
+
function Bi(e, t) {
|
|
700
700
|
return A({
|
|
701
701
|
url: "/zen/testcase/product/auto-case/list",
|
|
702
702
|
data: {
|
|
@@ -705,7 +705,7 @@ function _i(e, t) {
|
|
|
705
705
|
}
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
|
-
function
|
|
708
|
+
function Fi(e) {
|
|
709
709
|
return A({
|
|
710
710
|
url: "/zen/testcase/step/list",
|
|
711
711
|
data: {
|
|
@@ -713,72 +713,72 @@ function Bi(e) {
|
|
|
713
713
|
}
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
-
function
|
|
716
|
+
function Ui(e) {
|
|
717
717
|
return A({
|
|
718
718
|
url: "/zen/testcase/module/create",
|
|
719
719
|
data: e
|
|
720
720
|
});
|
|
721
721
|
}
|
|
722
|
-
function
|
|
722
|
+
function Ji(e) {
|
|
723
723
|
return A({
|
|
724
724
|
url: "/zen/testcase/create",
|
|
725
725
|
data: e
|
|
726
726
|
});
|
|
727
727
|
}
|
|
728
|
-
function
|
|
728
|
+
function Gi(e) {
|
|
729
729
|
return A({
|
|
730
730
|
url: "/zen/testcase/step/create",
|
|
731
731
|
data: e
|
|
732
732
|
});
|
|
733
733
|
}
|
|
734
|
-
function
|
|
734
|
+
function Vi(e) {
|
|
735
735
|
return A({
|
|
736
736
|
url: "/zen/testcase/modules/remove",
|
|
737
737
|
data: e
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
|
-
function
|
|
740
|
+
function Wi(e) {
|
|
741
741
|
return A({
|
|
742
742
|
url: "/zen/testcase/cases/remove",
|
|
743
743
|
data: e
|
|
744
744
|
});
|
|
745
745
|
}
|
|
746
|
-
function
|
|
746
|
+
function qi(e) {
|
|
747
747
|
return A({
|
|
748
748
|
url: "/zen/testcase/module/update/name",
|
|
749
749
|
data: e
|
|
750
750
|
});
|
|
751
751
|
}
|
|
752
|
-
function
|
|
752
|
+
function Hi(e) {
|
|
753
753
|
return A({
|
|
754
754
|
url: "/zen/testcase/case/update/name",
|
|
755
755
|
data: e
|
|
756
756
|
});
|
|
757
757
|
}
|
|
758
|
-
function
|
|
758
|
+
function Zi(e) {
|
|
759
759
|
return A({
|
|
760
760
|
url: "/zen/testcase/case/update/priority",
|
|
761
761
|
data: e
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
|
-
function
|
|
764
|
+
function Ki(e) {
|
|
765
765
|
return A({
|
|
766
766
|
url: "/zen/testcase/case/update/precondition",
|
|
767
767
|
data: e
|
|
768
768
|
});
|
|
769
769
|
}
|
|
770
|
-
function
|
|
770
|
+
function Yi(e) {
|
|
771
771
|
return A({
|
|
772
772
|
url: "/zen/testcase/case/result/create",
|
|
773
773
|
data: e
|
|
774
774
|
});
|
|
775
775
|
}
|
|
776
|
-
function
|
|
776
|
+
function Xi() {
|
|
777
777
|
return A({
|
|
778
778
|
url: "/zen/testcase/project/list"
|
|
779
779
|
});
|
|
780
780
|
}
|
|
781
|
-
function
|
|
781
|
+
function Qi(e) {
|
|
782
782
|
return A({
|
|
783
783
|
url: "/zen/testcase/project/execution/list",
|
|
784
784
|
data: {
|
|
@@ -786,7 +786,7 @@ function Xi(e) {
|
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
|
-
function
|
|
789
|
+
function ea(e) {
|
|
790
790
|
return A({
|
|
791
791
|
url: "/zen/testcase/execution/build/list",
|
|
792
792
|
data: {
|
|
@@ -794,13 +794,13 @@ function Qi(e) {
|
|
|
794
794
|
}
|
|
795
795
|
});
|
|
796
796
|
}
|
|
797
|
-
function
|
|
797
|
+
function ta(e) {
|
|
798
798
|
return A({
|
|
799
799
|
url: "/common/ai/talk",
|
|
800
800
|
data: e
|
|
801
801
|
});
|
|
802
802
|
}
|
|
803
|
-
function
|
|
803
|
+
function ia(e, t) {
|
|
804
804
|
const i = [];
|
|
805
805
|
t.forEach((s) => {
|
|
806
806
|
e.includes(s.value) && i.push(s);
|
|
@@ -816,9 +816,9 @@ function ta(e, t) {
|
|
|
816
816
|
weWorkListCache: n.sort((s, o) => o.usageCount - s.usageCount)
|
|
817
817
|
}), se();
|
|
818
818
|
}
|
|
819
|
-
async function
|
|
820
|
-
const t = (await
|
|
821
|
-
name: `${s.nick} - ${
|
|
819
|
+
async function rt() {
|
|
820
|
+
const t = (await Mi()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
821
|
+
name: `${s.nick} - ${Ot[s.title]}`,
|
|
822
822
|
value: s.weWorkUserId
|
|
823
823
|
})), i = fe("weWorkListCache"), n = i.map((s) => s.value), a = [];
|
|
824
824
|
return t.forEach((s) => {
|
|
@@ -829,8 +829,8 @@ async function st() {
|
|
|
829
829
|
});
|
|
830
830
|
}), a.sort((s, o) => o.usageCount - s.usageCount);
|
|
831
831
|
}
|
|
832
|
-
async function
|
|
833
|
-
const n = await
|
|
832
|
+
async function ot(e, t, i) {
|
|
833
|
+
const n = await rt();
|
|
834
834
|
let a = await ae({
|
|
835
835
|
message: e,
|
|
836
836
|
loop: !0,
|
|
@@ -840,10 +840,10 @@ async function rt(e, t, i) {
|
|
|
840
840
|
options: (s) => s ? n.filter((o) => o.name.includes(s)) : n,
|
|
841
841
|
validate: t
|
|
842
842
|
});
|
|
843
|
-
return a = Array.isArray(a) ? a : [a],
|
|
843
|
+
return a = Array.isArray(a) ? a : [a], ia(a, n), a;
|
|
844
844
|
}
|
|
845
|
-
async function
|
|
846
|
-
const { groups: n } = await
|
|
845
|
+
async function aa(e, t, i) {
|
|
846
|
+
const { groups: n } = await Si(), a = n.map((o) => ({
|
|
847
847
|
name: o.name,
|
|
848
848
|
value: o.url
|
|
849
849
|
}));
|
|
@@ -858,9 +858,9 @@ async function ia(e, t, i) {
|
|
|
858
858
|
});
|
|
859
859
|
return s = Array.isArray(s) ? s : [s], s;
|
|
860
860
|
}
|
|
861
|
-
async function
|
|
861
|
+
async function na() {
|
|
862
862
|
try {
|
|
863
|
-
|
|
863
|
+
Ke() && (await Ue({
|
|
864
864
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
865
865
|
}) ? L.rm("-rf", Ne()) : process.exit(0)), await le(ge(), { recursive: !0 });
|
|
866
866
|
const t = await k({
|
|
@@ -881,14 +881,14 @@ async function aa() {
|
|
|
881
881
|
]
|
|
882
882
|
}), i = await B({
|
|
883
883
|
message: "请输入LDAP账号:"
|
|
884
|
-
}), n = await
|
|
884
|
+
}), n = await Et({
|
|
885
885
|
message: "请输入LDAP密码:",
|
|
886
886
|
mask: !0
|
|
887
887
|
});
|
|
888
888
|
M("jobType", t), M("ldapAccount", i), M("ldapPassword", n);
|
|
889
|
-
const a = await
|
|
889
|
+
const a = await at();
|
|
890
890
|
Re(a);
|
|
891
|
-
const s = await
|
|
891
|
+
const s = await rt(), o = await ot("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((u) => u.value === o[0]);
|
|
892
892
|
M({
|
|
893
893
|
weWorkName: r,
|
|
894
894
|
weWorkUserId: c
|
|
@@ -898,18 +898,18 @@ async function aa() {
|
|
|
898
898
|
}
|
|
899
899
|
const e = w("配置信息初始化中").start();
|
|
900
900
|
try {
|
|
901
|
-
const t = await
|
|
901
|
+
const t = await ji();
|
|
902
902
|
M({
|
|
903
903
|
gitUserId: t.id,
|
|
904
904
|
gitName: t.name,
|
|
905
905
|
gitEnglishName: t.username,
|
|
906
906
|
gitEmail: t.email
|
|
907
|
-
}), ue("latestCheckVersionTimestamp", Date.now()), se(), E("jobType") === oe.FRONT_END && await
|
|
907
|
+
}), ue("latestCheckVersionTimestamp", Date.now()), se(), E("jobType") === oe.FRONT_END && await Oi(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
908
908
|
} catch (t) {
|
|
909
909
|
e.fail("配置信息初始化失败"), ce.isAxiosError(t) && p("请检查你的域名及令牌配置"), p(t);
|
|
910
910
|
}
|
|
911
911
|
}
|
|
912
|
-
async function
|
|
912
|
+
async function sa() {
|
|
913
913
|
await O(ve(), "", { mode: 493 }), await O(C(".gitignore"), `.commit-msg-tpl
|
|
914
914
|
`, { mode: 493 }), await O(C("commit-msg"), `#!/usr/bin/env sh
|
|
915
915
|
z run commit-msg`, { mode: 493 }), await O(C("pre-commit"), `#!/usr/bin/env sh
|
|
@@ -917,14 +917,14 @@ z run commit-files`, { mode: 493 });
|
|
|
917
917
|
const { language: e } = he();
|
|
918
918
|
e === b.JAVASCRIPT && (await O(
|
|
919
919
|
C(".prettierrc.json"),
|
|
920
|
-
`${JSON.stringify(await
|
|
920
|
+
`${JSON.stringify(await vi(), null, 2)}
|
|
921
921
|
`,
|
|
922
922
|
{
|
|
923
923
|
mode: 493
|
|
924
924
|
}
|
|
925
|
-
), await O(C(".prettierignore"), await
|
|
925
|
+
), await O(C(".prettierignore"), await $i(), { mode: 493 }), await O(C("tsconfig.node.json"), await yi(), { mode: 493 }), await O(C("tsconfig.browser.json"), await wi(), { mode: 493 })), e === b.JAVA && (await gi(`${W("FECDNDomain")}/file/vgnlfbfHRF.jar`, C("checkstyle.jar")), await O(C("checkstyle.xml"), await Ai(), { mode: 493 })), Ze();
|
|
926
926
|
}
|
|
927
|
-
async function
|
|
927
|
+
async function ra(e, t) {
|
|
928
928
|
const i = await l("git remote get-url --push origin");
|
|
929
929
|
i || p("获取项目远程git地址失败,请配置后重试");
|
|
930
930
|
let n = e;
|
|
@@ -947,14 +947,14 @@ async function sa(e, t) {
|
|
|
947
947
|
}));
|
|
948
948
|
let a = t;
|
|
949
949
|
if (!a) {
|
|
950
|
-
const s =
|
|
950
|
+
const s = Ye(i), o = await nt(s);
|
|
951
951
|
if (!o)
|
|
952
952
|
return p(`未找到项目,请确认项目${i}是否存在,或者当前账号权限`);
|
|
953
953
|
a = o.namespace.full_path;
|
|
954
954
|
}
|
|
955
|
-
|
|
955
|
+
ui({
|
|
956
956
|
language: n,
|
|
957
|
-
"lint-staged":
|
|
957
|
+
"lint-staged": Xt[n],
|
|
958
958
|
repository: {
|
|
959
959
|
url: i,
|
|
960
960
|
group: a
|
|
@@ -962,36 +962,36 @@ async function sa(e, t) {
|
|
|
962
962
|
});
|
|
963
963
|
}
|
|
964
964
|
async function Ie(e, t) {
|
|
965
|
-
e ? L.rm("-rf", Z) : v(C()) && (await
|
|
965
|
+
e ? L.rm("-rf", Z) : v(C()) && (await Ue({
|
|
966
966
|
message: `当前项目中已存在配置文件夹${Z},确认重新配置?`
|
|
967
|
-
}) ? L.rm("-rf", Z) : process.exit(0)), await le(C(), { recursive: !0 }), await
|
|
967
|
+
}) ? L.rm("-rf", Z) : process.exit(0)), await le(C(), { recursive: !0 }), await ra(e, t);
|
|
968
968
|
const i = w("项目初始化中...").start();
|
|
969
|
-
await
|
|
970
|
-
}
|
|
971
|
-
async function ra() {
|
|
972
|
-
v(C()) && v(ve()) ? He() : await Ie(), process.exit(0);
|
|
969
|
+
await sa(), i.succeed("项目初始化完成");
|
|
973
970
|
}
|
|
974
|
-
async function oa(
|
|
975
|
-
|
|
971
|
+
async function oa() {
|
|
972
|
+
v(C()) && v(ve()) ? Ze() : await Ie(), process.exit(0);
|
|
976
973
|
}
|
|
977
|
-
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(b).join("/")} `).action((...e) => z(oa, ...e));
|
|
978
974
|
async function ca(e, t) {
|
|
975
|
+
t.projectLanguage && !Object.values(b).includes(t.projectLanguage) && p("项目语言不支持"), e ? (Q(), e === "." ? (await Ie(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await oa() : p("参数错误。执行 z init -h 查看帮助。")) : await na();
|
|
976
|
+
}
|
|
977
|
+
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(b).join("/")} `).action((...e) => z(ca, ...e));
|
|
978
|
+
async function ua(e, t) {
|
|
979
979
|
if (!e)
|
|
980
980
|
return "不能为空";
|
|
981
981
|
if (!/^[a-z0-9-]+$/.test(e))
|
|
982
982
|
return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
|
|
983
|
-
if (
|
|
983
|
+
if (Qe().includes(e))
|
|
984
984
|
return "当前目录下已存在同名文件夹,请先处理。";
|
|
985
|
-
const a = (await
|
|
985
|
+
const a = (await ki(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
|
|
986
986
|
return a ? `远程仓库中已存在同名项目(${a.http_url_to_repo}),请更名后重试` : !0;
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function la(e) {
|
|
989
989
|
return e ? !0 : "不能为空";
|
|
990
990
|
}
|
|
991
|
-
function
|
|
991
|
+
function pa(e) {
|
|
992
992
|
return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
|
|
993
993
|
}
|
|
994
|
-
async function
|
|
994
|
+
async function ma(e) {
|
|
995
995
|
ne(), Q(), await pe();
|
|
996
996
|
let t, i;
|
|
997
997
|
e.branchType ? t = e.branchType : t = await k({
|
|
@@ -1012,15 +1012,15 @@ async function pa(e) {
|
|
|
1012
1012
|
]
|
|
1013
1013
|
}), e.branchPurpose ? i = e.branchPurpose : i = await B({
|
|
1014
1014
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1015
|
-
validate:
|
|
1015
|
+
validate: pa
|
|
1016
1016
|
});
|
|
1017
|
-
const n = `${t}_${i}_${
|
|
1017
|
+
const n = `${t}_${i}_${tt()}`;
|
|
1018
1018
|
await l(`git fetch origin ${y.MASTER}`), await l(`git checkout -b ${n} origin/${y.MASTER}`), await l(`git push -u origin ${n}`), process.exit(0);
|
|
1019
1019
|
}
|
|
1020
|
-
const
|
|
1021
|
-
async function
|
|
1020
|
+
const ct = (e) => `${W("ZenTaoDomain")}${e}`;
|
|
1021
|
+
async function da() {
|
|
1022
1022
|
const e = await $e({
|
|
1023
|
-
url:
|
|
1023
|
+
url: ct("/my-work-task.json?tid=mrrferp8"),
|
|
1024
1024
|
method: "get"
|
|
1025
1025
|
});
|
|
1026
1026
|
return e?.tasks ? e.tasks.filter((t) => t.status !== "done").map(({ id: t, name: i }) => ({
|
|
@@ -1031,9 +1031,9 @@ async function ma() {
|
|
|
1031
1031
|
name: i
|
|
1032
1032
|
})) : [];
|
|
1033
1033
|
}
|
|
1034
|
-
async function
|
|
1034
|
+
async function fa() {
|
|
1035
1035
|
const e = await $e({
|
|
1036
|
-
url:
|
|
1036
|
+
url: ct("/my-work-bug.json?tid=mrrferp8"),
|
|
1037
1037
|
method: "get"
|
|
1038
1038
|
});
|
|
1039
1039
|
return e?.bugs ? Object.values(e.bugs).map(({ id: t, title: i }) => ({
|
|
@@ -1044,10 +1044,10 @@ async function da() {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
})) : [];
|
|
1046
1046
|
}
|
|
1047
|
-
async function
|
|
1047
|
+
async function Be(e) {
|
|
1048
1048
|
let t = ` HEAD_MESSAGE_START ${e} HEAD_MESSAGE_END `;
|
|
1049
1049
|
const i = await l("git diff HEAD");
|
|
1050
|
-
return t += ` BODY_MESSAGE_START ${i} BODY_MESSAGE_END `, await
|
|
1050
|
+
return t += ` BODY_MESSAGE_START ${i} BODY_MESSAGE_END `, await ta({
|
|
1051
1051
|
type: "commit-message",
|
|
1052
1052
|
input: t
|
|
1053
1053
|
});
|
|
@@ -1057,12 +1057,12 @@ async function Te(e, t, i) {
|
|
|
1057
1057
|
let a = "", s = !0;
|
|
1058
1058
|
if ([S.FEAT, S.FIX, S.REFACTOR].includes(e)) {
|
|
1059
1059
|
const o = t.map((r) => r.value).join(",");
|
|
1060
|
-
if (i || (a = await
|
|
1060
|
+
if (i || (a = await Be(`${e}(${o})`)), !a) {
|
|
1061
1061
|
const r = t.map((c) => c.name).join(";");
|
|
1062
1062
|
a = `${e}(${o}): ${r}`, s = !1;
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
|
-
e === S.CHORE && (a = `${e}: ${t}`), await O(ve(), a, "utf-8"), s || i ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(j.yellow(a));
|
|
1065
|
+
e === S.CHORE && (t ? a = `${e}: ${t}` : a = await Be(`${e}`)), await O(ve(), a, "utf-8"), s || i ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(j.yellow(a));
|
|
1066
1066
|
}
|
|
1067
1067
|
async function ga(e) {
|
|
1068
1068
|
const t = await k({
|
|
@@ -1087,7 +1087,7 @@ async function ga(e) {
|
|
|
1087
1087
|
]
|
|
1088
1088
|
});
|
|
1089
1089
|
if ([S.FEAT, S.REFACTOR].includes(t)) {
|
|
1090
|
-
const i = await
|
|
1090
|
+
const i = await da();
|
|
1091
1091
|
if (!i.length)
|
|
1092
1092
|
return G("🤷 暂无开发任务");
|
|
1093
1093
|
const n = await ke({
|
|
@@ -1102,7 +1102,7 @@ async function ga(e) {
|
|
|
1102
1102
|
await Te(S.FEAT, n, e);
|
|
1103
1103
|
}
|
|
1104
1104
|
if (t === S.FIX) {
|
|
1105
|
-
const i = await
|
|
1105
|
+
const i = await fa();
|
|
1106
1106
|
if (!i.length)
|
|
1107
1107
|
return G("🤷 暂无BUG");
|
|
1108
1108
|
const n = await ke({
|
|
@@ -1117,31 +1117,31 @@ async function ga(e) {
|
|
|
1117
1117
|
await Te(S.FIX, n, e);
|
|
1118
1118
|
}
|
|
1119
1119
|
if (t === S.CHORE) {
|
|
1120
|
-
|
|
1120
|
+
let i = "";
|
|
1121
|
+
e && (i = await B({
|
|
1121
1122
|
message: "请输入commit msg:",
|
|
1122
1123
|
validate: (n) => n.length === 0 ? "请输入commit msg" : !0
|
|
1123
|
-
});
|
|
1124
|
-
await Te(S.CHORE, i);
|
|
1124
|
+
})), await Te(S.CHORE, i);
|
|
1125
1125
|
}
|
|
1126
1126
|
process.exit(0);
|
|
1127
1127
|
}
|
|
1128
1128
|
async function ha() {
|
|
1129
1129
|
try {
|
|
1130
1130
|
const e = {}, t = async () => {
|
|
1131
|
-
const P =
|
|
1131
|
+
const P = Qe(), { projects: te } = await hi(), q = te.map((re) => {
|
|
1132
1132
|
const Pe = {
|
|
1133
1133
|
name: `${re.name} [${re.desc}]`,
|
|
1134
1134
|
value: re.name,
|
|
1135
1135
|
disabled: !1
|
|
1136
1136
|
};
|
|
1137
1137
|
return P.includes(re.name) && (Pe.disabled = "目录下已存在同名文件夹"), Pe;
|
|
1138
|
-
}),
|
|
1138
|
+
}), yt = await k({
|
|
1139
1139
|
message: "请选择一个项目模板",
|
|
1140
1140
|
choices: q
|
|
1141
|
-
}), je = te.find((re) => re.name ===
|
|
1141
|
+
}), je = te.find((re) => re.name === yt);
|
|
1142
1142
|
e.tplName = je.name, e.tplUrl = je.url, e.tplLanguage = je.language;
|
|
1143
1143
|
}, i = async () => {
|
|
1144
|
-
const { groups: P } =
|
|
1144
|
+
const { groups: P } = Pi(), te = await k({
|
|
1145
1145
|
message: "请选择一个分组",
|
|
1146
1146
|
choices: P.map((q) => ({
|
|
1147
1147
|
name: `${q.name} [${q.description}]`,
|
|
@@ -1156,17 +1156,17 @@ async function ha() {
|
|
|
1156
1156
|
}, n = async () => {
|
|
1157
1157
|
e.projectName = await B({
|
|
1158
1158
|
message: "请输入项目名称",
|
|
1159
|
-
validate: (P) =>
|
|
1159
|
+
validate: (P) => ua(P, e.group?.name || "")
|
|
1160
1160
|
}), e.projectDesc = await B({
|
|
1161
1161
|
message: "请输入项目描述",
|
|
1162
|
-
validate:
|
|
1162
|
+
validate: la
|
|
1163
1163
|
});
|
|
1164
1164
|
};
|
|
1165
1165
|
await t(), await i(), await n();
|
|
1166
1166
|
const a = `${de}/${e.group?.name}/${e.projectName}.git`, s = w("模版初始化中").start();
|
|
1167
|
-
await l(`git clone --depth=1 ${e.tplUrl}`), await
|
|
1167
|
+
await l(`git clone --depth=1 ${e.tplUrl}`), await Fe(e.tplName, e.projectName), L.cd(e.projectName), L.rm("-rf", ".git"), await l(`git init --initial-branch=${y.MASTER}`), await l(`git remote add origin ${a}`), await l(`git config user.name ${E("gitName")}`), await l(`git config user.email ${E("gitEmail")}`);
|
|
1168
1168
|
const o = be();
|
|
1169
|
-
|
|
1169
|
+
li({
|
|
1170
1170
|
...o,
|
|
1171
1171
|
name: e.projectName,
|
|
1172
1172
|
description: e.projectDesc,
|
|
@@ -1174,12 +1174,12 @@ async function ha() {
|
|
|
1174
1174
|
...o.scripts,
|
|
1175
1175
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1176
1176
|
}
|
|
1177
|
-
}), await I.writeFile(m.resolve("README.md"),
|
|
1177
|
+
}), await I.writeFile(m.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Ie(e.tplLanguage, e.group?.name);
|
|
1178
1178
|
const r = w("依赖安装中").start();
|
|
1179
1179
|
await l("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1180
1180
|
const c = w("项目推送中").start();
|
|
1181
1181
|
await l('git add . && git commit -m "chore: 项目初始化"'), await l("git tag v0.0.1");
|
|
1182
|
-
const u = await
|
|
1182
|
+
const u = await Ei({
|
|
1183
1183
|
name: e.projectName,
|
|
1184
1184
|
description: e.projectDesc,
|
|
1185
1185
|
path: e.projectName,
|
|
@@ -1187,9 +1187,9 @@ async function ha() {
|
|
|
1187
1187
|
namespace_id: e.group?.id
|
|
1188
1188
|
});
|
|
1189
1189
|
await l(`git push -u origin ${y.MASTER}`), await l(`git push origin HEAD:${y.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${j.blue(a)}`);
|
|
1190
|
-
const d = w("初始化分支中").start(), g = `feat_init_${
|
|
1190
|
+
const d = w("初始化分支中").start(), g = `feat_init_${tt()}`, f = [y.DEV, y.TEST, y.RELEASE, g], h = await Promise.allSettled(
|
|
1191
1191
|
f.map(
|
|
1192
|
-
(P) =>
|
|
1192
|
+
(P) => Di({
|
|
1193
1193
|
id: u.id,
|
|
1194
1194
|
branch: P,
|
|
1195
1195
|
ref: y.MASTER
|
|
@@ -1238,12 +1238,12 @@ async function wa(e, t) {
|
|
|
1238
1238
|
/* Project */
|
|
1239
1239
|
}
|
|
1240
1240
|
]
|
|
1241
|
-
}), i === "project" ? await ha() : (ne(), Q(), i === "branch" ? (await pe(), await
|
|
1241
|
+
}), i === "project" ? await ha() : (ne(), Q(), i === "branch" ? (await pe(), await ma(t)) : i === "commit-msg" && (await l("git status -s") ? await ga(t.commitMessageCloseAi) : p("没有要提交的文件,无法生成提交信息")));
|
|
1242
1242
|
}
|
|
1243
1243
|
D.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(me).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").action((...e) => z(wa, ...e));
|
|
1244
1244
|
function ya(e) {
|
|
1245
|
-
return
|
|
1246
|
-
url: `${W("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${
|
|
1245
|
+
return it({
|
|
1246
|
+
url: `${W("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${zt}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
|
|
1247
1247
|
method: "post",
|
|
1248
1248
|
data: e.params
|
|
1249
1249
|
});
|
|
@@ -1280,24 +1280,24 @@ function va(e, t) {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
t === K.NPM && (i?.scripts.build || p("项目package.json文件scripts不存在命令build。")), t === K.SERVER && (i?.scripts.build || p("项目package.json文件scripts不存在命令build。"));
|
|
1282
1282
|
}
|
|
1283
|
-
async function
|
|
1283
|
+
async function ut(e, t) {
|
|
1284
1284
|
ne(), Q(), await pe();
|
|
1285
1285
|
let i = e, n = t.platform;
|
|
1286
1286
|
if (i && !Object.values(y).includes(i) && p("仅支持发布指定环境分支"), n && !Object.values(K).includes(n) && p("发布平台错误"), n || (n = await k({
|
|
1287
1287
|
message: "请选择平台",
|
|
1288
|
-
choices:
|
|
1288
|
+
choices: Pt
|
|
1289
1289
|
})), n === K.NPM && (i = y.MASTER), !i) {
|
|
1290
1290
|
const c = await k({
|
|
1291
1291
|
message: "请选择部署环境",
|
|
1292
|
-
choices:
|
|
1292
|
+
choices: We
|
|
1293
1293
|
});
|
|
1294
|
-
i =
|
|
1294
|
+
i = Zt(c);
|
|
1295
1295
|
}
|
|
1296
1296
|
let a = [];
|
|
1297
|
-
t.skipSelectionNotification || (a = await
|
|
1297
|
+
t.skipSelectionNotification || (a = await ot("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1298
1298
|
let s = [];
|
|
1299
|
-
t.skipGroupNotification || (s = await
|
|
1300
|
-
const o =
|
|
1299
|
+
t.skipGroupNotification || (s = await aa("请选择部署成功要通知的群组:", () => !0, !0));
|
|
1300
|
+
const o = Ht(i);
|
|
1301
1301
|
va(o, n);
|
|
1302
1302
|
const r = be();
|
|
1303
1303
|
await $a({
|
|
@@ -1307,11 +1307,11 @@ async function ct(e, t) {
|
|
|
1307
1307
|
notifyGroup: s
|
|
1308
1308
|
});
|
|
1309
1309
|
}
|
|
1310
|
-
async function
|
|
1310
|
+
async function lt(e, t, i, n) {
|
|
1311
1311
|
const a = w(`分支合并中,${e} -> ${t}`).start();
|
|
1312
1312
|
let s = 0;
|
|
1313
1313
|
try {
|
|
1314
|
-
const { iid: r } = await
|
|
1314
|
+
const { iid: r } = await Ci({
|
|
1315
1315
|
title: `${e} -> ${t} by z-develop`,
|
|
1316
1316
|
id: i.id,
|
|
1317
1317
|
source_branch: e,
|
|
@@ -1327,7 +1327,7 @@ async function ut(e, t, i, n) {
|
|
|
1327
1327
|
try {
|
|
1328
1328
|
await new Promise((r) => {
|
|
1329
1329
|
setTimeout(r, 5e3);
|
|
1330
|
-
}), await
|
|
1330
|
+
}), await Ri({
|
|
1331
1331
|
id: i.id,
|
|
1332
1332
|
iid: s
|
|
1333
1333
|
}), a.succeed(`分支${e}已合并到分支${t}`);
|
|
@@ -1336,12 +1336,12 @@ async function ut(e, t, i, n) {
|
|
|
1336
1336
|
const c = r?.response?.status;
|
|
1337
1337
|
if (c === 406)
|
|
1338
1338
|
return await o();
|
|
1339
|
-
if (await
|
|
1339
|
+
if (await Ii({
|
|
1340
1340
|
id: i.id,
|
|
1341
1341
|
iid: s,
|
|
1342
1342
|
state_event: "close"
|
|
1343
1343
|
}), c === 405) {
|
|
1344
|
-
const u = await
|
|
1344
|
+
const u = await xi({
|
|
1345
1345
|
id: i.id,
|
|
1346
1346
|
iid: s
|
|
1347
1347
|
});
|
|
@@ -1361,20 +1361,20 @@ async function Na(e, t) {
|
|
|
1361
1361
|
);
|
|
1362
1362
|
if (s || p(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await l(
|
|
1363
1363
|
`git branch --contains ${n} -r ${i}`
|
|
1364
|
-
) || (console.log(j.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await
|
|
1364
|
+
) || (console.log(j.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt(y.MASTER, e.sourceBranch, e)), t === y.MASTER) {
|
|
1365
1365
|
const r = s.split(`
|
|
1366
1366
|
`).filter((g) => g), c = await l(`git log -b origin/${$.TEST} -1 --format=%H`), d = (await l(
|
|
1367
1367
|
`git log ${n}...${c} -b origin/${$.TEST}`
|
|
1368
1368
|
)).split(`
|
|
1369
1369
|
`).filter((g) => g);
|
|
1370
|
-
|
|
1370
|
+
qt(d, r) || p("请先在测试环境发布要部署的代码");
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
1373
1373
|
async function ba(e, t) {
|
|
1374
1374
|
ne(), Q(), await pe();
|
|
1375
|
-
const i = await
|
|
1375
|
+
const i = await pi();
|
|
1376
1376
|
Object.values(y).includes(i.sourceBranch) && p(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1377
|
-
const a = (await
|
|
1377
|
+
const a = (await Li(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
|
|
1378
1378
|
let u = c.name;
|
|
1379
1379
|
return Object.values(y).includes(u) && (u = j.bold.blue(u)), {
|
|
1380
1380
|
name: u,
|
|
@@ -1395,16 +1395,16 @@ async function ba(e, t) {
|
|
|
1395
1395
|
), process.exit(1));
|
|
1396
1396
|
} else
|
|
1397
1397
|
await l(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`);
|
|
1398
|
-
await Na(i, s), await
|
|
1398
|
+
await Na(i, s), await lt(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}`), G(
|
|
1399
1399
|
`${i.sourceBranch}分支已移除,当前已切换到最新的${y.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1400
|
-
)), Object.values(y).includes(s) && await
|
|
1400
|
+
)), Object.values(y).includes(s) && await ut(s, {
|
|
1401
1401
|
platform: t.deployPlatform,
|
|
1402
1402
|
skipSelectionNotification: t.deploySkipSelectionNotification,
|
|
1403
1403
|
skipGroupNotification: t.skipGroupNotification
|
|
1404
1404
|
});
|
|
1405
1405
|
}
|
|
1406
1406
|
D.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(K).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => z(ba, ...e));
|
|
1407
|
-
D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(y).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(K).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => z(
|
|
1407
|
+
D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(y).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(K).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => z(ut, ...e));
|
|
1408
1408
|
async function Aa() {
|
|
1409
1409
|
try {
|
|
1410
1410
|
await l("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
|
|
@@ -1422,7 +1422,7 @@ function Sa() {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
async function ja() {
|
|
1424
1424
|
const e = w("代码风格检测中...").start();
|
|
1425
|
-
await
|
|
1425
|
+
await kt({
|
|
1426
1426
|
concurrent: 4,
|
|
1427
1427
|
debug: !1,
|
|
1428
1428
|
config: Sa(),
|
|
@@ -1431,7 +1431,7 @@ async function ja() {
|
|
|
1431
1431
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
1432
1432
|
}
|
|
1433
1433
|
function Ta(e) {
|
|
1434
|
-
if (e.includes("Merge") && e.includes("# Conflicts:") ||
|
|
1434
|
+
if (e.includes("Merge") && e.includes("# Conflicts:") || Ct.valid(e))
|
|
1435
1435
|
return !0;
|
|
1436
1436
|
const t = e.split(": ");
|
|
1437
1437
|
if (t.length === 1)
|
|
@@ -1445,7 +1445,7 @@ async function Ea() {
|
|
|
1445
1445
|
}
|
|
1446
1446
|
async function ka() {
|
|
1447
1447
|
await pe();
|
|
1448
|
-
const e = await
|
|
1448
|
+
const e = await Rt({
|
|
1449
1449
|
// 分组,展示仓库链接
|
|
1450
1450
|
format: ["group", "repo"],
|
|
1451
1451
|
// 交互式弹窗
|
|
@@ -1489,7 +1489,7 @@ async function Ra() {
|
|
|
1489
1489
|
}
|
|
1490
1490
|
}
|
|
1491
1491
|
function Ia() {
|
|
1492
|
-
v(m.resolve("./node_modules/.bin/vue-tsc")) || p("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"),
|
|
1492
|
+
v(m.resolve("./node_modules/.bin/vue-tsc")) || p("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), et("npx vue-tsc --build"), process.exit(0);
|
|
1493
1493
|
}
|
|
1494
1494
|
async function xa(e, t) {
|
|
1495
1495
|
ne(), Q();
|
|
@@ -1564,23 +1564,23 @@ D.command("run").alias("r").description("执行 eslint / prettier / type-check /
|
|
|
1564
1564
|
"[type]",
|
|
1565
1565
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs。"
|
|
1566
1566
|
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(xa, ...e));
|
|
1567
|
-
async function
|
|
1567
|
+
async function pt(e = "latest") {
|
|
1568
1568
|
const t = w("安装中...").start();
|
|
1569
1569
|
await l(`npm i -g ${ie.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", ue("latestCheckVersionTimestamp", Date.now()), ue("version", e), se(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1570
1570
|
}
|
|
1571
|
-
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(
|
|
1571
|
+
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(pt, ...e));
|
|
1572
1572
|
async function Da(e) {
|
|
1573
1573
|
let t = e;
|
|
1574
1574
|
t ? [$.DEV, $.TEST, $.RELEASE, $.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = $.DEV : t === "t" ? t = $.TEST : t === "r" ? t = $.RELEASE : t === "p" && (t = $.PROD) : p("参数输入有误") : t = await k({
|
|
1575
1575
|
message: "请选择环境",
|
|
1576
|
-
choices:
|
|
1576
|
+
choices: We
|
|
1577
1577
|
});
|
|
1578
1578
|
const i = be(), n = `dev:${t}`;
|
|
1579
|
-
i.scripts[n] ?
|
|
1579
|
+
i.scripts[n] ? et(`npm run ${n}`) : p(`项目中(package.json > scripts)不存在命令${n},请先添加!`);
|
|
1580
1580
|
}
|
|
1581
1581
|
D.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(Da, ...e));
|
|
1582
|
-
const xe = /Thumbs\.db|\.git|DS_Store|idea/,
|
|
1583
|
-
function
|
|
1582
|
+
const xe = /Thumbs\.db|\.git|DS_Store|idea/, mt = "testcase";
|
|
1583
|
+
function dt(e) {
|
|
1584
1584
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
1585
1585
|
if (t && !e.startsWith("["))
|
|
1586
1586
|
return {
|
|
@@ -1603,11 +1603,11 @@ async function X(e, t = {}) {
|
|
|
1603
1603
|
const { exclude: i = xe } = t, n = [];
|
|
1604
1604
|
async function a(s) {
|
|
1605
1605
|
const o = m.basename(s);
|
|
1606
|
-
if ((await
|
|
1606
|
+
if ((await At(s)).isFile())
|
|
1607
1607
|
return null;
|
|
1608
1608
|
const c = await Ce(s, { withFileTypes: !0 }), u = (await Promise.all(
|
|
1609
1609
|
c.filter((T) => T.isDirectory() && !i.test(T.name)).map((T) => a(m.join(s, T.name)))
|
|
1610
|
-
)).filter(Boolean), { type: d, id: g, displayName: f } =
|
|
1610
|
+
)).filter(Boolean), { type: d, id: g, displayName: f } = dt(o), h = {
|
|
1611
1611
|
name: o,
|
|
1612
1612
|
id: g,
|
|
1613
1613
|
displayName: f,
|
|
@@ -1619,13 +1619,13 @@ async function X(e, t = {}) {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
return await a(m.resolve(e)), n;
|
|
1621
1621
|
}
|
|
1622
|
-
async function
|
|
1622
|
+
async function ft(e, t = {}) {
|
|
1623
1623
|
const { exclude: i = xe } = t;
|
|
1624
1624
|
try {
|
|
1625
1625
|
const n = await Ce(m.resolve(e), { withFileTypes: !0 });
|
|
1626
1626
|
return await Promise.all(
|
|
1627
1627
|
n.filter((a) => a.isDirectory() && !i.test(a.name)).map((a) => {
|
|
1628
|
-
const s = m.join(e, a.name), { type: o, id: r, displayName: c } =
|
|
1628
|
+
const s = m.join(e, a.name), { type: o, id: r, displayName: c } = dt(a.name);
|
|
1629
1629
|
return {
|
|
1630
1630
|
name: a.name,
|
|
1631
1631
|
id: r,
|
|
@@ -1655,7 +1655,7 @@ async function we(e, t, i, n) {
|
|
|
1655
1655
|
if (a === s)
|
|
1656
1656
|
return !0;
|
|
1657
1657
|
const o = m.dirname(e), r = m.join(o, s);
|
|
1658
|
-
return await
|
|
1658
|
+
return await Kt(e) ? await Fe(e, r) : (await l(`git mv "${e}" "${r}"`), await l("git add .")), !0;
|
|
1659
1659
|
} catch (a) {
|
|
1660
1660
|
return p(`重命名文件夹失败: ${e} -> ${t}。${a}`), !1;
|
|
1661
1661
|
}
|
|
@@ -1664,7 +1664,7 @@ async function La(e, t, i = {}) {
|
|
|
1664
1664
|
const { exclude: n = xe } = i;
|
|
1665
1665
|
async function a(s, o) {
|
|
1666
1666
|
if (!s || s.length === 0) return;
|
|
1667
|
-
const r = await
|
|
1667
|
+
const r = await ft(o, { exclude: n });
|
|
1668
1668
|
for (const c of s) {
|
|
1669
1669
|
const u = String(c.value), d = V("module", c.label, u), g = r.find((h) => h.id === u);
|
|
1670
1670
|
let f = g?.path || m.join(o, d);
|
|
@@ -1673,7 +1673,7 @@ async function La(e, t, i = {}) {
|
|
|
1673
1673
|
}
|
|
1674
1674
|
await a(e, m.resolve(t));
|
|
1675
1675
|
}
|
|
1676
|
-
async function
|
|
1676
|
+
async function gt(e) {
|
|
1677
1677
|
const t = {
|
|
1678
1678
|
id: 0,
|
|
1679
1679
|
name: "",
|
|
@@ -1682,7 +1682,7 @@ async function ft(e) {
|
|
|
1682
1682
|
if (e)
|
|
1683
1683
|
Number.isNaN(Number(e)) && p("请输入正确的产品ID"), t.id = Number(e);
|
|
1684
1684
|
else {
|
|
1685
|
-
const i = await
|
|
1685
|
+
const i = await zi();
|
|
1686
1686
|
t.id = await k({
|
|
1687
1687
|
message: "请选择产品",
|
|
1688
1688
|
choices: i.map((n) => ({
|
|
@@ -1691,30 +1691,30 @@ async function ft(e) {
|
|
|
1691
1691
|
}))
|
|
1692
1692
|
});
|
|
1693
1693
|
}
|
|
1694
|
-
return t.name = await
|
|
1694
|
+
return t.name = await _i(t.id), t.path = m.join(mt, V("module", t.name, String(t.id))), t;
|
|
1695
1695
|
}
|
|
1696
1696
|
async function De(e) {
|
|
1697
|
-
return (await
|
|
1697
|
+
return (await ft(mt)).find((i) => Number(i.id) === e.id);
|
|
1698
1698
|
}
|
|
1699
|
-
async function
|
|
1699
|
+
async function ht(e, t) {
|
|
1700
1700
|
const i = {
|
|
1701
1701
|
precondition: e.precondition,
|
|
1702
1702
|
priority: e.pri,
|
|
1703
1703
|
steps: []
|
|
1704
1704
|
};
|
|
1705
|
-
i.steps = await
|
|
1705
|
+
i.steps = await Fi(e.id), I.writeJSONSync(t, i, {
|
|
1706
1706
|
spaces: 2
|
|
1707
1707
|
});
|
|
1708
1708
|
}
|
|
1709
|
-
async function
|
|
1709
|
+
async function wt(e, t) {
|
|
1710
1710
|
await le(t, {
|
|
1711
1711
|
recursive: !0
|
|
1712
|
-
}), await
|
|
1712
|
+
}), await ht(e, m.join(t, "config.json")), I.ensureFileSync(m.join(t, "data.yaml")), await O(
|
|
1713
1713
|
m.join(t, "data.yaml"),
|
|
1714
|
-
v(m.resolve(Z, "data.yaml")) ? await Ee(m.resolve(Z, "data.yaml")) : await
|
|
1714
|
+
v(m.resolve(Z, "data.yaml")) ? await Ee(m.resolve(Z, "data.yaml")) : await Ni()
|
|
1715
1715
|
), I.ensureFileSync(m.join(t, "main.py")), await O(
|
|
1716
1716
|
m.join(t, "main.py"),
|
|
1717
|
-
v(m.resolve(Z, "main.py")) ? await Ee(m.resolve(Z, "main.py")) : await
|
|
1717
|
+
v(m.resolve(Z, "main.py")) ? await Ee(m.resolve(Z, "main.py")) : await bi()
|
|
1718
1718
|
);
|
|
1719
1719
|
}
|
|
1720
1720
|
function Le(e) {
|
|
@@ -1732,7 +1732,7 @@ async function Ae(e, t) {
|
|
|
1732
1732
|
let i;
|
|
1733
1733
|
t ? ([R.MODULE, R.CASE].includes(t) || p(`不支持的参数${t}。参数值应为 ${R.MODULE} 或者 ${R.CASE}。`), i = t) : i = await k({
|
|
1734
1734
|
message: `请选择要${e}的数据类型`,
|
|
1735
|
-
choices:
|
|
1735
|
+
choices: _t
|
|
1736
1736
|
});
|
|
1737
1737
|
const n = i === R.MODULE ? "模块" : R.CASE === i ? "用例" : "";
|
|
1738
1738
|
return {
|
|
@@ -1741,7 +1741,7 @@ async function Ae(e, t) {
|
|
|
1741
1741
|
};
|
|
1742
1742
|
}
|
|
1743
1743
|
async function Se(e) {
|
|
1744
|
-
const t = await
|
|
1744
|
+
const t = await gt(e), i = await De(t);
|
|
1745
1745
|
return i || p(`本地未找到产品【${t.name}[${t.id}]】`), {
|
|
1746
1746
|
product: t,
|
|
1747
1747
|
localProduct: i
|
|
@@ -1752,7 +1752,7 @@ async function Pa(e, t, i) {
|
|
|
1752
1752
|
const a = Le(i);
|
|
1753
1753
|
let s = await X(t.path);
|
|
1754
1754
|
e.text = "获取远程用例列表...";
|
|
1755
|
-
const o = await
|
|
1755
|
+
const o = await Bi(t.id, a);
|
|
1756
1756
|
e.text = "本地用例同步中...";
|
|
1757
1757
|
for (const r of o) {
|
|
1758
1758
|
let c;
|
|
@@ -1760,13 +1760,13 @@ async function Pa(e, t, i) {
|
|
|
1760
1760
|
return p(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
1761
1761
|
const u = s.find(({ id: d }) => r.id === Number(d));
|
|
1762
1762
|
if (u)
|
|
1763
|
-
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && G(`重命名成功: ${u.displayName} -> ${r.title}`), s = await X(t.path), r.module === 0 ? c = m.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await
|
|
1763
|
+
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && G(`重命名成功: ${u.displayName} -> ${r.title}`), s = await X(t.path), r.module === 0 ? c = m.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await ht(
|
|
1764
1764
|
r,
|
|
1765
1765
|
m.join(c, V("case", r.title, String(r.id)), "config.json")
|
|
1766
1766
|
);
|
|
1767
1767
|
else {
|
|
1768
1768
|
const d = m.join(c, V("case", r.title, String(r.id)));
|
|
1769
|
-
await
|
|
1769
|
+
await wt(r, d);
|
|
1770
1770
|
}
|
|
1771
1771
|
}
|
|
1772
1772
|
}
|
|
@@ -1774,11 +1774,11 @@ async function Oa(e, t) {
|
|
|
1774
1774
|
e.text = "本地产品目录查找中...";
|
|
1775
1775
|
const i = await De(t);
|
|
1776
1776
|
i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await we(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await le(t.path, { recursive: !0 }), await l("git add .")), e.text = "获取远程模块列表...";
|
|
1777
|
-
const n = await
|
|
1777
|
+
const n = await st(t.id);
|
|
1778
1778
|
e.text = "本地同步模块中...", await La(n || [], t.path);
|
|
1779
1779
|
}
|
|
1780
1780
|
async function Ma(e, t) {
|
|
1781
|
-
const { type: i, typeStr: n } = await Ae("拉取", e), a = await
|
|
1781
|
+
const { type: i, typeStr: n } = await Ae("拉取", e), a = await gt(t.productId), s = w(`${n}同步中...`).start();
|
|
1782
1782
|
if (R.MODULE === i && await Oa(s, a), R.CASE === i && await Pa(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await l("git status -s")) {
|
|
1783
1783
|
const o = w("代码提交中...").start();
|
|
1784
1784
|
try {
|
|
@@ -1794,7 +1794,7 @@ async function za(e, t, i) {
|
|
|
1794
1794
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
1795
1795
|
}), a = w(`用例【${i}】开始创建...`).start();
|
|
1796
1796
|
a.text = "远程用例创建中...";
|
|
1797
|
-
const s = await
|
|
1797
|
+
const s = await Ji({
|
|
1798
1798
|
product: Number(e.id),
|
|
1799
1799
|
// 如果父模块是产品根目录,parent=0
|
|
1800
1800
|
module: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
@@ -1803,14 +1803,14 @@ async function za(e, t, i) {
|
|
|
1803
1803
|
openedBy: E("ldapAccount"),
|
|
1804
1804
|
precondition: n || ""
|
|
1805
1805
|
});
|
|
1806
|
-
a.text = "远程用例步骤创建中...", await
|
|
1806
|
+
a.text = "远程用例步骤创建中...", await Gi({
|
|
1807
1807
|
case: s,
|
|
1808
1808
|
type: "step",
|
|
1809
1809
|
desc: "按照预期执行",
|
|
1810
1810
|
expect: "正常执行,符合预期"
|
|
1811
1811
|
}), a.text = "本地用例创建中...";
|
|
1812
1812
|
const o = m.join(t.path, V("case", i, String(s)));
|
|
1813
|
-
return v(o) ? G(`${o}已存在,请检查是否对应,本地不再创建。`) : (await
|
|
1813
|
+
return v(o) ? G(`${o}已存在,请检查是否对应,本地不再创建。`) : (await wt(
|
|
1814
1814
|
{
|
|
1815
1815
|
id: s,
|
|
1816
1816
|
pri: 3,
|
|
@@ -1822,7 +1822,7 @@ async function za(e, t, i) {
|
|
|
1822
1822
|
async function _a(e, t, i) {
|
|
1823
1823
|
const n = w(`模块【${i}】开始创建...`).start();
|
|
1824
1824
|
n.text = "远程模块创建中...";
|
|
1825
|
-
const a = await
|
|
1825
|
+
const a = await Ui({
|
|
1826
1826
|
root: Number(e.id),
|
|
1827
1827
|
name: i,
|
|
1828
1828
|
// 如果父模块是产品根目录,parent=0
|
|
@@ -1861,7 +1861,7 @@ function Ba(e) {
|
|
|
1861
1861
|
return i(e);
|
|
1862
1862
|
}
|
|
1863
1863
|
async function Fa(e, t) {
|
|
1864
|
-
const { type: i, typeStr: n } = await Ae("创建", e), { product: a, localProduct: s } = await Se(t.productId), o = await
|
|
1864
|
+
const { type: i, typeStr: n } = await Ae("创建", e), { product: a, localProduct: s } = await Se(t.productId), o = await st(a.id), r = await Ba(o), c = V("module", r.label, String(r.value)), d = (await X(a.path, { hasRoot: !0 })).find((h) => h.name === c);
|
|
1865
1865
|
if (!d?.path || !v(d.path))
|
|
1866
1866
|
return p(`本地不存在${c}模块`);
|
|
1867
1867
|
const g = await B({
|
|
@@ -1907,7 +1907,7 @@ async function Ua(e, t) {
|
|
|
1907
1907
|
});
|
|
1908
1908
|
}
|
|
1909
1909
|
const s = w("远程用例删除中...").start(), o = a.map((r) => r.id);
|
|
1910
|
-
await
|
|
1910
|
+
await Wi({
|
|
1911
1911
|
product: Number(e.id),
|
|
1912
1912
|
caseIds: o
|
|
1913
1913
|
}), s.text = "本地用例删除中...";
|
|
@@ -1943,7 +1943,7 @@ async function Ja(e, t) {
|
|
|
1943
1943
|
}
|
|
1944
1944
|
a = a.sort((r, c) => r.path.localeCompare(c.path));
|
|
1945
1945
|
const s = w("远程模块删除中...").start(), o = a.map((r) => r.id);
|
|
1946
|
-
await
|
|
1946
|
+
await Vi({
|
|
1947
1947
|
product: Number(e.id),
|
|
1948
1948
|
moduleIds: o
|
|
1949
1949
|
}), s.text = "本地模块删除中...";
|
|
@@ -1997,7 +1997,7 @@ async function Va(e, t) {
|
|
|
1997
1997
|
validate: (f) => f.length > 0 && f.length < 255,
|
|
1998
1998
|
prefill: "editable"
|
|
1999
1999
|
}), o = w("用例重命名中...").start();
|
|
2000
|
-
s !== a.displayName ? (await
|
|
2000
|
+
s !== a.displayName ? (await Hi({
|
|
2001
2001
|
id: Number(a.id),
|
|
2002
2002
|
name: s
|
|
2003
2003
|
}), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path = m.join(m.dirname(a.path), V("case", s, String(a.id)))) : o.succeed("用例名称无变动");
|
|
@@ -2018,7 +2018,7 @@ async function Va(e, t) {
|
|
|
2018
2018
|
validate: (f) => f > 0 && f < 6
|
|
2019
2019
|
});
|
|
2020
2020
|
const u = w("用例优先级设置中...").start();
|
|
2021
|
-
c !== r.priority ? (await
|
|
2021
|
+
c !== r.priority ? (await Zi({
|
|
2022
2022
|
id: Number(a.id),
|
|
2023
2023
|
priority: c
|
|
2024
2024
|
}), I.writeJSONSync(
|
|
@@ -2036,7 +2036,7 @@ async function Va(e, t) {
|
|
|
2036
2036
|
prefill: "editable"
|
|
2037
2037
|
});
|
|
2038
2038
|
const g = w("用例前置条件设置中...").start();
|
|
2039
|
-
return d !== r.precondition ? (await
|
|
2039
|
+
return d !== r.precondition ? (await Ki({
|
|
2040
2040
|
id: Number(a.id),
|
|
2041
2041
|
precondition: d
|
|
2042
2042
|
}), I.writeJSONSync(
|
|
@@ -2081,7 +2081,7 @@ async function Wa(e, t) {
|
|
|
2081
2081
|
validate: (r) => r.length > 0 && r.length < 255,
|
|
2082
2082
|
prefill: "editable"
|
|
2083
2083
|
}), o = w("模块重命名中...").start();
|
|
2084
|
-
return s !== a.displayName ? (await
|
|
2084
|
+
return s !== a.displayName ? (await qi({
|
|
2085
2085
|
id: Number(a.id),
|
|
2086
2086
|
name: s
|
|
2087
2087
|
}), await we(a.path, s, "module", String(a.id)) && o.succeed(`模块重命名成功: ${a.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), a.id;
|
|
@@ -2102,7 +2102,7 @@ D.command("qa-update").alias("qu").description("修改模块或者用例").argum
|
|
|
2102
2102
|
async function Ha(e, t) {
|
|
2103
2103
|
if (!e.length)
|
|
2104
2104
|
return [];
|
|
2105
|
-
const i =
|
|
2105
|
+
const i = It(20), n = e.map(
|
|
2106
2106
|
(a) => i(async () => {
|
|
2107
2107
|
try {
|
|
2108
2108
|
const s = t.env || "production", o = await l(`python ${a.path}/main.py --env ${s}`);
|
|
@@ -2170,10 +2170,10 @@ async function Za(e) {
|
|
|
2170
2170
|
if (e.executionId)
|
|
2171
2171
|
Number.isNaN(Number(e.executionId)) && p(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
|
|
2172
2172
|
else {
|
|
2173
|
-
const g = await
|
|
2173
|
+
const g = await Xi(), f = await k({
|
|
2174
2174
|
message: "请选择用例执行出错后,BUG所属的项目",
|
|
2175
2175
|
choices: g.map(({ id: T, name: ee }) => ({ name: ee, value: T }))
|
|
2176
|
-
}), h = await
|
|
2176
|
+
}), h = await Qi(f);
|
|
2177
2177
|
u = await k({
|
|
2178
2178
|
message: "请选择用例执行出错后,BUG所属的执行",
|
|
2179
2179
|
choices: h.map(({ id: T, name: ee }) => ({ name: ee, value: T }))
|
|
@@ -2183,7 +2183,7 @@ async function Za(e) {
|
|
|
2183
2183
|
if (e.buildId)
|
|
2184
2184
|
d = e.buildId;
|
|
2185
2185
|
else {
|
|
2186
|
-
const g = await
|
|
2186
|
+
const g = await ea(Number(u));
|
|
2187
2187
|
if (g.length) {
|
|
2188
2188
|
const f = await ke({
|
|
2189
2189
|
message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
|
|
@@ -2199,7 +2199,7 @@ async function Za(e) {
|
|
|
2199
2199
|
}
|
|
2200
2200
|
s.start("上传中...");
|
|
2201
2201
|
for (const g of r)
|
|
2202
|
-
await
|
|
2202
|
+
await Yi({
|
|
2203
2203
|
caseId: g.id,
|
|
2204
2204
|
caseResult: "fail",
|
|
2205
2205
|
stepResults: g.result,
|
|
@@ -2221,7 +2221,7 @@ function Ka() {
|
|
|
2221
2221
|
async function Ya() {
|
|
2222
2222
|
const e = fe("latestCheckVersionTimestamp"), t = fe("versionCheckDuring");
|
|
2223
2223
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
2224
|
-
const i = await
|
|
2224
|
+
const i = await at();
|
|
2225
2225
|
Re(i);
|
|
2226
2226
|
let n;
|
|
2227
2227
|
try {
|
|
@@ -2231,23 +2231,23 @@ async function Ya() {
|
|
|
2231
2231
|
n = await Promise.race([
|
|
2232
2232
|
s,
|
|
2233
2233
|
l(`npm view ${ie.name} version --registry https://registry.npmmirror.com/`)
|
|
2234
|
-
]), n !== a && n !== ie.version && (console.log(`${j.blue(ie.name)}本地版本为${ie.version},低于线上版本${n},开始升级`), await
|
|
2234
|
+
]), n !== a && n !== ie.version && (console.log(`${j.blue(ie.name)}本地版本为${ie.version},低于线上版本${n},开始升级`), await pt(n)), ue("latestCheckVersionTimestamp", Date.now()), se();
|
|
2235
2235
|
} catch (a) {
|
|
2236
2236
|
console.log("升级出错!请重试,或者手动升级"), p(a);
|
|
2237
2237
|
}
|
|
2238
2238
|
}
|
|
2239
2239
|
}
|
|
2240
2240
|
async function Xa() {
|
|
2241
|
-
const e =
|
|
2241
|
+
const e = xt(process.argv.slice(2));
|
|
2242
2242
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2243
|
-
if (
|
|
2243
|
+
if (Ke()) {
|
|
2244
2244
|
const t = I.readJSONSync(Ne());
|
|
2245
2245
|
M(t.profile), ue(t.main), Re(t.constants), await Ya();
|
|
2246
2246
|
} else
|
|
2247
|
-
p(`请先初始化z-develop(执行 z i)。更多见${
|
|
2247
|
+
p(`请先初始化z-develop(执行 z i)。更多见${qe}`);
|
|
2248
2248
|
}
|
|
2249
2249
|
async function Qa() {
|
|
2250
2250
|
Ka(), await Xa();
|
|
2251
2251
|
}
|
|
2252
|
-
D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${j.blue(
|
|
2252
|
+
D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${j.blue(qe)}`).usage("<command> [options]").hook("preAction", Qa).version(ie.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
2253
2253
|
D.parse();
|