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