cli-z-develop 0.12.2 → 0.13.0
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 +423 -378
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { program as D } from "commander";
|
|
2
2
|
import $t from "node:child_process";
|
|
3
3
|
import { existsSync as v, readdirSync as vt, lstatSync as Nt, createWriteStream as bt } from "node:fs";
|
|
4
|
-
import { readdir as Re, mkdir as le, writeFile as L, rename as _e, readFile as
|
|
5
|
-
import
|
|
4
|
+
import { readdir as Re, mkdir as le, writeFile as L, rename as _e, readFile as Ee, stat as At } from "node:fs/promises";
|
|
5
|
+
import p from "node:path";
|
|
6
6
|
import ce, { AxiosError as jt } from "axios";
|
|
7
7
|
import S from "chalk";
|
|
8
8
|
import St from "dayjs";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import O from "shelljs";
|
|
10
|
+
import kt from "node:os";
|
|
11
11
|
import Me from "child_process";
|
|
12
|
-
import { confirm as Ue, select as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
12
|
+
import { confirm as Ue, select as k, input as F, password as Tt, checkbox as Ce, number as ze } from "@inquirer/prompts";
|
|
13
|
+
import y from "ora";
|
|
14
|
+
import x from "fs-extra";
|
|
15
15
|
import { select as ae } from "inquirer-select-pro";
|
|
16
|
-
import
|
|
16
|
+
import Et from "lint-staged";
|
|
17
17
|
import Ct from "semver";
|
|
18
18
|
import { run as Rt } from "npm-check-updates";
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
const Ge = "dev",
|
|
22
|
-
var b = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST =
|
|
19
|
+
import xt from "p-limit";
|
|
20
|
+
import It from "minimist";
|
|
21
|
+
const Ge = "dev", We = "test", Ve = "release", Dt = "production", Lt = "master";
|
|
22
|
+
var b = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = We] = "TEST", e[e.RELEASE = Ve] = "RELEASE", e[e.PROD = Dt] = "PROD", e))(b || {}), $ = /* @__PURE__ */ ((e) => (e[e.DEV = Ge] = "DEV", e[e.TEST = We] = "TEST", e[e.RELEASE = Ve] = "RELEASE", e[e.MASTER = Lt] = "MASTER", e))($ || {}), G = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(G || {});
|
|
23
23
|
const qe = [
|
|
24
24
|
{
|
|
25
25
|
name: `开发环境 - ${b.DEV}`,
|
|
@@ -37,7 +37,7 @@ const qe = [
|
|
|
37
37
|
name: `正式环境 - ${b.PROD}`,
|
|
38
38
|
value: b.PROD
|
|
39
39
|
}
|
|
40
|
-
],
|
|
40
|
+
], Ot = [
|
|
41
41
|
{
|
|
42
42
|
name: "网页 - h5",
|
|
43
43
|
value: "h5"
|
|
@@ -54,8 +54,8 @@ const qe = [
|
|
|
54
54
|
/* SERVER */
|
|
55
55
|
}
|
|
56
56
|
];
|
|
57
|
-
var de = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(de || {}), oe = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(oe || {}),
|
|
58
|
-
const
|
|
57
|
+
var de = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e))(de || {}), oe = /* @__PURE__ */ ((e) => (e.FRONT_END = "fe", e.BACK_END = "be", e.QUALITY_ASSURANCE = "qa", e))(oe || {}), w = /* @__PURE__ */ ((e) => (e.JAVA = "Java", e.JAVASCRIPT = "JavaScript", e.PYTHON = "Python", e.MARKDOWN = "Markdown", e))(w || {});
|
|
58
|
+
const Pt = {
|
|
59
59
|
1: "研发",
|
|
60
60
|
2: "测试",
|
|
61
61
|
3: "产品",
|
|
@@ -67,7 +67,7 @@ const Ot = {
|
|
|
67
67
|
9: "其他"
|
|
68
68
|
}, fe = "http://git.cxlqd.com", Mt = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
69
69
|
var j = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(j || {});
|
|
70
|
-
const zt = "fe-biz7tvsd",
|
|
70
|
+
const zt = "fe-biz7tvsd", Ke = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
71
71
|
var R = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(R || {});
|
|
72
72
|
const Bt = [
|
|
73
73
|
{
|
|
@@ -80,21 +80,21 @@ const Bt = [
|
|
|
80
80
|
value: "case"
|
|
81
81
|
/* CASE */
|
|
82
82
|
}
|
|
83
|
-
], Jt = ".z", Ft = "develop-config.json",
|
|
83
|
+
], Jt = ".z", Ft = "develop-config.json", Z = ".z", _t = ".commit-msg-tpl", Ut = "project.json";
|
|
84
84
|
function C(e = "") {
|
|
85
|
-
return
|
|
85
|
+
return p.join(Z, e);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function He() {
|
|
88
88
|
return C(Ut);
|
|
89
89
|
}
|
|
90
90
|
function Ne() {
|
|
91
91
|
return C(_t);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function Ze() {
|
|
94
94
|
Me.spawnSync("git", ["config", "core.hooksPath", C()]), Me.spawnSync("git", ["config", "commit.template", Ne()]);
|
|
95
95
|
}
|
|
96
96
|
function he(e = "") {
|
|
97
|
-
return
|
|
97
|
+
return p.resolve(kt.homedir(), Jt, e);
|
|
98
98
|
}
|
|
99
99
|
function be() {
|
|
100
100
|
return he(Ft);
|
|
@@ -116,11 +116,11 @@ function $e(e) {
|
|
|
116
116
|
}
|
|
117
117
|
return encodeURIComponent(t.replace(/\.git$/, ""));
|
|
118
118
|
}
|
|
119
|
-
const { red: Be, green:
|
|
119
|
+
const { red: Be, green: Wt, blue: An, magenta: Vt, yellow: jn } = S;
|
|
120
120
|
function ye(...e) {
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
console.log(
|
|
122
|
+
function W(...e) {
|
|
123
|
+
console.log(Wt(...e));
|
|
124
124
|
}
|
|
125
125
|
function Xe(e) {
|
|
126
126
|
e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(S.cyan(" 👋 下次见~")), console.log(), process.exit(1));
|
|
@@ -128,21 +128,21 @@ function Xe(e) {
|
|
|
128
128
|
function l(e, t = !1) {
|
|
129
129
|
Xe(e);
|
|
130
130
|
let i = e;
|
|
131
|
-
e instanceof Error ? (i = e.message, ce.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(Be(i)), console.log(
|
|
131
|
+
e instanceof Error ? (i = e.message, ce.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(Be(i)), console.log(Vt(e.stack))) : console.log(Be(e)), t || process.exit(1);
|
|
132
132
|
}
|
|
133
133
|
function Je(e) {
|
|
134
134
|
return v(e) ? Nt(e).isDirectory() : !1;
|
|
135
135
|
}
|
|
136
136
|
function Qe(e = process.cwd()) {
|
|
137
|
-
return Je(e) ? vt(e).filter((i) => Je(
|
|
137
|
+
return Je(e) ? vt(e).filter((i) => Je(p.resolve(e, i))) : [];
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
139
|
+
async function m(e, t = {
|
|
140
140
|
removeTailLinkBreak: !0,
|
|
141
141
|
silent: !0
|
|
142
142
|
}) {
|
|
143
143
|
let i = await new Promise((n, a) => {
|
|
144
144
|
try {
|
|
145
|
-
const s =
|
|
145
|
+
const s = O.exec(e, {
|
|
146
146
|
silent: t.silent
|
|
147
147
|
});
|
|
148
148
|
n(s);
|
|
@@ -170,16 +170,16 @@ function ne() {
|
|
|
170
170
|
v(C()) || l("当前不在项目根目录。请切换到项目根目录");
|
|
171
171
|
}
|
|
172
172
|
function Q() {
|
|
173
|
-
v(
|
|
173
|
+
v(p.resolve(".git")) || l("当前不是git项目根目录,请先执行git init,或切换到根目录");
|
|
174
174
|
}
|
|
175
|
-
async function
|
|
176
|
-
await
|
|
175
|
+
async function me() {
|
|
176
|
+
await m("git status -s") !== "" && l("请先提交代码变动,再进行操作");
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return e ===
|
|
178
|
+
function Kt(e) {
|
|
179
|
+
return e === $.MASTER ? b.PROD : e;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
182
|
-
return e === b.PROD ?
|
|
181
|
+
function Ht(e) {
|
|
182
|
+
return e === b.PROD ? $.MASTER : e;
|
|
183
183
|
}
|
|
184
184
|
async function z(e, ...t) {
|
|
185
185
|
try {
|
|
@@ -188,7 +188,7 @@ async function z(e, ...t) {
|
|
|
188
188
|
throw Xe(i), i;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
async function
|
|
191
|
+
async function Zt(e) {
|
|
192
192
|
return (await Re(e)).length === 0;
|
|
193
193
|
}
|
|
194
194
|
function Yt(e = "项目中文名", t = "项目描述") {
|
|
@@ -249,19 +249,24 @@ ${t}
|
|
|
249
249
|
`;
|
|
250
250
|
}
|
|
251
251
|
const Xt = {
|
|
252
|
-
[
|
|
252
|
+
[w.JAVA]: {
|
|
253
253
|
"**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml"
|
|
254
254
|
},
|
|
255
|
-
[
|
|
255
|
+
[w.JAVASCRIPT]: {
|
|
256
256
|
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
257
257
|
"*": "prettier -wu"
|
|
258
258
|
},
|
|
259
|
-
[
|
|
259
|
+
[w.PYTHON]: {
|
|
260
260
|
// TODO: 需要优化
|
|
261
261
|
// "**/*.{py}": "python --fix",
|
|
262
262
|
"**/*.{py}": "echo 'todo'"
|
|
263
|
+
},
|
|
264
|
+
[w.MARKDOWN]: {
|
|
265
|
+
"*": "prettier -wu",
|
|
266
|
+
"**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
267
|
+
"**/*.md": "markdownlint --fix"
|
|
263
268
|
}
|
|
264
|
-
}, Qt = "cli-z-develop", ei = "0.
|
|
269
|
+
}, Qt = "cli-z-develop", ei = "0.13.0", ti = "技术团队开发流程管理工具", ii = "dist/index.js", ai = { z: "bin/z.js", "z-develop": "bin/z.js" }, ni = { prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'", dev: "vite build --watch", "dev:debug": "DEBUG=true vite build --watch", build: "vite build", eslint: "eslint '**/*.{ts,js}' --fix", prettier: "prettier -wu .", upload: "npm run build && npm publish --access public --registry https://registry.npmjs.org/", "upload:patch": "npm version patch && npm run upload", "upload:minor": "npm version minor && npm run upload", "upload:major": "npm version major && npm run upload" }, si = "module", ri = "z", oi = { "@lonely9/eslint-config-team": "^1.3.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" }, ci = { "@inquirer/prompts": "^8.4.1", axios: "^1.15.0", chalk: "^5.6.2", commander: "^14.0.3", dayjs: "^1.11.20", "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", semver: "^7.7.4", shelljs: "^0.10.0" }, ie = {
|
|
265
270
|
name: Qt,
|
|
266
271
|
version: ei,
|
|
267
272
|
description: ti,
|
|
@@ -272,7 +277,7 @@ const Xt = {
|
|
|
272
277
|
author: ri,
|
|
273
278
|
devDependencies: oi,
|
|
274
279
|
dependencies: ci
|
|
275
|
-
},
|
|
280
|
+
}, I = {
|
|
276
281
|
// 个人数据
|
|
277
282
|
profile: {
|
|
278
283
|
ldapAccount: "",
|
|
@@ -306,65 +311,65 @@ const Xt = {
|
|
|
306
311
|
FECDNDomain: ""
|
|
307
312
|
}
|
|
308
313
|
};
|
|
309
|
-
function
|
|
310
|
-
return e ?
|
|
314
|
+
function E(e) {
|
|
315
|
+
return e ? I.profile[e] : I.profile;
|
|
311
316
|
}
|
|
312
317
|
function ge(e) {
|
|
313
|
-
return e ?
|
|
318
|
+
return e ? I.main[e] : I.main;
|
|
314
319
|
}
|
|
315
320
|
function q(e) {
|
|
316
|
-
return e ?
|
|
321
|
+
return e ? I.constants[e] : I.constants;
|
|
317
322
|
}
|
|
318
323
|
let _ = null, U = null;
|
|
319
324
|
function Ae() {
|
|
320
325
|
if (_)
|
|
321
326
|
return _;
|
|
322
|
-
const e =
|
|
323
|
-
return v(e) || l(`当前目录(${
|
|
327
|
+
const e = p.join("package.json");
|
|
328
|
+
return v(e) || l(`当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), _ = x.readJsonSync(e), _;
|
|
324
329
|
}
|
|
325
|
-
function
|
|
330
|
+
function pe() {
|
|
326
331
|
if (U)
|
|
327
332
|
return U;
|
|
328
|
-
const e =
|
|
333
|
+
const e = He();
|
|
329
334
|
return v(e) || l(
|
|
330
|
-
`当前目录(${
|
|
331
|
-
), U =
|
|
335
|
+
`当前目录(${O.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
336
|
+
), U = x.readJsonSync(e), U;
|
|
332
337
|
}
|
|
333
338
|
function ui(e) {
|
|
334
339
|
U ? U = {
|
|
335
340
|
...U,
|
|
336
341
|
...e
|
|
337
|
-
} : U = e,
|
|
342
|
+
} : U = e, x.writeJSONSync(He(), U, { spaces: 2 });
|
|
338
343
|
}
|
|
339
344
|
function li(e) {
|
|
340
345
|
_ ? _ = {
|
|
341
346
|
..._,
|
|
342
347
|
...e
|
|
343
|
-
} : _ = e,
|
|
348
|
+
} : _ = e, x.writeJSONSync(p.join("package.json"), _, { spaces: 2 });
|
|
344
349
|
}
|
|
345
|
-
const
|
|
350
|
+
const H = {
|
|
346
351
|
id: 0,
|
|
347
352
|
path: "",
|
|
348
353
|
group: "",
|
|
349
354
|
sourceBranch: "",
|
|
350
355
|
mergeRequestUrl: ""
|
|
351
356
|
};
|
|
352
|
-
async function
|
|
353
|
-
if (!
|
|
357
|
+
async function mi() {
|
|
358
|
+
if (!H.id)
|
|
354
359
|
try {
|
|
355
|
-
const e =
|
|
356
|
-
|
|
360
|
+
const e = pe(), t = $e(e.repository.url), i = await nt(t);
|
|
361
|
+
H.id = i.id, H.path = t, H.group = i.namespace.full_path, H.mergeRequestUrl = `${i.web_url}/merge_requests`;
|
|
357
362
|
} catch (e) {
|
|
358
363
|
l(e);
|
|
359
364
|
}
|
|
360
|
-
return
|
|
365
|
+
return H.sourceBranch || (H.sourceBranch = await m("git branch --show-current")), H;
|
|
361
366
|
}
|
|
362
367
|
function se() {
|
|
363
|
-
|
|
368
|
+
x.writeJSONSync(
|
|
364
369
|
be(),
|
|
365
370
|
{
|
|
366
371
|
main: ge(),
|
|
367
|
-
profile:
|
|
372
|
+
profile: E(),
|
|
368
373
|
constants: q()
|
|
369
374
|
},
|
|
370
375
|
{
|
|
@@ -373,20 +378,20 @@ function se() {
|
|
|
373
378
|
);
|
|
374
379
|
}
|
|
375
380
|
function M(e, t) {
|
|
376
|
-
t !== void 0 ?
|
|
377
|
-
...
|
|
381
|
+
t !== void 0 ? I.profile[e] = t : I.profile = {
|
|
382
|
+
...I.profile,
|
|
378
383
|
...e
|
|
379
384
|
};
|
|
380
385
|
}
|
|
381
|
-
function
|
|
382
|
-
|
|
383
|
-
...
|
|
386
|
+
function xe(e, t) {
|
|
387
|
+
I.constants = {
|
|
388
|
+
...I.constants,
|
|
384
389
|
...e
|
|
385
390
|
};
|
|
386
391
|
}
|
|
387
392
|
function ue(e, t) {
|
|
388
|
-
t !== void 0 ?
|
|
389
|
-
...
|
|
393
|
+
t !== void 0 ? I.main[e] = t : I.main = {
|
|
394
|
+
...I.main,
|
|
390
395
|
...e
|
|
391
396
|
};
|
|
392
397
|
}
|
|
@@ -407,8 +412,8 @@ async function Y(e) {
|
|
|
407
412
|
return s instanceof jt && ye(S.red("Error"), S.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
|
|
408
413
|
}
|
|
409
414
|
}
|
|
410
|
-
async function
|
|
411
|
-
const e =
|
|
415
|
+
async function pi() {
|
|
416
|
+
const e = E("gitToken");
|
|
412
417
|
if (e)
|
|
413
418
|
return e;
|
|
414
419
|
{
|
|
@@ -417,8 +422,8 @@ async function mi() {
|
|
|
417
422
|
method: "post",
|
|
418
423
|
data: {
|
|
419
424
|
grant_type: "password",
|
|
420
|
-
username:
|
|
421
|
-
password:
|
|
425
|
+
username: E("ldapAccount"),
|
|
426
|
+
password: E("ldapPassword")
|
|
422
427
|
}
|
|
423
428
|
}), i = `Bearer ${t}`;
|
|
424
429
|
return M("gitToken", i), se(), i;
|
|
@@ -428,12 +433,12 @@ async function N(e) {
|
|
|
428
433
|
return Y({
|
|
429
434
|
...e,
|
|
430
435
|
headers: {
|
|
431
|
-
Authorization: await
|
|
436
|
+
Authorization: await pi()
|
|
432
437
|
}
|
|
433
438
|
});
|
|
434
439
|
}
|
|
435
440
|
async function di() {
|
|
436
|
-
const e =
|
|
441
|
+
const e = E("zenTaoToken");
|
|
437
442
|
if (e)
|
|
438
443
|
return e;
|
|
439
444
|
{
|
|
@@ -441,8 +446,8 @@ async function di() {
|
|
|
441
446
|
url: `${q("ZenTaoDomain")}/api.php/v1/tokens`,
|
|
442
447
|
method: "post",
|
|
443
448
|
data: {
|
|
444
|
-
account:
|
|
445
|
-
password:
|
|
449
|
+
account: E("ldapAccount"),
|
|
450
|
+
password: E("ldapPassword")
|
|
446
451
|
}
|
|
447
452
|
});
|
|
448
453
|
return M("zenTaoToken", t), se(), t;
|
|
@@ -476,7 +481,7 @@ async function ve(e) {
|
|
|
476
481
|
}
|
|
477
482
|
}
|
|
478
483
|
async function fi() {
|
|
479
|
-
const e =
|
|
484
|
+
const e = E("k8sToken");
|
|
480
485
|
if (e)
|
|
481
486
|
return e;
|
|
482
487
|
{
|
|
@@ -487,8 +492,8 @@ async function fi() {
|
|
|
487
492
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
488
493
|
},
|
|
489
494
|
data: {
|
|
490
|
-
username:
|
|
491
|
-
password:
|
|
495
|
+
username: E("ldapAccount"),
|
|
496
|
+
password: E("ldapPassword")
|
|
492
497
|
}
|
|
493
498
|
}), i = `Bearer ${t}`;
|
|
494
499
|
return M("k8sToken", i), se(), i;
|
|
@@ -578,17 +583,17 @@ function Si() {
|
|
|
578
583
|
url: J("src/data/project-group-chats.json")
|
|
579
584
|
});
|
|
580
585
|
}
|
|
581
|
-
function
|
|
586
|
+
function ki() {
|
|
582
587
|
return N({
|
|
583
588
|
url: `${B()}/user`
|
|
584
589
|
});
|
|
585
590
|
}
|
|
586
|
-
function
|
|
591
|
+
function Ti() {
|
|
587
592
|
return N({
|
|
588
593
|
url: `${B()}/groups`
|
|
589
594
|
});
|
|
590
595
|
}
|
|
591
|
-
function
|
|
596
|
+
function Ei(e) {
|
|
592
597
|
return N({
|
|
593
598
|
url: `${B()}/projects`,
|
|
594
599
|
method: "post",
|
|
@@ -616,13 +621,13 @@ function Ri(e) {
|
|
|
616
621
|
data: e
|
|
617
622
|
});
|
|
618
623
|
}
|
|
619
|
-
function
|
|
624
|
+
function xi(e) {
|
|
620
625
|
return N({
|
|
621
626
|
url: `${B()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
622
627
|
method: "put"
|
|
623
628
|
});
|
|
624
629
|
}
|
|
625
|
-
function
|
|
630
|
+
function Ii(e) {
|
|
626
631
|
return N({
|
|
627
632
|
url: `${B()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
628
633
|
method: "put",
|
|
@@ -642,17 +647,17 @@ function Li(e) {
|
|
|
642
647
|
data: e
|
|
643
648
|
});
|
|
644
649
|
}
|
|
645
|
-
function
|
|
650
|
+
function Oi(e) {
|
|
646
651
|
return N({
|
|
647
652
|
url: `${B()}/projects/${e}/repository/branches`
|
|
648
653
|
});
|
|
649
654
|
}
|
|
650
|
-
function
|
|
655
|
+
function Pi() {
|
|
651
656
|
const e = he("fe-groups.json");
|
|
652
|
-
return v(e) ?
|
|
657
|
+
return v(e) ? x.readJSONSync(e) : { groups: [] };
|
|
653
658
|
}
|
|
654
659
|
async function Mi() {
|
|
655
|
-
const e = await
|
|
660
|
+
const e = await Ti(), t = Mt.map((i) => {
|
|
656
661
|
const n = e.find((a) => a.name === i);
|
|
657
662
|
return n ? {
|
|
658
663
|
name: n.name,
|
|
@@ -660,7 +665,7 @@ async function Mi() {
|
|
|
660
665
|
description: n.description
|
|
661
666
|
} : !1;
|
|
662
667
|
}).filter((i) => !!i);
|
|
663
|
-
|
|
668
|
+
x.writeJSONSync(he("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
664
669
|
}
|
|
665
670
|
async function A(e) {
|
|
666
671
|
const t = `${q("FEServerDomain")}/api`, { data: i } = await Y({
|
|
@@ -731,13 +736,13 @@ function Gi(e) {
|
|
|
731
736
|
data: e
|
|
732
737
|
});
|
|
733
738
|
}
|
|
734
|
-
function
|
|
739
|
+
function Wi(e) {
|
|
735
740
|
return A({
|
|
736
741
|
url: "/zen/testcase/step/create",
|
|
737
742
|
data: e
|
|
738
743
|
});
|
|
739
744
|
}
|
|
740
|
-
function
|
|
745
|
+
function Vi(e) {
|
|
741
746
|
return A({
|
|
742
747
|
url: "/zen/testcase/modules/remove",
|
|
743
748
|
data: e
|
|
@@ -749,19 +754,19 @@ function qi(e) {
|
|
|
749
754
|
data: e
|
|
750
755
|
});
|
|
751
756
|
}
|
|
752
|
-
function
|
|
757
|
+
function Ki(e) {
|
|
753
758
|
return A({
|
|
754
759
|
url: "/zen/testcase/module/update/name",
|
|
755
760
|
data: e
|
|
756
761
|
});
|
|
757
762
|
}
|
|
758
|
-
function
|
|
763
|
+
function Hi(e) {
|
|
759
764
|
return A({
|
|
760
765
|
url: "/zen/testcase/case/update/name",
|
|
761
766
|
data: e
|
|
762
767
|
});
|
|
763
768
|
}
|
|
764
|
-
function
|
|
769
|
+
function Zi(e) {
|
|
765
770
|
return A({
|
|
766
771
|
url: "/zen/testcase/case/update/priority",
|
|
767
772
|
data: e
|
|
@@ -824,7 +829,7 @@ function aa(e, t) {
|
|
|
824
829
|
}
|
|
825
830
|
async function rt() {
|
|
826
831
|
const t = (await zi()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
827
|
-
name: `${s.nick} - ${
|
|
832
|
+
name: `${s.nick} - ${Pt[s.title]}`,
|
|
828
833
|
value: s.weWorkUserId
|
|
829
834
|
})), i = ge("weWorkListCache"), n = i.map((s) => s.value), a = [];
|
|
830
835
|
return t.forEach((s) => {
|
|
@@ -868,8 +873,8 @@ async function sa() {
|
|
|
868
873
|
try {
|
|
869
874
|
Ye() && (await Ue({
|
|
870
875
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
871
|
-
}) ?
|
|
872
|
-
const t = await
|
|
876
|
+
}) ? O.rm("-rf", be()) : process.exit(0)), await le(he(), { recursive: !0 });
|
|
877
|
+
const t = await k({
|
|
873
878
|
message: "请选择岗位类型",
|
|
874
879
|
choices: [
|
|
875
880
|
{
|
|
@@ -890,13 +895,13 @@ async function sa() {
|
|
|
890
895
|
message: "请输入LDAP账号:"
|
|
891
896
|
});
|
|
892
897
|
i = i.trim();
|
|
893
|
-
let n = await
|
|
898
|
+
let n = await Tt({
|
|
894
899
|
message: "请输入LDAP密码:",
|
|
895
900
|
mask: !0
|
|
896
901
|
});
|
|
897
902
|
n = n.trim(), M("jobType", t), M("ldapAccount", i), M("ldapPassword", n);
|
|
898
903
|
const a = await at();
|
|
899
|
-
|
|
904
|
+
xe(a);
|
|
900
905
|
const s = await rt(), o = await ot("请选择你自己(用于企微通知):", (u) => u.length > 1 ? "只能选一个" : u.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((u) => u.value === o[0]);
|
|
901
906
|
M({
|
|
902
907
|
weWorkName: r,
|
|
@@ -905,15 +910,15 @@ async function sa() {
|
|
|
905
910
|
} catch (t) {
|
|
906
911
|
l(t);
|
|
907
912
|
}
|
|
908
|
-
const e =
|
|
913
|
+
const e = y("配置信息初始化中").start();
|
|
909
914
|
try {
|
|
910
|
-
const t = await
|
|
915
|
+
const t = await ki();
|
|
911
916
|
M({
|
|
912
917
|
gitUserId: t.id,
|
|
913
918
|
gitName: t.name,
|
|
914
919
|
gitEnglishName: t.username,
|
|
915
920
|
gitEmail: t.email
|
|
916
|
-
}), ue("latestCheckVersionTimestamp", Date.now()), se(),
|
|
921
|
+
}), ue("latestCheckVersionTimestamp", Date.now()), se(), E("jobType") === oe.FRONT_END && await Mi(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
917
922
|
} catch (t) {
|
|
918
923
|
e.fail("配置信息初始化失败"), ce.isAxiosError(t) && l("请检查你的域名及令牌配置"), l(t);
|
|
919
924
|
}
|
|
@@ -923,41 +928,45 @@ async function ra() {
|
|
|
923
928
|
`, { mode: 493 }), await L(C("commit-msg"), `#!/usr/bin/env sh
|
|
924
929
|
z run commit-msg`, { mode: 493 }), await L(C("pre-commit"), `#!/usr/bin/env sh
|
|
925
930
|
z run commit-files`, { mode: 493 });
|
|
926
|
-
const { language: e } =
|
|
927
|
-
if (e
|
|
931
|
+
const { language: e } = pe();
|
|
932
|
+
if ([w.JAVASCRIPT, w.MARKDOWN].includes(e) && (await L(
|
|
928
933
|
C(".prettierrc.json"),
|
|
929
934
|
`${JSON.stringify(await Ni(), null, 2)}
|
|
930
935
|
`,
|
|
931
936
|
{
|
|
932
937
|
mode: 493
|
|
933
938
|
}
|
|
934
|
-
), await L(C(".prettierignore"), await vi(), { mode: 493 }), await L(C("tsconfig.node.json"), await $i(), { mode: 493 }), await L(C("tsconfig.browser.json"), await yi(), { mode: 493 })), e ===
|
|
939
|
+
), await L(C(".prettierignore"), await vi(), { mode: 493 }), await L(C("tsconfig.node.json"), await $i(), { mode: 493 }), await L(C("tsconfig.browser.json"), await yi(), { mode: 493 })), e === w.JAVA) {
|
|
935
940
|
await gi(`${q("FECDNDomain")}/file/vgnlfbfHRF.jar`, C("checkstyle.jar")), await L(C("checkstyle.xml"), await ji(), { mode: 493 });
|
|
936
|
-
const t =
|
|
941
|
+
const t = p.join("package.json");
|
|
937
942
|
v(t) || await L(t, JSON.stringify({ version: "0.0.1" }, null, 2), {
|
|
938
943
|
mode: 493
|
|
939
944
|
});
|
|
940
945
|
}
|
|
941
|
-
|
|
946
|
+
Ze();
|
|
942
947
|
}
|
|
943
948
|
async function oa(e, t) {
|
|
944
|
-
const i = await
|
|
949
|
+
const i = await m("git remote get-url --push origin");
|
|
945
950
|
i || l("获取项目远程git地址失败,请配置后重试");
|
|
946
951
|
let n = e;
|
|
947
|
-
n || (n = await
|
|
952
|
+
n || (n = await k({
|
|
948
953
|
message: "请选择项目语言",
|
|
949
954
|
choices: [
|
|
950
955
|
{
|
|
951
|
-
name:
|
|
952
|
-
value:
|
|
956
|
+
name: w.JAVASCRIPT,
|
|
957
|
+
value: w.JAVASCRIPT
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
name: w.JAVA,
|
|
961
|
+
value: w.JAVA
|
|
953
962
|
},
|
|
954
963
|
{
|
|
955
|
-
name:
|
|
956
|
-
value:
|
|
964
|
+
name: w.PYTHON,
|
|
965
|
+
value: w.PYTHON
|
|
957
966
|
},
|
|
958
967
|
{
|
|
959
|
-
name:
|
|
960
|
-
value:
|
|
968
|
+
name: w.MARKDOWN,
|
|
969
|
+
value: w.MARKDOWN
|
|
961
970
|
}
|
|
962
971
|
]
|
|
963
972
|
}));
|
|
@@ -977,20 +986,20 @@ async function oa(e, t) {
|
|
|
977
986
|
}
|
|
978
987
|
});
|
|
979
988
|
}
|
|
980
|
-
async function
|
|
981
|
-
e ?
|
|
982
|
-
message: `当前项目中已存在配置文件夹${
|
|
983
|
-
}) ?
|
|
984
|
-
const i =
|
|
989
|
+
async function Ie(e, t) {
|
|
990
|
+
e ? O.rm("-rf", Z) : v(C()) && (await Ue({
|
|
991
|
+
message: `当前项目中已存在配置文件夹${Z},确认重新配置?`
|
|
992
|
+
}) ? O.rm("-rf", Z) : process.exit(0)), await le(C(), { recursive: !0 }), await oa(e, t);
|
|
993
|
+
const i = y("项目初始化中...").start();
|
|
985
994
|
await ra(), i.succeed("项目初始化完成");
|
|
986
995
|
}
|
|
987
996
|
async function ca() {
|
|
988
|
-
v(C()) && v(Ne()) ?
|
|
997
|
+
v(C()) && v(Ne()) ? Ze() : await Ie(), process.exit(0);
|
|
989
998
|
}
|
|
990
999
|
async function ua(e, t) {
|
|
991
|
-
t.projectLanguage && !Object.values(
|
|
1000
|
+
t.projectLanguage && !Object.values(w).includes(t.projectLanguage) && l("项目语言不支持"), e ? (Q(), e === "." ? (await Ie(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await ca() : l("参数错误。执行 z init -h 查看帮助。")) : await sa();
|
|
992
1001
|
}
|
|
993
|
-
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(
|
|
1002
|
+
D.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(w).join("/")} `).action((...e) => z(ua, ...e));
|
|
994
1003
|
async function la(e, t) {
|
|
995
1004
|
if (!e)
|
|
996
1005
|
return "不能为空";
|
|
@@ -1001,16 +1010,16 @@ async function la(e, t) {
|
|
|
1001
1010
|
const a = (await Ci(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
|
|
1002
1011
|
return a ? `远程仓库中已存在同名项目(${a.http_url_to_repo}),请更名后重试` : !0;
|
|
1003
1012
|
}
|
|
1004
|
-
function
|
|
1013
|
+
function ma(e) {
|
|
1005
1014
|
return e ? !0 : "不能为空";
|
|
1006
1015
|
}
|
|
1007
|
-
function
|
|
1016
|
+
function pa(e) {
|
|
1008
1017
|
return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
|
|
1009
1018
|
}
|
|
1010
1019
|
async function da(e) {
|
|
1011
|
-
ne(), Q(), await
|
|
1020
|
+
ne(), Q(), await me();
|
|
1012
1021
|
let t, i;
|
|
1013
|
-
e.branchType ? t = e.branchType : t = await
|
|
1022
|
+
e.branchType ? t = e.branchType : t = await k({
|
|
1014
1023
|
message: "请选择创建分支的类型",
|
|
1015
1024
|
choices: [
|
|
1016
1025
|
{
|
|
@@ -1028,10 +1037,10 @@ async function da(e) {
|
|
|
1028
1037
|
]
|
|
1029
1038
|
}), e.branchPurpose ? i = e.branchPurpose : (i = await F({
|
|
1030
1039
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1031
|
-
validate:
|
|
1040
|
+
validate: pa
|
|
1032
1041
|
}), i = i.trim());
|
|
1033
1042
|
const n = `${t}_${i}_${tt()}`;
|
|
1034
|
-
await
|
|
1043
|
+
await m(`git fetch origin ${$.MASTER}`), await m(`git checkout -b ${n} origin/${$.MASTER}`), await m(`git push -u origin ${n}`), process.exit(0);
|
|
1035
1044
|
}
|
|
1036
1045
|
const ct = (e) => `${q("ZenTaoDomain")}${e}`;
|
|
1037
1046
|
async function fa() {
|
|
@@ -1061,7 +1070,7 @@ async function ga() {
|
|
|
1061
1070
|
})) : [];
|
|
1062
1071
|
}
|
|
1063
1072
|
async function Fe(e) {
|
|
1064
|
-
const t = await
|
|
1073
|
+
const t = await m("git diff HEAD");
|
|
1065
1074
|
t || l("git暂存区没有内容,请先git add添加文件到暂存区");
|
|
1066
1075
|
const i = await ia({
|
|
1067
1076
|
type: "commit-message-v2",
|
|
@@ -1070,8 +1079,8 @@ async function Fe(e) {
|
|
|
1070
1079
|
});
|
|
1071
1080
|
return e + i;
|
|
1072
1081
|
}
|
|
1073
|
-
async function
|
|
1074
|
-
const n =
|
|
1082
|
+
async function Te(e, t, i) {
|
|
1083
|
+
const n = y("🤖 生成提交信息中...").start();
|
|
1075
1084
|
let a = "", s = !0;
|
|
1076
1085
|
if ([j.FEAT, j.FIX, j.REFACTOR].includes(e)) {
|
|
1077
1086
|
const o = t.map((r) => r.value).join(",");
|
|
@@ -1083,7 +1092,7 @@ async function Ee(e, t, i) {
|
|
|
1083
1092
|
e === j.CHORE && (t ? a = `${e}: ${t}` : a = await Fe(`${e}: `)), await L(Ne(), a, "utf-8"), s || i ? n.succeed("提交信息已生成(↓),可以进行提交了!") : n.warn("AI生成提交信息失败,已使用默认模板(↓),可以进行提交了!"), console.log(S.yellow(a));
|
|
1084
1093
|
}
|
|
1085
1094
|
async function ha(e) {
|
|
1086
|
-
const t = await
|
|
1095
|
+
const t = await k({
|
|
1087
1096
|
message: "请选择你要创建的模板类型",
|
|
1088
1097
|
choices: [
|
|
1089
1098
|
{
|
|
@@ -1107,7 +1116,7 @@ async function ha(e) {
|
|
|
1107
1116
|
if ([j.FEAT, j.REFACTOR].includes(t)) {
|
|
1108
1117
|
const i = await fa();
|
|
1109
1118
|
if (!i.length)
|
|
1110
|
-
return
|
|
1119
|
+
return W("🤷 暂无开发任务");
|
|
1111
1120
|
const n = await Ce({
|
|
1112
1121
|
message: "请关联开发任务(可多选):",
|
|
1113
1122
|
validate: (a) => a.length === 0 ? "请选择项" : !0,
|
|
@@ -1117,12 +1126,12 @@ async function ha(e) {
|
|
|
1117
1126
|
})),
|
|
1118
1127
|
pageSize: i.length
|
|
1119
1128
|
});
|
|
1120
|
-
await
|
|
1129
|
+
await Te(j.FEAT, n, e);
|
|
1121
1130
|
}
|
|
1122
1131
|
if (t === j.FIX) {
|
|
1123
1132
|
const i = await ga();
|
|
1124
1133
|
if (!i.length)
|
|
1125
|
-
return
|
|
1134
|
+
return W("🤷 暂无BUG");
|
|
1126
1135
|
const n = await Ce({
|
|
1127
1136
|
message: "请关联Bug(可多选):",
|
|
1128
1137
|
validate: (a) => a.length === 0 ? "请选择项" : !0,
|
|
@@ -1132,57 +1141,57 @@ async function ha(e) {
|
|
|
1132
1141
|
})),
|
|
1133
1142
|
pageSize: i.length
|
|
1134
1143
|
});
|
|
1135
|
-
await
|
|
1144
|
+
await Te(j.FIX, n, e);
|
|
1136
1145
|
}
|
|
1137
1146
|
if (t === j.CHORE) {
|
|
1138
1147
|
let i = "";
|
|
1139
1148
|
e && (i = await F({
|
|
1140
1149
|
message: "请输入commit msg:",
|
|
1141
1150
|
validate: (n) => n.length === 0 ? "请输入commit msg" : !0
|
|
1142
|
-
}), i = i.trim()), await
|
|
1151
|
+
}), i = i.trim()), await Te(j.CHORE, i);
|
|
1143
1152
|
}
|
|
1144
1153
|
process.exit(0);
|
|
1145
1154
|
}
|
|
1146
1155
|
async function wa() {
|
|
1147
1156
|
try {
|
|
1148
1157
|
const e = {}, t = async () => {
|
|
1149
|
-
const
|
|
1150
|
-
const
|
|
1158
|
+
const P = Qe(), { projects: te } = await hi(), K = te.map((re) => {
|
|
1159
|
+
const Pe = {
|
|
1151
1160
|
name: `${re.name} [${re.desc}]`,
|
|
1152
1161
|
value: re.name,
|
|
1153
1162
|
disabled: !1
|
|
1154
1163
|
};
|
|
1155
|
-
return
|
|
1156
|
-
}), yt = await
|
|
1164
|
+
return P.includes(re.name) && (Pe.disabled = "目录下已存在同名文件夹"), Pe;
|
|
1165
|
+
}), yt = await k({
|
|
1157
1166
|
message: "请选择一个项目模板",
|
|
1158
|
-
choices:
|
|
1159
|
-
}),
|
|
1160
|
-
e.tplName =
|
|
1167
|
+
choices: K
|
|
1168
|
+
}), ke = te.find((re) => re.name === yt);
|
|
1169
|
+
e.tplName = ke.name, e.tplUrl = ke.url, e.tplLanguage = ke.language;
|
|
1161
1170
|
}, i = async () => {
|
|
1162
|
-
const { groups:
|
|
1171
|
+
const { groups: P } = Pi(), te = await k({
|
|
1163
1172
|
message: "请选择一个分组",
|
|
1164
|
-
choices:
|
|
1165
|
-
name: `${
|
|
1166
|
-
value:
|
|
1167
|
-
short:
|
|
1173
|
+
choices: P.map((K) => ({
|
|
1174
|
+
name: `${K.name} [${K.description}]`,
|
|
1175
|
+
value: K.id,
|
|
1176
|
+
short: K.name
|
|
1168
1177
|
}))
|
|
1169
1178
|
});
|
|
1170
1179
|
e.group = {
|
|
1171
1180
|
id: te,
|
|
1172
|
-
name:
|
|
1181
|
+
name: P.find((K) => K.id === te)?.name
|
|
1173
1182
|
};
|
|
1174
1183
|
}, n = async () => {
|
|
1175
1184
|
e.projectName = await F({
|
|
1176
1185
|
message: "请输入项目名称",
|
|
1177
|
-
validate: (
|
|
1186
|
+
validate: (P) => la(P, e.group?.name || "")
|
|
1178
1187
|
}), e.projectName = e.projectName.trim(), e.projectDesc = await F({
|
|
1179
1188
|
message: "请输入项目描述",
|
|
1180
|
-
validate:
|
|
1189
|
+
validate: ma
|
|
1181
1190
|
}), e.projectDesc = e.projectDesc.trim();
|
|
1182
1191
|
};
|
|
1183
1192
|
await t(), await i(), await n();
|
|
1184
|
-
const a = `${fe}/${e.group?.name}/${e.projectName}.git`, s =
|
|
1185
|
-
await
|
|
1193
|
+
const a = `${fe}/${e.group?.name}/${e.projectName}.git`, s = y("模版初始化中").start();
|
|
1194
|
+
await m(`git clone --depth=1 ${e.tplUrl}`), await _e(e.tplName, e.projectName), O.cd(e.projectName), O.rm("-rf", ".git"), await m(`git init --initial-branch=${$.MASTER}`), await m(`git remote add origin ${a}`), await m(`git config user.name ${E("gitName")}`), await m(`git config user.email ${E("gitEmail")}`);
|
|
1186
1195
|
const o = Ae();
|
|
1187
1196
|
li({
|
|
1188
1197
|
...o,
|
|
@@ -1192,31 +1201,31 @@ async function wa() {
|
|
|
1192
1201
|
...o.scripts,
|
|
1193
1202
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1194
1203
|
}
|
|
1195
|
-
}), await
|
|
1196
|
-
const r =
|
|
1197
|
-
await
|
|
1198
|
-
const c =
|
|
1199
|
-
await
|
|
1200
|
-
const u = await
|
|
1204
|
+
}), await x.writeFile(p.resolve("README.md"), Yt(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Ie(e.tplLanguage, e.group?.name);
|
|
1205
|
+
const r = y("依赖安装中").start();
|
|
1206
|
+
await m("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1207
|
+
const c = y("项目推送中").start();
|
|
1208
|
+
await m('git add . && git commit -m "chore: 项目初始化"'), await m("git tag v0.0.1");
|
|
1209
|
+
const u = await Ei({
|
|
1201
1210
|
name: e.projectName,
|
|
1202
1211
|
description: e.projectDesc,
|
|
1203
1212
|
path: e.projectName,
|
|
1204
1213
|
visibility: "private",
|
|
1205
1214
|
namespace_id: e.group?.id
|
|
1206
1215
|
});
|
|
1207
|
-
await
|
|
1208
|
-
const d =
|
|
1216
|
+
await m(`git push -u origin ${$.MASTER}`), await m(`git push origin HEAD:${$.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${S.blue(a)}`);
|
|
1217
|
+
const d = y("初始化分支中").start(), f = `feat_init_${tt()}`, g = [$.DEV, $.TEST, $.RELEASE, f], h = await Promise.allSettled(
|
|
1209
1218
|
g.map(
|
|
1210
|
-
(
|
|
1219
|
+
(P) => Li({
|
|
1211
1220
|
id: u.id,
|
|
1212
|
-
branch:
|
|
1213
|
-
ref:
|
|
1221
|
+
branch: P,
|
|
1222
|
+
ref: $.MASTER
|
|
1214
1223
|
})
|
|
1215
1224
|
)
|
|
1216
|
-
),
|
|
1217
|
-
h.forEach(({ status:
|
|
1218
|
-
|
|
1219
|
-
}), await
|
|
1225
|
+
), T = [];
|
|
1226
|
+
h.forEach(({ status: P }, te) => {
|
|
1227
|
+
P === "fulfilled" && T.push(g[te]);
|
|
1228
|
+
}), await m("git pull"), T.includes(f) ? (await m(`git checkout -b ${f} origin/${f}`), d.succeed(`项目已切换到初始分支: ${S.blue(f)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
|
|
1220
1229
|
const ee = `cd ${e.projectName} && z start`;
|
|
1221
1230
|
console.log(`输入 ${S.green(ee)} 开始开发吧~`), process.exit(0);
|
|
1222
1231
|
} catch (e) {
|
|
@@ -1237,7 +1246,7 @@ async function ya(e, t) {
|
|
|
1237
1246
|
"commit-msg",
|
|
1238
1247
|
"cm"
|
|
1239
1248
|
/* CommitMsgAbbr */
|
|
1240
|
-
].includes(e) ? i = "commit-msg" : l("参数输入错误") : i = await
|
|
1249
|
+
].includes(e) ? i = "commit-msg" : l("参数输入错误") : i = await k({
|
|
1241
1250
|
message: "请选择你要创建的类型",
|
|
1242
1251
|
choices: [
|
|
1243
1252
|
{
|
|
@@ -1256,7 +1265,7 @@ async function ya(e, t) {
|
|
|
1256
1265
|
/* Project */
|
|
1257
1266
|
}
|
|
1258
1267
|
]
|
|
1259
|
-
}), i === "project" ? await wa() : (ne(), Q(), i === "branch" ? (await
|
|
1268
|
+
}), i === "project" ? await wa() : (ne(), Q(), i === "branch" ? (await me(), await da(t)) : i === "commit-msg" && (await m("git status -s") ? await ha(t.commitMessageCloseAi) : l("没有要变动的文件,无法生成提交信息")));
|
|
1260
1269
|
}
|
|
1261
1270
|
D.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(de).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").option("--commit-message-close-ai", "创建提交信息时,是否关闭AI生成").action((...e) => z(ya, ...e));
|
|
1262
1271
|
function $a(e) {
|
|
@@ -1267,7 +1276,7 @@ function $a(e) {
|
|
|
1267
1276
|
});
|
|
1268
1277
|
}
|
|
1269
1278
|
async function va(e) {
|
|
1270
|
-
const t =
|
|
1279
|
+
const t = y("部署任务创建中").start(), { targetBranch: i, notify: n, projectName: a } = e, s = n ? [.../* @__PURE__ */ new Set([E("weWorkUserId"), ...n])] : [E("weWorkUserId")];
|
|
1271
1280
|
try {
|
|
1272
1281
|
const { metadata: o, spec: r } = await $a({
|
|
1273
1282
|
projectName: a,
|
|
@@ -1293,30 +1302,30 @@ async function va(e) {
|
|
|
1293
1302
|
}
|
|
1294
1303
|
function Na(e, t) {
|
|
1295
1304
|
const i = Ae();
|
|
1296
|
-
if (
|
|
1305
|
+
if (pe()?.repository?.url || l(".z/project.json中缺少repository.url"), t === G.H5) {
|
|
1297
1306
|
const a = `build:${e}`;
|
|
1298
1307
|
i?.scripts[a] || l(`项目package.json文件scripts不存在命令${a}。`);
|
|
1299
1308
|
}
|
|
1300
1309
|
t === G.NPM && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。")), t === G.SERVER && (i?.scripts.build || l("项目package.json文件scripts不存在命令build。"));
|
|
1301
1310
|
}
|
|
1302
1311
|
async function ut(e, t) {
|
|
1303
|
-
ne(), Q(), await
|
|
1312
|
+
ne(), Q(), await me();
|
|
1304
1313
|
let i = e, n = t.platform;
|
|
1305
|
-
const a =
|
|
1306
|
-
if (a.language ===
|
|
1314
|
+
const a = pe();
|
|
1315
|
+
if (a.language === w.JAVA && (n = G.SERVER), i && !Object.values($).includes(i) && l("仅支持发布指定环境分支"), n && !Object.values(G).includes(n) && l("发布平台错误"), n || (n = await k({
|
|
1307
1316
|
message: "请选择平台",
|
|
1308
|
-
choices:
|
|
1309
|
-
})), n === G.NPM && (i =
|
|
1310
|
-
const u = await
|
|
1317
|
+
choices: Ot
|
|
1318
|
+
})), n === G.NPM && (i = $.MASTER), !i) {
|
|
1319
|
+
const u = await k({
|
|
1311
1320
|
message: "请选择部署环境",
|
|
1312
1321
|
choices: qe
|
|
1313
1322
|
});
|
|
1314
|
-
i =
|
|
1323
|
+
i = Ht(u);
|
|
1315
1324
|
}
|
|
1316
1325
|
let s = "";
|
|
1317
|
-
a.language ===
|
|
1326
|
+
a.language === w.JAVASCRIPT && (s = zt);
|
|
1318
1327
|
let o = "";
|
|
1319
|
-
if (a.language ===
|
|
1328
|
+
if (a.language === w.JAVASCRIPT && (o = Ae().name), a.language === w.JAVA) {
|
|
1320
1329
|
const { projects: u } = await wi(), d = u.find(
|
|
1321
1330
|
(f) => $e(f.url) === $e(a.repository.url)
|
|
1322
1331
|
);
|
|
@@ -1332,7 +1341,7 @@ async function ut(e, t) {
|
|
|
1332
1341
|
const g = f.find((h) => h.value === t.module);
|
|
1333
1342
|
g && (o = g.value);
|
|
1334
1343
|
}
|
|
1335
|
-
o = await
|
|
1344
|
+
o = await k({
|
|
1336
1345
|
message: "请选择部署模块",
|
|
1337
1346
|
choices: f
|
|
1338
1347
|
});
|
|
@@ -1341,8 +1350,8 @@ async function ut(e, t) {
|
|
|
1341
1350
|
let r = [];
|
|
1342
1351
|
t.skipSelectionNotification || (r = await ot("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1343
1352
|
let c = [];
|
|
1344
|
-
if (t.skipGroupNotification || (c = await na("请选择部署成功要通知的群组:", () => !0, !0)), a.language ===
|
|
1345
|
-
const u =
|
|
1353
|
+
if (t.skipGroupNotification || (c = await na("请选择部署成功要通知的群组:", () => !0, !0)), a.language === w.JAVASCRIPT) {
|
|
1354
|
+
const u = Kt(i);
|
|
1346
1355
|
Na(u, n);
|
|
1347
1356
|
}
|
|
1348
1357
|
await va({
|
|
@@ -1354,7 +1363,7 @@ async function ut(e, t) {
|
|
|
1354
1363
|
});
|
|
1355
1364
|
}
|
|
1356
1365
|
async function lt(e, t, i, n) {
|
|
1357
|
-
const a =
|
|
1366
|
+
const a = y(`分支合并中,${e} -> ${t}`).start();
|
|
1358
1367
|
let s = 0;
|
|
1359
1368
|
try {
|
|
1360
1369
|
const { iid: r } = await Ri({
|
|
@@ -1363,7 +1372,7 @@ async function lt(e, t, i, n) {
|
|
|
1363
1372
|
source_branch: e,
|
|
1364
1373
|
target_branch: t,
|
|
1365
1374
|
// 合到主分支上的分支需要在合并完成后被移除
|
|
1366
|
-
remove_source_branch: n ? !1 :
|
|
1375
|
+
remove_source_branch: n ? !1 : $.MASTER === t
|
|
1367
1376
|
});
|
|
1368
1377
|
s = r;
|
|
1369
1378
|
} catch (r) {
|
|
@@ -1373,7 +1382,7 @@ async function lt(e, t, i, n) {
|
|
|
1373
1382
|
try {
|
|
1374
1383
|
await new Promise((r) => {
|
|
1375
1384
|
setTimeout(r, 5e3);
|
|
1376
|
-
}), await
|
|
1385
|
+
}), await xi({
|
|
1377
1386
|
id: i.id,
|
|
1378
1387
|
iid: s
|
|
1379
1388
|
}), a.succeed(`分支${e}已合并到分支${t}`);
|
|
@@ -1382,7 +1391,7 @@ async function lt(e, t, i, n) {
|
|
|
1382
1391
|
const c = r?.response?.status;
|
|
1383
1392
|
if (c === 406)
|
|
1384
1393
|
return await o();
|
|
1385
|
-
if (await
|
|
1394
|
+
if (await Ii({
|
|
1386
1395
|
id: i.id,
|
|
1387
1396
|
iid: s,
|
|
1388
1397
|
state_event: "close"
|
|
@@ -1402,14 +1411,14 @@ async function lt(e, t, i, n) {
|
|
|
1402
1411
|
await o();
|
|
1403
1412
|
}
|
|
1404
1413
|
async function ba(e, t) {
|
|
1405
|
-
const i = `origin/${e.sourceBranch}`, n = await
|
|
1414
|
+
const i = `origin/${e.sourceBranch}`, n = await m(`git log -b origin/${$.MASTER} -1 --format=%H`), a = await m(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await m(
|
|
1406
1415
|
`git log ${n}...${a} -b ${i}`
|
|
1407
1416
|
);
|
|
1408
|
-
if (s || l(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await
|
|
1417
|
+
if (s || l(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await m(
|
|
1409
1418
|
`git branch --contains ${n} -r ${i}`
|
|
1410
|
-
) || (console.log(S.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt(
|
|
1419
|
+
) || (console.log(S.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await lt($.MASTER, e.sourceBranch, e)), t === $.MASTER) {
|
|
1411
1420
|
const r = s.split(`
|
|
1412
|
-
`).filter((f) => f), c = await
|
|
1421
|
+
`).filter((f) => f), c = await m(`git log -b origin/${b.TEST} -1 --format=%H`), d = (await m(
|
|
1413
1422
|
`git log ${n}...${c} -b origin/${b.TEST}`
|
|
1414
1423
|
)).split(`
|
|
1415
1424
|
`).filter((f) => f);
|
|
@@ -1417,61 +1426,72 @@ async function ba(e, t) {
|
|
|
1417
1426
|
}
|
|
1418
1427
|
}
|
|
1419
1428
|
async function Aa(e, t) {
|
|
1420
|
-
ne(), Q(), await
|
|
1421
|
-
const i = await
|
|
1422
|
-
Object.values(
|
|
1423
|
-
const a = (await
|
|
1429
|
+
ne(), Q(), await me();
|
|
1430
|
+
const i = await mi();
|
|
1431
|
+
Object.values($).includes(i.sourceBranch) && l(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1432
|
+
const a = (await Oi(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
|
|
1424
1433
|
let u = c.name;
|
|
1425
|
-
return Object.values(
|
|
1434
|
+
return Object.values($).includes(u) && (u = S.bold.blue(u)), {
|
|
1426
1435
|
name: u,
|
|
1427
1436
|
value: c.name
|
|
1428
1437
|
};
|
|
1429
1438
|
});
|
|
1430
1439
|
let s;
|
|
1431
|
-
e && !a.filter((c) => c.value === e).length && l(`未找到目标分支${e}`), e ? s = e : s = await
|
|
1440
|
+
e && !a.filter((c) => c.value === e).length && l(`未找到目标分支${e}`), e ? s = e : s = await k({
|
|
1432
1441
|
message: "请选择要合并到的目标分支:",
|
|
1433
1442
|
choices: a
|
|
1434
1443
|
});
|
|
1435
|
-
const o =
|
|
1436
|
-
if (await
|
|
1437
|
-
o.text = `存在远程分支origin/${i.sourceBranch}`, await
|
|
1438
|
-
const c = await
|
|
1439
|
-
await
|
|
1444
|
+
const o = y(`本地分支${i.sourceBranch}检测中`).start();
|
|
1445
|
+
if (await m(`git ls-remote --heads origin ${i.sourceBranch}`)) {
|
|
1446
|
+
o.text = `存在远程分支origin/${i.sourceBranch}`, await m("git fetch");
|
|
1447
|
+
const c = await m(`git rev-parse ${i.sourceBranch}`), u = await m(`git rev-parse origin/${i.sourceBranch}`);
|
|
1448
|
+
await m(`git merge-base ${u} HEAD`) === u ? (await m(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`)) : await m(`git merge-base ${c} ${u}`) === c ? (await m("git pull"), o.succeed(`本地分支${i.sourceBranch}已更新`)) : (o.fail(
|
|
1440
1449
|
`远程分支origin/${i.sourceBranch}和本地分支${i.sourceBranch}都有新的提交,请手动合并后再试。`
|
|
1441
1450
|
), process.exit(1));
|
|
1442
1451
|
} else
|
|
1443
|
-
await
|
|
1444
|
-
await ba(i, s), await lt(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster),
|
|
1445
|
-
`${i.sourceBranch}分支已移除,当前已切换到最新的${
|
|
1446
|
-
)), Object.values(
|
|
1452
|
+
await m(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`);
|
|
1453
|
+
await ba(i, s), await lt(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster), $.MASTER === s && !t.keepBranchAfterMergeMaster && (await m(`git checkout ${$.MASTER}`), await m(`git pull origin ${$.MASTER}`), await m(`git branch -d ${i.sourceBranch}`), W(
|
|
1454
|
+
`${i.sourceBranch}分支已移除,当前已切换到最新的${$.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1455
|
+
)), Object.values($).includes(s) && await ut(s, {
|
|
1447
1456
|
platform: t.deployPlatform,
|
|
1448
1457
|
skipSelectionNotification: t.deploySkipSelectionNotification,
|
|
1449
1458
|
skipGroupNotification: t.skipGroupNotification
|
|
1450
1459
|
});
|
|
1451
1460
|
}
|
|
1452
1461
|
D.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(G).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => z(Aa, ...e));
|
|
1453
|
-
D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(
|
|
1462
|
+
D.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values($).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(G).join("/")}`).option("--module <module>", "部署模块。Java项目适用,填入要部署的模块名称").option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => z(ut, ...e));
|
|
1454
1463
|
async function ja() {
|
|
1455
1464
|
try {
|
|
1456
|
-
await
|
|
1465
|
+
await m("java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml .", {
|
|
1457
1466
|
silent: !1
|
|
1458
|
-
}),
|
|
1467
|
+
}), W("checkstyle执行完毕"), process.exit(0);
|
|
1459
1468
|
} catch {
|
|
1460
1469
|
l("checkstyle执行出错"), process.exit(1);
|
|
1461
1470
|
}
|
|
1462
1471
|
}
|
|
1463
|
-
function Sa() {
|
|
1464
|
-
|
|
1472
|
+
async function Sa() {
|
|
1473
|
+
v(p.resolve("node_modules", ".bin", "markdownlint")) || l("该项目未安装markdownlint,请安装后重试");
|
|
1474
|
+
const e = y("markdownlint执行中...").start();
|
|
1475
|
+
try {
|
|
1476
|
+
await m('npx markdownlint "**/*.md" --fix', {
|
|
1477
|
+
silent: !1
|
|
1478
|
+
}), e.succeed("markdownlint执行成功"), process.exit(0);
|
|
1479
|
+
} catch {
|
|
1480
|
+
e.fail("markdownlint校验出错"), process.exit(1);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
function ka() {
|
|
1484
|
+
const e = pe();
|
|
1465
1485
|
if (e["lint-staged"])
|
|
1466
1486
|
return e["lint-staged"];
|
|
1467
1487
|
throw new Error("未找到lint配置");
|
|
1468
1488
|
}
|
|
1469
1489
|
async function Ta() {
|
|
1470
|
-
const e =
|
|
1471
|
-
await
|
|
1490
|
+
const e = y("代码风格检测中...").start();
|
|
1491
|
+
await Et({
|
|
1472
1492
|
concurrent: 4,
|
|
1473
1493
|
debug: !1,
|
|
1474
|
-
config:
|
|
1494
|
+
config: ka(),
|
|
1475
1495
|
quiet: !0,
|
|
1476
1496
|
relative: !0
|
|
1477
1497
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : (e.fail("代码风格检测未通过!"), process.exit(1));
|
|
@@ -1485,12 +1505,12 @@ function Ea(e) {
|
|
|
1485
1505
|
const i = t[0];
|
|
1486
1506
|
return /^(feat|fix|refactor)/.test(i) ? /\(\d+(?:,\d+)*\)/.test(i) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(i) ? [j.CHORE, j.CI].includes(i) ? !0 : "chore/ci类型无需填写ID。" : j.Break === i ? !0 : "不存在的提交类型。";
|
|
1487
1507
|
}
|
|
1488
|
-
async function
|
|
1489
|
-
const e = await
|
|
1508
|
+
async function Ca() {
|
|
1509
|
+
const e = await Ee(p.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = y("提交信息格式校验中...").start(), i = Ea(e);
|
|
1490
1510
|
i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : (t.fail(`提交信息格式校验失败。${i}`), process.exit(1));
|
|
1491
1511
|
}
|
|
1492
|
-
async function
|
|
1493
|
-
await
|
|
1512
|
+
async function Ra() {
|
|
1513
|
+
await me();
|
|
1494
1514
|
const e = await Rt({
|
|
1495
1515
|
// 分组,展示仓库链接
|
|
1496
1516
|
format: ["group", "repo"],
|
|
@@ -1502,18 +1522,18 @@ async function Ca() {
|
|
|
1502
1522
|
install: "always"
|
|
1503
1523
|
});
|
|
1504
1524
|
if (e && Object.keys(e).length) {
|
|
1505
|
-
|
|
1525
|
+
W("升级完成 🎉");
|
|
1506
1526
|
const t = Object.entries(e).map(([i, n]) => `${i}@${n}`).join("; ");
|
|
1507
|
-
await
|
|
1527
|
+
await m(`git add . && git commit -m "chore: 依赖升级。${t}"`);
|
|
1508
1528
|
}
|
|
1509
1529
|
process.exit(0);
|
|
1510
1530
|
}
|
|
1511
|
-
async function
|
|
1512
|
-
v(
|
|
1513
|
-
const t =
|
|
1531
|
+
async function xa(e) {
|
|
1532
|
+
v(p.resolve("node_modules", ".bin", "eslint")) || l("该项目未安装eslint,请安装后重试");
|
|
1533
|
+
const t = y("eslint执行中...").start();
|
|
1514
1534
|
try {
|
|
1515
1535
|
let i = "npx eslint '**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}' --fix";
|
|
1516
|
-
process.platform === "win32" && (i = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (i += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? i += ` --max-warnings ${Number(e.maxWarnings)}` : i += " --max-warnings 100", await
|
|
1536
|
+
process.platform === "win32" && (i = 'npx eslint "**/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}" --fix'), e.quiet && (i += " --quiet"), e.maxWarnings && !isNaN(Number(e.maxWarnings)) ? i += ` --max-warnings ${Number(e.maxWarnings)}` : i += " --max-warnings 100", await m(i, {
|
|
1517
1537
|
silent: !1
|
|
1518
1538
|
}), t.succeed("eslint执行成功"), process.exit(0);
|
|
1519
1539
|
} catch {
|
|
@@ -1521,10 +1541,10 @@ async function Ra(e) {
|
|
|
1521
1541
|
}
|
|
1522
1542
|
}
|
|
1523
1543
|
async function Ia() {
|
|
1524
|
-
v(
|
|
1525
|
-
const e =
|
|
1544
|
+
v(p.resolve("node_modules", ".bin", "prettier")) || l("该项目未安装prettier,请安装后重试");
|
|
1545
|
+
const e = y("prettier执行中...").start();
|
|
1526
1546
|
try {
|
|
1527
|
-
await
|
|
1547
|
+
await m(
|
|
1528
1548
|
"npx prettier --write . --config .z/.prettierrc.json --ignore-path .z/.prettierignore --ignore-unknown --no-error-on-unmatched-pattern",
|
|
1529
1549
|
{
|
|
1530
1550
|
silent: !1
|
|
@@ -1534,12 +1554,12 @@ async function Ia() {
|
|
|
1534
1554
|
e.fail("prettier校验出错"), process.exit(1);
|
|
1535
1555
|
}
|
|
1536
1556
|
}
|
|
1537
|
-
function
|
|
1538
|
-
v(
|
|
1557
|
+
function Da() {
|
|
1558
|
+
v(p.resolve("./node_modules/.bin/vue-tsc")) || l("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), et("npx vue-tsc --build"), process.exit(0);
|
|
1539
1559
|
}
|
|
1540
|
-
async function
|
|
1560
|
+
async function La(e, t) {
|
|
1541
1561
|
ne(), Q();
|
|
1542
|
-
const i =
|
|
1562
|
+
const i = pe();
|
|
1543
1563
|
let n;
|
|
1544
1564
|
if (e)
|
|
1545
1565
|
[
|
|
@@ -1570,7 +1590,11 @@ async function Da(e, t) {
|
|
|
1570
1590
|
"checkstyle",
|
|
1571
1591
|
"cs"
|
|
1572
1592
|
/* CheckStyleAbbr */
|
|
1573
|
-
].includes(e) ? n = "checkstyle" :
|
|
1593
|
+
].includes(e) ? n = "checkstyle" : [
|
|
1594
|
+
"markdown-lint",
|
|
1595
|
+
"ml"
|
|
1596
|
+
/* MarkdownLintAbbr */
|
|
1597
|
+
].includes(e) ? n = "markdown-lint" : l("参数输入错误");
|
|
1574
1598
|
else {
|
|
1575
1599
|
const a = [
|
|
1576
1600
|
{
|
|
@@ -1579,11 +1603,32 @@ async function Da(e, t) {
|
|
|
1579
1603
|
/* Prettier */
|
|
1580
1604
|
}
|
|
1581
1605
|
];
|
|
1582
|
-
i.language ===
|
|
1606
|
+
i.language === w.JAVA && a.push({
|
|
1583
1607
|
name: "执行 check-style",
|
|
1584
1608
|
value: "checkstyle"
|
|
1585
1609
|
/* CheckStyle */
|
|
1586
|
-
}), i.language ===
|
|
1610
|
+
}), i.language === w.JAVASCRIPT && a.push(
|
|
1611
|
+
{
|
|
1612
|
+
name: "执行 eslint",
|
|
1613
|
+
value: "eslint"
|
|
1614
|
+
/* Eslint */
|
|
1615
|
+
},
|
|
1616
|
+
{
|
|
1617
|
+
name: "执行 type-check",
|
|
1618
|
+
value: "type-check"
|
|
1619
|
+
/* TypeCheck */
|
|
1620
|
+
},
|
|
1621
|
+
{
|
|
1622
|
+
name: "执行 dependency-check",
|
|
1623
|
+
value: "dependency-check"
|
|
1624
|
+
/* DependencyCheck */
|
|
1625
|
+
}
|
|
1626
|
+
), i.language === w.MARKDOWN && a.push(
|
|
1627
|
+
{
|
|
1628
|
+
name: "执行markdown-lint",
|
|
1629
|
+
value: "markdown-lint"
|
|
1630
|
+
/* MarkdownLint */
|
|
1631
|
+
},
|
|
1587
1632
|
{
|
|
1588
1633
|
name: "执行 eslint",
|
|
1589
1634
|
value: "eslint"
|
|
@@ -1599,33 +1644,33 @@ async function Da(e, t) {
|
|
|
1599
1644
|
value: "dependency-check"
|
|
1600
1645
|
/* DependencyCheck */
|
|
1601
1646
|
}
|
|
1602
|
-
), n = await
|
|
1647
|
+
), n = await k({
|
|
1603
1648
|
message: "请选择你要执行的操作",
|
|
1604
1649
|
choices: a
|
|
1605
1650
|
});
|
|
1606
1651
|
}
|
|
1607
|
-
n === "commit-msg" ? await
|
|
1652
|
+
n === "commit-msg" ? await Ca() : n === "commit-files" ? await Ta() : n === "prettier" ? await Ia() : n === "eslint" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? await xa(t) : n === "type-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? Da() : n === "dependency-check" && [w.JAVASCRIPT, w.MARKDOWN].includes(i.language) ? await Ra() : n === "checkstyle" && i.language === w.JAVA ? await ja() : n === "markdown-lint" && i.language === w.MARKDOWN && await Sa();
|
|
1608
1653
|
}
|
|
1609
|
-
D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle。").argument(
|
|
1654
|
+
D.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check / checkstyle / markdown-lint。").argument(
|
|
1610
1655
|
"[type]",
|
|
1611
|
-
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs。"
|
|
1612
|
-
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(
|
|
1613
|
-
async function
|
|
1614
|
-
const t =
|
|
1615
|
-
await
|
|
1616
|
-
}
|
|
1617
|
-
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(
|
|
1618
|
-
async function
|
|
1656
|
+
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc, checkstyle|cs, markdown-lint|ml。"
|
|
1657
|
+
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(La, ...e));
|
|
1658
|
+
async function mt(e = "latest") {
|
|
1659
|
+
const t = y("安装中...").start();
|
|
1660
|
+
await m(`npm i -g ${ie.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", ue("latestCheckVersionTimestamp", Date.now()), ue("version", e), se(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1661
|
+
}
|
|
1662
|
+
D.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(mt, ...e));
|
|
1663
|
+
async function Oa(e) {
|
|
1619
1664
|
let t = e;
|
|
1620
|
-
t ? [b.DEV, b.TEST, b.RELEASE, b.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = b.DEV : t === "t" ? t = b.TEST : t === "r" ? t = b.RELEASE : t === "p" && (t = b.PROD) : l("参数输入有误") : t = await
|
|
1665
|
+
t ? [b.DEV, b.TEST, b.RELEASE, b.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = b.DEV : t === "t" ? t = b.TEST : t === "r" ? t = b.RELEASE : t === "p" && (t = b.PROD) : l("参数输入有误") : t = await k({
|
|
1621
1666
|
message: "请选择环境",
|
|
1622
1667
|
choices: qe
|
|
1623
1668
|
});
|
|
1624
1669
|
const i = Ae(), n = `dev:${t}`;
|
|
1625
1670
|
i.scripts[n] ? et(`npm run ${n}`) : l(`项目中(package.json > scripts)不存在命令${n},请先添加!`);
|
|
1626
1671
|
}
|
|
1627
|
-
D.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(
|
|
1628
|
-
const De = /Thumbs\.db|\.git|DS_Store|idea/,
|
|
1672
|
+
D.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(Oa, ...e));
|
|
1673
|
+
const De = /Thumbs\.db|\.git|DS_Store|idea/, pt = "testcase";
|
|
1629
1674
|
function dt(e) {
|
|
1630
1675
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
1631
1676
|
if (t && !e.startsWith("["))
|
|
@@ -1648,11 +1693,11 @@ function dt(e) {
|
|
|
1648
1693
|
async function X(e, t = {}) {
|
|
1649
1694
|
const { exclude: i = De } = t, n = [];
|
|
1650
1695
|
async function a(s) {
|
|
1651
|
-
const o =
|
|
1696
|
+
const o = p.basename(s);
|
|
1652
1697
|
if ((await At(s)).isFile())
|
|
1653
1698
|
return null;
|
|
1654
1699
|
const c = await Re(s, { withFileTypes: !0 }), u = (await Promise.all(
|
|
1655
|
-
c.filter((
|
|
1700
|
+
c.filter((T) => T.isDirectory() && !i.test(T.name)).map((T) => a(p.join(s, T.name)))
|
|
1656
1701
|
)).filter(Boolean), { type: d, id: f, displayName: g } = dt(o), h = {
|
|
1657
1702
|
name: o,
|
|
1658
1703
|
id: f,
|
|
@@ -1661,17 +1706,17 @@ async function X(e, t = {}) {
|
|
|
1661
1706
|
type: d,
|
|
1662
1707
|
children: u
|
|
1663
1708
|
};
|
|
1664
|
-
return (t.hasRoot ||
|
|
1709
|
+
return (t.hasRoot || p.resolve(e) !== s) && n.push(h), h;
|
|
1665
1710
|
}
|
|
1666
|
-
return await a(
|
|
1711
|
+
return await a(p.resolve(e)), n;
|
|
1667
1712
|
}
|
|
1668
1713
|
async function ft(e, t = {}) {
|
|
1669
1714
|
const { exclude: i = De } = t;
|
|
1670
1715
|
try {
|
|
1671
|
-
const n = await Re(
|
|
1716
|
+
const n = await Re(p.resolve(e), { withFileTypes: !0 });
|
|
1672
1717
|
return await Promise.all(
|
|
1673
1718
|
n.filter((a) => a.isDirectory() && !i.test(a.name)).map((a) => {
|
|
1674
|
-
const s =
|
|
1719
|
+
const s = p.join(e, a.name), { type: o, id: r, displayName: c } = dt(a.name);
|
|
1675
1720
|
return {
|
|
1676
1721
|
name: a.name,
|
|
1677
1722
|
id: r,
|
|
@@ -1685,7 +1730,7 @@ async function ft(e, t = {}) {
|
|
|
1685
1730
|
return l(`读取目录失败: ${e} : ${n}`), [];
|
|
1686
1731
|
}
|
|
1687
1732
|
}
|
|
1688
|
-
function
|
|
1733
|
+
function V(e, t, i) {
|
|
1689
1734
|
switch (e) {
|
|
1690
1735
|
case "module":
|
|
1691
1736
|
return i ? `${t}[${i}]` : t;
|
|
@@ -1697,11 +1742,11 @@ function W(e, t, i) {
|
|
|
1697
1742
|
}
|
|
1698
1743
|
async function we(e, t, i, n) {
|
|
1699
1744
|
try {
|
|
1700
|
-
const a =
|
|
1745
|
+
const a = p.basename(e), s = V(i, t, n);
|
|
1701
1746
|
if (a === s)
|
|
1702
1747
|
return !0;
|
|
1703
|
-
const o =
|
|
1704
|
-
return await
|
|
1748
|
+
const o = p.dirname(e), r = p.join(o, s);
|
|
1749
|
+
return await Zt(e) ? await _e(e, r) : (await m(`git mv "${e}" "${r}"`), await m("git add .")), !0;
|
|
1705
1750
|
} catch (a) {
|
|
1706
1751
|
return l(`重命名文件夹失败: ${e} -> ${t}。${a}`), !1;
|
|
1707
1752
|
}
|
|
@@ -1712,12 +1757,12 @@ async function Pa(e, t, i = {}) {
|
|
|
1712
1757
|
if (!s || s.length === 0) return;
|
|
1713
1758
|
const r = await ft(o, { exclude: n });
|
|
1714
1759
|
for (const c of s) {
|
|
1715
|
-
const u = String(c.value), d =
|
|
1716
|
-
let g = f?.path ||
|
|
1717
|
-
f ? f.displayName !== c.label && await we(f.path, c.label, "module", u) && (g =
|
|
1760
|
+
const u = String(c.value), d = V("module", c.label, u), f = r.find((h) => h.id === u);
|
|
1761
|
+
let g = f?.path || p.join(o, d);
|
|
1762
|
+
f ? f.displayName !== c.label && await we(f.path, c.label, "module", u) && (g = p.join(o, d)) : (await le(g, { recursive: !0 }), await m(`git add "${g}"`)), c.children && c.children.length > 0 && await a(c.children, g);
|
|
1718
1763
|
}
|
|
1719
1764
|
}
|
|
1720
|
-
await a(e,
|
|
1765
|
+
await a(e, p.resolve(t));
|
|
1721
1766
|
}
|
|
1722
1767
|
async function gt(e) {
|
|
1723
1768
|
const t = {
|
|
@@ -1729,7 +1774,7 @@ async function gt(e) {
|
|
|
1729
1774
|
Number.isNaN(Number(e)) && l("请输入正确的产品ID"), t.id = Number(e);
|
|
1730
1775
|
else {
|
|
1731
1776
|
const i = await Bi();
|
|
1732
|
-
t.id = await
|
|
1777
|
+
t.id = await k({
|
|
1733
1778
|
message: "请选择产品",
|
|
1734
1779
|
choices: i.map((n) => ({
|
|
1735
1780
|
name: `${n.label}[${n.value}]`,
|
|
@@ -1737,10 +1782,10 @@ async function gt(e) {
|
|
|
1737
1782
|
}))
|
|
1738
1783
|
});
|
|
1739
1784
|
}
|
|
1740
|
-
return t.name = await Ji(t.id), t.path =
|
|
1785
|
+
return t.name = await Ji(t.id), t.path = p.join(pt, V("module", t.name, String(t.id))), t;
|
|
1741
1786
|
}
|
|
1742
1787
|
async function Le(e) {
|
|
1743
|
-
return (await ft(
|
|
1788
|
+
return (await ft(pt)).find((i) => Number(i.id) === e.id);
|
|
1744
1789
|
}
|
|
1745
1790
|
async function ht(e, t) {
|
|
1746
1791
|
const i = {
|
|
@@ -1748,22 +1793,22 @@ async function ht(e, t) {
|
|
|
1748
1793
|
priority: e.pri,
|
|
1749
1794
|
steps: []
|
|
1750
1795
|
};
|
|
1751
|
-
i.steps = await _i(e.id),
|
|
1796
|
+
i.steps = await _i(e.id), x.writeJSONSync(t, i, {
|
|
1752
1797
|
spaces: 2
|
|
1753
1798
|
});
|
|
1754
1799
|
}
|
|
1755
1800
|
async function wt(e, t) {
|
|
1756
1801
|
await le(t, {
|
|
1757
1802
|
recursive: !0
|
|
1758
|
-
}), await ht(e,
|
|
1759
|
-
|
|
1760
|
-
v(
|
|
1761
|
-
),
|
|
1762
|
-
|
|
1763
|
-
v(
|
|
1803
|
+
}), await ht(e, p.join(t, "config.json")), x.ensureFileSync(p.join(t, "data.yaml")), await L(
|
|
1804
|
+
p.join(t, "data.yaml"),
|
|
1805
|
+
v(p.resolve(Z, "data.yaml")) ? await Ee(p.resolve(Z, "data.yaml")) : await bi()
|
|
1806
|
+
), x.ensureFileSync(p.join(t, "main.py")), await L(
|
|
1807
|
+
p.join(t, "main.py"),
|
|
1808
|
+
v(p.resolve(Z, "main.py")) ? await Ee(p.resolve(Z, "main.py")) : await Ai()
|
|
1764
1809
|
);
|
|
1765
1810
|
}
|
|
1766
|
-
function
|
|
1811
|
+
function Oe(e) {
|
|
1767
1812
|
if (e) {
|
|
1768
1813
|
const t = e.split(",").map((i) => i.trim()).filter((i) => {
|
|
1769
1814
|
const n = Number(i);
|
|
@@ -1774,9 +1819,9 @@ function Pe(e) {
|
|
|
1774
1819
|
return [];
|
|
1775
1820
|
}
|
|
1776
1821
|
async function je(e, t) {
|
|
1777
|
-
ne(), Q(), await
|
|
1822
|
+
ne(), Q(), await me();
|
|
1778
1823
|
let i;
|
|
1779
|
-
t ? ([R.MODULE, R.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${R.MODULE} 或者 ${R.CASE}。`), i = t) : i = await
|
|
1824
|
+
t ? ([R.MODULE, R.CASE].includes(t) || l(`不支持的参数${t}。参数值应为 ${R.MODULE} 或者 ${R.CASE}。`), i = t) : i = await k({
|
|
1780
1825
|
message: `请选择要${e}的数据类型`,
|
|
1781
1826
|
choices: Bt
|
|
1782
1827
|
});
|
|
@@ -1793,72 +1838,72 @@ async function Se(e) {
|
|
|
1793
1838
|
localProduct: i
|
|
1794
1839
|
};
|
|
1795
1840
|
}
|
|
1796
|
-
async function
|
|
1841
|
+
async function Ma(e, t, i) {
|
|
1797
1842
|
e.text = "查找本地产品目录...", await Le(t) || l(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
1798
|
-
const a =
|
|
1843
|
+
const a = Oe(i);
|
|
1799
1844
|
let s = await X(t.path);
|
|
1800
1845
|
e.text = "获取远程用例列表...";
|
|
1801
1846
|
const o = await Fi(t.id, a);
|
|
1802
1847
|
e.text = "本地用例同步中...";
|
|
1803
1848
|
for (const r of o) {
|
|
1804
1849
|
let c;
|
|
1805
|
-
if (r.module === 0 ? c =
|
|
1850
|
+
if (r.module === 0 ? c = p.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", !c)
|
|
1806
1851
|
return l(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
1807
1852
|
const u = s.find(({ id: d }) => r.id === Number(d));
|
|
1808
1853
|
if (u)
|
|
1809
|
-
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) &&
|
|
1854
|
+
u.displayName !== r.title && await we(u.path, r.title, u.type, u.id) && W(`重命名成功: ${u.displayName} -> ${r.title}`), s = await X(t.path), r.module === 0 ? c = p.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await ht(
|
|
1810
1855
|
r,
|
|
1811
|
-
|
|
1856
|
+
p.join(c, V("case", r.title, String(r.id)), "config.json")
|
|
1812
1857
|
);
|
|
1813
1858
|
else {
|
|
1814
|
-
const d =
|
|
1859
|
+
const d = p.join(c, V("case", r.title, String(r.id)));
|
|
1815
1860
|
await wt(r, d);
|
|
1816
1861
|
}
|
|
1817
1862
|
}
|
|
1818
1863
|
}
|
|
1819
|
-
async function
|
|
1864
|
+
async function za(e, t) {
|
|
1820
1865
|
e.text = "本地产品目录查找中...";
|
|
1821
1866
|
const i = await Le(t);
|
|
1822
|
-
i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await we(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await le(t.path, { recursive: !0 }), await
|
|
1867
|
+
i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await we(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await le(t.path, { recursive: !0 }), await m("git add .")), e.text = "获取远程模块列表...";
|
|
1823
1868
|
const n = await st(t.id);
|
|
1824
1869
|
e.text = "本地同步模块中...", await Pa(n || [], t.path);
|
|
1825
1870
|
}
|
|
1826
|
-
async function
|
|
1827
|
-
const { type: i, typeStr: n } = await je("拉取", e), a = await gt(t.productId), s =
|
|
1828
|
-
if (R.MODULE === i && await
|
|
1829
|
-
const o =
|
|
1871
|
+
async function Ba(e, t) {
|
|
1872
|
+
const { type: i, typeStr: n } = await je("拉取", e), a = await gt(t.productId), s = y(`${n}同步中...`).start();
|
|
1873
|
+
if (R.MODULE === i && await za(s, a), R.CASE === i && await Ma(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await m("git status -s")) {
|
|
1874
|
+
const o = y("代码提交中...").start();
|
|
1830
1875
|
try {
|
|
1831
|
-
await
|
|
1876
|
+
await m(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
|
|
1832
1877
|
} catch (r) {
|
|
1833
1878
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
1834
1879
|
}
|
|
1835
1880
|
}
|
|
1836
1881
|
}
|
|
1837
|
-
D.command("qa-pull").alias("qp").description("将禅道中的模块或者用例同步到本地").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "type=case时,可传指定用例ID(可传N个,逗号隔开);不传则为产品下全部用例").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(
|
|
1838
|
-
async function
|
|
1882
|
+
D.command("qa-pull").alias("qp").description("将禅道中的模块或者用例同步到本地").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "type=case时,可传指定用例ID(可传N个,逗号隔开);不传则为产品下全部用例").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(Ba, ...e));
|
|
1883
|
+
async function Ja(e, t, i) {
|
|
1839
1884
|
let n = await F({
|
|
1840
1885
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
1841
1886
|
});
|
|
1842
1887
|
n = n.trim();
|
|
1843
|
-
const a =
|
|
1888
|
+
const a = y(`用例【${i}】开始创建...`).start();
|
|
1844
1889
|
a.text = "远程用例创建中...";
|
|
1845
1890
|
const s = await Gi({
|
|
1846
1891
|
product: Number(e.id),
|
|
1847
1892
|
// 如果父模块是产品根目录,parent=0
|
|
1848
|
-
module:
|
|
1893
|
+
module: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
1849
1894
|
title: i,
|
|
1850
1895
|
type: "interface",
|
|
1851
|
-
openedBy:
|
|
1896
|
+
openedBy: E("ldapAccount"),
|
|
1852
1897
|
precondition: n || ""
|
|
1853
1898
|
});
|
|
1854
|
-
a.text = "远程用例步骤创建中...", await
|
|
1899
|
+
a.text = "远程用例步骤创建中...", await Wi({
|
|
1855
1900
|
case: s,
|
|
1856
1901
|
type: "step",
|
|
1857
1902
|
desc: "按照预期执行",
|
|
1858
1903
|
expect: "正常执行,符合预期"
|
|
1859
1904
|
}), a.text = "本地用例创建中...";
|
|
1860
|
-
const o =
|
|
1861
|
-
return v(o) ?
|
|
1905
|
+
const o = p.join(t.path, V("case", i, String(s)));
|
|
1906
|
+
return v(o) ? W(`${o}已存在,请检查是否对应,本地不再创建。`) : (await wt(
|
|
1862
1907
|
{
|
|
1863
1908
|
id: s,
|
|
1864
1909
|
pri: 3,
|
|
@@ -1867,24 +1912,24 @@ async function Ba(e, t, i) {
|
|
|
1867
1912
|
o
|
|
1868
1913
|
), a.succeed(`用例【[${o}】创建完成 🎉`), o);
|
|
1869
1914
|
}
|
|
1870
|
-
async function
|
|
1871
|
-
const n =
|
|
1915
|
+
async function Fa(e, t, i) {
|
|
1916
|
+
const n = y(`模块【${i}】开始创建...`).start();
|
|
1872
1917
|
n.text = "远程模块创建中...";
|
|
1873
1918
|
const a = await Ui({
|
|
1874
1919
|
root: Number(e.id),
|
|
1875
1920
|
name: i,
|
|
1876
1921
|
// 如果父模块是产品根目录,parent=0
|
|
1877
|
-
parent:
|
|
1922
|
+
parent: p.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0)
|
|
1878
1923
|
});
|
|
1879
1924
|
n.text = "本地模块创建中...";
|
|
1880
|
-
const s =
|
|
1925
|
+
const s = p.join(t.path, V("module", i, String(a)));
|
|
1881
1926
|
if (v(s))
|
|
1882
|
-
return
|
|
1927
|
+
return W(`${s}已存在,请检查是否对应,本地不再创建。`);
|
|
1883
1928
|
await le(s, {
|
|
1884
1929
|
recursive: !0
|
|
1885
1930
|
}), n.succeed(`模块【${s}】创建完成 🎉`);
|
|
1886
1931
|
}
|
|
1887
|
-
function
|
|
1932
|
+
function _a(e) {
|
|
1888
1933
|
function t(n) {
|
|
1889
1934
|
if (!n.children || n.children.length === 0) return;
|
|
1890
1935
|
const a = n.children[0];
|
|
@@ -1897,7 +1942,7 @@ function Fa(e) {
|
|
|
1897
1942
|
});
|
|
1898
1943
|
}
|
|
1899
1944
|
async function i(n, a = []) {
|
|
1900
|
-
const s = a.length ? `请选择层级(当前:${a.join(" / ")})` : "请选择层级", o = await
|
|
1945
|
+
const s = a.length ? `请选择层级(当前:${a.join(" / ")})` : "请选择层级", o = await k({
|
|
1901
1946
|
message: s,
|
|
1902
1947
|
choices: n.map((r) => ({
|
|
1903
1948
|
name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
|
|
@@ -1908,8 +1953,8 @@ function Fa(e) {
|
|
|
1908
1953
|
}
|
|
1909
1954
|
return i(e);
|
|
1910
1955
|
}
|
|
1911
|
-
async function
|
|
1912
|
-
const { type: i, typeStr: n } = await je("创建", e), { product: a, localProduct: s } = await Se(t.productId), o = await st(a.id), r = await
|
|
1956
|
+
async function Ua(e, t) {
|
|
1957
|
+
const { type: i, typeStr: n } = await je("创建", e), { product: a, localProduct: s } = await Se(t.productId), o = await st(a.id), r = await _a(o), c = V("module", r.label, String(r.value)), d = (await X(a.path, { hasRoot: !0 })).find((h) => h.name === c);
|
|
1913
1958
|
if (!d?.path || !v(d.path))
|
|
1914
1959
|
return l(`本地不存在${c}模块`);
|
|
1915
1960
|
let f = await F({
|
|
@@ -1919,17 +1964,17 @@ async function _a(e, t) {
|
|
|
1919
1964
|
});
|
|
1920
1965
|
f = f.trim();
|
|
1921
1966
|
let g = "";
|
|
1922
|
-
if (R.MODULE === i && await
|
|
1923
|
-
const h =
|
|
1967
|
+
if (R.MODULE === i && await Fa(s, d, f), R.CASE === i && (g = await Ja(s, d, f)), !t.disableAutoCommit && R.CASE === i) {
|
|
1968
|
+
const h = y("代码提交中...").start();
|
|
1924
1969
|
try {
|
|
1925
|
-
await
|
|
1926
|
-
} catch (
|
|
1927
|
-
h.fail(`提交失败,${
|
|
1970
|
+
await m(`git add . && git commit -m "chore: 创建了用例${p.basename(g)}"`), h.succeed("代码已提交 ✅");
|
|
1971
|
+
} catch (T) {
|
|
1972
|
+
h.fail(`提交失败,${T}`), process.exit(1);
|
|
1928
1973
|
}
|
|
1929
1974
|
}
|
|
1930
1975
|
}
|
|
1931
|
-
D.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(
|
|
1932
|
-
async function
|
|
1976
|
+
D.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(Ua, ...e));
|
|
1977
|
+
async function Ga(e, t) {
|
|
1933
1978
|
const n = (await X(e.path)).filter((r) => r.type === "case");
|
|
1934
1979
|
let a = [];
|
|
1935
1980
|
if (t.length)
|
|
@@ -1943,7 +1988,7 @@ async function Ua(e, t) {
|
|
|
1943
1988
|
id: Number(c.id),
|
|
1944
1989
|
path: c.path
|
|
1945
1990
|
},
|
|
1946
|
-
name: c.path.replace(
|
|
1991
|
+
name: c.path.replace(p.resolve(e.path), "")
|
|
1947
1992
|
}));
|
|
1948
1993
|
a = await ae({
|
|
1949
1994
|
message: "选择要删除的用例",
|
|
@@ -1955,16 +2000,16 @@ async function Ua(e, t) {
|
|
|
1955
2000
|
}
|
|
1956
2001
|
});
|
|
1957
2002
|
}
|
|
1958
|
-
const s =
|
|
2003
|
+
const s = y("远程用例删除中...").start(), o = a.map((r) => r.id);
|
|
1959
2004
|
await qi({
|
|
1960
2005
|
product: Number(e.id),
|
|
1961
2006
|
caseIds: o
|
|
1962
2007
|
}), s.text = "本地用例删除中...";
|
|
1963
2008
|
for (const r of a)
|
|
1964
|
-
v(r.path) &&
|
|
2009
|
+
v(r.path) && O.rm("-rf", r.path);
|
|
1965
2010
|
return s.succeed("用例删除完成"), o;
|
|
1966
2011
|
}
|
|
1967
|
-
async function
|
|
2012
|
+
async function Wa(e, t) {
|
|
1968
2013
|
const n = (await X(e.path)).filter((r) => r.type === "module");
|
|
1969
2014
|
let a = [];
|
|
1970
2015
|
if (t.length)
|
|
@@ -1978,7 +2023,7 @@ async function Ga(e, t) {
|
|
|
1978
2023
|
id: Number(c.id),
|
|
1979
2024
|
path: c.path
|
|
1980
2025
|
},
|
|
1981
|
-
name: c.path.replace(
|
|
2026
|
+
name: c.path.replace(p.resolve(e.path), "")
|
|
1982
2027
|
}));
|
|
1983
2028
|
a = await ae({
|
|
1984
2029
|
message: "选择要删除的模块",
|
|
@@ -1991,29 +2036,29 @@ async function Ga(e, t) {
|
|
|
1991
2036
|
});
|
|
1992
2037
|
}
|
|
1993
2038
|
a = a.sort((r, c) => r.path.localeCompare(c.path));
|
|
1994
|
-
const s =
|
|
1995
|
-
await
|
|
2039
|
+
const s = y("远程模块删除中...").start(), o = a.map((r) => r.id);
|
|
2040
|
+
await Vi({
|
|
1996
2041
|
product: Number(e.id),
|
|
1997
2042
|
moduleIds: o
|
|
1998
2043
|
}), s.text = "本地模块删除中...";
|
|
1999
2044
|
for (const r of a)
|
|
2000
|
-
v(r.path) &&
|
|
2045
|
+
v(r.path) && O.rm("-rf", r.path);
|
|
2001
2046
|
return s.succeed("模块删除完成"), o;
|
|
2002
2047
|
}
|
|
2003
2048
|
async function Va(e, t) {
|
|
2004
|
-
const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await Se(t.productId), s =
|
|
2049
|
+
const { type: i, typeStr: n } = await je("删除", e), { localProduct: a } = await Se(t.productId), s = Oe(t.targetIds);
|
|
2005
2050
|
let o = [];
|
|
2006
|
-
if (R.MODULE === i ? o = await
|
|
2007
|
-
const r =
|
|
2051
|
+
if (R.MODULE === i ? o = await Wa(a, s) : R.CASE === i && (o = await Ga(a, s)), !t.disableAutoCommit && await m("git status -s")) {
|
|
2052
|
+
const r = y("代码提交中...").start();
|
|
2008
2053
|
try {
|
|
2009
|
-
await
|
|
2054
|
+
await m(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
2010
2055
|
} catch (c) {
|
|
2011
2056
|
r.fail(`提交失败,${c}`), process.exit(1);
|
|
2012
2057
|
}
|
|
2013
2058
|
}
|
|
2014
2059
|
}
|
|
2015
2060
|
D.command("qa-remove").alias("qr").description("删除模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--target-ids <targetIds>", "可传指定目标(用例/模块)ID。可传N个,逗号隔开").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(Va, ...e));
|
|
2016
|
-
async function
|
|
2061
|
+
async function qa(e, t) {
|
|
2017
2062
|
const n = (await X(e.path)).filter((g) => g.type === "case");
|
|
2018
2063
|
let a;
|
|
2019
2064
|
if (t.targetId) {
|
|
@@ -2026,14 +2071,14 @@ async function Wa(e, t) {
|
|
|
2026
2071
|
path: h.path,
|
|
2027
2072
|
displayName: h.displayName
|
|
2028
2073
|
},
|
|
2029
|
-
name: h.path.replace(
|
|
2074
|
+
name: h.path.replace(p.resolve(e.path), "")
|
|
2030
2075
|
}));
|
|
2031
2076
|
[a] = await ae({
|
|
2032
2077
|
message: "选择要更新的用例",
|
|
2033
2078
|
pageSize: 100,
|
|
2034
2079
|
loop: !1,
|
|
2035
2080
|
multiple: void 0,
|
|
2036
|
-
options: (h) => h ? g.filter((
|
|
2081
|
+
options: (h) => h ? g.filter((T) => T.name.includes(h)) : g,
|
|
2037
2082
|
validate(h) {
|
|
2038
2083
|
return h.length > 1 ? "只能选一个" : h.length < 1 ? "请选一个" : !0;
|
|
2039
2084
|
}
|
|
@@ -2047,12 +2092,12 @@ async function Wa(e, t) {
|
|
|
2047
2092
|
prefill: "editable"
|
|
2048
2093
|
});
|
|
2049
2094
|
s = s.trim();
|
|
2050
|
-
const o =
|
|
2051
|
-
s !== a.displayName ? (await
|
|
2095
|
+
const o = y("用例重命名中...").start();
|
|
2096
|
+
s !== a.displayName ? (await Hi({
|
|
2052
2097
|
id: Number(a.id),
|
|
2053
2098
|
name: s
|
|
2054
|
-
}), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path =
|
|
2055
|
-
let r =
|
|
2099
|
+
}), await we(a.path, s, "case", String(a.id)) && o.succeed(`用例重命名成功: ${a.displayName} -> ${s}`), a.displayName = s, a.path = p.join(p.dirname(a.path), V("case", s, String(a.id)))) : o.succeed("用例名称无变动");
|
|
2100
|
+
let r = x.readJsonSync(p.join(a.path, "config.json")), c;
|
|
2056
2101
|
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await ze({
|
|
2057
2102
|
message: "修改用例优先级",
|
|
2058
2103
|
min: 1,
|
|
@@ -2068,30 +2113,30 @@ async function Wa(e, t) {
|
|
|
2068
2113
|
default: r.priority,
|
|
2069
2114
|
validate: (g) => g > 0 && g < 6
|
|
2070
2115
|
});
|
|
2071
|
-
const u =
|
|
2072
|
-
c !== r.priority ? (await
|
|
2116
|
+
const u = y("用例优先级设置中...").start();
|
|
2117
|
+
c !== r.priority ? (await Zi({
|
|
2073
2118
|
id: Number(a.id),
|
|
2074
2119
|
priority: c
|
|
2075
|
-
}),
|
|
2076
|
-
|
|
2120
|
+
}), x.writeJSONSync(
|
|
2121
|
+
p.join(a.path, "config.json"),
|
|
2077
2122
|
{
|
|
2078
2123
|
...r,
|
|
2079
2124
|
priority: c
|
|
2080
2125
|
},
|
|
2081
2126
|
{ spaces: 2 }
|
|
2082
|
-
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r =
|
|
2127
|
+
), u.succeed(`用例优先级修改成功:${r.priority} -> ${c}`)) : u.succeed("用例优先级无变动"), r = x.readJsonSync(p.join(a.path, "config.json"));
|
|
2083
2128
|
let d;
|
|
2084
2129
|
t.casePrecondition ? d = t.casePrecondition : (d = await F({
|
|
2085
2130
|
message: "修改用例前置条件",
|
|
2086
2131
|
default: r.precondition,
|
|
2087
2132
|
prefill: "editable"
|
|
2088
2133
|
}), d = d.trim());
|
|
2089
|
-
const f =
|
|
2134
|
+
const f = y("用例前置条件设置中...").start();
|
|
2090
2135
|
return d !== r.precondition ? (await Yi({
|
|
2091
2136
|
id: Number(a.id),
|
|
2092
2137
|
precondition: d
|
|
2093
|
-
}),
|
|
2094
|
-
|
|
2138
|
+
}), x.writeJSONSync(
|
|
2139
|
+
p.join(a.path, "config.json"),
|
|
2095
2140
|
{
|
|
2096
2141
|
...r,
|
|
2097
2142
|
precondition: d
|
|
@@ -2099,7 +2144,7 @@ async function Wa(e, t) {
|
|
|
2099
2144
|
{ spaces: 2 }
|
|
2100
2145
|
), f.succeed(`用例前置条件修改成功:${r.precondition} -> ${d}`)) : f.succeed("用例前置条件无变动"), a.id;
|
|
2101
2146
|
}
|
|
2102
|
-
async function
|
|
2147
|
+
async function Ka(e, t) {
|
|
2103
2148
|
const n = (await X(e.path)).filter((r) => r.type === "module");
|
|
2104
2149
|
let a;
|
|
2105
2150
|
if (t.targetId) {
|
|
@@ -2112,7 +2157,7 @@ async function qa(e, t) {
|
|
|
2112
2157
|
path: c.path,
|
|
2113
2158
|
displayName: c.displayName
|
|
2114
2159
|
},
|
|
2115
|
-
name: c.path.replace(
|
|
2160
|
+
name: c.path.replace(p.resolve(e.path), "")
|
|
2116
2161
|
}));
|
|
2117
2162
|
[a] = await ae({
|
|
2118
2163
|
message: "选择要更新的模块",
|
|
@@ -2133,8 +2178,8 @@ async function qa(e, t) {
|
|
|
2133
2178
|
prefill: "editable"
|
|
2134
2179
|
});
|
|
2135
2180
|
s = s.trim();
|
|
2136
|
-
const o =
|
|
2137
|
-
return s !== a.displayName ? (await
|
|
2181
|
+
const o = y("模块重命名中...").start();
|
|
2182
|
+
return s !== a.displayName ? (await Ki({
|
|
2138
2183
|
id: Number(a.id),
|
|
2139
2184
|
name: s
|
|
2140
2185
|
}), await we(a.path, s, "module", String(a.id)) && o.succeed(`模块重命名成功: ${a.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), a.id;
|
|
@@ -2142,10 +2187,10 @@ async function qa(e, t) {
|
|
|
2142
2187
|
async function Ha(e, t) {
|
|
2143
2188
|
const { type: i, typeStr: n } = await je("修改", e), { localProduct: a } = await Se(t.productId);
|
|
2144
2189
|
let s;
|
|
2145
|
-
if (R.MODULE === i ? s = await
|
|
2146
|
-
const o =
|
|
2190
|
+
if (R.MODULE === i ? s = await Ka(a, t) : R.CASE === i && (s = await qa(a, t)), !t.disableAutoCommit && await m("git status -s")) {
|
|
2191
|
+
const o = y("代码提交中...").start();
|
|
2147
2192
|
try {
|
|
2148
|
-
await
|
|
2193
|
+
await m(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
|
|
2149
2194
|
} catch (r) {
|
|
2150
2195
|
o.fail(`提交失败,${r}`), process.exit(1);
|
|
2151
2196
|
}
|
|
@@ -2155,10 +2200,10 @@ D.command("qa-update").alias("qu").description("修改模块或者用例").argum
|
|
|
2155
2200
|
async function Za(e, t) {
|
|
2156
2201
|
if (!e.length)
|
|
2157
2202
|
return [];
|
|
2158
|
-
const i =
|
|
2203
|
+
const i = xt(20), n = e.map(
|
|
2159
2204
|
(a) => i(async () => {
|
|
2160
2205
|
try {
|
|
2161
|
-
const s = t.env || "production", o = await
|
|
2206
|
+
const s = t.env || "production", o = await m(`python ${a.path}/main.py --env ${s}`);
|
|
2162
2207
|
try {
|
|
2163
2208
|
a.result = JSON.parse(o);
|
|
2164
2209
|
} catch {
|
|
@@ -2172,7 +2217,7 @@ async function Za(e, t) {
|
|
|
2172
2217
|
);
|
|
2173
2218
|
return await Promise.all(n), e;
|
|
2174
2219
|
}
|
|
2175
|
-
async function
|
|
2220
|
+
async function Ya(e) {
|
|
2176
2221
|
ne(), Q();
|
|
2177
2222
|
const { localProduct: t } = await Se(e.productId);
|
|
2178
2223
|
let i = [];
|
|
@@ -2184,7 +2229,7 @@ async function Ka(e) {
|
|
|
2184
2229
|
displayName: c.displayName
|
|
2185
2230
|
}));
|
|
2186
2231
|
else {
|
|
2187
|
-
const c =
|
|
2232
|
+
const c = Oe(e.caseIds);
|
|
2188
2233
|
if (c.length)
|
|
2189
2234
|
i = a.filter((u) => c.includes(Number(u.id))).map((u) => ({
|
|
2190
2235
|
id: Number(u.id),
|
|
@@ -2198,7 +2243,7 @@ async function Ka(e) {
|
|
|
2198
2243
|
path: d.path,
|
|
2199
2244
|
displayName: d.displayName
|
|
2200
2245
|
},
|
|
2201
|
-
name: d.path.replace(
|
|
2246
|
+
name: d.path.replace(p.resolve(t.path), "")
|
|
2202
2247
|
}));
|
|
2203
2248
|
i = await ae({
|
|
2204
2249
|
message: "选择要执行的用例",
|
|
@@ -2211,25 +2256,25 @@ async function Ka(e) {
|
|
|
2211
2256
|
});
|
|
2212
2257
|
}
|
|
2213
2258
|
}
|
|
2214
|
-
const s =
|
|
2259
|
+
const s = y("用例执行中...").start(), r = (await Za(i, e)).filter((c) => c.result.length);
|
|
2215
2260
|
if (r.length === 0)
|
|
2216
2261
|
s.succeed("所有用例执行通过 🎉");
|
|
2217
2262
|
else {
|
|
2218
2263
|
if (e.processStep === "1")
|
|
2219
|
-
return
|
|
2264
|
+
return W("执行报告如下:"), console.log(JSON.stringify(r, null, 2)), process.exit(0);
|
|
2220
2265
|
const c = r.reduce((f, g) => f + g.result.length, 0);
|
|
2221
2266
|
s.warn(`【${r.length}】个用例执行出错,【${c}】个BUG将创建。`);
|
|
2222
2267
|
let u = 0;
|
|
2223
2268
|
if (e.executionId)
|
|
2224
2269
|
Number.isNaN(Number(e.executionId)) && l(`executionId ${e.executionId}不是正整数`), u = Number(e.executionId);
|
|
2225
2270
|
else {
|
|
2226
|
-
const f = await Qi(), g = await
|
|
2271
|
+
const f = await Qi(), g = await k({
|
|
2227
2272
|
message: "请选择用例执行出错后,BUG所属的项目",
|
|
2228
|
-
choices: f.map(({ id:
|
|
2273
|
+
choices: f.map(({ id: T, name: ee }) => ({ name: ee, value: T }))
|
|
2229
2274
|
}), h = await ea(g);
|
|
2230
|
-
u = await
|
|
2275
|
+
u = await k({
|
|
2231
2276
|
message: "请选择用例执行出错后,BUG所属的执行",
|
|
2232
|
-
choices: h.map(({ id:
|
|
2277
|
+
choices: h.map(({ id: T, name: ee }) => ({ name: ee, value: T }))
|
|
2233
2278
|
});
|
|
2234
2279
|
}
|
|
2235
2280
|
let d;
|
|
@@ -2241,9 +2286,9 @@ async function Ka(e) {
|
|
|
2241
2286
|
const g = await Ce({
|
|
2242
2287
|
message: "请选择BUG关联的构建版本(可多选;非必选,默认主干)",
|
|
2243
2288
|
required: !1,
|
|
2244
|
-
choices: f.map(({ id: h, name:
|
|
2289
|
+
choices: f.map(({ id: h, name: T, date: ee, builder: P }) => ({
|
|
2245
2290
|
value: h,
|
|
2246
|
-
name: `${
|
|
2291
|
+
name: `${T} ${P} ${ee}`
|
|
2247
2292
|
}))
|
|
2248
2293
|
});
|
|
2249
2294
|
g.length ? d = g.join(",") : d = "";
|
|
@@ -2256,7 +2301,7 @@ async function Ka(e) {
|
|
|
2256
2301
|
caseId: f.id,
|
|
2257
2302
|
caseResult: "fail",
|
|
2258
2303
|
stepResults: f.result,
|
|
2259
|
-
runner:
|
|
2304
|
+
runner: E("ldapAccount"),
|
|
2260
2305
|
executionId: u,
|
|
2261
2306
|
openedBuild: d
|
|
2262
2307
|
});
|
|
@@ -2265,17 +2310,17 @@ async function Ka(e) {
|
|
|
2265
2310
|
);
|
|
2266
2311
|
}
|
|
2267
2312
|
}
|
|
2268
|
-
D.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认主干(trunk)").action((...e) => z(
|
|
2269
|
-
function
|
|
2313
|
+
D.command("qa-exec").alias("qe").description("执行用例").option("--product-id <productId>", "指定产品ID").option("--case-ids <caseIds>", "可传指定用例ID。可传N个,逗号隔开").option("--all", "执行产品下所有用例").option("--concurrency <concurrency>", "最多并行执行脚本数。默认20").option("--process-step <step>", "不传默认2。 1. 仅在本地返回执行报告; 2. 执行出错的结果提交到禅道用例并提交BUG。").option("--env <env>", "环境变量,会作为参数传递给执行脚本。默认production").option("--execution-id <executionId>", "提bug时,要关联的禅道执行ID").option("--build-id <buildId>", "提bug时,要关联的禅道执行构建ID。默认主干(trunk)").action((...e) => z(Ya, ...e));
|
|
2314
|
+
function Xa() {
|
|
2270
2315
|
process.on("unhandledRejection", (e) => {
|
|
2271
2316
|
}), process.on("uncaughtException", (e) => {
|
|
2272
|
-
}),
|
|
2317
|
+
}), O.config.fatal = !0, O.config.silent = !0, O.config.verbose = !1;
|
|
2273
2318
|
}
|
|
2274
|
-
async function
|
|
2319
|
+
async function Qa() {
|
|
2275
2320
|
const e = ge("latestCheckVersionTimestamp"), t = ge("versionCheckDuring");
|
|
2276
2321
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
2277
2322
|
const i = await at();
|
|
2278
|
-
|
|
2323
|
+
xe(i);
|
|
2279
2324
|
let n;
|
|
2280
2325
|
try {
|
|
2281
2326
|
const a = "TIME_OUT", s = new Promise((o) => {
|
|
@@ -2283,24 +2328,24 @@ async function Xa() {
|
|
|
2283
2328
|
});
|
|
2284
2329
|
n = await Promise.race([
|
|
2285
2330
|
s,
|
|
2286
|
-
|
|
2287
|
-
]), n !== a && n !== ie.version && (console.log(`${S.blue(ie.name)}本地版本为${ie.version},低于线上版本${n},开始升级`), await
|
|
2331
|
+
m(`npm view ${ie.name} version --registry https://registry.npmmirror.com/`)
|
|
2332
|
+
]), n !== a && n !== ie.version && (console.log(`${S.blue(ie.name)}本地版本为${ie.version},低于线上版本${n},开始升级`), await mt(n)), ue("latestCheckVersionTimestamp", Date.now()), se();
|
|
2288
2333
|
} catch (a) {
|
|
2289
2334
|
console.log("升级出错!请重试,或者手动升级"), l(a);
|
|
2290
2335
|
}
|
|
2291
2336
|
}
|
|
2292
2337
|
}
|
|
2293
|
-
async function
|
|
2294
|
-
const e =
|
|
2338
|
+
async function en() {
|
|
2339
|
+
const e = It(process.argv.slice(2));
|
|
2295
2340
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2296
2341
|
if (Ye()) {
|
|
2297
|
-
const t =
|
|
2298
|
-
M(t.profile), ue(t.main),
|
|
2342
|
+
const t = x.readJSONSync(be());
|
|
2343
|
+
M(t.profile), ue(t.main), xe(t.constants), await Qa();
|
|
2299
2344
|
} else
|
|
2300
|
-
l(`请先初始化z-develop(执行 z i)。更多见${
|
|
2345
|
+
l(`请先初始化z-develop(执行 z i)。更多见${Ke}`);
|
|
2301
2346
|
}
|
|
2302
|
-
async function
|
|
2303
|
-
|
|
2347
|
+
async function tn() {
|
|
2348
|
+
Xa(), await en();
|
|
2304
2349
|
}
|
|
2305
|
-
D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(
|
|
2350
|
+
D.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${S.blue(Ke)}`).usage("<command> [options]").hook("preAction", tn).version(ie.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
2306
2351
|
D.parse();
|