cli-z-develop 0.14.10 → 0.14.11
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 +479 -463
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { program as
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import { existsSync as A, readdirSync as Rt, lstatSync as
|
|
5
|
-
import { readdir as xe, mkdir as pe, writeFile as
|
|
1
|
+
import { program as D } from "commander";
|
|
2
|
+
import It from "node:child_process";
|
|
3
|
+
import * as Be from "node:fs";
|
|
4
|
+
import { existsSync as A, readdirSync as Rt, lstatSync as Ct, createWriteStream as xt, writeFileSync as Dt } from "node:fs";
|
|
5
|
+
import { readdir as xe, mkdir as pe, writeFile as P, rename as Xe, readFile as Ie, stat as Pt } from "node:fs/promises";
|
|
6
6
|
import m from "node:path";
|
|
7
|
-
import le, { AxiosError as
|
|
7
|
+
import le, { AxiosError as Lt } from "axios";
|
|
8
8
|
import N from "chalk";
|
|
9
|
-
import
|
|
9
|
+
import Ot from "dayjs";
|
|
10
10
|
import L from "shelljs";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { confirm as
|
|
11
|
+
import Mt from "node:os";
|
|
12
|
+
import Ue from "child_process";
|
|
13
|
+
import { confirm as Ye, select as k, input as B, password as zt, checkbox as ve, number as _e } from "@inquirer/prompts";
|
|
14
14
|
import y from "ora";
|
|
15
|
-
import
|
|
15
|
+
import R from "fs-extra";
|
|
16
16
|
import { select as H } from "inquirer-select-pro";
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { run as
|
|
20
|
-
import
|
|
21
|
-
import { generateTypescriptBundleApi as
|
|
22
|
-
import { highlight as
|
|
23
|
-
import { ESLint as
|
|
24
|
-
import { readFileSync as
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
const
|
|
28
|
-
var E = /* @__PURE__ */ ((e) => (e[e.DEV =
|
|
29
|
-
const
|
|
17
|
+
import Ft from "lint-staged";
|
|
18
|
+
import Jt from "semver";
|
|
19
|
+
import { run as Bt } from "npm-check-updates";
|
|
20
|
+
import Ut from "p-limit";
|
|
21
|
+
import { generateTypescriptBundleApi as _t, validateSwagger as Gt, getParsedSwagger as Vt, generateTypescriptApi as Wt } from "@lonely9/api-generate";
|
|
22
|
+
import { highlight as qt } from "cli-highlight";
|
|
23
|
+
import { ESLint as Qe } from "eslint";
|
|
24
|
+
import { readFileSync as Zt } from "fs";
|
|
25
|
+
import Ht from "prettier";
|
|
26
|
+
import Kt from "minimist";
|
|
27
|
+
const et = "dev", tt = "test", at = "release", Xt = "production", Yt = "master";
|
|
28
|
+
var E = /* @__PURE__ */ ((e) => (e[e.DEV = et] = "DEV", e[e.TEST = tt] = "TEST", e[e.RELEASE = at] = "RELEASE", e[e.PROD = Xt] = "PROD", e))(E || {}), $ = /* @__PURE__ */ ((e) => (e[e.DEV = et] = "DEV", e[e.TEST = tt] = "TEST", e[e.RELEASE = at] = "RELEASE", e[e.MASTER = Yt] = "MASTER", e))($ || {}), W = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(W || {});
|
|
29
|
+
const it = [
|
|
30
30
|
{
|
|
31
31
|
name: `开发环境 - ${E.DEV}`,
|
|
32
32
|
value: E.DEV
|
|
@@ -43,7 +43,7 @@ const at = [
|
|
|
43
43
|
name: `正式环境 - ${E.PROD}`,
|
|
44
44
|
value: E.PROD
|
|
45
45
|
}
|
|
46
|
-
],
|
|
46
|
+
], Qt = [
|
|
47
47
|
{
|
|
48
48
|
name: "网页 - h5",
|
|
49
49
|
value: "h5"
|
|
@@ -61,7 +61,7 @@ const at = [
|
|
|
61
61
|
}
|
|
62
62
|
];
|
|
63
63
|
var de = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(de || {}), ue = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(ue || {}), w = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e.MARKDOWN = "Markdown", e))(w || {});
|
|
64
|
-
const
|
|
64
|
+
const ea = {
|
|
65
65
|
1: "研发",
|
|
66
66
|
2: "测试",
|
|
67
67
|
3: "产品",
|
|
@@ -71,11 +71,11 @@ const Yt = {
|
|
|
71
71
|
7: "行政",
|
|
72
72
|
8: "财务",
|
|
73
73
|
9: "其他"
|
|
74
|
-
}, fe = "http://git.cxlqd.com",
|
|
74
|
+
}, fe = "http://git.cxlqd.com", ta = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
75
75
|
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 || {});
|
|
76
|
-
const
|
|
77
|
-
var
|
|
78
|
-
const
|
|
76
|
+
const aa = "fe-biz7tvsd", nt = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
77
|
+
var I = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(I || {});
|
|
78
|
+
const ia = [
|
|
79
79
|
{
|
|
80
80
|
name: "模块",
|
|
81
81
|
value: "module"
|
|
@@ -86,30 +86,30 @@ const ta = [
|
|
|
86
86
|
value: "case"
|
|
87
87
|
/* CASE */
|
|
88
88
|
}
|
|
89
|
-
],
|
|
89
|
+
], na = 150 * 1024, Ge = 0.8 * 1024 * 1024, Re = ",", sa = ".z", ra = "develop-config.json", Q = ".z", oa = ".commit-msg-tpl", ca = "project.json";
|
|
90
90
|
function T(e = "") {
|
|
91
91
|
return m.join(Q, e);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
return T(
|
|
93
|
+
function st() {
|
|
94
|
+
return T(ca);
|
|
95
95
|
}
|
|
96
96
|
function Ne() {
|
|
97
|
-
return T(
|
|
97
|
+
return T(oa);
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
99
|
+
function rt() {
|
|
100
|
+
Ue.spawnSync("git", ["config", "core.hooksPath", T()]), Ue.spawnSync("git", ["config", "commit.template", Ne()]);
|
|
101
101
|
}
|
|
102
102
|
function he(e = "") {
|
|
103
|
-
return m.resolve(
|
|
103
|
+
return m.resolve(Mt.homedir(), sa, e);
|
|
104
104
|
}
|
|
105
105
|
function Ae() {
|
|
106
|
-
return he(
|
|
106
|
+
return he(ra);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function ua() {
|
|
109
109
|
return A(he());
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
111
|
+
function ot() {
|
|
112
|
+
return ua() && A(Ae());
|
|
113
113
|
}
|
|
114
114
|
function ee(e, t = !0) {
|
|
115
115
|
let a = e.trim();
|
|
@@ -123,57 +123,59 @@ function ee(e, t = !0) {
|
|
|
123
123
|
const i = a.replace(/\.git$/, "");
|
|
124
124
|
return t ? encodeURIComponent(i) : i;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function ct(e, t) {
|
|
127
127
|
return ee(e) === ee(t);
|
|
128
128
|
}
|
|
129
|
-
const { red:
|
|
129
|
+
const { red: Ve, green: la, blue: us, magenta: ma, yellow: pa } = N;
|
|
130
130
|
function ye(...e) {
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
console.log(
|
|
132
|
+
function We(...e) {
|
|
133
|
+
console.log(pa(...e));
|
|
134
134
|
}
|
|
135
135
|
function q(...e) {
|
|
136
|
-
console.log(
|
|
136
|
+
console.log(la(...e));
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function ut(e) {
|
|
139
139
|
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));
|
|
140
140
|
}
|
|
141
141
|
function p(e, t = !1) {
|
|
142
|
-
|
|
142
|
+
ut(e);
|
|
143
143
|
let a = e;
|
|
144
|
-
e instanceof Error ? (a = e.message, le.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(
|
|
144
|
+
e instanceof Error ? (a = e.message, le.isAxiosError(e) && (a = `请求失败:${e.message}`), console.log(Ve(a)), console.log(ma(e.stack))) : console.log(Ve(e)), t || process.exit(1);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
return A(e) ?
|
|
146
|
+
function qe(e) {
|
|
147
|
+
return A(e) ? Ct(e).isDirectory() : !1;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
return
|
|
149
|
+
function lt(e = process.cwd()) {
|
|
150
|
+
return qe(e) ? Rt(e).filter((a) => qe(m.resolve(e, a))) : [];
|
|
151
151
|
}
|
|
152
|
-
async function d(e, t = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
async function d(e, t = {}) {
|
|
153
|
+
const a = {
|
|
154
|
+
removeTailLinkBreak: !0,
|
|
155
|
+
silent: !0,
|
|
156
|
+
...t
|
|
157
|
+
};
|
|
158
|
+
let n = await new Promise((i, s) => {
|
|
157
159
|
try {
|
|
158
|
-
const
|
|
159
|
-
silent:
|
|
160
|
+
const o = L.exec(e, {
|
|
161
|
+
silent: a.silent
|
|
160
162
|
});
|
|
161
|
-
|
|
162
|
-
} catch (
|
|
163
|
-
|
|
163
|
+
i(o);
|
|
164
|
+
} catch (o) {
|
|
165
|
+
s(o);
|
|
164
166
|
}
|
|
165
167
|
});
|
|
166
|
-
return
|
|
168
|
+
return n = n.toString(), a.removeTailLinkBreak && (n = n.replace(/\n$/, "")), n;
|
|
167
169
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
+
function da(e) {
|
|
171
|
+
It.execSync(e, {
|
|
170
172
|
stdio: "inherit"
|
|
171
173
|
});
|
|
172
174
|
}
|
|
173
|
-
function
|
|
174
|
-
return
|
|
175
|
+
function mt() {
|
|
176
|
+
return Ot(Date.now()).format("YYMMDD");
|
|
175
177
|
}
|
|
176
|
-
function
|
|
178
|
+
function fa(e, t) {
|
|
177
179
|
for (const a of t)
|
|
178
180
|
if (!e.includes(a))
|
|
179
181
|
return !1;
|
|
@@ -188,23 +190,23 @@ function K() {
|
|
|
188
190
|
async function be() {
|
|
189
191
|
await d("git status -s") !== "" && p("请先提交代码变动,再进行操作");
|
|
190
192
|
}
|
|
191
|
-
function
|
|
193
|
+
function ga(e) {
|
|
192
194
|
return e === $.MASTER ? E.PROD : e;
|
|
193
195
|
}
|
|
194
|
-
function
|
|
196
|
+
function ha(e) {
|
|
195
197
|
return e === E.PROD ? $.MASTER : e;
|
|
196
198
|
}
|
|
197
199
|
async function M(e, ...t) {
|
|
198
200
|
try {
|
|
199
201
|
await e(...t);
|
|
200
202
|
} catch (a) {
|
|
201
|
-
throw
|
|
203
|
+
throw ut(a), a;
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
|
-
async function
|
|
206
|
+
async function wa(e) {
|
|
205
207
|
return (await xe(e)).length === 0;
|
|
206
208
|
}
|
|
207
|
-
function
|
|
209
|
+
function ya(e = "项目中文名", t = "项目描述") {
|
|
208
210
|
return `
|
|
209
211
|
# ${e}
|
|
210
212
|
${t}
|
|
@@ -261,7 +263,7 @@ ${t}
|
|
|
261
263
|
在此处放入飞书文档链接。请在[前端团队-项目手册](https://hxhtbr8t8uy.feishu.cn/drive/folder/QfQ7favVWljQk7d63Prc8mUGnJf)中按照分类新建文档。
|
|
262
264
|
`;
|
|
263
265
|
}
|
|
264
|
-
const
|
|
266
|
+
const va = {
|
|
265
267
|
[w.JAVA]: {
|
|
266
268
|
"**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml"
|
|
267
269
|
},
|
|
@@ -279,17 +281,17 @@ const wa = {
|
|
|
279
281
|
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
280
282
|
"**/*.md": "markdownlint --fix"
|
|
281
283
|
}
|
|
282
|
-
},
|
|
283
|
-
name:
|
|
284
|
-
version:
|
|
285
|
-
description:
|
|
286
|
-
main:
|
|
287
|
-
bin:
|
|
288
|
-
scripts:
|
|
289
|
-
type:
|
|
290
|
-
author:
|
|
291
|
-
devDependencies:
|
|
292
|
-
dependencies:
|
|
284
|
+
}, $a = "cli-z-develop", Na = "0.14.11", Aa = "技术团队开发流程管理工具", ba = "dist/index.js", ja = { z: "bin/z.js", "z-develop": "bin/z.js" }, Sa = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", test: "bun src/main.ts", "test:debug": "DEBUG=true bun src/main.ts", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", "build:w": "vite build --watch", eslint: "eslint '**/*.{ts,js}' --fix", prettier: "prettier -wu .", upload: "npm run build && npm publish --access public --registry https://registry.npmjs.org/", "upload:patch": "npm version patch && npm run upload", "upload:minor": "npm version minor && npm run upload", "upload:major": "npm version major && npm run upload" }, ka = "module", Ea = "z", Ta = { "@lonely9/eslint-config-team": "^1.3.8", "@tsconfig/node22": "^22.0.5", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.9", "@types/minimist": "^1.2.5", "@types/node": "^22.15.29", "@types/semver": "^7.7.1", "@types/shelljs": "^0.10.0", "@typescript-eslint/eslint-plugin": "^8.58.2", "@typescript-eslint/parser": "^8.58.2", eslint: "^9.39.2", jiti: "^2.6.1", prettier: "^3.8.2", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.2.6" }, Ia = { "@inquirer/prompts": "^8.4.1", "@lonely9/api-generate": "^0.2.10", axios: "^1.15.0", chalk: "^5.6.2", "cli-highlight": "^2.1.11", commander: "^14.0.3", dayjs: "^1.11.20", eslint: "^9.39.2", "fs-extra": "^11.3.4", "inquirer-select-pro": "^1.0.0-alpha.9", "lint-staged": "^16.4.0", minimist: "^1.2.8", "npm-check-updates": "^19.3.1", ora: "^9.3.0", "p-limit": "^7.3.0", prettier: "^3.8.2", semver: "^7.7.4", shelljs: "^0.10.0" }, re = {
|
|
285
|
+
name: $a,
|
|
286
|
+
version: Na,
|
|
287
|
+
description: Aa,
|
|
288
|
+
main: ba,
|
|
289
|
+
bin: ja,
|
|
290
|
+
scripts: Sa,
|
|
291
|
+
type: ka,
|
|
292
|
+
author: Ea,
|
|
293
|
+
devDependencies: Ta,
|
|
294
|
+
dependencies: Ia
|
|
293
295
|
}, x = {
|
|
294
296
|
// 个人数据
|
|
295
297
|
profile: {
|
|
@@ -330,35 +332,35 @@ function C(e) {
|
|
|
330
332
|
function ge(e) {
|
|
331
333
|
return e ? x.main[e] : x.main;
|
|
332
334
|
}
|
|
333
|
-
function
|
|
335
|
+
function U(e) {
|
|
334
336
|
return e ? x.constants[e] : x.constants;
|
|
335
337
|
}
|
|
336
|
-
let
|
|
337
|
-
function
|
|
338
|
-
if (
|
|
339
|
-
return
|
|
338
|
+
let G = null, V = null;
|
|
339
|
+
function De() {
|
|
340
|
+
if (G)
|
|
341
|
+
return G;
|
|
340
342
|
const e = m.join("package.json");
|
|
341
|
-
return A(e) || p(`当前目录(${L.pwd()})不存在${e}文件,请在项目根目录执行该命令。`),
|
|
343
|
+
return A(e) || p(`当前目录(${L.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), G = R.readJsonSync(e), G;
|
|
342
344
|
}
|
|
343
345
|
function ie() {
|
|
344
346
|
if (V)
|
|
345
347
|
return V;
|
|
346
|
-
const e =
|
|
348
|
+
const e = st();
|
|
347
349
|
return A(e) || p(
|
|
348
350
|
`当前目录(${L.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
349
|
-
), V =
|
|
351
|
+
), V = R.readJsonSync(e), V;
|
|
350
352
|
}
|
|
351
|
-
function
|
|
353
|
+
function pt(e) {
|
|
352
354
|
V ? V = {
|
|
353
355
|
...V,
|
|
354
356
|
...e
|
|
355
|
-
} : V = e,
|
|
357
|
+
} : V = e, R.writeJSONSync(st(), V, { spaces: 2 });
|
|
356
358
|
}
|
|
357
|
-
function
|
|
358
|
-
|
|
359
|
-
...
|
|
359
|
+
function Ra(e) {
|
|
360
|
+
G ? G = {
|
|
361
|
+
...G,
|
|
360
362
|
...e
|
|
361
|
-
} :
|
|
363
|
+
} : G = e, R.writeJSONSync(m.join("package.json"), G, { spaces: 2 });
|
|
362
364
|
}
|
|
363
365
|
const Y = {
|
|
364
366
|
id: 0,
|
|
@@ -367,10 +369,10 @@ const Y = {
|
|
|
367
369
|
sourceBranch: "",
|
|
368
370
|
mergeRequestUrl: ""
|
|
369
371
|
};
|
|
370
|
-
async function
|
|
372
|
+
async function Ca() {
|
|
371
373
|
if (!Y.id)
|
|
372
374
|
try {
|
|
373
|
-
const e = ie(), t = ee(e.repository.url), a = await
|
|
375
|
+
const e = ie(), t = ee(e.repository.url), a = await ft(t);
|
|
374
376
|
Y.id = a.id, Y.path = t, Y.group = a.namespace.full_path, Y.mergeRequestUrl = `${a.web_url}/merge_requests`;
|
|
375
377
|
} catch (e) {
|
|
376
378
|
p(e);
|
|
@@ -378,12 +380,12 @@ async function Ra() {
|
|
|
378
380
|
return Y.sourceBranch || (Y.sourceBranch = await d("git branch --show-current")), Y;
|
|
379
381
|
}
|
|
380
382
|
function oe() {
|
|
381
|
-
|
|
383
|
+
R.writeJSONSync(
|
|
382
384
|
Ae(),
|
|
383
385
|
{
|
|
384
386
|
main: ge(),
|
|
385
387
|
profile: C(),
|
|
386
|
-
constants:
|
|
388
|
+
constants: U()
|
|
387
389
|
},
|
|
388
390
|
{
|
|
389
391
|
spaces: 2
|
|
@@ -422,10 +424,10 @@ async function ne(e) {
|
|
|
422
424
|
const o = await le(s);
|
|
423
425
|
return ye(N.green("Response"), N.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
|
|
424
426
|
} catch (s) {
|
|
425
|
-
return s instanceof
|
|
427
|
+
return s instanceof Lt && ye(N.red("Error"), N.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
|
|
426
428
|
}
|
|
427
429
|
}
|
|
428
|
-
async function
|
|
430
|
+
async function xa() {
|
|
429
431
|
const e = C("gitToken");
|
|
430
432
|
if (e)
|
|
431
433
|
return e;
|
|
@@ -446,17 +448,17 @@ async function b(e) {
|
|
|
446
448
|
return ne({
|
|
447
449
|
...e,
|
|
448
450
|
headers: {
|
|
449
|
-
Authorization: await
|
|
451
|
+
Authorization: await xa()
|
|
450
452
|
}
|
|
451
453
|
});
|
|
452
454
|
}
|
|
453
|
-
async function
|
|
455
|
+
async function Da() {
|
|
454
456
|
const e = C("zenTaoToken");
|
|
455
457
|
if (e)
|
|
456
458
|
return e;
|
|
457
459
|
{
|
|
458
460
|
const { token: t } = await ne({
|
|
459
|
-
url: `${
|
|
461
|
+
url: `${U("ZenTaoDomain")}/api.php/v1/tokens`,
|
|
460
462
|
method: "post",
|
|
461
463
|
data: {
|
|
462
464
|
account: C("ldapAccount"),
|
|
@@ -470,7 +472,7 @@ async function $e(e) {
|
|
|
470
472
|
const t = await ne({
|
|
471
473
|
...e,
|
|
472
474
|
headers: {
|
|
473
|
-
Token: await
|
|
475
|
+
Token: await Da()
|
|
474
476
|
}
|
|
475
477
|
});
|
|
476
478
|
if (e.url.includes("local")) {
|
|
@@ -493,13 +495,13 @@ async function $e(e) {
|
|
|
493
495
|
return {};
|
|
494
496
|
}
|
|
495
497
|
}
|
|
496
|
-
async function
|
|
498
|
+
async function Pa() {
|
|
497
499
|
const e = C("k8sToken");
|
|
498
500
|
if (e)
|
|
499
501
|
return e;
|
|
500
502
|
{
|
|
501
503
|
const { access_token: t } = await ne({
|
|
502
|
-
url: `${
|
|
504
|
+
url: `${U("K8sDomain")}/oauth/login/LDAP`,
|
|
503
505
|
method: "post",
|
|
504
506
|
headers: {
|
|
505
507
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -512,9 +514,9 @@ async function xa() {
|
|
|
512
514
|
return J("k8sToken", a), oe(), a;
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
|
-
async function
|
|
517
|
+
async function La(e, t) {
|
|
516
518
|
try {
|
|
517
|
-
const a =
|
|
519
|
+
const a = xt(t, { mode: 493 });
|
|
518
520
|
return (await le({
|
|
519
521
|
method: "get",
|
|
520
522
|
url: e,
|
|
@@ -530,89 +532,89 @@ async function Pa(e, t) {
|
|
|
530
532
|
}
|
|
531
533
|
}
|
|
532
534
|
const z = () => `${fe}/api/v4`, F = (e) => `${z()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
|
|
533
|
-
function
|
|
535
|
+
function Oa() {
|
|
534
536
|
return b({
|
|
535
537
|
url: F("src/data/template-projects.json")
|
|
536
538
|
});
|
|
537
539
|
}
|
|
538
|
-
function
|
|
540
|
+
function Ma() {
|
|
539
541
|
return b({
|
|
540
542
|
url: F("src/data/java-project-module.json")
|
|
541
543
|
});
|
|
542
544
|
}
|
|
543
|
-
function
|
|
545
|
+
function za() {
|
|
544
546
|
return b({
|
|
545
547
|
url: F("src/data/java-project-api.json")
|
|
546
548
|
});
|
|
547
549
|
}
|
|
548
|
-
function
|
|
550
|
+
function Pe() {
|
|
549
551
|
return b({
|
|
550
552
|
url: F("src/data/z-develop-config.json")
|
|
551
553
|
});
|
|
552
554
|
}
|
|
553
|
-
function
|
|
555
|
+
function Fa() {
|
|
554
556
|
return b({
|
|
555
557
|
url: F("src/assets/tsconfig.browser.json")
|
|
556
558
|
});
|
|
557
559
|
}
|
|
558
|
-
function
|
|
560
|
+
function Ja() {
|
|
559
561
|
return b({
|
|
560
562
|
url: F("src/assets/tsconfig.node.json")
|
|
561
563
|
});
|
|
562
564
|
}
|
|
563
|
-
function
|
|
565
|
+
function Ba() {
|
|
564
566
|
return b({
|
|
565
567
|
url: F("src/assets/.prettierignore")
|
|
566
568
|
});
|
|
567
569
|
}
|
|
568
|
-
function
|
|
570
|
+
function Ua() {
|
|
569
571
|
return b({
|
|
570
572
|
url: F("src/assets/.prettierrc.json")
|
|
571
573
|
});
|
|
572
574
|
}
|
|
573
|
-
function
|
|
575
|
+
function _a() {
|
|
574
576
|
return b({
|
|
575
577
|
url: F("src/assets/data.yaml")
|
|
576
578
|
});
|
|
577
579
|
}
|
|
578
|
-
function
|
|
580
|
+
function Ga() {
|
|
579
581
|
return b({
|
|
580
582
|
url: F("src/assets/main.py")
|
|
581
583
|
});
|
|
582
584
|
}
|
|
583
|
-
function
|
|
585
|
+
function Va() {
|
|
584
586
|
return b({
|
|
585
587
|
url: F("src/assets/checkstyle.xml")
|
|
586
588
|
});
|
|
587
589
|
}
|
|
588
|
-
function
|
|
590
|
+
function dt() {
|
|
589
591
|
return b({
|
|
590
592
|
url: F("src/data/project-group-chats.json")
|
|
591
593
|
});
|
|
592
594
|
}
|
|
593
|
-
function
|
|
595
|
+
function Wa() {
|
|
594
596
|
return b({
|
|
595
597
|
url: `${z()}/user`
|
|
596
598
|
});
|
|
597
599
|
}
|
|
598
|
-
function
|
|
600
|
+
function qa() {
|
|
599
601
|
return b({
|
|
600
602
|
url: `${z()}/groups`
|
|
601
603
|
});
|
|
602
604
|
}
|
|
603
|
-
function
|
|
605
|
+
function Za(e) {
|
|
604
606
|
return b({
|
|
605
607
|
url: `${z()}/projects`,
|
|
606
608
|
method: "post",
|
|
607
609
|
data: e
|
|
608
610
|
});
|
|
609
611
|
}
|
|
610
|
-
function
|
|
612
|
+
function ft(e) {
|
|
611
613
|
return b({
|
|
612
614
|
url: `${z()}/projects/${e}`
|
|
613
615
|
});
|
|
614
616
|
}
|
|
615
|
-
function
|
|
617
|
+
function Ha(e) {
|
|
616
618
|
return b({
|
|
617
619
|
url: `${z()}/projects`,
|
|
618
620
|
data: {
|
|
@@ -621,50 +623,50 @@ function qa(e) {
|
|
|
621
623
|
}
|
|
622
624
|
});
|
|
623
625
|
}
|
|
624
|
-
function
|
|
626
|
+
function Ka(e) {
|
|
625
627
|
return b({
|
|
626
628
|
url: `${z()}/projects/${e.id}/merge_requests`,
|
|
627
629
|
method: "post",
|
|
628
630
|
data: e
|
|
629
631
|
});
|
|
630
632
|
}
|
|
631
|
-
function
|
|
633
|
+
function Xa(e) {
|
|
632
634
|
return b({
|
|
633
635
|
url: `${z()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
634
636
|
method: "put"
|
|
635
637
|
});
|
|
636
638
|
}
|
|
637
|
-
function
|
|
639
|
+
function Ya(e) {
|
|
638
640
|
return b({
|
|
639
641
|
url: `${z()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
640
642
|
method: "put",
|
|
641
643
|
data: e
|
|
642
644
|
});
|
|
643
645
|
}
|
|
644
|
-
function
|
|
646
|
+
function Qa(e) {
|
|
645
647
|
return b({
|
|
646
648
|
url: `${z()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
647
649
|
method: "get"
|
|
648
650
|
});
|
|
649
651
|
}
|
|
650
|
-
function
|
|
652
|
+
function ei(e) {
|
|
651
653
|
return b({
|
|
652
654
|
url: `${z()}/projects/${e.id}/repository/branches`,
|
|
653
655
|
method: "post",
|
|
654
656
|
data: e
|
|
655
657
|
});
|
|
656
658
|
}
|
|
657
|
-
function
|
|
659
|
+
function ti(e) {
|
|
658
660
|
return b({
|
|
659
661
|
url: `${z()}/projects/${e}/repository/branches`
|
|
660
662
|
});
|
|
661
663
|
}
|
|
662
|
-
function
|
|
664
|
+
function ai() {
|
|
663
665
|
const e = he("fe-groups.json");
|
|
664
|
-
return A(e) ?
|
|
666
|
+
return A(e) ? R.readJSONSync(e) : { groups: [] };
|
|
665
667
|
}
|
|
666
|
-
async function
|
|
667
|
-
const e = await
|
|
668
|
+
async function ii() {
|
|
669
|
+
const e = await qa(), t = ta.map((a) => {
|
|
668
670
|
const n = e.find((i) => i.name === a);
|
|
669
671
|
return n ? {
|
|
670
672
|
name: n.name,
|
|
@@ -672,43 +674,43 @@ async function ti() {
|
|
|
672
674
|
description: n.description
|
|
673
675
|
} : !1;
|
|
674
676
|
}).filter((a) => !!a);
|
|
675
|
-
|
|
677
|
+
R.writeJSONSync(he("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
676
678
|
}
|
|
677
679
|
async function j(e) {
|
|
678
|
-
const t = `${
|
|
680
|
+
const t = `${U("FEServerDomain")}/api`, a = await ne({
|
|
679
681
|
url: t + e.url,
|
|
680
682
|
headers: {
|
|
681
683
|
"the-key-one": "z-develop",
|
|
682
|
-
"the-key-two":
|
|
684
|
+
"the-key-two": U("ZDevelopPassword")
|
|
683
685
|
},
|
|
684
686
|
data: e.data,
|
|
685
687
|
method: e.method || "post"
|
|
686
688
|
});
|
|
687
689
|
return a.code !== 0 && p(`${a.code}: ${a.message}`), a.data;
|
|
688
690
|
}
|
|
689
|
-
async function
|
|
690
|
-
const t = `${
|
|
691
|
+
async function ni(e) {
|
|
692
|
+
const t = `${U("FEServerDomain")}/api`;
|
|
691
693
|
return await ne({
|
|
692
694
|
url: t + e.url,
|
|
693
695
|
headers: {
|
|
694
696
|
"the-key-one": "z-develop",
|
|
695
|
-
"the-key-two":
|
|
697
|
+
"the-key-two": U("ZDevelopPassword")
|
|
696
698
|
},
|
|
697
699
|
data: e.data,
|
|
698
700
|
method: e.method || "post"
|
|
699
701
|
});
|
|
700
702
|
}
|
|
701
|
-
function
|
|
703
|
+
function si() {
|
|
702
704
|
return j({
|
|
703
705
|
url: "/user/list2"
|
|
704
706
|
});
|
|
705
707
|
}
|
|
706
|
-
function
|
|
708
|
+
function ri() {
|
|
707
709
|
return j({
|
|
708
710
|
url: "/zen/testcase/product/list"
|
|
709
711
|
});
|
|
710
712
|
}
|
|
711
|
-
function
|
|
713
|
+
function gt(e) {
|
|
712
714
|
return j({
|
|
713
715
|
url: "/zen/testcase/product/module/list",
|
|
714
716
|
data: {
|
|
@@ -716,7 +718,7 @@ function ft(e) {
|
|
|
716
718
|
}
|
|
717
719
|
});
|
|
718
720
|
}
|
|
719
|
-
function
|
|
721
|
+
function oi(e) {
|
|
720
722
|
return j({
|
|
721
723
|
url: "/zen/testcase/product/name",
|
|
722
724
|
data: {
|
|
@@ -724,7 +726,7 @@ function si(e) {
|
|
|
724
726
|
}
|
|
725
727
|
});
|
|
726
728
|
}
|
|
727
|
-
function
|
|
729
|
+
function ci(e, t) {
|
|
728
730
|
return j({
|
|
729
731
|
url: "/zen/testcase/product/auto-case/list",
|
|
730
732
|
data: {
|
|
@@ -733,7 +735,7 @@ function ri(e, t) {
|
|
|
733
735
|
}
|
|
734
736
|
});
|
|
735
737
|
}
|
|
736
|
-
function
|
|
738
|
+
function ui(e) {
|
|
737
739
|
return j({
|
|
738
740
|
url: "/zen/testcase/step/list",
|
|
739
741
|
data: {
|
|
@@ -741,72 +743,72 @@ function oi(e) {
|
|
|
741
743
|
}
|
|
742
744
|
});
|
|
743
745
|
}
|
|
744
|
-
function
|
|
746
|
+
function li(e) {
|
|
745
747
|
return j({
|
|
746
748
|
url: "/zen/testcase/module/create",
|
|
747
749
|
data: e
|
|
748
750
|
});
|
|
749
751
|
}
|
|
750
|
-
function
|
|
752
|
+
function mi(e) {
|
|
751
753
|
return j({
|
|
752
754
|
url: "/zen/testcase/create",
|
|
753
755
|
data: e
|
|
754
756
|
});
|
|
755
757
|
}
|
|
756
|
-
function
|
|
758
|
+
function pi(e) {
|
|
757
759
|
return j({
|
|
758
760
|
url: "/zen/testcase/step/create",
|
|
759
761
|
data: e
|
|
760
762
|
});
|
|
761
763
|
}
|
|
762
|
-
function
|
|
764
|
+
function di(e) {
|
|
763
765
|
return j({
|
|
764
766
|
url: "/zen/testcase/modules/remove",
|
|
765
767
|
data: e
|
|
766
768
|
});
|
|
767
769
|
}
|
|
768
|
-
function
|
|
770
|
+
function fi(e) {
|
|
769
771
|
return j({
|
|
770
772
|
url: "/zen/testcase/cases/remove",
|
|
771
773
|
data: e
|
|
772
774
|
});
|
|
773
775
|
}
|
|
774
|
-
function
|
|
776
|
+
function gi(e) {
|
|
775
777
|
return j({
|
|
776
778
|
url: "/zen/testcase/module/update/name",
|
|
777
779
|
data: e
|
|
778
780
|
});
|
|
779
781
|
}
|
|
780
|
-
function
|
|
782
|
+
function hi(e) {
|
|
781
783
|
return j({
|
|
782
784
|
url: "/zen/testcase/case/update/name",
|
|
783
785
|
data: e
|
|
784
786
|
});
|
|
785
787
|
}
|
|
786
|
-
function
|
|
788
|
+
function wi(e) {
|
|
787
789
|
return j({
|
|
788
790
|
url: "/zen/testcase/case/update/priority",
|
|
789
791
|
data: e
|
|
790
792
|
});
|
|
791
793
|
}
|
|
792
|
-
function
|
|
794
|
+
function yi(e) {
|
|
793
795
|
return j({
|
|
794
796
|
url: "/zen/testcase/case/update/precondition",
|
|
795
797
|
data: e
|
|
796
798
|
});
|
|
797
799
|
}
|
|
798
|
-
function
|
|
800
|
+
function vi(e) {
|
|
799
801
|
return j({
|
|
800
802
|
url: "/zen/testcase/case/result/create",
|
|
801
803
|
data: e
|
|
802
804
|
});
|
|
803
805
|
}
|
|
804
|
-
function
|
|
806
|
+
function $i() {
|
|
805
807
|
return j({
|
|
806
808
|
url: "/zen/testcase/project/list"
|
|
807
809
|
});
|
|
808
810
|
}
|
|
809
|
-
function
|
|
811
|
+
function Ni(e) {
|
|
810
812
|
return j({
|
|
811
813
|
url: "/zen/testcase/project/execution/list",
|
|
812
814
|
data: {
|
|
@@ -814,7 +816,7 @@ function vi(e) {
|
|
|
814
816
|
}
|
|
815
817
|
});
|
|
816
818
|
}
|
|
817
|
-
function
|
|
819
|
+
function Ai(e) {
|
|
818
820
|
return j({
|
|
819
821
|
url: "/zen/testcase/execution/build/list",
|
|
820
822
|
data: {
|
|
@@ -822,25 +824,25 @@ function $i(e) {
|
|
|
822
824
|
}
|
|
823
825
|
});
|
|
824
826
|
}
|
|
825
|
-
function
|
|
827
|
+
function Ze(e) {
|
|
826
828
|
return j({
|
|
827
829
|
url: "/common/ai/talk",
|
|
828
830
|
data: e
|
|
829
831
|
});
|
|
830
832
|
}
|
|
831
|
-
function
|
|
832
|
-
return
|
|
833
|
+
function bi(e) {
|
|
834
|
+
return ni({
|
|
833
835
|
url: "/common/notify/group/send",
|
|
834
836
|
data: e
|
|
835
837
|
});
|
|
836
838
|
}
|
|
837
|
-
function
|
|
839
|
+
function ji(e) {
|
|
838
840
|
return j({
|
|
839
841
|
url: "/deploy/create/chain",
|
|
840
842
|
data: e
|
|
841
843
|
});
|
|
842
844
|
}
|
|
843
|
-
function
|
|
845
|
+
function Si(e, t) {
|
|
844
846
|
const a = [];
|
|
845
847
|
t.forEach((s) => {
|
|
846
848
|
e.includes(s.value) && a.push(s);
|
|
@@ -856,9 +858,9 @@ function ji(e, t) {
|
|
|
856
858
|
weWorkListCache: n.sort((s, o) => o.usageCount - s.usageCount)
|
|
857
859
|
}), oe();
|
|
858
860
|
}
|
|
859
|
-
async function
|
|
860
|
-
const t = (await
|
|
861
|
-
name: `${s.nick} - ${
|
|
861
|
+
async function ht() {
|
|
862
|
+
const t = (await si()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
863
|
+
name: `${s.nick} - ${ea[s.title]}`,
|
|
862
864
|
value: s.weWorkUserId
|
|
863
865
|
})), a = ge("weWorkListCache"), n = a.map((s) => s.value), i = [];
|
|
864
866
|
return t.forEach((s) => {
|
|
@@ -869,8 +871,8 @@ async function gt() {
|
|
|
869
871
|
});
|
|
870
872
|
}), i.sort((s, o) => o.usageCount - s.usageCount);
|
|
871
873
|
}
|
|
872
|
-
async function
|
|
873
|
-
const n = await
|
|
874
|
+
async function wt(e, t, a) {
|
|
875
|
+
const n = await ht();
|
|
874
876
|
let i = await H({
|
|
875
877
|
message: e,
|
|
876
878
|
loop: !0,
|
|
@@ -880,10 +882,10 @@ async function ht(e, t, a) {
|
|
|
880
882
|
options: (s) => s ? n.filter((o) => o.name.includes(s)) : n,
|
|
881
883
|
validate: t
|
|
882
884
|
});
|
|
883
|
-
return i = Array.isArray(i) ? i : [i],
|
|
885
|
+
return i = Array.isArray(i) ? i : [i], Si(i, n), i;
|
|
884
886
|
}
|
|
885
|
-
async function
|
|
886
|
-
const { groups: n } = await
|
|
887
|
+
async function ki(e, t, a) {
|
|
888
|
+
const { groups: n } = await dt(), i = n.map((o) => ({
|
|
887
889
|
name: o.name,
|
|
888
890
|
value: o.url
|
|
889
891
|
}));
|
|
@@ -898,9 +900,9 @@ async function Si(e, t, a) {
|
|
|
898
900
|
});
|
|
899
901
|
return s = Array.isArray(s) ? s : [s], s;
|
|
900
902
|
}
|
|
901
|
-
async function
|
|
903
|
+
async function Ei() {
|
|
902
904
|
try {
|
|
903
|
-
|
|
905
|
+
ot() && (await Ye({
|
|
904
906
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
905
907
|
}) ? L.rm("-rf", Ae()) : process.exit(0)), await pe(he(), { recursive: !0 });
|
|
906
908
|
const t = await k({
|
|
@@ -920,18 +922,18 @@ async function ki() {
|
|
|
920
922
|
}
|
|
921
923
|
]
|
|
922
924
|
});
|
|
923
|
-
let a = await
|
|
925
|
+
let a = await B({
|
|
924
926
|
message: "请输入LDAP账号:"
|
|
925
927
|
});
|
|
926
928
|
a = a.trim();
|
|
927
|
-
let n = await
|
|
929
|
+
let n = await zt({
|
|
928
930
|
message: "请输入LDAP密码:",
|
|
929
931
|
mask: !0
|
|
930
932
|
});
|
|
931
933
|
n = n.trim(), J("jobType", t), J("ldapAccount", a), J("ldapPassword", n);
|
|
932
|
-
const i = await
|
|
934
|
+
const i = await Pe();
|
|
933
935
|
je(i);
|
|
934
|
-
const s = await
|
|
936
|
+
const s = await ht(), o = await wt("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((u) => u.value === o[0]);
|
|
935
937
|
J({
|
|
936
938
|
weWorkName: r,
|
|
937
939
|
weWorkUserId: c
|
|
@@ -941,40 +943,40 @@ async function ki() {
|
|
|
941
943
|
}
|
|
942
944
|
const e = y("配置信息初始化中").start();
|
|
943
945
|
try {
|
|
944
|
-
const t = await
|
|
946
|
+
const t = await Wa();
|
|
945
947
|
J({
|
|
946
948
|
gitUserId: t.id,
|
|
947
949
|
gitName: t.name,
|
|
948
950
|
gitEnglishName: t.username,
|
|
949
951
|
gitEmail: t.email
|
|
950
|
-
}), me("latestCheckVersionTimestamp", Date.now()), oe(), C("jobType") === ue.FRONT_END && await
|
|
952
|
+
}), me("latestCheckVersionTimestamp", Date.now()), oe(), C("jobType") === ue.FRONT_END && await ii(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
951
953
|
} catch (t) {
|
|
952
954
|
e.fail("配置信息初始化失败"), le.isAxiosError(t) && p("请检查你的域名及令牌配置"), p(t);
|
|
953
955
|
}
|
|
954
956
|
}
|
|
955
|
-
async function
|
|
956
|
-
await
|
|
957
|
-
`, { mode: 493 }), await
|
|
958
|
-
z run commit-msg`, { mode: 493 }), await
|
|
957
|
+
async function Ti() {
|
|
958
|
+
await P(Ne(), "", { mode: 493 }), await P(T(".gitignore"), `.commit-msg-tpl
|
|
959
|
+
`, { mode: 493 }), await P(T("commit-msg"), `#!/usr/bin/env sh
|
|
960
|
+
z run commit-msg`, { mode: 493 }), await P(T("pre-commit"), `#!/usr/bin/env sh
|
|
959
961
|
z run commit-files`, { mode: 493 });
|
|
960
962
|
const { language: e } = ie();
|
|
961
|
-
if ([w.JAVASCRIPT, w.MARKDOWN].includes(e) && (await
|
|
963
|
+
if ([w.JAVASCRIPT, w.MARKDOWN].includes(e) && (await P(
|
|
962
964
|
T(".prettierrc.json"),
|
|
963
|
-
`${JSON.stringify(await
|
|
965
|
+
`${JSON.stringify(await Ua(), null, 2)}
|
|
964
966
|
`,
|
|
965
967
|
{
|
|
966
968
|
mode: 493
|
|
967
969
|
}
|
|
968
|
-
), await
|
|
969
|
-
await
|
|
970
|
+
), await P(T(".prettierignore"), await Ba(), { mode: 493 }), await P(T("tsconfig.node.json"), await Ja(), { mode: 493 }), await P(T("tsconfig.browser.json"), await Fa(), { mode: 493 })), e === w.JAVA) {
|
|
971
|
+
await La(`${U("FECDNDomain")}/file/vgnlfbfHRF.jar`, T("checkstyle.jar")), await P(T("checkstyle.xml"), await Va(), { mode: 493 });
|
|
970
972
|
const t = m.join("package.json");
|
|
971
|
-
A(t) || await
|
|
973
|
+
A(t) || await P(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
|
|
972
974
|
mode: 493
|
|
973
975
|
});
|
|
974
976
|
}
|
|
975
|
-
|
|
977
|
+
rt();
|
|
976
978
|
}
|
|
977
|
-
async function
|
|
979
|
+
async function Ii(e, t) {
|
|
978
980
|
const a = await d("git remote get-url --push origin");
|
|
979
981
|
a || p("获取项目远程git地址失败,请配置后重试");
|
|
980
982
|
let n = e;
|
|
@@ -1001,14 +1003,14 @@ async function Ti(e, t) {
|
|
|
1001
1003
|
}));
|
|
1002
1004
|
let i = t;
|
|
1003
1005
|
if (!i) {
|
|
1004
|
-
const s = ee(a), o = await
|
|
1006
|
+
const s = ee(a), o = await ft(s);
|
|
1005
1007
|
if (!o)
|
|
1006
1008
|
return p(`未找到项目,请确认项目${a}是否存在,或者当前账号权限`);
|
|
1007
1009
|
i = o.namespace.full_path;
|
|
1008
1010
|
}
|
|
1009
|
-
|
|
1011
|
+
pt({
|
|
1010
1012
|
language: n,
|
|
1011
|
-
"lint-staged":
|
|
1013
|
+
"lint-staged": va[n],
|
|
1012
1014
|
repository: {
|
|
1013
1015
|
url: a,
|
|
1014
1016
|
group: i
|
|
@@ -1016,36 +1018,36 @@ async function Ti(e, t) {
|
|
|
1016
1018
|
});
|
|
1017
1019
|
}
|
|
1018
1020
|
async function Le(e, t) {
|
|
1019
|
-
e ? L.rm("-rf", Q) : A(T()) && (await
|
|
1021
|
+
e ? L.rm("-rf", Q) : A(T()) && (await Ye({
|
|
1020
1022
|
message: `当前项目中已存在配置文件夹${Q},确认重新配置?`
|
|
1021
|
-
}) ? L.rm("-rf", Q) : process.exit(0)), await pe(T(), { recursive: !0 }), await
|
|
1023
|
+
}) ? L.rm("-rf", Q) : process.exit(0)), await pe(T(), { recursive: !0 }), await Ii(e, t);
|
|
1022
1024
|
const a = y("项目初始化中...").start();
|
|
1023
|
-
await
|
|
1025
|
+
await Ti(), a.succeed("项目初始化完成");
|
|
1024
1026
|
}
|
|
1025
1027
|
async function Ri() {
|
|
1026
|
-
A(T()) && A(Ne()) ?
|
|
1028
|
+
A(T()) && A(Ne()) ? rt() : await Le(), process.exit(0);
|
|
1027
1029
|
}
|
|
1028
|
-
async function Ii(e, t) {
|
|
1029
|
-
t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && p("项目语言不支持"), e ? (K(), e === "." ? (await Le(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await Ri() : p("参数错误。执行 z init -h 查看帮助。")) : await ki();
|
|
1030
|
-
}
|
|
1031
|
-
P.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => M(Ii, ...e));
|
|
1032
1030
|
async function Ci(e, t) {
|
|
1031
|
+
t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && p("项目语言不支持"), e ? (K(), e === "." ? (await Le(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await Ri() : p("参数错误。执行 z init -h 查看帮助。")) : await Ei();
|
|
1032
|
+
}
|
|
1033
|
+
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => M(Ci, ...e));
|
|
1034
|
+
async function xi(e, t) {
|
|
1033
1035
|
if (!e)
|
|
1034
1036
|
return "不能为空";
|
|
1035
1037
|
if (!/^[a-z0-9-]+$/.test(e))
|
|
1036
1038
|
return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
|
|
1037
|
-
if (
|
|
1039
|
+
if (lt().includes(e))
|
|
1038
1040
|
return "当前目录下已存在同名文件夹,请先处理。";
|
|
1039
|
-
const i = (await
|
|
1041
|
+
const i = (await Ha(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
|
|
1040
1042
|
return i ? `远程仓库中已存在同名项目(${i.http_url_to_repo}),请更名后重试` : !0;
|
|
1041
1043
|
}
|
|
1042
|
-
function
|
|
1044
|
+
function Di(e) {
|
|
1043
1045
|
return e ? !0 : "不能为空";
|
|
1044
1046
|
}
|
|
1045
1047
|
function Pi(e) {
|
|
1046
1048
|
return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
|
|
1047
1049
|
}
|
|
1048
|
-
async function
|
|
1050
|
+
async function Li(e) {
|
|
1049
1051
|
ae(), K(), await be();
|
|
1050
1052
|
let t, a;
|
|
1051
1053
|
e.branchType ? t = e.branchType : t = await k({
|
|
@@ -1064,17 +1066,17 @@ async function Di(e) {
|
|
|
1064
1066
|
value: de.REFACTOR
|
|
1065
1067
|
}
|
|
1066
1068
|
]
|
|
1067
|
-
}), e.branchPurpose ? a = e.branchPurpose : (a = await
|
|
1069
|
+
}), e.branchPurpose ? a = e.branchPurpose : (a = await B({
|
|
1068
1070
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1069
1071
|
validate: Pi
|
|
1070
1072
|
}), a = a.trim());
|
|
1071
|
-
const n = `${t}_${a}_${
|
|
1073
|
+
const n = `${t}_${a}_${mt()}`;
|
|
1072
1074
|
await d(`git fetch origin ${$.MASTER}`), await d(`git checkout -b ${n} origin/${$.MASTER}`), await d(`git push -u origin ${n}`), process.exit(0);
|
|
1073
1075
|
}
|
|
1074
|
-
const
|
|
1075
|
-
async function
|
|
1076
|
+
const yt = (e) => `${U("ZenTaoDomain")}${e}`;
|
|
1077
|
+
async function Oi() {
|
|
1076
1078
|
const e = await $e({
|
|
1077
|
-
url:
|
|
1079
|
+
url: yt("/my-work-task.json?tid=mrrferp8"),
|
|
1078
1080
|
method: "get"
|
|
1079
1081
|
});
|
|
1080
1082
|
return e?.tasks ? e.tasks.filter((t) => t.status !== "done").map(({ id: t, name: a }) => ({
|
|
@@ -1085,9 +1087,9 @@ async function Li() {
|
|
|
1085
1087
|
name: a
|
|
1086
1088
|
})) : [];
|
|
1087
1089
|
}
|
|
1088
|
-
async function
|
|
1090
|
+
async function Mi() {
|
|
1089
1091
|
const e = await $e({
|
|
1090
|
-
url:
|
|
1092
|
+
url: yt("/my-work-bug.json?tid=mrrferp8"),
|
|
1091
1093
|
method: "get"
|
|
1092
1094
|
});
|
|
1093
1095
|
return e?.bugs ? Object.values(e.bugs).map(({ id: t, title: a }) => ({
|
|
@@ -1098,47 +1100,61 @@ async function Oi() {
|
|
|
1098
1100
|
}
|
|
1099
1101
|
})) : [];
|
|
1100
1102
|
}
|
|
1101
|
-
const Ce = async () => (await
|
|
1103
|
+
const Ce = async () => (await B({
|
|
1102
1104
|
message: "请输入commit msg:",
|
|
1103
1105
|
validate: (t) => t.length === 0 ? "请输入commit msg" : !0
|
|
1104
1106
|
})).trim();
|
|
1105
|
-
async function
|
|
1106
|
-
const a = await d("git diff
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
async function He(e, t) {
|
|
1108
|
+
const a = await d("git diff HEAD", {
|
|
1109
|
+
removeTailLinkBreak: !1
|
|
1110
|
+
});
|
|
1111
|
+
if (a || p("git暂存区没有内容,请先git add添加文件到暂存区"), Buffer.byteLength(a, "utf-8") < Ge) {
|
|
1112
|
+
const u = await Ze({
|
|
1113
|
+
type: "commit-message-v2",
|
|
1114
|
+
input: a
|
|
1115
|
+
// modelName: "qwen-turbo",
|
|
1116
|
+
});
|
|
1117
|
+
return e + u;
|
|
1118
|
+
}
|
|
1119
|
+
const n = await d("git diff --name-only HEAD");
|
|
1120
|
+
n || p("git暂存区没有内容,请先git add添加文件到暂存区");
|
|
1121
|
+
const i = n.replace(/\r\n/g, `
|
|
1109
1122
|
`).split(`
|
|
1110
|
-
`).filter(Boolean),
|
|
1111
|
-
for (const
|
|
1123
|
+
`).filter(Boolean), s = [], o = [];
|
|
1124
|
+
for (const u of i)
|
|
1112
1125
|
try {
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1126
|
+
const l = u.replace(/(["\\$`])/g, "\\$1"), f = await d(`git diff HEAD -- "${l}"`, {
|
|
1127
|
+
removeTailLinkBreak: !1
|
|
1128
|
+
});
|
|
1129
|
+
f && Buffer.byteLength(f, "utf-8") < na && (s.push(u), o.push(f));
|
|
1115
1130
|
} catch {
|
|
1116
1131
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1132
|
+
const r = o.join(`
|
|
1133
|
+
`);
|
|
1134
|
+
if (s.length === 0 || Buffer.byteLength(r, "utf-8") > Ge)
|
|
1135
|
+
return We("变更内容太大,无法自动生成commit msg"), t.stop(), await Ce();
|
|
1136
|
+
if (!r)
|
|
1137
|
+
return We("无法获取文件差异信息"), t.stop(), await Ce();
|
|
1138
|
+
const c = await Ze({
|
|
1123
1139
|
type: "commit-message-v2",
|
|
1124
|
-
input:
|
|
1140
|
+
input: r
|
|
1125
1141
|
// modelName: "qwen-turbo",
|
|
1126
1142
|
});
|
|
1127
|
-
return e +
|
|
1143
|
+
return e + c;
|
|
1128
1144
|
}
|
|
1129
1145
|
async function Te(e, t, a) {
|
|
1130
1146
|
const n = y("🤖 生成提交信息中...").start();
|
|
1131
1147
|
let i = "", s = !0;
|
|
1132
1148
|
if ([S.FEAT, S.FIX, S.REFACTOR].includes(e)) {
|
|
1133
1149
|
const o = t.map((r) => r.value).join(",");
|
|
1134
|
-
if (a || (i = await
|
|
1150
|
+
if (a || (i = await He(`${e}(${o}): `, n)), !i) {
|
|
1135
1151
|
const r = t.map((c) => c.name).join(";");
|
|
1136
1152
|
i = `${e}(${o}): ${r}`, s = !1;
|
|
1137
1153
|
}
|
|
1138
1154
|
}
|
|
1139
|
-
e === S.CHORE && (t ? i = `${e}: ${t}` : i = await
|
|
1155
|
+
e === S.CHORE && (t ? i = `${e}: ${t}` : i = await He(`${e}: `, n)), await P(Ne(), i, "utf-8"), s || a ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(N.yellow(i));
|
|
1140
1156
|
}
|
|
1141
|
-
async function
|
|
1157
|
+
async function zi(e) {
|
|
1142
1158
|
const t = await k({
|
|
1143
1159
|
message: "请选择你要创建的模板类型",
|
|
1144
1160
|
choices: [
|
|
@@ -1161,7 +1177,7 @@ async function Mi(e) {
|
|
|
1161
1177
|
]
|
|
1162
1178
|
});
|
|
1163
1179
|
if ([S.FEAT, S.REFACTOR].includes(t)) {
|
|
1164
|
-
const a = await
|
|
1180
|
+
const a = await Oi();
|
|
1165
1181
|
if (!a.length)
|
|
1166
1182
|
return q("🤷 暂无开发任务");
|
|
1167
1183
|
const n = await ve({
|
|
@@ -1176,7 +1192,7 @@ async function Mi(e) {
|
|
|
1176
1192
|
await Te(S.FEAT, n, e);
|
|
1177
1193
|
}
|
|
1178
1194
|
if (t === S.FIX) {
|
|
1179
|
-
const a = await
|
|
1195
|
+
const a = await Mi();
|
|
1180
1196
|
if (!a.length)
|
|
1181
1197
|
return q("🤷 暂无BUG");
|
|
1182
1198
|
const n = await ve({
|
|
@@ -1196,23 +1212,23 @@ async function Mi(e) {
|
|
|
1196
1212
|
}
|
|
1197
1213
|
process.exit(0);
|
|
1198
1214
|
}
|
|
1199
|
-
async function
|
|
1215
|
+
async function Fi() {
|
|
1200
1216
|
try {
|
|
1201
1217
|
const e = {}, t = async () => {
|
|
1202
|
-
const O =
|
|
1218
|
+
const O = lt(), { projects: se } = await Oa(), X = se.map((ce) => {
|
|
1203
1219
|
const Je = {
|
|
1204
1220
|
name: `${ce.name} [${ce.desc}]`,
|
|
1205
1221
|
value: ce.name,
|
|
1206
1222
|
disabled: !1
|
|
1207
1223
|
};
|
|
1208
1224
|
return O.includes(ce.name) && (Je.disabled = "目录下已存在同名文件夹"), Je;
|
|
1209
|
-
}),
|
|
1225
|
+
}), Tt = await k({
|
|
1210
1226
|
message: "请选择一个项目模板",
|
|
1211
1227
|
choices: X
|
|
1212
|
-
}), Ee = se.find((ce) => ce.name ===
|
|
1228
|
+
}), Ee = se.find((ce) => ce.name === Tt);
|
|
1213
1229
|
e.tplName = Ee.name, e.tplUrl = Ee.url, e.tplLanguage = Ee.language;
|
|
1214
1230
|
}, a = async () => {
|
|
1215
|
-
const { groups: O } =
|
|
1231
|
+
const { groups: O } = ai(), se = await k({
|
|
1216
1232
|
message: "请选择一个分组",
|
|
1217
1233
|
choices: O.map((X) => ({
|
|
1218
1234
|
name: `${X.name} [${X.description}]`,
|
|
@@ -1225,19 +1241,19 @@ async function zi() {
|
|
|
1225
1241
|
name: O.find((X) => X.id === se)?.name
|
|
1226
1242
|
};
|
|
1227
1243
|
}, n = async () => {
|
|
1228
|
-
e.projectName = await
|
|
1244
|
+
e.projectName = await B({
|
|
1229
1245
|
message: "请输入项目名称",
|
|
1230
|
-
validate: (O) =>
|
|
1231
|
-
}), e.projectName = e.projectName.trim(), e.projectDesc = await
|
|
1246
|
+
validate: (O) => xi(O, e.group?.name || "")
|
|
1247
|
+
}), e.projectName = e.projectName.trim(), e.projectDesc = await B({
|
|
1232
1248
|
message: "请输入项目描述",
|
|
1233
|
-
validate:
|
|
1249
|
+
validate: Di
|
|
1234
1250
|
}), e.projectDesc = e.projectDesc.trim();
|
|
1235
1251
|
};
|
|
1236
1252
|
await t(), await a(), await n();
|
|
1237
1253
|
const i = `${fe}/${e.group?.name}/${e.projectName}.git`, s = y("模版初始化中").start();
|
|
1238
|
-
await d(`git clone --depth=1 ${e.tplUrl}`), await
|
|
1239
|
-
const o =
|
|
1240
|
-
|
|
1254
|
+
await d(`git clone --depth=1 ${e.tplUrl}`), await Xe(e.tplName, e.projectName), L.cd(e.projectName), L.rm("-rf", ".git"), await d(`git init --initial-branch=${$.MASTER}`), await d(`git remote add origin ${i}`), await d(`git config user.name ${C("gitName")}`), await d(`git config user.email ${C("gitEmail")}`);
|
|
1255
|
+
const o = De();
|
|
1256
|
+
Ra({
|
|
1241
1257
|
...o,
|
|
1242
1258
|
name: e.projectName,
|
|
1243
1259
|
description: e.projectDesc,
|
|
@@ -1245,12 +1261,12 @@ async function zi() {
|
|
|
1245
1261
|
...o.scripts,
|
|
1246
1262
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1247
1263
|
}
|
|
1248
|
-
}), await
|
|
1264
|
+
}), await R.writeFile(m.resolve("README.md"), ya(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Le(e.tplLanguage, e.group?.name);
|
|
1249
1265
|
const r = y("依赖安装中").start();
|
|
1250
1266
|
await d("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1251
1267
|
const c = y("项目推送中").start();
|
|
1252
1268
|
await d('git add . && git commit -m "chore: 项目初始化"'), await d("git tag v0.0.1");
|
|
1253
|
-
const u = await
|
|
1269
|
+
const u = await Za({
|
|
1254
1270
|
name: e.projectName,
|
|
1255
1271
|
description: e.projectDesc,
|
|
1256
1272
|
path: e.projectName,
|
|
@@ -1258,9 +1274,9 @@ async function zi() {
|
|
|
1258
1274
|
namespace_id: e.group?.id
|
|
1259
1275
|
});
|
|
1260
1276
|
await d(`git push -u origin ${$.MASTER}`), await d(`git push origin HEAD:${$.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${N.blue(i)}`);
|
|
1261
|
-
const l = y("初始化分支中").start(), f = `feat_init_${
|
|
1277
|
+
const l = y("初始化分支中").start(), f = `feat_init_${mt()}`, h = [$.DEV, $.TEST, $.RELEASE, f], g = await Promise.allSettled(
|
|
1262
1278
|
h.map(
|
|
1263
|
-
(O) =>
|
|
1279
|
+
(O) => ei({
|
|
1264
1280
|
id: u.id,
|
|
1265
1281
|
branch: O,
|
|
1266
1282
|
ref: $.MASTER
|
|
@@ -1270,13 +1286,13 @@ async function zi() {
|
|
|
1270
1286
|
g.forEach(({ status: O }, se) => {
|
|
1271
1287
|
O === "fulfilled" && v.push(h[se]);
|
|
1272
1288
|
}), await d("git pull"), v.includes(f) ? (await d(`git checkout -b ${f} origin/${f}`), l.succeed(`项目已切换到初始分支: ${N.blue(f)}`)) : l.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
|
|
1273
|
-
const
|
|
1274
|
-
console.log(`输入 ${N.green(
|
|
1289
|
+
const _ = `cd ${e.projectName} && z start`;
|
|
1290
|
+
console.log(`输入 ${N.green(_)} 开始开发吧~`), process.exit(0);
|
|
1275
1291
|
} catch (e) {
|
|
1276
1292
|
p(e);
|
|
1277
1293
|
}
|
|
1278
1294
|
}
|
|
1279
|
-
async function
|
|
1295
|
+
async function Ji(e, t) {
|
|
1280
1296
|
let a;
|
|
1281
1297
|
e ? [
|
|
1282
1298
|
"project",
|
|
@@ -1309,51 +1325,51 @@ async function Fi(e, t) {
|
|
|
1309
1325
|
/* Project */
|
|
1310
1326
|
}
|
|
1311
1327
|
]
|
|
1312
|
-
}), a === "project" ? await
|
|
1328
|
+
}), a === "project" ? await Fi() : (ae(), K(), a === "branch" ? await Li(t) : a === "commit-msg" && (await d("git status -s") ? await zi(t.commitMessageCloseAi) : p("没有要变动的文件,无法生成提交信息")));
|
|
1313
1329
|
}
|
|
1314
|
-
|
|
1315
|
-
const
|
|
1316
|
-
const t = await
|
|
1330
|
+
D.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(de).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").action((...e) => M(Ji, ...e));
|
|
1331
|
+
const Bi = async (e) => {
|
|
1332
|
+
const t = await Pa(), a = C("weWorkUserId"), { notifyUsers: n, notifyGroups: i, ...s } = e, o = y("部署任务创建中").start(), r = await ji({
|
|
1317
1333
|
...s,
|
|
1318
1334
|
userToken: t,
|
|
1319
1335
|
userWeworkId: a,
|
|
1320
|
-
notifyUsers: [.../* @__PURE__ */ new Set([a, ...n])].join(
|
|
1321
|
-
notifyGroups: i.join(
|
|
1336
|
+
notifyUsers: [.../* @__PURE__ */ new Set([a, ...n])].join(Re),
|
|
1337
|
+
notifyGroups: i.join(Re)
|
|
1322
1338
|
});
|
|
1323
1339
|
s.moduleNames.length > 1 ? (o.succeed(`多模块部署任务创建完成,共 ${s.moduleNames.length} 个模块`), o.succeed(`当前已创建首个模块 ${N.blue(s.moduleNames[0])} 的 k8s 地址:`), console.log(N.blue(r)), o.info("后续模块会在前一个模块完成后依次部署,并通过企微通知下发对应地址。")) : (o.succeed("部署任务创建完成"), console.log(`如有需要,可在k8s中查看 ${N.blue(r)}`));
|
|
1324
1340
|
};
|
|
1325
1341
|
function Ui(e, t) {
|
|
1326
|
-
const a =
|
|
1342
|
+
const a = De();
|
|
1327
1343
|
if (ie()?.repository?.url || p(".z/project.json中缺少repository.url"), t === W.H5) {
|
|
1328
1344
|
const i = `build:${e}`;
|
|
1329
1345
|
a?.scripts[i] || p(`项目package.json文件scripts不存在命令${i}。`);
|
|
1330
1346
|
}
|
|
1331
1347
|
t === W.NPM && (a?.scripts.build || p("项目package.json文件scripts不存在命令build。")), t === W.SERVER && (a?.scripts.build || p("项目package.json文件scripts不存在命令build。"));
|
|
1332
1348
|
}
|
|
1333
|
-
async function
|
|
1349
|
+
async function vt(e, t) {
|
|
1334
1350
|
ae(), K();
|
|
1335
1351
|
let a = e, n = t.platform;
|
|
1336
1352
|
const i = ie();
|
|
1337
1353
|
if (i.language === w.JAVA && (n = W.SERVER), a && !Object.values($).includes(a) && p("仅支持发布指定环境分支"), n && !Object.values(W).includes(n) && p("发布平台错误"), n || (n = await k({
|
|
1338
1354
|
message: "请选择平台",
|
|
1339
|
-
choices:
|
|
1355
|
+
choices: Qt
|
|
1340
1356
|
})), n === W.NPM && (a = $.MASTER), !a) {
|
|
1341
1357
|
const u = await k({
|
|
1342
1358
|
message: "请选择部署环境",
|
|
1343
|
-
choices:
|
|
1359
|
+
choices: it
|
|
1344
1360
|
});
|
|
1345
|
-
a =
|
|
1361
|
+
a = ha(u);
|
|
1346
1362
|
}
|
|
1347
1363
|
let s = "";
|
|
1348
|
-
i.language === w.JAVASCRIPT && (s =
|
|
1364
|
+
i.language === w.JAVASCRIPT && (s = aa);
|
|
1349
1365
|
const o = [];
|
|
1350
1366
|
if (i.language === w.JAVASCRIPT) {
|
|
1351
1367
|
let u = "";
|
|
1352
|
-
const l =
|
|
1368
|
+
const l = De();
|
|
1353
1369
|
l.name.startsWith("@") && l.name.includes("/") ? u = l.name.split("/").pop() || "" : u = l.name, u && o.push(u);
|
|
1354
1370
|
}
|
|
1355
1371
|
if (i.language === w.JAVA) {
|
|
1356
|
-
const { projects: u } = await
|
|
1372
|
+
const { projects: u } = await Ma(), l = u.find(
|
|
1357
1373
|
(f) => ee(f.url) === ee(i.repository.url)
|
|
1358
1374
|
);
|
|
1359
1375
|
if (!l)
|
|
@@ -1365,7 +1381,7 @@ async function yt(e, t) {
|
|
|
1365
1381
|
value: g
|
|
1366
1382
|
}));
|
|
1367
1383
|
if (t.module) {
|
|
1368
|
-
const g = new Set(t.module.split(
|
|
1384
|
+
const g = new Set(t.module.split(Re));
|
|
1369
1385
|
f.forEach((v) => g.has(v.value) && o.push(v.value));
|
|
1370
1386
|
}
|
|
1371
1387
|
const h = await H({
|
|
@@ -1379,7 +1395,7 @@ async function yt(e, t) {
|
|
|
1379
1395
|
filter: !0,
|
|
1380
1396
|
theme: {
|
|
1381
1397
|
style: {
|
|
1382
|
-
renderSelectedOptions: (g) => g.map((v,
|
|
1398
|
+
renderSelectedOptions: (g) => g.map((v, _) => `${_ + 1}.${v.value}`).join(", ")
|
|
1383
1399
|
}
|
|
1384
1400
|
}
|
|
1385
1401
|
});
|
|
@@ -1387,13 +1403,13 @@ async function yt(e, t) {
|
|
|
1387
1403
|
}
|
|
1388
1404
|
}
|
|
1389
1405
|
let r = [];
|
|
1390
|
-
t.skipSelectionNotification || (r = await
|
|
1406
|
+
t.skipSelectionNotification || (r = await wt("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1391
1407
|
let c = [];
|
|
1392
|
-
if (t.skipGroupNotification || (c = await
|
|
1393
|
-
const u =
|
|
1408
|
+
if (t.skipGroupNotification || (c = await ki("请选择部署成功要通知的群组:", () => !0, !0)), i.language === w.JAVASCRIPT) {
|
|
1409
|
+
const u = ga(a);
|
|
1394
1410
|
Ui(u, n);
|
|
1395
1411
|
}
|
|
1396
|
-
await
|
|
1412
|
+
await Bi({
|
|
1397
1413
|
moduleNames: o,
|
|
1398
1414
|
k8sGroupName: s,
|
|
1399
1415
|
branchName: a,
|
|
@@ -1401,11 +1417,11 @@ async function yt(e, t) {
|
|
|
1401
1417
|
notifyGroups: c
|
|
1402
1418
|
});
|
|
1403
1419
|
}
|
|
1404
|
-
async function
|
|
1420
|
+
async function $t(e, t, a, n) {
|
|
1405
1421
|
const i = y(`分支合并中,${e} -> ${t}`).start();
|
|
1406
1422
|
let s = 0;
|
|
1407
1423
|
try {
|
|
1408
|
-
const { iid: r } = await
|
|
1424
|
+
const { iid: r } = await Ka({
|
|
1409
1425
|
title: `${e} -> ${t} by z-develop`,
|
|
1410
1426
|
id: a.id,
|
|
1411
1427
|
source_branch: e,
|
|
@@ -1421,7 +1437,7 @@ async function vt(e, t, a, n) {
|
|
|
1421
1437
|
try {
|
|
1422
1438
|
await new Promise((r) => {
|
|
1423
1439
|
setTimeout(r, 5e3);
|
|
1424
|
-
}), await
|
|
1440
|
+
}), await Xa({
|
|
1425
1441
|
id: a.id,
|
|
1426
1442
|
iid: s
|
|
1427
1443
|
}), i.succeed(`分支${e}已合并到分支${t}`);
|
|
@@ -1430,12 +1446,12 @@ async function vt(e, t, a, n) {
|
|
|
1430
1446
|
const c = r?.response?.status;
|
|
1431
1447
|
if (c === 406)
|
|
1432
1448
|
return await o();
|
|
1433
|
-
if (await
|
|
1449
|
+
if (await Ya({
|
|
1434
1450
|
id: a.id,
|
|
1435
1451
|
iid: s,
|
|
1436
1452
|
state_event: "close"
|
|
1437
1453
|
}), c === 405) {
|
|
1438
|
-
const u = await
|
|
1454
|
+
const u = await Qa({
|
|
1439
1455
|
id: a.id,
|
|
1440
1456
|
iid: s
|
|
1441
1457
|
});
|
|
@@ -1449,26 +1465,26 @@ async function vt(e, t, a, n) {
|
|
|
1449
1465
|
};
|
|
1450
1466
|
await o();
|
|
1451
1467
|
}
|
|
1452
|
-
async function
|
|
1468
|
+
async function _i(e, t) {
|
|
1453
1469
|
const a = `origin/${e.sourceBranch}`, n = await d(`git log -b origin/${$.MASTER} -1 --format=%H`), i = await d(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await d(
|
|
1454
1470
|
`git log ${n}...${i} -b ${a}`
|
|
1455
1471
|
);
|
|
1456
1472
|
if (s || p(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await d(
|
|
1457
1473
|
`git branch --contains ${n} -r ${a}`
|
|
1458
|
-
) || (console.log(N.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await
|
|
1474
|
+
) || (console.log(N.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await $t($.MASTER, e.sourceBranch, e)), t === $.MASTER) {
|
|
1459
1475
|
const r = s.split(`
|
|
1460
1476
|
`).filter((f) => f), c = await d(`git log -b origin/${E.TEST} -1 --format=%H`), l = (await d(
|
|
1461
1477
|
`git log ${n}...${c} -b origin/${E.TEST}`
|
|
1462
1478
|
)).split(`
|
|
1463
1479
|
`).filter((f) => f);
|
|
1464
|
-
|
|
1480
|
+
fa(l, r) || p("请先在测试环境发布要部署的代码");
|
|
1465
1481
|
}
|
|
1466
1482
|
}
|
|
1467
1483
|
async function Gi(e, t) {
|
|
1468
1484
|
ae(), K(), await be();
|
|
1469
|
-
const a = await
|
|
1485
|
+
const a = await Ca();
|
|
1470
1486
|
Object.values($).includes(a.sourceBranch) && p(`当前分支${a.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1471
|
-
const i = (await
|
|
1487
|
+
const i = (await ti(a.id)).filter((c) => ![a.sourceBranch].includes(c.name)).map((c) => {
|
|
1472
1488
|
let u = c.name;
|
|
1473
1489
|
return Object.values($).includes(u) && (u = N.bold.blue(u)), {
|
|
1474
1490
|
name: u,
|
|
@@ -1489,17 +1505,17 @@ async function Gi(e, t) {
|
|
|
1489
1505
|
), process.exit(1));
|
|
1490
1506
|
} else
|
|
1491
1507
|
await d(`git push -u origin ${a.sourceBranch}`), o.succeed(`本地分支${a.sourceBranch}已推送到远程分支origin/${a.sourceBranch}`);
|
|
1492
|
-
await
|
|
1508
|
+
await _i(a, s), await $t(a.sourceBranch, s, a, t.keepBranchAfterMergeMaster), $.MASTER === s && !t.keepBranchAfterMergeMaster && (await d(`git checkout ${$.MASTER}`), await d(`git pull origin ${$.MASTER}`), await d(`git branch -d ${a.sourceBranch}`), q(
|
|
1493
1509
|
`${a.sourceBranch}分支已移除,当前已切换到最新的${$.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1494
|
-
)), Object.values($).includes(s) && await
|
|
1510
|
+
)), Object.values($).includes(s) && await vt(s, {
|
|
1495
1511
|
platform: t.deployPlatform,
|
|
1496
1512
|
skipSelectionNotification: t.deploySkipSelectionNotification,
|
|
1497
1513
|
skipGroupNotification: t.skipGroupNotification
|
|
1498
1514
|
});
|
|
1499
1515
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
async function
|
|
1516
|
+
D.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(W).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => M(Gi, ...e));
|
|
1517
|
+
D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values($).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(W).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称,多个使用逗号分隔").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => M(vt, ...e));
|
|
1518
|
+
async function Vi() {
|
|
1503
1519
|
try {
|
|
1504
1520
|
await d("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
|
|
1505
1521
|
silent: !1
|
|
@@ -1508,7 +1524,7 @@ async function _i() {
|
|
|
1508
1524
|
p("checkstyle执行出错"), process.exit(1);
|
|
1509
1525
|
}
|
|
1510
1526
|
}
|
|
1511
|
-
async function
|
|
1527
|
+
async function Wi() {
|
|
1512
1528
|
A(m.resolve("node_modules", ".bin", "markdownlint")) || p("该项目未安装markdownlint,请安装后重试");
|
|
1513
1529
|
const e = y("markdownlint执行中...").start();
|
|
1514
1530
|
try {
|
|
@@ -1519,24 +1535,24 @@ async function Vi() {
|
|
|
1519
1535
|
e.fail("markdownlint校验出错"), process.exit(1);
|
|
1520
1536
|
}
|
|
1521
1537
|
}
|
|
1522
|
-
function
|
|
1538
|
+
function qi() {
|
|
1523
1539
|
const e = ie();
|
|
1524
1540
|
if (e["lint-staged"])
|
|
1525
1541
|
return e["lint-staged"];
|
|
1526
1542
|
throw new Error("未找到lint配置");
|
|
1527
1543
|
}
|
|
1528
|
-
async function
|
|
1544
|
+
async function Zi() {
|
|
1529
1545
|
const e = y("代码风格检测中...").start();
|
|
1530
|
-
await
|
|
1546
|
+
await Ft({
|
|
1531
1547
|
concurrent: 4,
|
|
1532
1548
|
debug: !1,
|
|
1533
|
-
config:
|
|
1549
|
+
config: qi(),
|
|
1534
1550
|
quiet: !0,
|
|
1535
1551
|
relative: !0
|
|
1536
1552
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
1537
1553
|
}
|
|
1538
|
-
function
|
|
1539
|
-
if (e.includes("Merge") && e.includes("# Conflicts:") ||
|
|
1554
|
+
function Hi(e) {
|
|
1555
|
+
if (e.includes("Merge") && e.includes("# Conflicts:") || Jt.valid(e))
|
|
1540
1556
|
return !0;
|
|
1541
1557
|
const t = e.split(": ");
|
|
1542
1558
|
if (t.length === 1)
|
|
@@ -1544,13 +1560,13 @@ function Zi(e) {
|
|
|
1544
1560
|
const a = t[0];
|
|
1545
1561
|
return /^(feat|fix|refactor)/.test(a) ? /\(\d+(?:,\d+)*\)/.test(a) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(a) ? [S.CHORE, S.CI].includes(a) ? !0 : "chore/ci类型无需填写ID。" : S.Break === a ? !0 : "不存在的提交类型。";
|
|
1546
1562
|
}
|
|
1547
|
-
async function
|
|
1548
|
-
const e = await
|
|
1563
|
+
async function Ki() {
|
|
1564
|
+
const e = await Ie(m.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), a = Hi(e);
|
|
1549
1565
|
a === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${a}`), process.exit(1));
|
|
1550
1566
|
}
|
|
1551
|
-
async function
|
|
1567
|
+
async function Xi() {
|
|
1552
1568
|
await be();
|
|
1553
|
-
const e = await
|
|
1569
|
+
const e = await Bt({
|
|
1554
1570
|
// 分组,展示仓库链接
|
|
1555
1571
|
format: ["group", "repo"],
|
|
1556
1572
|
// 交互式弹窗
|
|
@@ -1567,7 +1583,7 @@ async function Ki() {
|
|
|
1567
1583
|
}
|
|
1568
1584
|
process.exit(0);
|
|
1569
1585
|
}
|
|
1570
|
-
async function
|
|
1586
|
+
async function Yi(e) {
|
|
1571
1587
|
A(m.resolve("node_modules", ".bin", "eslint")) || p("该项目未安装eslint,请安装后重试");
|
|
1572
1588
|
const t = y("eslint执行中...").start();
|
|
1573
1589
|
try {
|
|
@@ -1579,7 +1595,7 @@ async function Xi(e) {
|
|
|
1579
1595
|
t.fail("eslint校验出错"), process.exit(1);
|
|
1580
1596
|
}
|
|
1581
1597
|
}
|
|
1582
|
-
async function
|
|
1598
|
+
async function Qi() {
|
|
1583
1599
|
A(m.resolve("node_modules", ".bin", "prettier")) || p("该项目未安装prettier,请安装后重试");
|
|
1584
1600
|
const e = y("prettier执行中...").start();
|
|
1585
1601
|
try {
|
|
@@ -1593,10 +1609,10 @@ async function Yi() {
|
|
|
1593
1609
|
e.fail("prettier校验出错"), process.exit(1);
|
|
1594
1610
|
}
|
|
1595
1611
|
}
|
|
1596
|
-
function
|
|
1597
|
-
A(m.resolve("./node_modules/.bin/vue-tsc")) || p("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"),
|
|
1612
|
+
function en() {
|
|
1613
|
+
A(m.resolve("./node_modules/.bin/vue-tsc")) || p("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), da("npx vue-tsc --build"), process.exit(0);
|
|
1598
1614
|
}
|
|
1599
|
-
async function
|
|
1615
|
+
async function tn(e, t) {
|
|
1600
1616
|
ae(), K();
|
|
1601
1617
|
const a = ie();
|
|
1602
1618
|
let n;
|
|
@@ -1688,21 +1704,21 @@ async function en(e, t) {
|
|
|
1688
1704
|
choices: i
|
|
1689
1705
|
});
|
|
1690
1706
|
}
|
|
1691
|
-
n === "commit-msg" ? await
|
|
1707
|
+
n === "commit-msg" ? await Ki() : n === "commit-files" ? await Zi() : n === "prettier" ? await Qi() : n === "eslint" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await Yi(t) : n === "type-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? en() : n === "dependency-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(a.language) ? await Xi() : n === "checkstyle" && a.language === w.JAVA ? await Vi() : n === "markdown-lint" && a.language === w.MARKDOWN && await Wi();
|
|
1692
1708
|
}
|
|
1693
|
-
|
|
1709
|
+
D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint。").argument(
|
|
1694
1710
|
"[type]",
|
|
1695
1711
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs, markdown-lint|ml。"
|
|
1696
|
-
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => M(
|
|
1697
|
-
async function
|
|
1712
|
+
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => M(tn, ...e));
|
|
1713
|
+
async function Nt(e = "latest") {
|
|
1698
1714
|
const t = y("安装中...").start();
|
|
1699
1715
|
await d(`npm i -g ${re.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", me("latestCheckVersionTimestamp", Date.now()), me("version", e);
|
|
1700
|
-
const a = await
|
|
1716
|
+
const a = await Pe();
|
|
1701
1717
|
je(a), oe(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1702
1718
|
}
|
|
1703
|
-
|
|
1704
|
-
const Oe = /Thumbs\.db|\.git|DS_Store|idea/,
|
|
1705
|
-
function
|
|
1719
|
+
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => M(Nt, ...e));
|
|
1720
|
+
const Oe = /Thumbs\.db|\.git|DS_Store|idea/, At = "testcase";
|
|
1721
|
+
function bt(e) {
|
|
1706
1722
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
1707
1723
|
if (t && !e.startsWith("["))
|
|
1708
1724
|
return {
|
|
@@ -1725,11 +1741,11 @@ async function te(e, t = {}) {
|
|
|
1725
1741
|
const { exclude: a = Oe } = t, n = [];
|
|
1726
1742
|
async function i(s) {
|
|
1727
1743
|
const o = m.basename(s);
|
|
1728
|
-
if ((await
|
|
1744
|
+
if ((await Pt(s)).isFile())
|
|
1729
1745
|
return null;
|
|
1730
1746
|
const c = await xe(s, { withFileTypes: !0 }), u = (await Promise.all(
|
|
1731
1747
|
c.filter((v) => v.isDirectory() && !a.test(v.name)).map((v) => i(m.join(s, v.name)))
|
|
1732
|
-
)).filter(Boolean), { type: l, id: f, displayName: h } =
|
|
1748
|
+
)).filter(Boolean), { type: l, id: f, displayName: h } = bt(o), g = {
|
|
1733
1749
|
name: o,
|
|
1734
1750
|
id: f,
|
|
1735
1751
|
displayName: h,
|
|
@@ -1741,13 +1757,13 @@ async function te(e, t = {}) {
|
|
|
1741
1757
|
}
|
|
1742
1758
|
return await i(m.resolve(e)), n;
|
|
1743
1759
|
}
|
|
1744
|
-
async function
|
|
1760
|
+
async function jt(e, t = {}) {
|
|
1745
1761
|
const { exclude: a = Oe } = t;
|
|
1746
1762
|
try {
|
|
1747
1763
|
const n = await xe(m.resolve(e), { withFileTypes: !0 });
|
|
1748
1764
|
return await Promise.all(
|
|
1749
1765
|
n.filter((i) => i.isDirectory() && !a.test(i.name)).map((i) => {
|
|
1750
|
-
const s = m.join(e, i.name), { type: o, id: r, displayName: c } =
|
|
1766
|
+
const s = m.join(e, i.name), { type: o, id: r, displayName: c } = bt(i.name);
|
|
1751
1767
|
return {
|
|
1752
1768
|
name: i.name,
|
|
1753
1769
|
id: r,
|
|
@@ -1777,16 +1793,16 @@ async function we(e, t, a, n) {
|
|
|
1777
1793
|
if (i === s)
|
|
1778
1794
|
return !0;
|
|
1779
1795
|
const o = m.dirname(e), r = m.join(o, s);
|
|
1780
|
-
return await
|
|
1796
|
+
return await wa(e) ? await Xe(e, r) : (await d(`git mv "${e}" "${r}"`), await d("git add .")), !0;
|
|
1781
1797
|
} catch (i) {
|
|
1782
1798
|
return p(`重命名文件夹失败: ${e} -> ${t}。${i}`), !1;
|
|
1783
1799
|
}
|
|
1784
1800
|
}
|
|
1785
|
-
async function
|
|
1801
|
+
async function an(e, t, a = {}) {
|
|
1786
1802
|
const { exclude: n = Oe } = a;
|
|
1787
1803
|
async function i(s, o) {
|
|
1788
1804
|
if (!s || s.length === 0) return;
|
|
1789
|
-
const r = await
|
|
1805
|
+
const r = await jt(o, { exclude: n });
|
|
1790
1806
|
for (const c of s) {
|
|
1791
1807
|
const u = String(c.value), l = Z("module", c.label, u), f = r.find((g) => g.id === u);
|
|
1792
1808
|
let h = f?.path || m.join(o, l);
|
|
@@ -1795,7 +1811,7 @@ async function tn(e, t, a = {}) {
|
|
|
1795
1811
|
}
|
|
1796
1812
|
await i(e, m.resolve(t));
|
|
1797
1813
|
}
|
|
1798
|
-
async function
|
|
1814
|
+
async function St(e) {
|
|
1799
1815
|
const t = {
|
|
1800
1816
|
id: 0,
|
|
1801
1817
|
name: "",
|
|
@@ -1804,7 +1820,7 @@ async function jt(e) {
|
|
|
1804
1820
|
if (e)
|
|
1805
1821
|
Number.isNaN(Number(e)) && p("请输入正确的产品ID"), t.id = Number(e);
|
|
1806
1822
|
else {
|
|
1807
|
-
const a = await
|
|
1823
|
+
const a = await ri();
|
|
1808
1824
|
t.id = await k({
|
|
1809
1825
|
message: "请选择产品",
|
|
1810
1826
|
choices: a.map((n) => ({
|
|
@@ -1813,30 +1829,30 @@ async function jt(e) {
|
|
|
1813
1829
|
}))
|
|
1814
1830
|
});
|
|
1815
1831
|
}
|
|
1816
|
-
return t.name = await
|
|
1832
|
+
return t.name = await oi(t.id), t.path = m.join(At, Z("module", t.name, String(t.id))), t;
|
|
1817
1833
|
}
|
|
1818
1834
|
async function Me(e) {
|
|
1819
|
-
return (await
|
|
1835
|
+
return (await jt(At)).find((a) => Number(a.id) === e.id);
|
|
1820
1836
|
}
|
|
1821
|
-
async function
|
|
1837
|
+
async function kt(e, t) {
|
|
1822
1838
|
const a = {
|
|
1823
1839
|
precondition: e.precondition,
|
|
1824
1840
|
priority: e.pri,
|
|
1825
1841
|
steps: []
|
|
1826
1842
|
};
|
|
1827
|
-
a.steps = await
|
|
1843
|
+
a.steps = await ui(e.id), R.writeJSONSync(t, a, {
|
|
1828
1844
|
spaces: 2
|
|
1829
1845
|
});
|
|
1830
1846
|
}
|
|
1831
|
-
async function
|
|
1847
|
+
async function Et(e, t) {
|
|
1832
1848
|
await pe(t, {
|
|
1833
1849
|
recursive: !0
|
|
1834
|
-
}), await
|
|
1850
|
+
}), await kt(e, m.join(t, "config.json")), R.ensureFileSync(m.join(t, "data.yaml")), await P(
|
|
1835
1851
|
m.join(t, "data.yaml"),
|
|
1836
|
-
A(m.resolve(Q, "data.yaml")) ? await
|
|
1837
|
-
),
|
|
1852
|
+
A(m.resolve(Q, "data.yaml")) ? await Ie(m.resolve(Q, "data.yaml")) : await _a()
|
|
1853
|
+
), R.ensureFileSync(m.join(t, "main.py")), await P(
|
|
1838
1854
|
m.join(t, "main.py"),
|
|
1839
|
-
A(m.resolve(Q, "main.py")) ? await
|
|
1855
|
+
A(m.resolve(Q, "main.py")) ? await Ie(m.resolve(Q, "main.py")) : await Ga()
|
|
1840
1856
|
);
|
|
1841
1857
|
}
|
|
1842
1858
|
function ze(e) {
|
|
@@ -1852,29 +1868,29 @@ function ze(e) {
|
|
|
1852
1868
|
async function Se(e, t) {
|
|
1853
1869
|
ae(), K(), await be();
|
|
1854
1870
|
let a;
|
|
1855
|
-
t ? ([
|
|
1871
|
+
t ? ([I.MODULE, I.CASE].includes(t) || p(`不支持的参数${t}。参数值应为 ${I.MODULE} 或者 ${I.CASE}。`), a = t) : a = await k({
|
|
1856
1872
|
message: `请选择要${e}的数据类型`,
|
|
1857
|
-
choices:
|
|
1873
|
+
choices: ia
|
|
1858
1874
|
});
|
|
1859
|
-
const n = a ===
|
|
1875
|
+
const n = a === I.MODULE ? "模块" : I.CASE === a ? "用例" : "";
|
|
1860
1876
|
return {
|
|
1861
1877
|
type: a,
|
|
1862
1878
|
typeStr: n
|
|
1863
1879
|
};
|
|
1864
1880
|
}
|
|
1865
1881
|
async function ke(e) {
|
|
1866
|
-
const t = await
|
|
1882
|
+
const t = await St(e), a = await Me(t);
|
|
1867
1883
|
return a || p(`本地未找到产品【${t.name}[${t.id}]】`), {
|
|
1868
1884
|
product: t,
|
|
1869
1885
|
localProduct: a
|
|
1870
1886
|
};
|
|
1871
1887
|
}
|
|
1872
|
-
async function
|
|
1888
|
+
async function nn(e, t, a) {
|
|
1873
1889
|
e.text = "查找本地产品目录...", await Me(t) || p(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
1874
1890
|
const i = ze(a);
|
|
1875
1891
|
let s = await te(t.path);
|
|
1876
1892
|
e.text = "获取远程用例列表...";
|
|
1877
|
-
const o = await
|
|
1893
|
+
const o = await ci(t.id, i);
|
|
1878
1894
|
e.text = "本地用例同步中...";
|
|
1879
1895
|
for (const r of o) {
|
|
1880
1896
|
let c;
|
|
@@ -1882,26 +1898,26 @@ async function an(e, t, a) {
|
|
|
1882
1898
|
return p(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
1883
1899
|
const u = s.find(({ id: l }) => r.id === Number(l));
|
|
1884
1900
|
if (u)
|
|
1885
|
-
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && q(`重命名成功: ${u.displayName} -> ${r.title}`), s = await te(t.path), r.module === 0 ? c = m.resolve(t.path) : c = s.find((l) => Number(l.id) === r.module)?.path || "", await
|
|
1901
|
+
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && q(`重命名成功: ${u.displayName} -> ${r.title}`), s = await te(t.path), r.module === 0 ? c = m.resolve(t.path) : c = s.find((l) => Number(l.id) === r.module)?.path || "", await kt(
|
|
1886
1902
|
r,
|
|
1887
1903
|
m.join(c, Z("case", r.title, String(r.id)), "config.json")
|
|
1888
1904
|
);
|
|
1889
1905
|
else {
|
|
1890
1906
|
const l = m.join(c, Z("case", r.title, String(r.id)));
|
|
1891
|
-
await
|
|
1907
|
+
await Et(r, l);
|
|
1892
1908
|
}
|
|
1893
1909
|
}
|
|
1894
1910
|
}
|
|
1895
|
-
async function
|
|
1911
|
+
async function sn(e, t) {
|
|
1896
1912
|
e.text = "本地产品目录查找中...";
|
|
1897
1913
|
const a = await Me(t);
|
|
1898
1914
|
a ? (e.text = "找到产品目录。开始重命名...", a.displayName !== t.name && await we(a.path, t.name, a.type, a.id) && (e.text = `重命名成功: ${a.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await pe(t.path, { recursive: !0 }), await d("git add .")), e.text = "获取远程模块列表...";
|
|
1899
|
-
const n = await
|
|
1900
|
-
e.text = "本地同步模块中...", await
|
|
1915
|
+
const n = await gt(t.id);
|
|
1916
|
+
e.text = "本地同步模块中...", await an(n || [], t.path);
|
|
1901
1917
|
}
|
|
1902
|
-
async function
|
|
1903
|
-
const { type: a, typeStr: n } = await Se("拉取", e), i = await
|
|
1904
|
-
if (
|
|
1918
|
+
async function rn(e, t) {
|
|
1919
|
+
const { type: a, typeStr: n } = await Se("拉取", e), i = await St(t.productId), s = y(`${n}同步中...`).start();
|
|
1920
|
+
if (I.MODULE === a && await sn(s, i), I.CASE === a && await nn(s, i, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await d("git status -s")) {
|
|
1905
1921
|
const o = y("代码提交中...").start();
|
|
1906
1922
|
try {
|
|
1907
1923
|
await d(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
|
|
@@ -1910,15 +1926,15 @@ async function sn(e, t) {
|
|
|
1910
1926
|
}
|
|
1911
1927
|
}
|
|
1912
1928
|
}
|
|
1913
|
-
|
|
1914
|
-
async function
|
|
1915
|
-
let n = await
|
|
1929
|
+
D.command("qa-pull").alias("qp").description("将禅道中的模块或者用例同步到本地").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "type=case时,可传指定用例ID(可传N个,逗号隔开);不传则为产品下全部用例").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(rn, ...e));
|
|
1930
|
+
async function on(e, t, a) {
|
|
1931
|
+
let n = await B({
|
|
1916
1932
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
1917
1933
|
});
|
|
1918
1934
|
n = n.trim();
|
|
1919
1935
|
const i = y(`用例【${a}】开始创建...`).start();
|
|
1920
1936
|
i.text = "远程用例创建中...";
|
|
1921
|
-
const s = await
|
|
1937
|
+
const s = await mi({
|
|
1922
1938
|
product: Number(e.id),
|
|
1923
1939
|
// 如果父模块是产品根目录,parent=0
|
|
1924
1940
|
module: m.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
@@ -1927,14 +1943,14 @@ async function rn(e, t, a) {
|
|
|
1927
1943
|
openedBy: C("ldapAccount"),
|
|
1928
1944
|
precondition: n || ""
|
|
1929
1945
|
});
|
|
1930
|
-
i.text = "远程用例步骤创建中...", await
|
|
1946
|
+
i.text = "远程用例步骤创建中...", await pi({
|
|
1931
1947
|
case: s,
|
|
1932
1948
|
type: "step",
|
|
1933
1949
|
desc: "按照预期执行",
|
|
1934
1950
|
expect: "正常执行,符合预期"
|
|
1935
1951
|
}), i.text = "本地用例创建中...";
|
|
1936
1952
|
const o = m.join(t.path, Z("case", a, String(s)));
|
|
1937
|
-
return A(o) ? q(`${o}已存在,请检查是否对应,本地不再创建。`) : (await
|
|
1953
|
+
return A(o) ? q(`${o}已存在,请检查是否对应,本地不再创建。`) : (await Et(
|
|
1938
1954
|
{
|
|
1939
1955
|
id: s,
|
|
1940
1956
|
pri: 3,
|
|
@@ -1943,10 +1959,10 @@ async function rn(e, t, a) {
|
|
|
1943
1959
|
o
|
|
1944
1960
|
), i.succeed(`用例【[${o}】创建完成 🎉`), o);
|
|
1945
1961
|
}
|
|
1946
|
-
async function
|
|
1962
|
+
async function cn(e, t, a) {
|
|
1947
1963
|
const n = y(`模块【${a}】开始创建...`).start();
|
|
1948
1964
|
n.text = "远程模块创建中...";
|
|
1949
|
-
const i = await
|
|
1965
|
+
const i = await li({
|
|
1950
1966
|
root: Number(e.id),
|
|
1951
1967
|
name: a,
|
|
1952
1968
|
// 如果父模块是产品根目录,parent=0
|
|
@@ -1960,7 +1976,7 @@ async function on(e, t, a) {
|
|
|
1960
1976
|
recursive: !0
|
|
1961
1977
|
}), n.succeed(`模块【${s}】创建完成 🎉`);
|
|
1962
1978
|
}
|
|
1963
|
-
function
|
|
1979
|
+
function un(e) {
|
|
1964
1980
|
function t(n) {
|
|
1965
1981
|
if (!n.children || n.children.length === 0) return;
|
|
1966
1982
|
const i = n.children[0];
|
|
@@ -1984,18 +2000,18 @@ function cn(e) {
|
|
|
1984
2000
|
}
|
|
1985
2001
|
return a(e);
|
|
1986
2002
|
}
|
|
1987
|
-
async function
|
|
1988
|
-
const { type: a, typeStr: n } = await Se("创建", e), { product: i, localProduct: s } = await ke(t.productId), o = await
|
|
2003
|
+
async function ln(e, t) {
|
|
2004
|
+
const { type: a, typeStr: n } = await Se("创建", e), { product: i, localProduct: s } = await ke(t.productId), o = await gt(i.id), r = await un(o), c = Z("module", r.label, String(r.value)), l = (await te(i.path, { hasRoot: !0 })).find((g) => g.name === c);
|
|
1989
2005
|
if (!l?.path || !A(l.path))
|
|
1990
2006
|
return p(`本地不存在${c}模块`);
|
|
1991
|
-
let f = await
|
|
2007
|
+
let f = await B({
|
|
1992
2008
|
message: `请输入你要创建的${n}名称`,
|
|
1993
2009
|
required: !0,
|
|
1994
2010
|
validate: (g) => g.length > 0 && g.length < 255
|
|
1995
2011
|
});
|
|
1996
2012
|
f = f.trim();
|
|
1997
2013
|
let h = "";
|
|
1998
|
-
if (
|
|
2014
|
+
if (I.MODULE === a && await cn(s, l, f), I.CASE === a && (h = await on(s, l, f)), !t.disableAutoCommit && I.CASE === a) {
|
|
1999
2015
|
const g = y("代码提交中...").start();
|
|
2000
2016
|
try {
|
|
2001
2017
|
await d(`git add . && git commit -m "chore: 创建了用例${m.basename(h)}"`), g.succeed("代码已提交 ✅");
|
|
@@ -2004,8 +2020,8 @@ async function un(e, t) {
|
|
|
2004
2020
|
}
|
|
2005
2021
|
}
|
|
2006
2022
|
}
|
|
2007
|
-
|
|
2008
|
-
async function
|
|
2023
|
+
D.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(ln, ...e));
|
|
2024
|
+
async function mn(e, t) {
|
|
2009
2025
|
const n = (await te(e.path)).filter((r) => r.type === "case");
|
|
2010
2026
|
let i = [];
|
|
2011
2027
|
if (t.length)
|
|
@@ -2032,7 +2048,7 @@ async function ln(e, t) {
|
|
|
2032
2048
|
});
|
|
2033
2049
|
}
|
|
2034
2050
|
const s = y("远程用例删除中...").start(), o = i.map((r) => r.id);
|
|
2035
|
-
await
|
|
2051
|
+
await fi({
|
|
2036
2052
|
product: Number(e.id),
|
|
2037
2053
|
caseIds: o
|
|
2038
2054
|
}), s.text = "本地用例删除中...";
|
|
@@ -2040,7 +2056,7 @@ async function ln(e, t) {
|
|
|
2040
2056
|
A(r.path) && L.rm("-rf", r.path);
|
|
2041
2057
|
return s.succeed("用例删除完成"), o;
|
|
2042
2058
|
}
|
|
2043
|
-
async function
|
|
2059
|
+
async function pn(e, t) {
|
|
2044
2060
|
const n = (await te(e.path)).filter((r) => r.type === "module");
|
|
2045
2061
|
let i = [];
|
|
2046
2062
|
if (t.length)
|
|
@@ -2068,7 +2084,7 @@ async function mn(e, t) {
|
|
|
2068
2084
|
}
|
|
2069
2085
|
i = i.sort((r, c) => r.path.localeCompare(c.path));
|
|
2070
2086
|
const s = y("远程模块删除中...").start(), o = i.map((r) => r.id);
|
|
2071
|
-
await
|
|
2087
|
+
await di({
|
|
2072
2088
|
product: Number(e.id),
|
|
2073
2089
|
moduleIds: o
|
|
2074
2090
|
}), s.text = "本地模块删除中...";
|
|
@@ -2076,10 +2092,10 @@ async function mn(e, t) {
|
|
|
2076
2092
|
A(r.path) && L.rm("-rf", r.path);
|
|
2077
2093
|
return s.succeed("模块删除完成"), o;
|
|
2078
2094
|
}
|
|
2079
|
-
async function
|
|
2095
|
+
async function dn(e, t) {
|
|
2080
2096
|
const { type: a, typeStr: n } = await Se("删除", e), { localProduct: i } = await ke(t.productId), s = ze(t.targetIds);
|
|
2081
2097
|
let o = [];
|
|
2082
|
-
if (
|
|
2098
|
+
if (I.MODULE === a ? o = await pn(i, s) : I.CASE === a && (o = await mn(i, s)), !t.disableAutoCommit && await d("git status -s")) {
|
|
2083
2099
|
const r = y("代码提交中...").start();
|
|
2084
2100
|
try {
|
|
2085
2101
|
await d(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
@@ -2088,8 +2104,8 @@ async function pn(e, t) {
|
|
|
2088
2104
|
}
|
|
2089
2105
|
}
|
|
2090
2106
|
}
|
|
2091
|
-
|
|
2092
|
-
async function
|
|
2107
|
+
D.command("qa-remove").alias("qr").description("删除模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-ids <targetIds>", "可传指定目标(用例/模块)ID。可传N个,逗号隔开").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(dn, ...e));
|
|
2108
|
+
async function fn(e, t) {
|
|
2093
2109
|
const n = (await te(e.path)).filter((h) => h.type === "case");
|
|
2094
2110
|
let i;
|
|
2095
2111
|
if (t.targetId) {
|
|
@@ -2115,7 +2131,7 @@ async function dn(e, t) {
|
|
|
2115
2131
|
}
|
|
2116
2132
|
});
|
|
2117
2133
|
}
|
|
2118
|
-
let s = await
|
|
2134
|
+
let s = await B({
|
|
2119
2135
|
message: "修改用例名称",
|
|
2120
2136
|
default: i.displayName,
|
|
2121
2137
|
required: !0,
|
|
@@ -2124,19 +2140,19 @@ async function dn(e, t) {
|
|
|
2124
2140
|
});
|
|
2125
2141
|
s = s.trim();
|
|
2126
2142
|
const o = y("用例重命名中...").start();
|
|
2127
|
-
s !== i.displayName ? (await
|
|
2143
|
+
s !== i.displayName ? (await hi({
|
|
2128
2144
|
id: Number(i.id),
|
|
2129
2145
|
name: s
|
|
2130
2146
|
}), await we(i.path, s, "case", String(i.id)) && o.succeed(`用例重命名成功: ${i.displayName} -> ${s}`), i.displayName = s, i.path = m.join(m.dirname(i.path), Z("case", s, String(i.id)))) : o.succeed("用例名称无变动");
|
|
2131
|
-
let r =
|
|
2132
|
-
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await
|
|
2147
|
+
let r = R.readJsonSync(m.join(i.path, "config.json")), c;
|
|
2148
|
+
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await _e({
|
|
2133
2149
|
message: "修改用例优先级",
|
|
2134
2150
|
min: 1,
|
|
2135
2151
|
max: 5,
|
|
2136
2152
|
required: !0,
|
|
2137
2153
|
default: r.priority,
|
|
2138
2154
|
validate: (h) => h > 0 && h < 6
|
|
2139
|
-
}) : c = await
|
|
2155
|
+
}) : c = await _e({
|
|
2140
2156
|
message: "修改用例优先级",
|
|
2141
2157
|
min: 1,
|
|
2142
2158
|
max: 5,
|
|
@@ -2145,28 +2161,28 @@ async function dn(e, t) {
|
|
|
2145
2161
|
validate: (h) => h > 0 && h < 6
|
|
2146
2162
|
});
|
|
2147
2163
|
const u = y("用例优先级设置中...").start();
|
|
2148
|
-
c !== r.priority ? (await
|
|
2164
|
+
c !== r.priority ? (await wi({
|
|
2149
2165
|
id: Number(i.id),
|
|
2150
2166
|
priority: c
|
|
2151
|
-
}),
|
|
2167
|
+
}), R.writeJSONSync(
|
|
2152
2168
|
m.join(i.path, "config.json"),
|
|
2153
2169
|
{
|
|
2154
2170
|
...r,
|
|
2155
2171
|
priority: c
|
|
2156
2172
|
},
|
|
2157
2173
|
{ spaces: 2 }
|
|
2158
|
-
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r =
|
|
2174
|
+
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = R.readJsonSync(m.join(i.path, "config.json"));
|
|
2159
2175
|
let l;
|
|
2160
|
-
t.casePrecondition ? l = t.casePrecondition : (l = await
|
|
2176
|
+
t.casePrecondition ? l = t.casePrecondition : (l = await B({
|
|
2161
2177
|
message: "修改用例前置条件",
|
|
2162
2178
|
default: r.precondition,
|
|
2163
2179
|
prefill: "editable"
|
|
2164
2180
|
}), l = l.trim());
|
|
2165
2181
|
const f = y("用例前置条件设置中...").start();
|
|
2166
|
-
return l !== r.precondition ? (await
|
|
2182
|
+
return l !== r.precondition ? (await yi({
|
|
2167
2183
|
id: Number(i.id),
|
|
2168
2184
|
precondition: l
|
|
2169
|
-
}),
|
|
2185
|
+
}), R.writeJSONSync(
|
|
2170
2186
|
m.join(i.path, "config.json"),
|
|
2171
2187
|
{
|
|
2172
2188
|
...r,
|
|
@@ -2175,7 +2191,7 @@ async function dn(e, t) {
|
|
|
2175
2191
|
{ spaces: 2 }
|
|
2176
2192
|
), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${l}`)) : f.succeed("用例前置条件无变动"), i.id;
|
|
2177
2193
|
}
|
|
2178
|
-
async function
|
|
2194
|
+
async function gn(e, t) {
|
|
2179
2195
|
const n = (await te(e.path)).filter((r) => r.type === "module");
|
|
2180
2196
|
let i;
|
|
2181
2197
|
if (t.targetId) {
|
|
@@ -2201,7 +2217,7 @@ async function fn(e, t) {
|
|
|
2201
2217
|
}
|
|
2202
2218
|
});
|
|
2203
2219
|
}
|
|
2204
|
-
let s = await
|
|
2220
|
+
let s = await B({
|
|
2205
2221
|
message: "修改模块名称",
|
|
2206
2222
|
default: i.displayName,
|
|
2207
2223
|
required: !0,
|
|
@@ -2210,15 +2226,15 @@ async function fn(e, t) {
|
|
|
2210
2226
|
});
|
|
2211
2227
|
s = s.trim();
|
|
2212
2228
|
const o = y("模块重命名中...").start();
|
|
2213
|
-
return s !== i.displayName ? (await
|
|
2229
|
+
return s !== i.displayName ? (await gi({
|
|
2214
2230
|
id: Number(i.id),
|
|
2215
2231
|
name: s
|
|
2216
2232
|
}), await we(i.path, s, "module", String(i.id)) && o.succeed(`模块重命名成功: ${i.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), i.id;
|
|
2217
2233
|
}
|
|
2218
|
-
async function
|
|
2234
|
+
async function hn(e, t) {
|
|
2219
2235
|
const { type: a, typeStr: n } = await Se("修改", e), { localProduct: i } = await ke(t.productId);
|
|
2220
2236
|
let s;
|
|
2221
|
-
if (
|
|
2237
|
+
if (I.MODULE === a ? s = await gn(i, t) : I.CASE === a && (s = await fn(i, t)), !t.disableAutoCommit && await d("git status -s")) {
|
|
2222
2238
|
const o = y("代码提交中...").start();
|
|
2223
2239
|
try {
|
|
2224
2240
|
await d(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
|
|
@@ -2227,11 +2243,11 @@ async function gn(e, t) {
|
|
|
2227
2243
|
}
|
|
2228
2244
|
}
|
|
2229
2245
|
}
|
|
2230
|
-
|
|
2231
|
-
async function
|
|
2246
|
+
D.command("qa-update").alias("qu").description("修改模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-id <targetId>", "可传指定目标(用例/模块)ID").option("--target-name <targetName>", "可传指定目标(用例/模块)修改后的名称").option("--case-priority <casePriority>", "如果是用例,指定修改后的优先级").option("--case-precondition <casePrecondition>", "如果是用例,指定修改后的前置条件").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => M(hn, ...e));
|
|
2247
|
+
async function wn(e, t) {
|
|
2232
2248
|
if (!e.length)
|
|
2233
2249
|
return [];
|
|
2234
|
-
const a =
|
|
2250
|
+
const a = Ut(20), n = e.map(
|
|
2235
2251
|
(i) => a(async () => {
|
|
2236
2252
|
try {
|
|
2237
2253
|
const s = t.env || "production", o = await d(`python ${i.path}/main.py --env ${s}`);
|
|
@@ -2248,7 +2264,7 @@ async function hn(e, t) {
|
|
|
2248
2264
|
);
|
|
2249
2265
|
return await Promise.all(n), e;
|
|
2250
2266
|
}
|
|
2251
|
-
async function
|
|
2267
|
+
async function yn(e) {
|
|
2252
2268
|
ae(), K();
|
|
2253
2269
|
const { localProduct: t } = await ke(e.productId);
|
|
2254
2270
|
let a = [];
|
|
@@ -2287,7 +2303,7 @@ async function wn(e) {
|
|
|
2287
2303
|
});
|
|
2288
2304
|
}
|
|
2289
2305
|
}
|
|
2290
|
-
const s = y("用例执行中...").start(), r = (await
|
|
2306
|
+
const s = y("用例执行中...").start(), r = (await wn(a, e)).filter((c) => c.result.length);
|
|
2291
2307
|
if (r.length === 0)
|
|
2292
2308
|
s.succeed("所有用例执行通过 🎉");
|
|
2293
2309
|
else {
|
|
@@ -2299,27 +2315,27 @@ async function wn(e) {
|
|
|
2299
2315
|
if (e.executionId)
|
|
2300
2316
|
Number.isNaN(Number(e.executionId)) && p(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
|
|
2301
2317
|
else {
|
|
2302
|
-
const f = await
|
|
2318
|
+
const f = await $i(), h = await k({
|
|
2303
2319
|
message: "请选择用例执行出错后,BUG所属的项目",
|
|
2304
|
-
choices: f.map(({ id: v, name:
|
|
2305
|
-
}), g = await
|
|
2320
|
+
choices: f.map(({ id: v, name: _ }) => ({ name: _, value: v }))
|
|
2321
|
+
}), g = await Ni(h);
|
|
2306
2322
|
u = await k({
|
|
2307
2323
|
message: "请选择用例执行出错后,BUG所属的执行",
|
|
2308
|
-
choices: g.map(({ id: v, name:
|
|
2324
|
+
choices: g.map(({ id: v, name: _ }) => ({ name: _, value: v }))
|
|
2309
2325
|
});
|
|
2310
2326
|
}
|
|
2311
2327
|
let l;
|
|
2312
2328
|
if (e.buildId)
|
|
2313
2329
|
l = e.buildId;
|
|
2314
2330
|
else {
|
|
2315
|
-
const f = await
|
|
2331
|
+
const f = await Ai(Number(u));
|
|
2316
2332
|
if (f.length) {
|
|
2317
2333
|
const h = await ve({
|
|
2318
2334
|
message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
|
|
2319
2335
|
required: !1,
|
|
2320
|
-
choices: f.map(({ id: g, name: v, date:
|
|
2336
|
+
choices: f.map(({ id: g, name: v, date: _, builder: O }) => ({
|
|
2321
2337
|
value: g,
|
|
2322
|
-
name: `${v} ${O} ${
|
|
2338
|
+
name: `${v} ${O} ${_}`
|
|
2323
2339
|
}))
|
|
2324
2340
|
});
|
|
2325
2341
|
h.length ? l = h.join(",") : l = "";
|
|
@@ -2328,7 +2344,7 @@ async function wn(e) {
|
|
|
2328
2344
|
}
|
|
2329
2345
|
s.start("上传中...");
|
|
2330
2346
|
for (const f of r)
|
|
2331
|
-
await
|
|
2347
|
+
await vi({
|
|
2332
2348
|
caseId: f.id,
|
|
2333
2349
|
caseResult: "fail",
|
|
2334
2350
|
stepResults: f.result,
|
|
@@ -2337,12 +2353,12 @@ async function wn(e) {
|
|
|
2337
2353
|
openedBuild: l
|
|
2338
2354
|
});
|
|
2339
2355
|
s.succeed(
|
|
2340
|
-
`用例执行完成。查看相关BUG(${
|
|
2356
|
+
`用例执行完成。查看相关BUG(${U("ZenTaoDomain")}/zentao/execution-bug-${u}.html}) `
|
|
2341
2357
|
);
|
|
2342
2358
|
}
|
|
2343
2359
|
}
|
|
2344
|
-
|
|
2345
|
-
const
|
|
2360
|
+
D.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认主干(trunk)").action((...e) => M(yn, ...e));
|
|
2361
|
+
const Ke = (e) => {
|
|
2346
2362
|
const t = e.trim();
|
|
2347
2363
|
if (!t)
|
|
2348
2364
|
return "请输入生成目录";
|
|
@@ -2352,11 +2368,11 @@ const Ze = (e) => {
|
|
|
2352
2368
|
return "只允许输入相对路径";
|
|
2353
2369
|
const a = m.normalize(t);
|
|
2354
2370
|
return !a || a === "." || a === ".." ? "请输入有效的目录路径" : a.startsWith(`..${m.sep}`) ? "路径不能跳出当前项目" : !0;
|
|
2355
|
-
},
|
|
2356
|
-
const { projects: e } = await
|
|
2371
|
+
}, vn = async () => {
|
|
2372
|
+
const { projects: e } = await za(), t = ie();
|
|
2357
2373
|
if (t.serverProjectURL) {
|
|
2358
2374
|
const n = e.find(
|
|
2359
|
-
(i) =>
|
|
2375
|
+
(i) => ct(i.url, t.serverProjectURL)
|
|
2360
2376
|
);
|
|
2361
2377
|
if (n)
|
|
2362
2378
|
return {
|
|
@@ -2371,11 +2387,11 @@ const Ze = (e) => {
|
|
|
2371
2387
|
value: n.url
|
|
2372
2388
|
}))
|
|
2373
2389
|
});
|
|
2374
|
-
return
|
|
2390
|
+
return pt({ ...t, serverProjectURL: a }), {
|
|
2375
2391
|
projectId: decodeURIComponent(ee(a)),
|
|
2376
2392
|
moduleList: e.find((n) => n.url === a)?.modules || []
|
|
2377
2393
|
};
|
|
2378
|
-
},
|
|
2394
|
+
}, $n = async (e) => {
|
|
2379
2395
|
if (e) {
|
|
2380
2396
|
if (["all", "single"].includes(e))
|
|
2381
2397
|
return e;
|
|
@@ -2394,7 +2410,7 @@ const Ze = (e) => {
|
|
|
2394
2410
|
}
|
|
2395
2411
|
]
|
|
2396
2412
|
});
|
|
2397
|
-
},
|
|
2413
|
+
}, Nn = async (e, t) => {
|
|
2398
2414
|
if (e)
|
|
2399
2415
|
return e.split(",").filter((a) => t.map((n) => n.name).includes(a.trim()));
|
|
2400
2416
|
{
|
|
@@ -2410,14 +2426,14 @@ const Ze = (e) => {
|
|
|
2410
2426
|
});
|
|
2411
2427
|
return a?.length ? a : t.map((n) => n.name);
|
|
2412
2428
|
}
|
|
2413
|
-
},
|
|
2429
|
+
}, An = async (e) => e && [E.DEV, E.TEST, E.RELEASE, E.PROD].includes(e.trim()) ? e : await k({
|
|
2414
2430
|
message: "请选择对应的环境",
|
|
2415
2431
|
// 去掉prod 环境
|
|
2416
|
-
choices:
|
|
2432
|
+
choices: it.filter((t) => t.value !== E.PROD)
|
|
2417
2433
|
}), Fe = (e) => {
|
|
2418
2434
|
const t = /^https?:\/\/[^/]+\/api\/([^/]+)\/v3\//;
|
|
2419
2435
|
return e.match(t)?.[1];
|
|
2420
|
-
},
|
|
2436
|
+
}, bn = async (e, t) => {
|
|
2421
2437
|
try {
|
|
2422
2438
|
const a = await ne({
|
|
2423
2439
|
url: e,
|
|
@@ -2425,13 +2441,13 @@ const Ze = (e) => {
|
|
|
2425
2441
|
}), n = Fe(e);
|
|
2426
2442
|
return n && (a.paths = Object.fromEntries(
|
|
2427
2443
|
Object.entries(a.paths).map(([i, s]) => [`/${n}${i}`, s])
|
|
2428
|
-
)),
|
|
2444
|
+
)), Gt(a, {
|
|
2429
2445
|
throwOnValidateError: !t
|
|
2430
2446
|
});
|
|
2431
2447
|
} catch (a) {
|
|
2432
2448
|
throw p(`Error fetching Swagger JSON: ${a.message}`), a;
|
|
2433
2449
|
}
|
|
2434
|
-
},
|
|
2450
|
+
}, jn = (e) => {
|
|
2435
2451
|
const t = (a) => {
|
|
2436
2452
|
const { reason: n, url: i } = a;
|
|
2437
2453
|
return `## ${Fe(i)}服务接口文档校验失败
|
|
@@ -2440,19 +2456,19 @@ ${n.message}`;
|
|
|
2440
2456
|
return `# 服务端接口文档校验失败
|
|
2441
2457
|
${e.map(t).join(`
|
|
2442
2458
|
`)}`;
|
|
2443
|
-
},
|
|
2444
|
-
const a =
|
|
2445
|
-
(c) => c.projects.some((u) =>
|
|
2459
|
+
}, Sn = async (e, t) => {
|
|
2460
|
+
const a = jn(e), n = ie(), { groups: i } = await dt(), s = i.find(
|
|
2461
|
+
(c) => c.projects.some((u) => ct(u, n.serverProjectURL))
|
|
2446
2462
|
);
|
|
2447
2463
|
t.fail("API数据解析失败"), s || (t.fail("未找到对应的项目群聊组!"), process.stdout.write(`${N.red(a)}
|
|
2448
2464
|
`), process.exit(1));
|
|
2449
|
-
const { code: o, message: r } = await
|
|
2465
|
+
const { code: o, message: r } = await bi({
|
|
2450
2466
|
content: a,
|
|
2451
2467
|
webhooks: [s.url]
|
|
2452
2468
|
});
|
|
2453
2469
|
o !== 0 && t.fail(`发送消息到企微群组失败: ${N.red(r)}`), process.stdout.write(`${N.red(a)}
|
|
2454
2470
|
`), process.exit(1);
|
|
2455
|
-
},
|
|
2471
|
+
}, kn = async (e, t, a, n) => {
|
|
2456
2472
|
const i = e.filter((u) => t.includes(u.name)).map((u) => u.swagger);
|
|
2457
2473
|
if (!i.length)
|
|
2458
2474
|
throw new Error("Failed to fetch Swagger JSON");
|
|
@@ -2462,14 +2478,14 @@ ${e.map(t).join(`
|
|
|
2462
2478
|
});
|
|
2463
2479
|
if (!s.length)
|
|
2464
2480
|
throw new Error("Failed to fetch Swagger JSON");
|
|
2465
|
-
const o = y("API数据请求中...").start(), r = await Promise.allSettled(s.map((u) =>
|
|
2481
|
+
const o = y("API数据请求中...").start(), r = await Promise.allSettled(s.map((u) => bn(u, n))), c = r.flatMap(
|
|
2466
2482
|
(u, l) => u.status === "rejected" ? [{ reason: u.reason, url: s[l] }] : []
|
|
2467
2483
|
);
|
|
2468
|
-
return c.length && await
|
|
2469
|
-
},
|
|
2484
|
+
return c.length && await Sn(c, o), o.succeed("API数据请求成功"), r.flatMap((u, l) => u.status === "fulfilled" ? [{ serverName: Fe(s[l]), swaggerJson: u.value }] : []);
|
|
2485
|
+
}, En = async (e, t) => {
|
|
2470
2486
|
const a = [];
|
|
2471
2487
|
for (const n of e) {
|
|
2472
|
-
const { apis: i } = await
|
|
2488
|
+
const { apis: i } = await Vt(n, {
|
|
2473
2489
|
throwOnValidateError: !t
|
|
2474
2490
|
});
|
|
2475
2491
|
a.push(...i.map((s) => ({ name: `${s.path}${s.summary ? `(${s.summary})` : ""}`, value: s.path })));
|
|
@@ -2489,86 +2505,86 @@ ${e.map(t).join(`
|
|
|
2489
2505
|
}
|
|
2490
2506
|
}
|
|
2491
2507
|
});
|
|
2492
|
-
},
|
|
2508
|
+
}, Tn = async (e, t, a) => {
|
|
2493
2509
|
const n = y("API 开始生成...").start();
|
|
2494
2510
|
try {
|
|
2495
2511
|
n.stop();
|
|
2496
2512
|
for (const { swaggerJson: i, serverName: s } of e) {
|
|
2497
2513
|
if (!t.some((r) => r.startsWith(`/${s}`)))
|
|
2498
2514
|
continue;
|
|
2499
|
-
const o = await
|
|
2515
|
+
const o = await Wt({
|
|
2500
2516
|
swaggerJson: i,
|
|
2501
2517
|
merge: !0,
|
|
2502
2518
|
controller: t,
|
|
2503
2519
|
throwOnValidateError: !a,
|
|
2504
2520
|
importMethods: !1
|
|
2505
2521
|
});
|
|
2506
|
-
console.log(
|
|
2522
|
+
console.log(qt(o, { language: "typescript", ignoreIllegals: !0 }));
|
|
2507
2523
|
}
|
|
2508
2524
|
n.start().succeed("API 生成成功");
|
|
2509
2525
|
} catch (i) {
|
|
2510
2526
|
n.fail(`API 生成失败: ${i.message}`);
|
|
2511
2527
|
}
|
|
2512
|
-
},
|
|
2528
|
+
}, In = (e) => {
|
|
2513
2529
|
if (e) {
|
|
2514
|
-
const t =
|
|
2530
|
+
const t = Ke(e);
|
|
2515
2531
|
return t !== !0 && p(t), e;
|
|
2516
2532
|
}
|
|
2517
|
-
return
|
|
2533
|
+
return B({
|
|
2518
2534
|
message: "请输入 API 输出目录,默认为 src/services",
|
|
2519
2535
|
default: "src/services",
|
|
2520
|
-
validate:
|
|
2536
|
+
validate: Ke
|
|
2521
2537
|
});
|
|
2522
|
-
}, Rn = new
|
|
2538
|
+
}, Rn = new Qe({
|
|
2523
2539
|
fix: !0
|
|
2524
|
-
}),
|
|
2540
|
+
}), Cn = async (e) => {
|
|
2525
2541
|
const t = await Rn.lintFiles(e);
|
|
2526
|
-
await
|
|
2542
|
+
await Qe.outputFixes(t);
|
|
2527
2543
|
for (const a of e) {
|
|
2528
|
-
const n = m.resolve(a), i =
|
|
2544
|
+
const n = m.resolve(a), i = Zt(n, "utf-8"), s = await Ht.format(i, {
|
|
2529
2545
|
filepath: n
|
|
2530
2546
|
});
|
|
2531
|
-
|
|
2547
|
+
Dt(n, s);
|
|
2532
2548
|
}
|
|
2533
|
-
},
|
|
2549
|
+
}, xn = async (e, t, a) => {
|
|
2534
2550
|
const { dir: n, skipSwaggerValidate: i } = t, s = e.map((o) => o.swaggerJson);
|
|
2535
2551
|
if (a === "single") {
|
|
2536
|
-
const o = await
|
|
2537
|
-
await
|
|
2552
|
+
const o = await En(s, i);
|
|
2553
|
+
await Tn(e, o, i);
|
|
2538
2554
|
} else {
|
|
2539
|
-
const o = y("API 开始生成...").start(), r = await
|
|
2555
|
+
const o = y("API 开始生成...").start(), r = await _t(
|
|
2540
2556
|
s.map((f) => ({
|
|
2541
2557
|
swaggerJson: f,
|
|
2542
2558
|
throwOnValidateError: !i
|
|
2543
2559
|
}))
|
|
2544
2560
|
);
|
|
2545
2561
|
o.stop();
|
|
2546
|
-
const c = await
|
|
2547
|
-
|
|
2562
|
+
const c = await In(n), u = m.resolve(c);
|
|
2563
|
+
Be.mkdirSync(u, { recursive: !0 });
|
|
2548
2564
|
const l = [];
|
|
2549
2565
|
o.start(), o.text = "API 生成中...";
|
|
2550
2566
|
for (const f of r) {
|
|
2551
2567
|
const { path: h, content: g } = f, v = m.resolve(u, h);
|
|
2552
|
-
l.push(v),
|
|
2568
|
+
l.push(v), Be.writeFileSync(v, g);
|
|
2553
2569
|
}
|
|
2554
|
-
o.text = "开始格式化代码", await
|
|
2570
|
+
o.text = "开始格式化代码", await Cn(l), o.text = "代码格式化完成", o.succeed(`API 已生成到 ${c} 目录下`);
|
|
2555
2571
|
}
|
|
2556
2572
|
};
|
|
2557
|
-
async function
|
|
2573
|
+
async function Dn(e, t) {
|
|
2558
2574
|
ae(), K();
|
|
2559
|
-
const { moduleList: a } = await
|
|
2560
|
-
await
|
|
2575
|
+
const { moduleList: a } = await vn(), { module: n, env: i, skipSwaggerValidate: s = !1 } = t, o = await Nn(n, a), r = await An(i), c = await kn(a, o, r, s), u = await $n(e);
|
|
2576
|
+
await xn(c, t, u), process.exit(0);
|
|
2561
2577
|
}
|
|
2562
|
-
|
|
2578
|
+
D.command("api").alias("a").description("选择对应的服务端项目,获取接口并转成ts接口代码及类型").argument("[type]", "可选值为service单个服务, controller单个controller, single单个接口").option("--module [module]", "模块名称。多个使用逗号隔开").option("--env [env]", "指定环境。dev/test/release").option("--controller-name [controllerName]", "controller名称").option("--api-name [apiName]", "api名称").option("--skip-swagger-validate [skipSwaggerValidate]", "是否跳过 swagger 校验").action((...e) => M(Dn, ...e));
|
|
2563
2579
|
function Pn() {
|
|
2564
2580
|
process.on("unhandledRejection", (e) => {
|
|
2565
2581
|
}), process.on("uncaughtException", (e) => {
|
|
2566
2582
|
}), L.config.fatal = !0, L.config.silent = !0, L.config.verbose = !1;
|
|
2567
2583
|
}
|
|
2568
|
-
async function
|
|
2584
|
+
async function Ln() {
|
|
2569
2585
|
const e = ge("latestCheckVersionTimestamp"), t = ge("versionCheckDuring");
|
|
2570
2586
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
2571
|
-
const a = await
|
|
2587
|
+
const a = await Pe();
|
|
2572
2588
|
je(a);
|
|
2573
2589
|
let n;
|
|
2574
2590
|
try {
|
|
@@ -2578,23 +2594,23 @@ async function Dn() {
|
|
|
2578
2594
|
n = await Promise.race([
|
|
2579
2595
|
s,
|
|
2580
2596
|
d(`npm view ${re.name} version --registry https://registry.npmmirror.com/`)
|
|
2581
|
-
]), n !== i && n !== re.version && (console.log(`${N.blue(re.name)}本地版本为${re.version},低于线上版本${n},开始升级`), await
|
|
2597
|
+
]), n !== i && n !== re.version && (console.log(`${N.blue(re.name)}本地版本为${re.version},低于线上版本${n},开始升级`), await Nt(n)), me("latestCheckVersionTimestamp", Date.now()), oe();
|
|
2582
2598
|
} catch (i) {
|
|
2583
2599
|
console.log("升级出错!请重试,或者手动升级"), p(i);
|
|
2584
2600
|
}
|
|
2585
2601
|
}
|
|
2586
2602
|
}
|
|
2587
|
-
async function
|
|
2588
|
-
const e =
|
|
2603
|
+
async function On() {
|
|
2604
|
+
const e = Kt(process.argv.slice(2));
|
|
2589
2605
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2590
|
-
if (
|
|
2591
|
-
const t =
|
|
2592
|
-
J(t.profile), me(t.main), je(t.constants), await
|
|
2606
|
+
if (ot()) {
|
|
2607
|
+
const t = R.readJSONSync(Ae());
|
|
2608
|
+
J(t.profile), me(t.main), je(t.constants), await Ln();
|
|
2593
2609
|
} else
|
|
2594
|
-
p(`请先初始化z-develop(执行 z i)。更多见${
|
|
2610
|
+
p(`请先初始化z-develop(执行 z i)。更多见${nt}`);
|
|
2595
2611
|
}
|
|
2596
|
-
async function
|
|
2597
|
-
Pn(), await
|
|
2612
|
+
async function Mn() {
|
|
2613
|
+
Pn(), await On();
|
|
2598
2614
|
}
|
|
2599
|
-
|
|
2600
|
-
|
|
2615
|
+
D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${N.blue(nt)}`).usage("<command> [options]").hook("preAction", Mn).version(re.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
2616
|
+
D.parse();
|