cli-z-develop 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.js +334 -331
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { program as x } from "commander";
|
|
2
|
-
import
|
|
3
|
-
import { existsSync as $, readdirSync as
|
|
2
|
+
import yt from "node:child_process";
|
|
3
|
+
import { existsSync as $, readdirSync as $t, lstatSync as vt } from "node:fs";
|
|
4
|
+
import { readdir as je, mkdir as se, writeFile as M, rename as Fe, readFile as Se, stat as bt } from "node:fs/promises";
|
|
4
5
|
import l from "node:path";
|
|
5
|
-
import le, { AxiosError as
|
|
6
|
+
import le, { AxiosError as Nt } from "axios";
|
|
6
7
|
import N from "chalk";
|
|
7
|
-
import
|
|
8
|
+
import St from "dayjs";
|
|
8
9
|
import D from "shelljs";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import { confirm as Fe, select as T, input as _, password as At, checkbox as Le, number as Pe } from "@inquirer/prompts";
|
|
10
|
+
import jt from "node:os";
|
|
11
|
+
import Le from "child_process";
|
|
12
|
+
import { confirm as _e, select as E, input as _, password as At, checkbox as Pe, number as Oe } from "@inquirer/prompts";
|
|
13
13
|
import w from "ora";
|
|
14
14
|
import j from "fs-extra";
|
|
15
15
|
import { select as re } from "inquirer-select-pro";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
16
|
+
import Et from "lint-staged";
|
|
17
|
+
import Tt from "semver";
|
|
18
18
|
import { run as kt } from "npm-check-updates";
|
|
19
19
|
import Ct from "minimist";
|
|
20
|
-
const
|
|
21
|
-
var v = /* @__PURE__ */ ((e) => (e[e.DEV =
|
|
22
|
-
const
|
|
20
|
+
const Be = "dev", Ue = "test", Je = "release", Rt = "production", It = "master";
|
|
21
|
+
var v = /* @__PURE__ */ ((e) => (e[e.DEV = Be] = "DEV", e[e.TEST = Ue] = "TEST", e[e.RELEASE = Je] = "RELEASE", e[e.PROD = Rt] = "PROD", e))(v || {}), h = /* @__PURE__ */ ((e) => (e[e.DEV = Be] = "DEV", e[e.TEST = Ue] = "TEST", e[e.RELEASE = Je] = "RELEASE", e[e.MASTER = It] = "MASTER", e))(h || {}), H = /* @__PURE__ */ ((e) => (e.H5 = "h5", e.NPM = "npm", e.SERVER = "server", e))(H || {});
|
|
22
|
+
const Ge = [
|
|
23
23
|
{
|
|
24
24
|
name: `开发环境 - ${v.DEV}`,
|
|
25
25
|
value: v.DEV
|
|
@@ -66,7 +66,7 @@ const xt = {
|
|
|
66
66
|
9: "其他"
|
|
67
67
|
}, me = "http://git.cxlqd.com", Lt = ["fe-biz", "fe-base", "fe-tpl", "fe-component", "fe-demo"];
|
|
68
68
|
var b = /* @__PURE__ */ ((e) => (e.FEAT = "feat", e.FIX = "fix", e.REFACTOR = "refactor", e.CHORE = "chore", e.CI = "ci", e.Break = "BREAKING CHANGE", e))(b || {});
|
|
69
|
-
const Pt = "fe-biz7tvsd",
|
|
69
|
+
const Pt = "fe-biz7tvsd", We = "https://hxhtbr8t8uy.feishu.cn/wiki/LWW5wAQFPiXkmRkKcjOcyDDknLg";
|
|
70
70
|
var S = /* @__PURE__ */ ((e) => (e.MODULE = "module", e.CASE = "case", e))(S || {});
|
|
71
71
|
const Ot = [
|
|
72
72
|
{
|
|
@@ -83,17 +83,17 @@ const Ot = [
|
|
|
83
83
|
function k(e = "") {
|
|
84
84
|
return l.join(q, e);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function Ae() {
|
|
87
87
|
return k(_t);
|
|
88
88
|
}
|
|
89
89
|
function we() {
|
|
90
90
|
return k(Ft);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
92
|
+
function Ve() {
|
|
93
|
+
Le.spawnSync("git", ["config", "core.hooksPath", k()]), Le.spawnSync("git", ["config", "commit.template", we()]);
|
|
94
94
|
}
|
|
95
95
|
function de(e = "") {
|
|
96
|
-
return l.resolve(
|
|
96
|
+
return l.resolve(jt.homedir(), Mt, e);
|
|
97
97
|
}
|
|
98
98
|
function ye() {
|
|
99
99
|
return de(zt);
|
|
@@ -101,10 +101,10 @@ function ye() {
|
|
|
101
101
|
function Bt() {
|
|
102
102
|
return $(de());
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function qe() {
|
|
105
105
|
return Bt() && $(ye());
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function He(e) {
|
|
108
108
|
let t = e.trim();
|
|
109
109
|
const i = t.match(/^git@([^:]+):(.+)$/);
|
|
110
110
|
if (i)
|
|
@@ -115,25 +115,25 @@ function qe(e) {
|
|
|
115
115
|
}
|
|
116
116
|
return encodeURIComponent(t.replace(/\.git$/, ""));
|
|
117
117
|
}
|
|
118
|
-
const { red:
|
|
118
|
+
const { red: Me, green: Ut, blue: on, magenta: Jt } = N;
|
|
119
119
|
function ge(...e) {
|
|
120
120
|
}
|
|
121
121
|
function J(...e) {
|
|
122
122
|
console.log(Ut(...e));
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function Ze(e) {
|
|
125
125
|
e instanceof Error && (e.name === "ExitPromptError" || e.message.includes("User force closed the prompt with")) && (console.log(), console.log(N.cyan(" 👋 下次见~")), console.log(), process.exit(1));
|
|
126
126
|
}
|
|
127
127
|
function m(e, t = !1) {
|
|
128
|
-
|
|
128
|
+
Ze(e);
|
|
129
129
|
let i = e;
|
|
130
|
-
e instanceof Error ? (i = e.message, le.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(
|
|
130
|
+
e instanceof Error ? (i = e.message, le.isAxiosError(e) && (i = `请求失败:${e.message}`), console.log(Me(i)), console.log(Jt(e.stack))) : console.log(Me(e)), t || process.exit(1);
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
return $(e) ?
|
|
132
|
+
function ze(e) {
|
|
133
|
+
return $(e) ? vt(e).isDirectory() : !1;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
return
|
|
135
|
+
function Ke(e = process.cwd()) {
|
|
136
|
+
return ze(e) ? $t(e).filter((i) => ze(l.resolve(e, i))) : [];
|
|
137
137
|
}
|
|
138
138
|
async function u(e, t = {
|
|
139
139
|
removeTailLinkBreak: !0,
|
|
@@ -151,13 +151,13 @@ async function u(e, t = {
|
|
|
151
151
|
});
|
|
152
152
|
return i = i.toString(), t.removeTailLinkBreak && (i = i.replace(/\n$/, "")), i;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
154
|
+
function Qe(e) {
|
|
155
|
+
yt.execSync(e, {
|
|
156
156
|
stdio: "inherit"
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
return
|
|
159
|
+
function Ye() {
|
|
160
|
+
return St(Date.now()).format("YYMMDD");
|
|
161
161
|
}
|
|
162
162
|
function Gt(e, t) {
|
|
163
163
|
for (const i of t)
|
|
@@ -184,10 +184,13 @@ async function z(e, ...t) {
|
|
|
184
184
|
try {
|
|
185
185
|
await e(...t);
|
|
186
186
|
} catch (i) {
|
|
187
|
-
throw
|
|
187
|
+
throw Ze(i), i;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
function qt(e
|
|
190
|
+
async function qt(e) {
|
|
191
|
+
return (await je(e)).length === 0;
|
|
192
|
+
}
|
|
193
|
+
function Ht(e = "项目中文名", t = "项目描述") {
|
|
191
194
|
return `
|
|
192
195
|
# ${e}
|
|
193
196
|
${t}
|
|
@@ -244,7 +247,7 @@ ${t}
|
|
|
244
247
|
在此处放入飞书文档链接。请在[前端团队-项目手册](https://hxhtbr8t8uy.feishu.cn/drive/folder/QfQ7favVWljQk7d63Prc8mUGnJf)中按照分类新建文档。
|
|
245
248
|
`;
|
|
246
249
|
}
|
|
247
|
-
const
|
|
250
|
+
const Zt = `{
|
|
248
251
|
"printWidth": 120,
|
|
249
252
|
"tabWidth": 2,
|
|
250
253
|
"useTabs": false,
|
|
@@ -265,7 +268,7 @@ const Ht = `{
|
|
|
265
268
|
"embeddedLanguageFormatting": "auto",
|
|
266
269
|
"singleAttributePerLine": false
|
|
267
270
|
}
|
|
268
|
-
`,
|
|
271
|
+
`, Kt = `# 系统 信息文件
|
|
269
272
|
.DS_Store/
|
|
270
273
|
Thumbs.db
|
|
271
274
|
|
|
@@ -287,7 +290,7 @@ dist/
|
|
|
287
290
|
|
|
288
291
|
# 垃圾文件
|
|
289
292
|
.Trashes
|
|
290
|
-
`,
|
|
293
|
+
`, Qt = {
|
|
291
294
|
[I.JAVA]: {
|
|
292
295
|
// TODO: 需要优化
|
|
293
296
|
// "**/*.{java}": "java -jar ./.z/checkstyle.jar -c ./.z/checkstyle.xml",
|
|
@@ -302,7 +305,7 @@ dist/
|
|
|
302
305
|
// "**/*.{py}": "python --fix",
|
|
303
306
|
"**/*.{py}": "echo 'todo'"
|
|
304
307
|
}
|
|
305
|
-
},
|
|
308
|
+
}, Yt = `[
|
|
306
309
|
{
|
|
307
310
|
"Precondition": "前置条件",
|
|
308
311
|
"Title": "用例名称",
|
|
@@ -311,17 +314,17 @@ dist/
|
|
|
311
314
|
"Method": "接口类型",
|
|
312
315
|
"Expected": "期望结果"
|
|
313
316
|
}
|
|
314
|
-
]`,
|
|
315
|
-
name:
|
|
316
|
-
version:
|
|
317
|
-
description:
|
|
318
|
-
main:
|
|
319
|
-
bin:
|
|
320
|
-
scripts:
|
|
321
|
-
type:
|
|
322
|
-
author:
|
|
323
|
-
devDependencies:
|
|
324
|
-
dependencies:
|
|
317
|
+
]`, Xt = "# from assets", ei = "cli-z-develop", ti = "0.10.1", ii = "技术团队开发流程管理工具", ai = "dist/index.js", ni = { z: "bin/z.js", "z-develop": "bin/z.js" }, si = { 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" }, ri = "module", oi = "z", ci = { "@lonely9/eslint-config-team": "^1.3.5", "@tsconfig/node22": "^22.0.5", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.9", "@types/minimist": "^1.2.5", "@types/node": "^22.15.29", "@types/semver": "^7.7.1", "@types/shelljs": "^0.10.0", "@typescript-eslint/eslint-plugin": "^8.53.0", "@typescript-eslint/parser": "^8.53.0", eslint: "^9.39.2", jiti: "^2.6.1", prettier: "^3.7.4", typescript: "^5.9.3", vite: "^7.3.1", "vue-tsc": "^3.2.2" }, ui = { "@inquirer/prompts": "^8.2.0", axios: "^1.13.6", chalk: "^5.6.2", commander: "^14.0.2", dayjs: "^1.11.19", "fs-extra": "^11.3.3", "inquirer-select-pro": "^1.0.0-alpha.9", "lint-staged": "^16.2.7", minimist: "^1.2.8", "npm-check-updates": "^19.3.1", ora: "^9.0.0", semver: "^7.7.3", shelljs: "^0.10.0" }, Q = {
|
|
318
|
+
name: ei,
|
|
319
|
+
version: ti,
|
|
320
|
+
description: ii,
|
|
321
|
+
main: ai,
|
|
322
|
+
bin: ni,
|
|
323
|
+
scripts: si,
|
|
324
|
+
type: ri,
|
|
325
|
+
author: oi,
|
|
326
|
+
devDependencies: ci,
|
|
327
|
+
dependencies: ui
|
|
325
328
|
}, C = {
|
|
326
329
|
// 个人数据
|
|
327
330
|
profile: {
|
|
@@ -371,21 +374,21 @@ function $e() {
|
|
|
371
374
|
const e = l.join("package.json");
|
|
372
375
|
return $(e) || m(`当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令。`), B = j.readJsonSync(e), B;
|
|
373
376
|
}
|
|
374
|
-
function
|
|
377
|
+
function Ee() {
|
|
375
378
|
if (U)
|
|
376
379
|
return U;
|
|
377
|
-
const e =
|
|
380
|
+
const e = Ae();
|
|
378
381
|
return $(e) || m(
|
|
379
382
|
`当前目录(${D.pwd()})不存在${e}文件,请在项目根目录执行该命令,或者初始化项目(z init .)。`
|
|
380
383
|
), U = j.readJsonSync(e), U;
|
|
381
384
|
}
|
|
382
|
-
function
|
|
385
|
+
function li(e) {
|
|
383
386
|
U ? U = {
|
|
384
387
|
...U,
|
|
385
388
|
...e
|
|
386
|
-
} : U = e, j.writeJSONSync(
|
|
389
|
+
} : U = e, j.writeJSONSync(Ae(), U, { spaces: 2 });
|
|
387
390
|
}
|
|
388
|
-
function
|
|
391
|
+
function mi(e) {
|
|
389
392
|
B ? B = {
|
|
390
393
|
...B,
|
|
391
394
|
...e
|
|
@@ -398,10 +401,10 @@ const V = {
|
|
|
398
401
|
sourceBranch: "",
|
|
399
402
|
mergeRequestUrl: ""
|
|
400
403
|
};
|
|
401
|
-
async function
|
|
404
|
+
async function pi() {
|
|
402
405
|
if (!V.id)
|
|
403
406
|
try {
|
|
404
|
-
const e =
|
|
407
|
+
const e = Ee(), t = He(e.repository.url), i = await tt(t);
|
|
405
408
|
V.id = i.id, V.path = t, V.group = i.namespace.full_path, V.mergeRequestUrl = `${i.web_url}/merge_requests`;
|
|
406
409
|
} catch (e) {
|
|
407
410
|
m(e);
|
|
@@ -452,10 +455,10 @@ async function Z(e) {
|
|
|
452
455
|
const o = await le(s);
|
|
453
456
|
return ge(N.green("Response"), N.grey(JSON.stringify(o.data, null, 2))), Promise.resolve(o.data);
|
|
454
457
|
} catch (s) {
|
|
455
|
-
return s instanceof
|
|
458
|
+
return s instanceof Nt && ge(N.red("Error"), N.grey(JSON.stringify(s?.response?.data))), Promise.reject(s);
|
|
456
459
|
}
|
|
457
460
|
}
|
|
458
|
-
async function
|
|
461
|
+
async function di() {
|
|
459
462
|
const e = A("gitToken");
|
|
460
463
|
if (e)
|
|
461
464
|
return e;
|
|
@@ -476,11 +479,11 @@ async function R(e) {
|
|
|
476
479
|
return Z({
|
|
477
480
|
...e,
|
|
478
481
|
headers: {
|
|
479
|
-
Authorization: await
|
|
482
|
+
Authorization: await di()
|
|
480
483
|
}
|
|
481
484
|
});
|
|
482
485
|
}
|
|
483
|
-
async function
|
|
486
|
+
async function fi() {
|
|
484
487
|
const e = A("zenTaoToken");
|
|
485
488
|
if (e)
|
|
486
489
|
return e;
|
|
@@ -500,7 +503,7 @@ async function he(e) {
|
|
|
500
503
|
const t = await Z({
|
|
501
504
|
...e,
|
|
502
505
|
headers: {
|
|
503
|
-
Token: await
|
|
506
|
+
Token: await fi()
|
|
504
507
|
}
|
|
505
508
|
});
|
|
506
509
|
if (e.url.includes("local")) {
|
|
@@ -523,7 +526,7 @@ async function he(e) {
|
|
|
523
526
|
return {};
|
|
524
527
|
}
|
|
525
528
|
}
|
|
526
|
-
async function
|
|
529
|
+
async function gi() {
|
|
527
530
|
const e = A("k8sToken");
|
|
528
531
|
if (e)
|
|
529
532
|
return e;
|
|
@@ -542,56 +545,56 @@ async function fi() {
|
|
|
542
545
|
return L("k8sToken", i), te(), i;
|
|
543
546
|
}
|
|
544
547
|
}
|
|
545
|
-
async function
|
|
548
|
+
async function Xe(e) {
|
|
546
549
|
const t = await Z({
|
|
547
550
|
...e,
|
|
548
551
|
headers: {
|
|
549
|
-
Authorization: await
|
|
552
|
+
Authorization: await gi()
|
|
550
553
|
}
|
|
551
554
|
});
|
|
552
|
-
return t.code === 401 ? (L("k8sToken", ""),
|
|
555
|
+
return t.code === 401 ? (L("k8sToken", ""), Xe({
|
|
553
556
|
...e
|
|
554
557
|
})) : t;
|
|
555
558
|
}
|
|
556
|
-
const P = () => `${me}/api/v4`,
|
|
557
|
-
function
|
|
559
|
+
const P = () => `${me}/api/v4`, ke = (e) => `${P()}/projects/100/repository/files/${encodeURIComponent(e)}/raw?ref=master`;
|
|
560
|
+
function hi() {
|
|
558
561
|
return R({
|
|
559
|
-
url:
|
|
562
|
+
url: ke("src/data/template-projects.json")
|
|
560
563
|
});
|
|
561
564
|
}
|
|
562
|
-
function
|
|
565
|
+
function et() {
|
|
563
566
|
return R({
|
|
564
|
-
url:
|
|
567
|
+
url: ke("src/data/z-develop-config.json")
|
|
565
568
|
});
|
|
566
569
|
}
|
|
567
|
-
function
|
|
570
|
+
function wi() {
|
|
568
571
|
return R({
|
|
569
|
-
url:
|
|
572
|
+
url: ke("src/data/project-group-chats.json")
|
|
570
573
|
});
|
|
571
574
|
}
|
|
572
|
-
function
|
|
575
|
+
function yi() {
|
|
573
576
|
return R({
|
|
574
577
|
url: `${P()}/user`
|
|
575
578
|
});
|
|
576
579
|
}
|
|
577
|
-
function
|
|
580
|
+
function $i() {
|
|
578
581
|
return R({
|
|
579
582
|
url: `${P()}/groups`
|
|
580
583
|
});
|
|
581
584
|
}
|
|
582
|
-
function
|
|
585
|
+
function vi(e) {
|
|
583
586
|
return R({
|
|
584
587
|
url: `${P()}/projects`,
|
|
585
588
|
method: "post",
|
|
586
589
|
data: e
|
|
587
590
|
});
|
|
588
591
|
}
|
|
589
|
-
function
|
|
592
|
+
function tt(e) {
|
|
590
593
|
return R({
|
|
591
594
|
url: `${P()}/projects/${e}`
|
|
592
595
|
});
|
|
593
596
|
}
|
|
594
|
-
function
|
|
597
|
+
function bi(e) {
|
|
595
598
|
return R({
|
|
596
599
|
url: `${P()}/projects`,
|
|
597
600
|
data: {
|
|
@@ -600,33 +603,33 @@ function vi(e) {
|
|
|
600
603
|
}
|
|
601
604
|
});
|
|
602
605
|
}
|
|
603
|
-
function
|
|
606
|
+
function Ni(e) {
|
|
604
607
|
return R({
|
|
605
608
|
url: `${P()}/projects/${e.id}/merge_requests`,
|
|
606
609
|
method: "post",
|
|
607
610
|
data: e
|
|
608
611
|
});
|
|
609
612
|
}
|
|
610
|
-
function
|
|
613
|
+
function Si(e) {
|
|
611
614
|
return R({
|
|
612
615
|
url: `${P()}/projects/${e.id}/merge_requests/${e.iid}/merge`,
|
|
613
616
|
method: "put"
|
|
614
617
|
});
|
|
615
618
|
}
|
|
616
|
-
function
|
|
619
|
+
function ji(e) {
|
|
617
620
|
return R({
|
|
618
621
|
url: `${P()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
619
622
|
method: "put",
|
|
620
623
|
data: e
|
|
621
624
|
});
|
|
622
625
|
}
|
|
623
|
-
function
|
|
626
|
+
function Ai(e) {
|
|
624
627
|
return R({
|
|
625
628
|
url: `${P()}/projects/${e.id}/merge_requests/${e.iid}`,
|
|
626
629
|
method: "get"
|
|
627
630
|
});
|
|
628
631
|
}
|
|
629
|
-
function
|
|
632
|
+
function Ei(e) {
|
|
630
633
|
return R({
|
|
631
634
|
url: `${P()}/projects/${e.id}/repository/branches`,
|
|
632
635
|
method: "post",
|
|
@@ -638,12 +641,12 @@ function Ti(e) {
|
|
|
638
641
|
url: `${P()}/projects/${e}/repository/branches`
|
|
639
642
|
});
|
|
640
643
|
}
|
|
641
|
-
function
|
|
644
|
+
function ki() {
|
|
642
645
|
const e = de("fe-groups.json");
|
|
643
646
|
return $(e) ? j.readJSONSync(e) : { groups: [] };
|
|
644
647
|
}
|
|
645
|
-
async function
|
|
646
|
-
const e = await
|
|
648
|
+
async function Ci() {
|
|
649
|
+
const e = await $i(), t = Lt.map((i) => {
|
|
647
650
|
const n = e.find((a) => a.name === i);
|
|
648
651
|
return n ? {
|
|
649
652
|
name: n.name,
|
|
@@ -653,7 +656,7 @@ async function ki() {
|
|
|
653
656
|
}).filter((i) => !!i);
|
|
654
657
|
j.writeJSONSync(de("fe-groups.json"), { groups: t }, { spaces: 2 });
|
|
655
658
|
}
|
|
656
|
-
async function
|
|
659
|
+
async function T(e) {
|
|
657
660
|
const t = `${ee("FEServerDomain")}/api`, { data: i } = await Z({
|
|
658
661
|
url: `${t}/auth/z-develop/login`,
|
|
659
662
|
method: "post"
|
|
@@ -667,34 +670,34 @@ async function E(e) {
|
|
|
667
670
|
});
|
|
668
671
|
return n.code !== 0 && m(`${n.code}: ${n.message}`), n.data;
|
|
669
672
|
}
|
|
670
|
-
function
|
|
671
|
-
return
|
|
673
|
+
function Ri() {
|
|
674
|
+
return T({
|
|
672
675
|
url: "/user/list2"
|
|
673
676
|
});
|
|
674
677
|
}
|
|
675
|
-
function
|
|
676
|
-
return
|
|
678
|
+
function Ii() {
|
|
679
|
+
return T({
|
|
677
680
|
url: "/zen/testcase/product/list"
|
|
678
681
|
});
|
|
679
682
|
}
|
|
680
|
-
function
|
|
681
|
-
return
|
|
683
|
+
function it(e) {
|
|
684
|
+
return T({
|
|
682
685
|
url: "/zen/testcase/product/module/list",
|
|
683
686
|
data: {
|
|
684
687
|
product: e
|
|
685
688
|
}
|
|
686
689
|
});
|
|
687
690
|
}
|
|
688
|
-
function
|
|
689
|
-
return
|
|
691
|
+
function Di(e) {
|
|
692
|
+
return T({
|
|
690
693
|
url: "/zen/testcase/product/name",
|
|
691
694
|
data: {
|
|
692
695
|
product: e
|
|
693
696
|
}
|
|
694
697
|
});
|
|
695
698
|
}
|
|
696
|
-
function
|
|
697
|
-
return
|
|
699
|
+
function xi(e, t) {
|
|
700
|
+
return T({
|
|
698
701
|
url: "/zen/testcase/product/auto-case/list",
|
|
699
702
|
data: {
|
|
700
703
|
product: e,
|
|
@@ -702,69 +705,69 @@ function Di(e, t) {
|
|
|
702
705
|
}
|
|
703
706
|
});
|
|
704
707
|
}
|
|
705
|
-
function
|
|
706
|
-
return
|
|
708
|
+
function Li(e) {
|
|
709
|
+
return T({
|
|
707
710
|
url: "/zen/testcase/step/list",
|
|
708
711
|
data: {
|
|
709
712
|
id: e
|
|
710
713
|
}
|
|
711
714
|
});
|
|
712
715
|
}
|
|
713
|
-
function
|
|
714
|
-
return
|
|
716
|
+
function Pi(e) {
|
|
717
|
+
return T({
|
|
715
718
|
url: "/zen/testcase/module/create",
|
|
716
719
|
data: e
|
|
717
720
|
});
|
|
718
721
|
}
|
|
719
|
-
function
|
|
720
|
-
return
|
|
722
|
+
function Oi(e) {
|
|
723
|
+
return T({
|
|
721
724
|
url: "/zen/testcase/create",
|
|
722
725
|
data: e
|
|
723
726
|
});
|
|
724
727
|
}
|
|
725
|
-
function
|
|
726
|
-
return
|
|
728
|
+
function Mi(e) {
|
|
729
|
+
return T({
|
|
727
730
|
url: "/zen/testcase/step/create",
|
|
728
731
|
data: e
|
|
729
732
|
});
|
|
730
733
|
}
|
|
731
|
-
function
|
|
732
|
-
return
|
|
734
|
+
function zi(e) {
|
|
735
|
+
return T({
|
|
733
736
|
url: "/zen/testcase/modules/remove",
|
|
734
737
|
data: e
|
|
735
738
|
});
|
|
736
739
|
}
|
|
737
|
-
function
|
|
738
|
-
return
|
|
740
|
+
function Fi(e) {
|
|
741
|
+
return T({
|
|
739
742
|
url: "/zen/testcase/cases/remove",
|
|
740
743
|
data: e
|
|
741
744
|
});
|
|
742
745
|
}
|
|
743
|
-
function
|
|
744
|
-
return
|
|
746
|
+
function _i(e) {
|
|
747
|
+
return T({
|
|
745
748
|
url: "/zen/testcase/module/update/name",
|
|
746
749
|
data: e
|
|
747
750
|
});
|
|
748
751
|
}
|
|
749
|
-
function
|
|
750
|
-
return
|
|
752
|
+
function Bi(e) {
|
|
753
|
+
return T({
|
|
751
754
|
url: "/zen/testcase/case/update/name",
|
|
752
755
|
data: e
|
|
753
756
|
});
|
|
754
757
|
}
|
|
755
|
-
function
|
|
756
|
-
return
|
|
758
|
+
function Ui(e) {
|
|
759
|
+
return T({
|
|
757
760
|
url: "/zen/testcase/case/update/priority",
|
|
758
761
|
data: e
|
|
759
762
|
});
|
|
760
763
|
}
|
|
761
|
-
function
|
|
762
|
-
return
|
|
764
|
+
function Ji(e) {
|
|
765
|
+
return T({
|
|
763
766
|
url: "/zen/testcase/case/update/precondition",
|
|
764
767
|
data: e
|
|
765
768
|
});
|
|
766
769
|
}
|
|
767
|
-
function
|
|
770
|
+
function Gi(e, t) {
|
|
768
771
|
const i = [];
|
|
769
772
|
t.forEach((s) => {
|
|
770
773
|
e.includes(s.value) && i.push(s);
|
|
@@ -780,8 +783,8 @@ function Ji(e, t) {
|
|
|
780
783
|
weWorkListCache: n.sort((s, o) => o.usageCount - s.usageCount)
|
|
781
784
|
}), te();
|
|
782
785
|
}
|
|
783
|
-
async function
|
|
784
|
-
const t = (await
|
|
786
|
+
async function at() {
|
|
787
|
+
const t = (await Ri()).filter((s) => [1, 2, 3, 4, 5].includes(s.title)).map((s) => ({
|
|
785
788
|
name: `${s.nick} - ${xt[s.title]}`,
|
|
786
789
|
value: s.weWorkUserId
|
|
787
790
|
})), i = pe("weWorkListCache"), n = i.map((s) => s.value), a = [];
|
|
@@ -793,8 +796,8 @@ async function it() {
|
|
|
793
796
|
});
|
|
794
797
|
}), a.sort((s, o) => o.usageCount - s.usageCount);
|
|
795
798
|
}
|
|
796
|
-
async function
|
|
797
|
-
const n = await
|
|
799
|
+
async function nt(e, t, i) {
|
|
800
|
+
const n = await at();
|
|
798
801
|
let a = await re({
|
|
799
802
|
message: e,
|
|
800
803
|
loop: !0,
|
|
@@ -804,10 +807,10 @@ async function at(e, t, i) {
|
|
|
804
807
|
options: (s) => s ? n.filter((o) => o.name.includes(s)) : n,
|
|
805
808
|
validate: t
|
|
806
809
|
});
|
|
807
|
-
return a = Array.isArray(a) ? a : [a],
|
|
810
|
+
return a = Array.isArray(a) ? a : [a], Gi(a, n), a;
|
|
808
811
|
}
|
|
809
|
-
async function
|
|
810
|
-
const { groups: n } = await
|
|
812
|
+
async function Wi(e, t, i) {
|
|
813
|
+
const { groups: n } = await wi(), a = n.map((o) => ({
|
|
811
814
|
name: o.name,
|
|
812
815
|
value: o.url
|
|
813
816
|
}));
|
|
@@ -822,12 +825,12 @@ async function Gi(e, t, i) {
|
|
|
822
825
|
});
|
|
823
826
|
return s = Array.isArray(s) ? s : [s], s;
|
|
824
827
|
}
|
|
825
|
-
async function
|
|
828
|
+
async function Vi() {
|
|
826
829
|
try {
|
|
827
|
-
|
|
830
|
+
qe() && (await _e({
|
|
828
831
|
message: "系统中已存在z的配置文件,确认重新配置?"
|
|
829
832
|
}) ? D.rm("-rf", ye()) : process.exit(0)), await se(de(), { recursive: !0 });
|
|
830
|
-
const t = await
|
|
833
|
+
const t = await E({
|
|
831
834
|
message: "请选择岗位类型",
|
|
832
835
|
choices: [
|
|
833
836
|
{
|
|
@@ -850,9 +853,9 @@ async function Wi() {
|
|
|
850
853
|
mask: !0
|
|
851
854
|
});
|
|
852
855
|
L("jobType", t), L("ldapAccount", i), L("ldapPassword", n);
|
|
853
|
-
const a = await
|
|
856
|
+
const a = await et();
|
|
854
857
|
Te(a);
|
|
855
|
-
const s = await
|
|
858
|
+
const s = await at(), o = await nt("请选择你自己(用于企微通知):", (p) => p.length > 1 ? "只能选一个" : p.length < 1 ? "请选一个" : !0), { name: r, value: c } = s.find((p) => p.value === o[0]);
|
|
856
859
|
L({
|
|
857
860
|
weWorkName: r,
|
|
858
861
|
weWorkUserId: c
|
|
@@ -862,18 +865,18 @@ async function Wi() {
|
|
|
862
865
|
}
|
|
863
866
|
const e = w("配置信息初始化中").start();
|
|
864
867
|
try {
|
|
865
|
-
const t = await
|
|
868
|
+
const t = await yi();
|
|
866
869
|
L({
|
|
867
870
|
gitUserId: t.id,
|
|
868
871
|
gitName: t.name,
|
|
869
872
|
gitEnglishName: t.username,
|
|
870
873
|
gitEmail: t.email
|
|
871
|
-
}), ne("latestCheckVersionTimestamp", Date.now()), te(), A("jobType") === ae.FRONT_END && await
|
|
874
|
+
}), ne("latestCheckVersionTimestamp", Date.now()), te(), A("jobType") === ae.FRONT_END && await Ci(), e.succeed("配置信息初始化完成"), process.exit(0);
|
|
872
875
|
} catch (t) {
|
|
873
876
|
e.fail("配置信息初始化失败"), le.isAxiosError(t) && m("请检查你的域名及令牌配置"), m(t);
|
|
874
877
|
}
|
|
875
878
|
}
|
|
876
|
-
const
|
|
879
|
+
const qi = `{
|
|
877
880
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
878
881
|
"_version": "0.0.1",
|
|
879
882
|
"compilerOptions": {
|
|
@@ -920,7 +923,7 @@ const Vi = `{
|
|
|
920
923
|
"skipLibCheck": true
|
|
921
924
|
}
|
|
922
925
|
}
|
|
923
|
-
`,
|
|
926
|
+
`, Hi = `{
|
|
924
927
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
925
928
|
"_version": "0.0.1",
|
|
926
929
|
"compilerOptions": {
|
|
@@ -960,21 +963,21 @@ const Vi = `{
|
|
|
960
963
|
}
|
|
961
964
|
}
|
|
962
965
|
`;
|
|
963
|
-
async function
|
|
966
|
+
async function Zi() {
|
|
964
967
|
await M(we(), "", { mode: 493 }), await M(k(".gitignore"), `.commit-msg-tpl
|
|
965
968
|
`, { mode: 493 }), await M(k("commit-msg"), `#!/usr/bin/env sh
|
|
966
969
|
z run commit-msg`, { mode: 493 }), await M(k("pre-commit"), `#!/usr/bin/env sh
|
|
967
970
|
z run commit-files`, { mode: 493 });
|
|
968
|
-
const { language: e } =
|
|
969
|
-
e === I.JAVASCRIPT && (await M(k(".prettierrc.json"),
|
|
971
|
+
const { language: e } = Ee();
|
|
972
|
+
e === I.JAVASCRIPT && (await M(k(".prettierrc.json"), Zt, { mode: 493 }), await M(k(".prettierignore"), Kt, { mode: 493 }), await M(k("tsconfig.node.json"), Hi, { mode: 493 }), await M(k("tsconfig.browser.json"), qi, {
|
|
970
973
|
mode: 493
|
|
971
|
-
})),
|
|
974
|
+
})), Ve();
|
|
972
975
|
}
|
|
973
|
-
async function
|
|
976
|
+
async function Ki(e, t) {
|
|
974
977
|
const i = await u("git remote get-url --push origin");
|
|
975
978
|
i || m("获取项目远程git地址失败,请配置后重试");
|
|
976
979
|
let n = e;
|
|
977
|
-
n || (n = await
|
|
980
|
+
n || (n = await E({
|
|
978
981
|
message: "请选择项目语言",
|
|
979
982
|
choices: [
|
|
980
983
|
{
|
|
@@ -993,52 +996,52 @@ async function Zi(e, t) {
|
|
|
993
996
|
}));
|
|
994
997
|
let a = t;
|
|
995
998
|
if (!a) {
|
|
996
|
-
const s =
|
|
999
|
+
const s = He(i), o = await tt(s);
|
|
997
1000
|
if (!o)
|
|
998
1001
|
return m(`未找到项目,请确认项目${i}是否存在,或者当前账号权限`);
|
|
999
1002
|
a = o.namespace.full_path;
|
|
1000
1003
|
}
|
|
1001
|
-
|
|
1004
|
+
li({
|
|
1002
1005
|
language: n,
|
|
1003
|
-
"lint-staged":
|
|
1006
|
+
"lint-staged": Qt[n],
|
|
1004
1007
|
repository: {
|
|
1005
1008
|
url: i,
|
|
1006
1009
|
group: a
|
|
1007
1010
|
}
|
|
1008
1011
|
});
|
|
1009
1012
|
}
|
|
1010
|
-
async function
|
|
1011
|
-
e ? D.rm("-rf", q) : $(k()) && (await
|
|
1013
|
+
async function Ce(e, t) {
|
|
1014
|
+
e ? D.rm("-rf", q) : $(k()) && (await _e({
|
|
1012
1015
|
message: `当前项目中已存在配置文件夹${q},确认重新配置?`
|
|
1013
|
-
}) ? D.rm("-rf", q) : process.exit(0)), await se(k(), { recursive: !0 }), await
|
|
1014
|
-
}
|
|
1015
|
-
async function Ki() {
|
|
1016
|
-
$(k()) && $(we()) ? We() : await ke(), process.exit(0);
|
|
1016
|
+
}) ? D.rm("-rf", q) : process.exit(0)), await se(k(), { recursive: !0 }), await Ki(e, t), await Zi(), J("项目初始化完成");
|
|
1017
1017
|
}
|
|
1018
|
-
async function Qi(
|
|
1019
|
-
|
|
1018
|
+
async function Qi() {
|
|
1019
|
+
$(k()) && $(we()) ? Ve() : await Ce(), process.exit(0);
|
|
1020
1020
|
}
|
|
1021
|
-
x.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(I).join("/")} `).action((...e) => z(Qi, ...e));
|
|
1022
1021
|
async function Yi(e, t) {
|
|
1022
|
+
t.projectLanguage && !Object.values(I).includes(t.projectLanguage) && m("项目语言不支持"), e ? (X(), e === "." ? (await Ce(t.projectLanguage, void 0), process.exit(0)) : e === "prepare" ? await Qi() : m("参数错误。执行 z init -h 查看帮助。")) : await Vi();
|
|
1023
|
+
}
|
|
1024
|
+
x.command("init").alias("i").description("初始化工具配置、项目配置").argument("[type]", "非必填。不传为初始化全局配置;传 . 为初始化当前项目;传 prepare 为初始化GIT HOOKS").option("--project-language", `项目语言。可选值:${Object.values(I).join("/")} `).action((...e) => z(Yi, ...e));
|
|
1025
|
+
async function Xi(e, t) {
|
|
1023
1026
|
if (!e)
|
|
1024
1027
|
return "不能为空";
|
|
1025
1028
|
if (!/^[a-z0-9-]+$/.test(e))
|
|
1026
1029
|
return "格式为小写字母、中横线(可选)、数字(不推荐)。如apple, apple-tree";
|
|
1027
|
-
if (
|
|
1030
|
+
if (Ke().includes(e))
|
|
1028
1031
|
return "当前目录下已存在同名文件夹,请先处理。";
|
|
1029
|
-
const a = (await
|
|
1032
|
+
const a = (await bi(e)).find((s) => s.path_with_namespace === `${t}/${e}`);
|
|
1030
1033
|
return a ? `远程仓库中已存在同名项目(${a.http_url_to_repo}),请更名后重试` : !0;
|
|
1031
1034
|
}
|
|
1032
|
-
function
|
|
1035
|
+
function ea(e) {
|
|
1033
1036
|
return e ? !0 : "不能为空";
|
|
1034
1037
|
}
|
|
1035
|
-
function
|
|
1038
|
+
function ta(e) {
|
|
1036
1039
|
return e ? /^[a-zA-Z0-9.]+$/.test(e) ? !0 : "格式为大小写字母、数字、小数点,小驼峰命名。如userInfo、systemRouter3" : "不能为空";
|
|
1037
1040
|
}
|
|
1038
|
-
async function
|
|
1041
|
+
async function ia(e) {
|
|
1039
1042
|
oe(), X(), await ce();
|
|
1040
1043
|
let t, i;
|
|
1041
|
-
e.branchType ? t = e.branchType : t = await
|
|
1044
|
+
e.branchType ? t = e.branchType : t = await E({
|
|
1042
1045
|
message: "请选择创建分支的类型",
|
|
1043
1046
|
choices: [
|
|
1044
1047
|
{
|
|
@@ -1056,15 +1059,15 @@ async function ta(e) {
|
|
|
1056
1059
|
]
|
|
1057
1060
|
}), e.branchPurpose ? i = e.branchPurpose : i = await _({
|
|
1058
1061
|
message: "请输入创建分支的目的(大小写字母、数字,小驼峰式命名。如userInfo)",
|
|
1059
|
-
validate:
|
|
1062
|
+
validate: ta
|
|
1060
1063
|
});
|
|
1061
|
-
const n = `${t}_${i}_${
|
|
1064
|
+
const n = `${t}_${i}_${Ye()}`;
|
|
1062
1065
|
await u(`git fetch origin ${h.MASTER}`), await u(`git checkout -b ${n} origin/${h.MASTER}`), await u(`git push -u origin ${n}`), process.exit(0);
|
|
1063
1066
|
}
|
|
1064
|
-
const
|
|
1065
|
-
async function
|
|
1067
|
+
const st = (e) => `${ee("ZenTaoDomain")}${e}`;
|
|
1068
|
+
async function aa() {
|
|
1066
1069
|
const e = await he({
|
|
1067
|
-
url:
|
|
1070
|
+
url: st("/my-work-task.json?tid=mrrferp8"),
|
|
1068
1071
|
method: "get"
|
|
1069
1072
|
});
|
|
1070
1073
|
return e?.tasks ? e.tasks.filter((t) => t.status !== "done").map(({ id: t, name: i }) => ({
|
|
@@ -1075,9 +1078,9 @@ async function ia() {
|
|
|
1075
1078
|
name: i
|
|
1076
1079
|
})) : [];
|
|
1077
1080
|
}
|
|
1078
|
-
async function
|
|
1081
|
+
async function na() {
|
|
1079
1082
|
const e = await he({
|
|
1080
|
-
url:
|
|
1083
|
+
url: st("/my-work-bug.json?tid=mrrferp8"),
|
|
1081
1084
|
method: "get"
|
|
1082
1085
|
});
|
|
1083
1086
|
return e?.bugs ? Object.values(e.bugs).map(({ id: t, title: i }) => ({
|
|
@@ -1096,8 +1099,8 @@ async function Ne(e, t) {
|
|
|
1096
1099
|
}
|
|
1097
1100
|
e === b.CHORE && (i = `${e}: ${t}`), await M(we(), i, "utf-8"), console.log(N.yellow(i)), J("commit msg模板写入成功,可以进行提交了");
|
|
1098
1101
|
}
|
|
1099
|
-
async function
|
|
1100
|
-
const e = await
|
|
1102
|
+
async function sa() {
|
|
1103
|
+
const e = await E({
|
|
1101
1104
|
message: "请选择你要创建的模板类型",
|
|
1102
1105
|
choices: [
|
|
1103
1106
|
{
|
|
@@ -1119,10 +1122,10 @@ async function na() {
|
|
|
1119
1122
|
]
|
|
1120
1123
|
});
|
|
1121
1124
|
if ([b.FEAT, b.REFACTOR].includes(e)) {
|
|
1122
|
-
const t = await
|
|
1125
|
+
const t = await aa();
|
|
1123
1126
|
if (!t.length)
|
|
1124
1127
|
return J("🤷 暂无开发任务");
|
|
1125
|
-
const i = await
|
|
1128
|
+
const i = await Pe({
|
|
1126
1129
|
message: "请关联开发任务(可多选):",
|
|
1127
1130
|
validate: (n) => n.length === 0 ? "请选择项" : !0,
|
|
1128
1131
|
choices: t.map((n) => ({
|
|
@@ -1134,10 +1137,10 @@ async function na() {
|
|
|
1134
1137
|
await Ne(b.FEAT, i);
|
|
1135
1138
|
}
|
|
1136
1139
|
if (e === b.FIX) {
|
|
1137
|
-
const t = await
|
|
1140
|
+
const t = await na();
|
|
1138
1141
|
if (!t.length)
|
|
1139
1142
|
return J("🤷 暂无BUG");
|
|
1140
|
-
const i = await
|
|
1143
|
+
const i = await Pe({
|
|
1141
1144
|
message: "请关联Bug(可多选):",
|
|
1142
1145
|
validate: (n) => n.length === 0 ? "请选择项" : !0,
|
|
1143
1146
|
choices: t.map((n) => ({
|
|
@@ -1157,23 +1160,23 @@ async function na() {
|
|
|
1157
1160
|
}
|
|
1158
1161
|
process.exit(0);
|
|
1159
1162
|
}
|
|
1160
|
-
async function
|
|
1163
|
+
async function ra() {
|
|
1161
1164
|
try {
|
|
1162
1165
|
const e = {}, t = async () => {
|
|
1163
|
-
const F =
|
|
1164
|
-
const
|
|
1166
|
+
const F = Ke(), { projects: K } = await hi(), W = K.map((ie) => {
|
|
1167
|
+
const xe = {
|
|
1165
1168
|
name: `${ie.name} [${ie.desc}]`,
|
|
1166
1169
|
value: ie.name,
|
|
1167
1170
|
disabled: !1
|
|
1168
1171
|
};
|
|
1169
|
-
return F.includes(ie.name) && (
|
|
1170
|
-
}),
|
|
1172
|
+
return F.includes(ie.name) && (xe.disabled = "目录下已存在同名文件夹"), xe;
|
|
1173
|
+
}), wt = await E({
|
|
1171
1174
|
message: "请选择一个项目模板",
|
|
1172
1175
|
choices: W
|
|
1173
|
-
}), be = K.find((ie) => ie.name ===
|
|
1176
|
+
}), be = K.find((ie) => ie.name === wt);
|
|
1174
1177
|
e.tplName = be.name, e.tplUrl = be.url, e.tplLanguage = be.language;
|
|
1175
1178
|
}, i = async () => {
|
|
1176
|
-
const { groups: F } =
|
|
1179
|
+
const { groups: F } = ki(), K = await E({
|
|
1177
1180
|
message: "请选择一个分组",
|
|
1178
1181
|
choices: F.map((W) => ({
|
|
1179
1182
|
name: `${W.name} [${W.description}]`,
|
|
@@ -1188,17 +1191,17 @@ async function sa() {
|
|
|
1188
1191
|
}, n = async () => {
|
|
1189
1192
|
e.projectName = await _({
|
|
1190
1193
|
message: "请输入项目名称",
|
|
1191
|
-
validate: (F) =>
|
|
1194
|
+
validate: (F) => Xi(F, e.group?.name || "")
|
|
1192
1195
|
}), e.projectDesc = await _({
|
|
1193
1196
|
message: "请输入项目描述",
|
|
1194
|
-
validate:
|
|
1197
|
+
validate: ea
|
|
1195
1198
|
});
|
|
1196
1199
|
};
|
|
1197
1200
|
await t(), await i(), await n();
|
|
1198
1201
|
const a = `${me}/${e.group?.name}/${e.projectName}.git`, s = w("模版初始化中").start();
|
|
1199
|
-
await u(`git clone --depth=1 ${e.tplUrl}`), await
|
|
1202
|
+
await u(`git clone --depth=1 ${e.tplUrl}`), await Fe(e.tplName, e.projectName), D.cd(e.projectName), D.rm("-rf", ".git"), await u(`git init --initial-branch=${h.MASTER}`), await u(`git remote add origin ${a}`), await u(`git config user.name ${A("gitName")}`), await u(`git config user.email ${A("gitEmail")}`);
|
|
1200
1203
|
const o = $e();
|
|
1201
|
-
|
|
1204
|
+
mi({
|
|
1202
1205
|
...o,
|
|
1203
1206
|
name: e.projectName,
|
|
1204
1207
|
description: e.projectDesc,
|
|
@@ -1206,12 +1209,12 @@ async function sa() {
|
|
|
1206
1209
|
...o.scripts,
|
|
1207
1210
|
prepare: "[ -n '$z' ] && z init prepare || echo 'Warning: z not exist at global'"
|
|
1208
1211
|
}
|
|
1209
|
-
}), await j.writeFile(l.resolve("README.md"),
|
|
1212
|
+
}), await j.writeFile(l.resolve("README.md"), Ht(e.projectName, e.projectDesc)), s.succeed("模版初始化完成"), await Ce(e.tplLanguage, e.group?.name);
|
|
1210
1213
|
const r = w("依赖安装中").start();
|
|
1211
1214
|
await u("npm install --registry https://registry.npmmirror.com/"), r.succeed("依赖安装完成");
|
|
1212
1215
|
const c = w("项目推送中").start();
|
|
1213
1216
|
await u('git add . && git commit -m "chore: 项目初始化"'), await u("git tag v0.0.1");
|
|
1214
|
-
const p = await
|
|
1217
|
+
const p = await vi({
|
|
1215
1218
|
name: e.projectName,
|
|
1216
1219
|
description: e.projectDesc,
|
|
1217
1220
|
path: e.projectName,
|
|
@@ -1219,9 +1222,9 @@ async function sa() {
|
|
|
1219
1222
|
namespace_id: e.group?.id
|
|
1220
1223
|
});
|
|
1221
1224
|
await u(`git push -u origin ${h.MASTER}`), await u(`git push origin HEAD:${h.MASTER} --tags`), c.succeed(`项目已推送到远程,地址: ${N.blue(a)}`);
|
|
1222
|
-
const d = w("初始化分支中").start(), y = `feat_init_${
|
|
1225
|
+
const d = w("初始化分支中").start(), y = `feat_init_${Ye()}`, f = [h.DEV, h.TEST, h.RELEASE, y], g = await Promise.allSettled(
|
|
1223
1226
|
f.map(
|
|
1224
|
-
(F) =>
|
|
1227
|
+
(F) => Ei({
|
|
1225
1228
|
id: p.id,
|
|
1226
1229
|
branch: F,
|
|
1227
1230
|
ref: h.MASTER
|
|
@@ -1231,13 +1234,13 @@ async function sa() {
|
|
|
1231
1234
|
g.forEach(({ status: F }, K) => {
|
|
1232
1235
|
F === "fulfilled" && O.push(f[K]);
|
|
1233
1236
|
}), await u("git pull"), O.includes(y) ? (await u(`git checkout -b ${y} origin/${y}`), d.succeed(`项目已切换到初始分支: ${N.blue(y)}`)) : d.warn("开发分支检出失败!项目当前在主分支,请自行检出开发分支。");
|
|
1234
|
-
const
|
|
1235
|
-
console.log(`输入 ${N.green(
|
|
1237
|
+
const ht = `cd ${e.projectName} && z start`;
|
|
1238
|
+
console.log(`输入 ${N.green(ht)} 开始开发吧~`), process.exit(0);
|
|
1236
1239
|
} catch (e) {
|
|
1237
1240
|
m(e);
|
|
1238
1241
|
}
|
|
1239
1242
|
}
|
|
1240
|
-
async function
|
|
1243
|
+
async function oa(e, t) {
|
|
1241
1244
|
let i;
|
|
1242
1245
|
e ? [
|
|
1243
1246
|
"project",
|
|
@@ -1251,7 +1254,7 @@ async function ra(e, t) {
|
|
|
1251
1254
|
"commit-msg",
|
|
1252
1255
|
"cm"
|
|
1253
1256
|
/* CommitMsgAbbr */
|
|
1254
|
-
].includes(e) ? i = "commit-msg" : m("参数输入错误") : i = await
|
|
1257
|
+
].includes(e) ? i = "commit-msg" : m("参数输入错误") : i = await E({
|
|
1255
1258
|
message: "请选择你要创建的类型",
|
|
1256
1259
|
choices: [
|
|
1257
1260
|
{
|
|
@@ -1270,20 +1273,20 @@ async function ra(e, t) {
|
|
|
1270
1273
|
/* Project */
|
|
1271
1274
|
}
|
|
1272
1275
|
]
|
|
1273
|
-
}), i === "project" ? await
|
|
1276
|
+
}), i === "project" ? await ra() : (oe(), X(), i === "branch" ? (await ce(), await ia(t)) : i === "commit-msg" && await sa());
|
|
1274
1277
|
}
|
|
1275
|
-
x.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(ue).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").action((...e) => z(
|
|
1276
|
-
function
|
|
1277
|
-
return
|
|
1278
|
+
x.command("create").alias("c").description("创建项目/分支/提交信息").argument("[type]", "可选值为project|pr, branch|b, commit-msg|cm").option("--branch-type <type>", `分支类型。可选值:${Object.values(ue).join(", ")}`).option("--branch-purpose <purpose>", "创建分支的目的").action((...e) => z(oa, ...e));
|
|
1279
|
+
function ca(e) {
|
|
1280
|
+
return Xe({
|
|
1278
1281
|
url: `${ee("K8sDomain")}/kapis/clusters/youshou-local/devops.kubesphere.io/v1alpha3/namespaces/${Pt}/pipelines/${e.projectName}/pipelineruns?branch=${e.branchName}`,
|
|
1279
1282
|
method: "post",
|
|
1280
1283
|
data: e.params
|
|
1281
1284
|
});
|
|
1282
1285
|
}
|
|
1283
|
-
async function
|
|
1286
|
+
async function ua(e) {
|
|
1284
1287
|
const t = w("部署任务创建中").start(), { targetBranch: i, notify: n, projectName: a } = e, s = n ? [.../* @__PURE__ */ new Set([A("weWorkUserId"), ...n])] : [A("weWorkUserId")];
|
|
1285
1288
|
try {
|
|
1286
|
-
const { metadata: o, spec: r } = await
|
|
1289
|
+
const { metadata: o, spec: r } = await ca({
|
|
1287
1290
|
projectName: a,
|
|
1288
1291
|
branchName: i,
|
|
1289
1292
|
params: {
|
|
@@ -1304,46 +1307,46 @@ async function ca(e) {
|
|
|
1304
1307
|
t.fail("部署任务创建失败"), m(o);
|
|
1305
1308
|
}
|
|
1306
1309
|
}
|
|
1307
|
-
function
|
|
1310
|
+
function la(e, t) {
|
|
1308
1311
|
const i = $e();
|
|
1309
|
-
if (
|
|
1312
|
+
if (Ee()?.repository?.url || m(".z/project.json中缺少repository.url"), t === H.H5) {
|
|
1310
1313
|
const a = `build:${e}`;
|
|
1311
1314
|
i?.scripts[a] || m(`项目package.json文件scripts不存在命令${a}。`);
|
|
1312
1315
|
}
|
|
1313
1316
|
t === H.NPM && (i?.scripts.build || m("项目package.json文件scripts不存在命令build。")), t === H.SERVER && (i?.scripts.build || m("项目package.json文件scripts不存在命令build。"));
|
|
1314
1317
|
}
|
|
1315
|
-
async function
|
|
1318
|
+
async function rt(e, t) {
|
|
1316
1319
|
oe(), X(), await ce();
|
|
1317
1320
|
let i = e, n = t.platform;
|
|
1318
|
-
if (i && !Object.values(h).includes(i) && m("仅支持发布指定环境分支"), n && !Object.values(H).includes(n) && m("发布平台错误"), n || (n = await
|
|
1321
|
+
if (i && !Object.values(h).includes(i) && m("仅支持发布指定环境分支"), n && !Object.values(H).includes(n) && m("发布平台错误"), n || (n = await E({
|
|
1319
1322
|
message: "请选择平台",
|
|
1320
1323
|
choices: Dt
|
|
1321
1324
|
})), n === H.NPM && (i = h.MASTER), !i) {
|
|
1322
|
-
const c = await
|
|
1325
|
+
const c = await E({
|
|
1323
1326
|
message: "请选择部署环境",
|
|
1324
|
-
choices:
|
|
1327
|
+
choices: Ge
|
|
1325
1328
|
});
|
|
1326
1329
|
i = Vt(c);
|
|
1327
1330
|
}
|
|
1328
1331
|
let a = [];
|
|
1329
|
-
t.skipSelectionNotification || (a = await
|
|
1332
|
+
t.skipSelectionNotification || (a = await nt("请选择部署成功要通知的人员:", () => !0, !0));
|
|
1330
1333
|
let s = [];
|
|
1331
|
-
t.skipGroupNotification || (s = await
|
|
1334
|
+
t.skipGroupNotification || (s = await Wi("请选择部署成功要通知的群组:", () => !0, !0));
|
|
1332
1335
|
const o = Wt(i);
|
|
1333
|
-
|
|
1336
|
+
la(o, n);
|
|
1334
1337
|
const r = $e();
|
|
1335
|
-
await
|
|
1338
|
+
await ua({
|
|
1336
1339
|
projectName: r.name,
|
|
1337
1340
|
targetBranch: i,
|
|
1338
1341
|
notify: a,
|
|
1339
1342
|
notifyGroup: s
|
|
1340
1343
|
});
|
|
1341
1344
|
}
|
|
1342
|
-
async function
|
|
1345
|
+
async function ot(e, t, i, n) {
|
|
1343
1346
|
const a = w(`分支合并中,${e} -> ${t}`).start();
|
|
1344
1347
|
let s = 0;
|
|
1345
1348
|
try {
|
|
1346
|
-
const { iid: r } = await
|
|
1349
|
+
const { iid: r } = await Ni({
|
|
1347
1350
|
title: `${e} -> ${t} by z-develop`,
|
|
1348
1351
|
id: i.id,
|
|
1349
1352
|
source_branch: e,
|
|
@@ -1359,7 +1362,7 @@ async function rt(e, t, i, n) {
|
|
|
1359
1362
|
try {
|
|
1360
1363
|
await new Promise((r) => {
|
|
1361
1364
|
setTimeout(r, 5e3);
|
|
1362
|
-
}), await
|
|
1365
|
+
}), await Si({
|
|
1363
1366
|
id: i.id,
|
|
1364
1367
|
iid: s
|
|
1365
1368
|
}), a.succeed(`分支${e}已合并到分支${t}`);
|
|
@@ -1368,12 +1371,12 @@ async function rt(e, t, i, n) {
|
|
|
1368
1371
|
const c = r?.response?.status;
|
|
1369
1372
|
if (c === 406)
|
|
1370
1373
|
return await o();
|
|
1371
|
-
if (await
|
|
1374
|
+
if (await ji({
|
|
1372
1375
|
id: i.id,
|
|
1373
1376
|
iid: s,
|
|
1374
1377
|
state_event: "close"
|
|
1375
1378
|
}), c === 405) {
|
|
1376
|
-
const p = await
|
|
1379
|
+
const p = await Ai({
|
|
1377
1380
|
id: i.id,
|
|
1378
1381
|
iid: s
|
|
1379
1382
|
});
|
|
@@ -1387,13 +1390,13 @@ async function rt(e, t, i, n) {
|
|
|
1387
1390
|
};
|
|
1388
1391
|
await o();
|
|
1389
1392
|
}
|
|
1390
|
-
async function
|
|
1393
|
+
async function ma(e, t) {
|
|
1391
1394
|
const i = `origin/${e.sourceBranch}`, n = await u(`git log -b origin/${h.MASTER} -1 --format=%H`), a = await u(`git log -b origin/${e.sourceBranch} -1 --format=%H`), s = await u(
|
|
1392
1395
|
`git log ${n}...${a} -b ${i}`
|
|
1393
1396
|
);
|
|
1394
1397
|
if (s || m(`分支${e.sourceBranch}上不存在新的commit,不需要合并。`), await u(
|
|
1395
1398
|
`git branch --contains ${n} -r ${i}`
|
|
1396
|
-
) || (console.log(N.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await
|
|
1399
|
+
) || (console.log(N.yellow("注意:当前分支上不存在远程主分支最新代码,将在自动合入后继续。")), await ot(h.MASTER, e.sourceBranch, e)), t === h.MASTER) {
|
|
1397
1400
|
const r = s.split(`
|
|
1398
1401
|
`).filter((y) => y), c = await u(`git log -b origin/${v.TEST} -1 --format=%H`), d = (await u(
|
|
1399
1402
|
`git log ${n}...${c} -b origin/${v.TEST}`
|
|
@@ -1402,9 +1405,9 @@ async function la(e, t) {
|
|
|
1402
1405
|
Gt(d, r) || m("请先在测试环境发布要部署的代码");
|
|
1403
1406
|
}
|
|
1404
1407
|
}
|
|
1405
|
-
async function
|
|
1408
|
+
async function pa(e, t) {
|
|
1406
1409
|
oe(), X(), await ce();
|
|
1407
|
-
const i = await
|
|
1410
|
+
const i = await pi();
|
|
1408
1411
|
Object.values(h).includes(i.sourceBranch) && m(`当前分支${i.sourceBranch}不可作为源分支合并到目标分支。`);
|
|
1409
1412
|
const a = (await Ti(i.id)).filter((c) => ![i.sourceBranch].includes(c.name)).map((c) => {
|
|
1410
1413
|
let p = c.name;
|
|
@@ -1414,7 +1417,7 @@ async function ma(e, t) {
|
|
|
1414
1417
|
};
|
|
1415
1418
|
});
|
|
1416
1419
|
let s;
|
|
1417
|
-
e && !a.filter((c) => c.value === e).length && m(`未找到目标分支${e}`), e ? s = e : s = await
|
|
1420
|
+
e && !a.filter((c) => c.value === e).length && m(`未找到目标分支${e}`), e ? s = e : s = await E({
|
|
1418
1421
|
message: "请选择要合并到的目标分支:",
|
|
1419
1422
|
choices: a
|
|
1420
1423
|
});
|
|
@@ -1427,18 +1430,18 @@ async function ma(e, t) {
|
|
|
1427
1430
|
), process.exit(1));
|
|
1428
1431
|
} else
|
|
1429
1432
|
await u(`git push -u origin ${i.sourceBranch}`), o.succeed(`本地分支${i.sourceBranch}已推送到远程分支origin/${i.sourceBranch}`);
|
|
1430
|
-
await
|
|
1433
|
+
await ma(i, s), await ot(i.sourceBranch, s, i, t.keepBranchAfterMergeMaster), h.MASTER === s && !t.keepBranchAfterMergeMaster && (await u(`git checkout ${h.MASTER}`), await u(`git pull origin ${h.MASTER}`), await u(`git branch -d ${i.sourceBranch}`), J(
|
|
1431
1434
|
`${i.sourceBranch}分支已移除,当前已切换到最新的${h.MASTER}。如需继续开发,请检出新分支(z c b)。`
|
|
1432
|
-
)), Object.values(h).includes(s) && await
|
|
1435
|
+
)), Object.values(h).includes(s) && await rt(s, {
|
|
1433
1436
|
platform: t.deployPlatform,
|
|
1434
1437
|
skipSelectionNotification: t.deploySkipSelectionNotification,
|
|
1435
1438
|
skipGroupNotification: t.skipGroupNotification
|
|
1436
1439
|
});
|
|
1437
1440
|
}
|
|
1438
|
-
x.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(H).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => z(
|
|
1439
|
-
x.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(h).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(H).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => z(
|
|
1440
|
-
function
|
|
1441
|
-
const e =
|
|
1441
|
+
x.command("merge").alias("m").description("合并当前分支到指定远程分支,并部署。").argument("[branch]", "目标分支名称").option("--deploy-platform <platform>", `合并成功后要部署的平台。可选值:${Object.values(H).join("/")}`).option("--deploy-skip-selection-notification", "部署时,是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").option("--keep-branch-after-merge-master", "在合并到主分支之后,是否保留分支。默认否").action((...e) => z(pa, ...e));
|
|
1442
|
+
x.command("deploy").alias("d").description("部署到指定环境").argument("[branchName]", `部署环境。可选值:${Object.values(h).join("/")}`).option("--platform <platform>", `部署平台。可选值:${Object.values(H).join("/")}`).option("--skip-selection-notification", "是否跳过选择部署通知人环节").option("--skip-group-notification", "是否跳过选择部署通知群聊环节").action((...e) => z(rt, ...e));
|
|
1443
|
+
function da() {
|
|
1444
|
+
const e = Ae();
|
|
1442
1445
|
if ($(e)) {
|
|
1443
1446
|
const t = j.readJsonSync(e);
|
|
1444
1447
|
if (t["lint-staged"])
|
|
@@ -1447,18 +1450,18 @@ function pa() {
|
|
|
1447
1450
|
} else
|
|
1448
1451
|
throw new Error("请先初始化项目(z i .)。");
|
|
1449
1452
|
}
|
|
1450
|
-
async function
|
|
1453
|
+
async function fa() {
|
|
1451
1454
|
const e = w("代码风格检测中...").start();
|
|
1452
|
-
await
|
|
1455
|
+
await Et({
|
|
1453
1456
|
concurrent: 4,
|
|
1454
1457
|
debug: !1,
|
|
1455
|
-
config:
|
|
1458
|
+
config: da(),
|
|
1456
1459
|
quiet: !0,
|
|
1457
1460
|
relative: !0
|
|
1458
1461
|
}) ? (e.succeed("代码风格检测通过!"), process.exit(0)) : e.fail("代码风格检测未通过!");
|
|
1459
1462
|
}
|
|
1460
|
-
function
|
|
1461
|
-
if (e.includes("Merge") && e.includes("# Conflicts:") ||
|
|
1463
|
+
function ga(e) {
|
|
1464
|
+
if (e.includes("Merge") && e.includes("# Conflicts:") || Tt.valid(e))
|
|
1462
1465
|
return !0;
|
|
1463
1466
|
const t = e.split(": ");
|
|
1464
1467
|
if (t.length === 1)
|
|
@@ -1466,11 +1469,11 @@ function fa(e) {
|
|
|
1466
1469
|
const i = t[0];
|
|
1467
1470
|
return /^(feat|fix|refactor)/.test(i) ? /\(\d+(?:,\d+)*\)/.test(i) ? !0 : "ID缺少或者格式不正确。" : /^(chore|ci)/.test(i) ? [b.CHORE, b.CI].includes(i) ? !0 : "chore/ci类型无需填写ID。" : b.Break === i ? !0 : "不存在的提交类型。";
|
|
1468
1471
|
}
|
|
1469
|
-
async function
|
|
1470
|
-
const e = await Se(l.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = w("提交信息格式校验中...").start(), i =
|
|
1472
|
+
async function ha() {
|
|
1473
|
+
const e = await Se(l.resolve(".git", "COMMIT_EDITMSG"), "utf-8"), t = w("提交信息格式校验中...").start(), i = ga(e);
|
|
1471
1474
|
i === !0 ? (t.succeed("提交信息格式校验通过"), process.exit(0)) : t.fail(`提交信息格式校验失败。${i}`);
|
|
1472
1475
|
}
|
|
1473
|
-
async function
|
|
1476
|
+
async function wa() {
|
|
1474
1477
|
await ce();
|
|
1475
1478
|
const e = await kt({
|
|
1476
1479
|
// 分组,展示仓库链接
|
|
@@ -1489,7 +1492,7 @@ async function ha() {
|
|
|
1489
1492
|
}
|
|
1490
1493
|
process.exit(0);
|
|
1491
1494
|
}
|
|
1492
|
-
async function
|
|
1495
|
+
async function ya(e) {
|
|
1493
1496
|
$(l.resolve("node_modules", ".bin", "eslint")) || m("该项目未安装eslint,请安装后重试");
|
|
1494
1497
|
const t = w("eslint执行中...").start();
|
|
1495
1498
|
try {
|
|
@@ -1501,7 +1504,7 @@ async function wa(e) {
|
|
|
1501
1504
|
t.fail("eslint校验出错");
|
|
1502
1505
|
}
|
|
1503
1506
|
}
|
|
1504
|
-
async function
|
|
1507
|
+
async function $a() {
|
|
1505
1508
|
$(l.resolve("node_modules", ".bin", "prettier")) || m("该项目未安装prettier,请安装后重试");
|
|
1506
1509
|
const e = w("prettier执行中...").start();
|
|
1507
1510
|
try {
|
|
@@ -1515,10 +1518,10 @@ async function ya() {
|
|
|
1515
1518
|
e.fail("prettier校验出错");
|
|
1516
1519
|
}
|
|
1517
1520
|
}
|
|
1518
|
-
function
|
|
1519
|
-
$(l.resolve("./node_modules/.bin/vue-tsc")) || m("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"),
|
|
1521
|
+
function va() {
|
|
1522
|
+
$(l.resolve("./node_modules/.bin/vue-tsc")) || m("请先安装vue-tsc。推荐命令: npm i -D vue-tsc"), Qe("npx vue-tsc --build"), process.exit(0);
|
|
1520
1523
|
}
|
|
1521
|
-
async function
|
|
1524
|
+
async function ba(e, t) {
|
|
1522
1525
|
oe(), X();
|
|
1523
1526
|
let i;
|
|
1524
1527
|
e ? [
|
|
@@ -1545,7 +1548,7 @@ async function va(e, t) {
|
|
|
1545
1548
|
"dependency-check",
|
|
1546
1549
|
"dc"
|
|
1547
1550
|
/* DependencyCheckAbbr */
|
|
1548
|
-
].includes(e) ? i = "dependency-check" : m("参数输入错误") : i = await
|
|
1551
|
+
].includes(e) ? i = "dependency-check" : m("参数输入错误") : i = await E({
|
|
1549
1552
|
message: "请选择你要执行的操作",
|
|
1550
1553
|
choices: [
|
|
1551
1554
|
{
|
|
@@ -1569,29 +1572,29 @@ async function va(e, t) {
|
|
|
1569
1572
|
/* DependencyCheck */
|
|
1570
1573
|
}
|
|
1571
1574
|
]
|
|
1572
|
-
}), i === "commit-msg" ? await
|
|
1575
|
+
}), i === "commit-msg" ? await ha() : i === "commit-files" ? await fa() : i === "prettier" ? await $a() : i === "eslint" ? await ya(t) : i === "type-check" ? va() : i === "dependency-check" && await wa();
|
|
1573
1576
|
}
|
|
1574
1577
|
x.command("run").alias("r").description("执行 eslint / prettier / type-check / dependency-check 脚本。").argument(
|
|
1575
1578
|
"[type]",
|
|
1576
1579
|
"非必填。可选值为commit-msg|cm, commit-files|cf, prettier|p, eslint|e, type-check|tc, dependency-check|dc。"
|
|
1577
|
-
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(
|
|
1578
|
-
async function
|
|
1580
|
+
).option("--quiet", "eslint只打印error").option("--max-warnings [VALUE]", "eslint结果warn超过多少个会异常退出,默认为100", parseInt).action((...e) => z(ba, ...e));
|
|
1581
|
+
async function ct(e = "latest") {
|
|
1579
1582
|
const t = w("安装中...").start();
|
|
1580
1583
|
await u(`npm i -g ${Q.name}@${e} --registry https://registry.npmmirror.com/`), t.text = "本地配置更新中...", ne("latestCheckVersionTimestamp", Date.now()), ne("version", e), te(), t.succeed(`升级完成,当前版本${e}`), process.exit(0);
|
|
1581
1584
|
}
|
|
1582
|
-
x.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(
|
|
1583
|
-
async function
|
|
1585
|
+
x.command("update").alias("u").description("升级").argument("[version]", "版本号", "latest").action((...e) => z(ct, ...e));
|
|
1586
|
+
async function Na(e) {
|
|
1584
1587
|
let t = e;
|
|
1585
|
-
t ? [v.DEV, v.TEST, v.RELEASE, v.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = v.DEV : t === "t" ? t = v.TEST : t === "r" ? t = v.RELEASE : t === "p" && (t = v.PROD) : m("参数输入有误") : t = await
|
|
1588
|
+
t ? [v.DEV, v.TEST, v.RELEASE, v.PROD, "d", "t", "r", "p"].includes(e) ? t === "d" ? t = v.DEV : t === "t" ? t = v.TEST : t === "r" ? t = v.RELEASE : t === "p" && (t = v.PROD) : m("参数输入有误") : t = await E({
|
|
1586
1589
|
message: "请选择环境",
|
|
1587
|
-
choices:
|
|
1590
|
+
choices: Ge
|
|
1588
1591
|
});
|
|
1589
1592
|
const i = $e(), n = `dev:${t}`;
|
|
1590
|
-
i.scripts[n] ?
|
|
1593
|
+
i.scripts[n] ? Qe(`npm run ${n}`) : m(`项目中(package.json > scripts)不存在命令${n},请先添加!`);
|
|
1591
1594
|
}
|
|
1592
|
-
x.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(
|
|
1593
|
-
const
|
|
1594
|
-
function
|
|
1595
|
+
x.command("start").alias("s").description("启动本地开发环境").argument("[env]", "业务环境。可选值 dev|d, test|t, release|r, prod|p").action((...e) => z(Na, ...e));
|
|
1596
|
+
const Re = /Thumbs\.db|\.git|DS_Store|idea/, ut = "testcase";
|
|
1597
|
+
function lt(e) {
|
|
1595
1598
|
const t = e.match(/^(.*[^[])?\[(\d+)]$/);
|
|
1596
1599
|
if (t && !e.startsWith("["))
|
|
1597
1600
|
return {
|
|
@@ -1611,14 +1614,14 @@ function ut(e) {
|
|
|
1611
1614
|
};
|
|
1612
1615
|
}
|
|
1613
1616
|
async function Y(e, t = {}) {
|
|
1614
|
-
const { exclude: i =
|
|
1617
|
+
const { exclude: i = Re } = t, n = [];
|
|
1615
1618
|
async function a(s) {
|
|
1616
1619
|
const o = l.basename(s);
|
|
1617
|
-
if ((await
|
|
1620
|
+
if ((await bt(s)).isFile())
|
|
1618
1621
|
return null;
|
|
1619
|
-
const c = await
|
|
1622
|
+
const c = await je(s, { withFileTypes: !0 }), p = (await Promise.all(
|
|
1620
1623
|
c.filter((O) => O.isDirectory() && !i.test(O.name)).map((O) => a(l.join(s, O.name)))
|
|
1621
|
-
)).filter(Boolean), { type: d, id: y, displayName: f } =
|
|
1624
|
+
)).filter(Boolean), { type: d, id: y, displayName: f } = lt(o), g = {
|
|
1622
1625
|
name: o,
|
|
1623
1626
|
id: y,
|
|
1624
1627
|
displayName: f,
|
|
@@ -1630,13 +1633,13 @@ async function Y(e, t = {}) {
|
|
|
1630
1633
|
}
|
|
1631
1634
|
return await a(l.resolve(e)), n;
|
|
1632
1635
|
}
|
|
1633
|
-
async function
|
|
1634
|
-
const { exclude: i =
|
|
1636
|
+
async function mt(e, t = {}) {
|
|
1637
|
+
const { exclude: i = Re } = t;
|
|
1635
1638
|
try {
|
|
1636
|
-
const n = await
|
|
1639
|
+
const n = await je(l.resolve(e), { withFileTypes: !0 });
|
|
1637
1640
|
return await Promise.all(
|
|
1638
1641
|
n.filter((a) => a.isDirectory() && !i.test(a.name)).map((a) => {
|
|
1639
|
-
const s = l.join(e, a.name), { type: o, id: r, displayName: c } =
|
|
1642
|
+
const s = l.join(e, a.name), { type: o, id: r, displayName: c } = lt(a.name);
|
|
1640
1643
|
return {
|
|
1641
1644
|
name: a.name,
|
|
1642
1645
|
id: r,
|
|
@@ -1666,16 +1669,16 @@ async function fe(e, t, i, n) {
|
|
|
1666
1669
|
if (a === s)
|
|
1667
1670
|
return !0;
|
|
1668
1671
|
const o = l.dirname(e), r = l.join(o, s);
|
|
1669
|
-
return await u(`git mv "${e}" "${r}"`), await u("git add ."), !0;
|
|
1672
|
+
return await qt(e) ? await Fe(e, r) : (await u(`git mv "${e}" "${r}"`), await u("git add .")), !0;
|
|
1670
1673
|
} catch (a) {
|
|
1671
|
-
return m(
|
|
1674
|
+
return m(`重命名文件夹失败: ${e} -> ${t}。${a}`), !1;
|
|
1672
1675
|
}
|
|
1673
1676
|
}
|
|
1674
|
-
async function
|
|
1675
|
-
const { exclude: n =
|
|
1677
|
+
async function Sa(e, t, i = {}) {
|
|
1678
|
+
const { exclude: n = Re } = i;
|
|
1676
1679
|
async function a(s, o) {
|
|
1677
1680
|
if (!s || s.length === 0) return;
|
|
1678
|
-
const r = await
|
|
1681
|
+
const r = await mt(o, { exclude: n });
|
|
1679
1682
|
for (const c of s) {
|
|
1680
1683
|
const p = String(c.value), d = G("module", c.label, p), y = r.find((g) => g.id === p);
|
|
1681
1684
|
let f = y?.path || l.join(o, d);
|
|
@@ -1684,7 +1687,7 @@ async function Na(e, t, i = {}) {
|
|
|
1684
1687
|
}
|
|
1685
1688
|
await a(e, l.resolve(t));
|
|
1686
1689
|
}
|
|
1687
|
-
async function
|
|
1690
|
+
async function pt(e) {
|
|
1688
1691
|
const t = {
|
|
1689
1692
|
id: 0,
|
|
1690
1693
|
name: "",
|
|
@@ -1693,8 +1696,8 @@ async function mt(e) {
|
|
|
1693
1696
|
if (e)
|
|
1694
1697
|
Number.isNaN(Number(e)) && m("请输入正确的产品ID"), t.id = Number(e);
|
|
1695
1698
|
else {
|
|
1696
|
-
const i = await
|
|
1697
|
-
t.id = await
|
|
1699
|
+
const i = await Ii();
|
|
1700
|
+
t.id = await E({
|
|
1698
1701
|
message: "请选择产品",
|
|
1699
1702
|
choices: i.map((n) => ({
|
|
1700
1703
|
name: `${n.label}[${n.value}]`,
|
|
@@ -1702,33 +1705,33 @@ async function mt(e) {
|
|
|
1702
1705
|
}))
|
|
1703
1706
|
});
|
|
1704
1707
|
}
|
|
1705
|
-
return t.name = await
|
|
1708
|
+
return t.name = await Di(t.id), t.path = l.join(ut, G("module", t.name, String(t.id))), t;
|
|
1706
1709
|
}
|
|
1707
|
-
async function
|
|
1708
|
-
return (await
|
|
1710
|
+
async function Ie(e) {
|
|
1711
|
+
return (await mt(ut)).find((i) => Number(i.id) === e.id);
|
|
1709
1712
|
}
|
|
1710
|
-
async function
|
|
1713
|
+
async function dt(e, t) {
|
|
1711
1714
|
const i = {
|
|
1712
1715
|
precondition: e.precondition,
|
|
1713
1716
|
priority: e.pri,
|
|
1714
1717
|
steps: []
|
|
1715
1718
|
};
|
|
1716
|
-
i.steps = await
|
|
1719
|
+
i.steps = await Li(e.id), j.writeJSONSync(t, i, {
|
|
1717
1720
|
spaces: 2
|
|
1718
1721
|
});
|
|
1719
1722
|
}
|
|
1720
|
-
async function
|
|
1723
|
+
async function ft(e, t) {
|
|
1721
1724
|
await se(t, {
|
|
1722
1725
|
recursive: !0
|
|
1723
|
-
}), await
|
|
1726
|
+
}), await dt(e, l.join(t, "config.json")), j.ensureFileSync(l.join(t, "data.json")), await M(
|
|
1724
1727
|
l.join(t, "data.json"),
|
|
1725
|
-
$(l.resolve(q, "data.json")) ? await Se(l.resolve(q, "data.json")) :
|
|
1728
|
+
$(l.resolve(q, "data.json")) ? await Se(l.resolve(q, "data.json")) : Yt
|
|
1726
1729
|
), j.ensureFileSync(l.join(t, "main.py")), await M(
|
|
1727
1730
|
l.join(t, "main.py"),
|
|
1728
|
-
$(l.resolve(q, "main.py")) ? await Se(l.resolve(q, "main.py")) :
|
|
1731
|
+
$(l.resolve(q, "main.py")) ? await Se(l.resolve(q, "main.py")) : Xt
|
|
1729
1732
|
);
|
|
1730
1733
|
}
|
|
1731
|
-
function
|
|
1734
|
+
function gt(e) {
|
|
1732
1735
|
if (e) {
|
|
1733
1736
|
const t = e.split(",").map((i) => i.trim()).filter((i) => {
|
|
1734
1737
|
const n = Number(i);
|
|
@@ -1741,7 +1744,7 @@ function ft(e) {
|
|
|
1741
1744
|
async function ve(e, t) {
|
|
1742
1745
|
oe(), X(), await ce();
|
|
1743
1746
|
let i;
|
|
1744
|
-
t ? ([S.MODULE, S.CASE].includes(t) || m(`不支持的参数${t}。参数值应为 ${S.MODULE} 或者 ${S.CASE}。`), i = t) : i = await
|
|
1747
|
+
t ? ([S.MODULE, S.CASE].includes(t) || m(`不支持的参数${t}。参数值应为 ${S.MODULE} 或者 ${S.CASE}。`), i = t) : i = await E({
|
|
1745
1748
|
message: `请选择要${e}的数据类型`,
|
|
1746
1749
|
choices: Ot
|
|
1747
1750
|
});
|
|
@@ -1751,19 +1754,19 @@ async function ve(e, t) {
|
|
|
1751
1754
|
typeStr: n
|
|
1752
1755
|
};
|
|
1753
1756
|
}
|
|
1754
|
-
async function
|
|
1755
|
-
const t = await
|
|
1757
|
+
async function De(e) {
|
|
1758
|
+
const t = await pt(e), i = await Ie(t);
|
|
1756
1759
|
return i || m(`本地未找到产品【${t.name}[${t.id}]】`), {
|
|
1757
1760
|
product: t,
|
|
1758
1761
|
localProduct: i
|
|
1759
1762
|
};
|
|
1760
1763
|
}
|
|
1761
|
-
async function
|
|
1762
|
-
e.text = "查找本地产品目录...", await
|
|
1763
|
-
const a =
|
|
1764
|
+
async function ja(e, t, i) {
|
|
1765
|
+
e.text = "查找本地产品目录...", await Ie(t) || m(`本地未找到产品【${t.name}[${t.id}]】`), e.text = "解析ID参数...";
|
|
1766
|
+
const a = gt(i);
|
|
1764
1767
|
let s = await Y(t.path);
|
|
1765
1768
|
e.text = "获取远程用例列表...";
|
|
1766
|
-
const o = await
|
|
1769
|
+
const o = await xi(t.id, a);
|
|
1767
1770
|
e.text = "本地用例同步中...";
|
|
1768
1771
|
for (const r of o) {
|
|
1769
1772
|
let c;
|
|
@@ -1771,26 +1774,26 @@ async function Sa(e, t, i) {
|
|
|
1771
1774
|
return m(`用例${r.title}[${r.id}]未找到所属模块(${r.module}),请先拉取模块`);
|
|
1772
1775
|
const p = s.find(({ id: d }) => r.id === Number(d));
|
|
1773
1776
|
if (p)
|
|
1774
|
-
p.displayName !== r.title && await fe(p.path, r.title, p.type, p.id) && J(`重命名成功: ${p.displayName} -> ${r.title}`), s = await Y(t.path), r.module === 0 ? c = l.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await
|
|
1777
|
+
p.displayName !== r.title && await fe(p.path, r.title, p.type, p.id) && J(`重命名成功: ${p.displayName} -> ${r.title}`), s = await Y(t.path), r.module === 0 ? c = l.resolve(t.path) : c = s.find((d) => Number(d.id) === r.module)?.path || "", await dt(
|
|
1775
1778
|
r,
|
|
1776
1779
|
l.join(c, G("case", r.title, String(r.id)), "config.json")
|
|
1777
1780
|
);
|
|
1778
1781
|
else {
|
|
1779
1782
|
const d = l.join(c, G("case", r.title, String(r.id)));
|
|
1780
|
-
await
|
|
1783
|
+
await ft(r, d);
|
|
1781
1784
|
}
|
|
1782
1785
|
}
|
|
1783
1786
|
}
|
|
1784
|
-
async function
|
|
1787
|
+
async function Aa(e, t) {
|
|
1785
1788
|
e.text = "本地产品目录查找中...";
|
|
1786
|
-
const i = await
|
|
1789
|
+
const i = await Ie(t);
|
|
1787
1790
|
i ? (e.text = "找到产品目录。开始重命名...", i.displayName !== t.name && await fe(i.path, t.name, i.type, i.id) && (e.text = `重命名成功: ${i.displayName} -> ${t.name}`)) : (e.text = "未找到。开始创建产品目录...", await se(t.path, { recursive: !0 }), await u("git add .")), e.text = "获取远程模块列表...";
|
|
1788
|
-
const n = await
|
|
1789
|
-
e.text = "本地同步模块中...", await
|
|
1791
|
+
const n = await it(t.id);
|
|
1792
|
+
e.text = "本地同步模块中...", await Sa(n || [], t.path);
|
|
1790
1793
|
}
|
|
1791
|
-
async function
|
|
1792
|
-
const { type: i, typeStr: n } = await ve("拉取", e), a = await
|
|
1793
|
-
if (S.MODULE === i && await
|
|
1794
|
+
async function Ea(e, t) {
|
|
1795
|
+
const { type: i, typeStr: n } = await ve("拉取", e), a = await pt(t.productId), s = w(`${n}同步中...`).start();
|
|
1796
|
+
if (S.MODULE === i && await Aa(s, a), S.CASE === i && await ja(s, a, t.caseIds), s.succeed(`${n}同步完成 🎉`), !t.disableAutoCommit && await u("git status -s")) {
|
|
1794
1797
|
const o = w("代码提交中...").start();
|
|
1795
1798
|
try {
|
|
1796
1799
|
await u(`git add . && git commit -m "chore: 同步禅道${n}数据"`), o.succeed("代码已提交 ✅");
|
|
@@ -1799,13 +1802,13 @@ async function Aa(e, t) {
|
|
|
1799
1802
|
}
|
|
1800
1803
|
}
|
|
1801
1804
|
}
|
|
1802
|
-
x.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(
|
|
1805
|
+
x.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(Ea, ...e));
|
|
1803
1806
|
async function Ta(e, t, i) {
|
|
1804
1807
|
const n = await _({
|
|
1805
1808
|
message: "请输入你要创建的用例的前置条件(可不填)"
|
|
1806
1809
|
}), a = w(`用例【${i}】开始创建...`).start();
|
|
1807
1810
|
a.text = "远程用例创建中...";
|
|
1808
|
-
const s = await
|
|
1811
|
+
const s = await Oi({
|
|
1809
1812
|
product: Number(e.id),
|
|
1810
1813
|
// 如果父模块是产品根目录,parent=0
|
|
1811
1814
|
module: l.resolve(e?.path) === t?.path ? 0 : Number(t?.id || 0),
|
|
@@ -1814,14 +1817,14 @@ async function Ta(e, t, i) {
|
|
|
1814
1817
|
openedBy: A("ldapAccount"),
|
|
1815
1818
|
precondition: n || ""
|
|
1816
1819
|
});
|
|
1817
|
-
a.text = "远程用例步骤创建中...", await
|
|
1820
|
+
a.text = "远程用例步骤创建中...", await Mi({
|
|
1818
1821
|
case: s,
|
|
1819
1822
|
type: "step",
|
|
1820
1823
|
desc: "按照预期执行",
|
|
1821
1824
|
expect: "正常执行,符合预期"
|
|
1822
1825
|
}), a.text = "本地用例创建中...";
|
|
1823
1826
|
const o = l.join(t.path, G("case", i, String(s)));
|
|
1824
|
-
return $(o) ? J(`${o}已存在,请检查是否对应,本地不再创建。`) : (await
|
|
1827
|
+
return $(o) ? J(`${o}已存在,请检查是否对应,本地不再创建。`) : (await ft(
|
|
1825
1828
|
{
|
|
1826
1829
|
id: s,
|
|
1827
1830
|
pri: 3,
|
|
@@ -1830,10 +1833,10 @@ async function Ta(e, t, i) {
|
|
|
1830
1833
|
o
|
|
1831
1834
|
), a.succeed(`用例【[${o}】创建完成 🎉`), o);
|
|
1832
1835
|
}
|
|
1833
|
-
async function
|
|
1836
|
+
async function ka(e, t, i) {
|
|
1834
1837
|
const n = w(`模块【${i}】开始创建...`).start();
|
|
1835
1838
|
n.text = "远程模块创建中...";
|
|
1836
|
-
const a = await
|
|
1839
|
+
const a = await Pi({
|
|
1837
1840
|
root: Number(e.id),
|
|
1838
1841
|
name: i,
|
|
1839
1842
|
// 如果父模块是产品根目录,parent=0
|
|
@@ -1847,7 +1850,7 @@ async function Ea(e, t, i) {
|
|
|
1847
1850
|
recursive: !0
|
|
1848
1851
|
}), n.succeed(`模块【${s}】创建完成 🎉`);
|
|
1849
1852
|
}
|
|
1850
|
-
function
|
|
1853
|
+
function Ca(e) {
|
|
1851
1854
|
function t(n) {
|
|
1852
1855
|
if (!n.children || n.children.length === 0) return;
|
|
1853
1856
|
const a = n.children[0];
|
|
@@ -1860,7 +1863,7 @@ function ka(e) {
|
|
|
1860
1863
|
});
|
|
1861
1864
|
}
|
|
1862
1865
|
async function i(n, a = []) {
|
|
1863
|
-
const s = a.length ? `请选择层级(当前:${a.join(" / ")})` : "请选择层级", o = await
|
|
1866
|
+
const s = a.length ? `请选择层级(当前:${a.join(" / ")})` : "请选择层级", o = await E({
|
|
1864
1867
|
message: s,
|
|
1865
1868
|
choices: n.map((r) => ({
|
|
1866
1869
|
name: `${r.tempTitle ? r.tempTitle : r.label} ${r.children?.length ? "(有子级)" : ""}`,
|
|
@@ -1871,8 +1874,8 @@ function ka(e) {
|
|
|
1871
1874
|
}
|
|
1872
1875
|
return i(e);
|
|
1873
1876
|
}
|
|
1874
|
-
async function
|
|
1875
|
-
const { type: i, typeStr: n } = await ve("创建", e), { product: a, localProduct: s } = await
|
|
1877
|
+
async function Ra(e, t) {
|
|
1878
|
+
const { type: i, typeStr: n } = await ve("创建", e), { product: a, localProduct: s } = await De(t.productId), o = await it(a.id), r = await Ca(o), c = G("module", r.label, String(r.value)), d = (await Y(a.path, { hasRoot: !0 })).find((g) => g.name === c);
|
|
1876
1879
|
if (!d?.path || !$(d.path))
|
|
1877
1880
|
return m(`本地不存在${c}模块`);
|
|
1878
1881
|
const y = await _({
|
|
@@ -1881,7 +1884,7 @@ async function Ca(e, t) {
|
|
|
1881
1884
|
validate: (g) => g.length > 0 && g.length < 255
|
|
1882
1885
|
});
|
|
1883
1886
|
let f = "";
|
|
1884
|
-
if (S.MODULE === i && await
|
|
1887
|
+
if (S.MODULE === i && await ka(s, d, y), S.CASE === i && (f = await Ta(s, d, y)), !t.disableAutoCommit && S.CASE === i) {
|
|
1885
1888
|
const g = w("代码提交中...").start();
|
|
1886
1889
|
try {
|
|
1887
1890
|
await u(`git add . && git commit -m "chore: 创建了用例${l.basename(f)}"`), g.succeed("代码已提交 ✅");
|
|
@@ -1890,8 +1893,8 @@ async function Ca(e, t) {
|
|
|
1890
1893
|
}
|
|
1891
1894
|
}
|
|
1892
1895
|
}
|
|
1893
|
-
x.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(
|
|
1894
|
-
async function
|
|
1896
|
+
x.command("qa-create").alias("qc").description("创建模块或者用例").argument("[type]", "可选值为module/case").option("--product-id <productId>", "指定产品ID").option("--disable-auto-commit", "是否跳过自动将修改结果提交。").action((...e) => z(Ra, ...e));
|
|
1897
|
+
async function Ia(e, t) {
|
|
1895
1898
|
const n = (await Y(e.path)).filter((r) => r.type === "case");
|
|
1896
1899
|
let a = [];
|
|
1897
1900
|
if (t.length)
|
|
@@ -1918,7 +1921,7 @@ async function Ra(e, t) {
|
|
|
1918
1921
|
});
|
|
1919
1922
|
}
|
|
1920
1923
|
const s = w("远程用例删除中...").start(), o = a.map((r) => r.id);
|
|
1921
|
-
await
|
|
1924
|
+
await Fi({
|
|
1922
1925
|
product: Number(e.id),
|
|
1923
1926
|
caseIds: o
|
|
1924
1927
|
}), s.text = "本地用例删除中...";
|
|
@@ -1926,7 +1929,7 @@ async function Ra(e, t) {
|
|
|
1926
1929
|
$(r.path) && D.rm("-rf", r.path);
|
|
1927
1930
|
return s.succeed("用例删除完成"), o;
|
|
1928
1931
|
}
|
|
1929
|
-
async function
|
|
1932
|
+
async function Da(e, t) {
|
|
1930
1933
|
const n = (await Y(e.path)).filter((r) => r.type === "module");
|
|
1931
1934
|
let a = [];
|
|
1932
1935
|
if (t.length)
|
|
@@ -1954,7 +1957,7 @@ async function Ia(e, t) {
|
|
|
1954
1957
|
}
|
|
1955
1958
|
a = a.sort((r, c) => r.path.localeCompare(c.path));
|
|
1956
1959
|
const s = w("远程模块删除中...").start(), o = a.map((r) => r.id);
|
|
1957
|
-
await
|
|
1960
|
+
await zi({
|
|
1958
1961
|
product: Number(e.id),
|
|
1959
1962
|
moduleIds: o
|
|
1960
1963
|
}), s.text = "本地模块删除中...";
|
|
@@ -1962,10 +1965,10 @@ async function Ia(e, t) {
|
|
|
1962
1965
|
$(r.path) && D.rm("-rf", r.path);
|
|
1963
1966
|
return s.succeed("模块删除完成"), o;
|
|
1964
1967
|
}
|
|
1965
|
-
async function
|
|
1966
|
-
const { type: i, typeStr: n } = await ve("删除", e), { localProduct: a } = await
|
|
1968
|
+
async function xa(e, t) {
|
|
1969
|
+
const { type: i, typeStr: n } = await ve("删除", e), { localProduct: a } = await De(t.productId), s = gt(t.targetIds);
|
|
1967
1970
|
let o = [];
|
|
1968
|
-
if (S.MODULE === i ? o = await
|
|
1971
|
+
if (S.MODULE === i ? o = await Da(a, s) : S.CASE === i && (o = await Ia(a, s)), !t.disableAutoCommit && await u("git status -s")) {
|
|
1969
1972
|
const r = w("代码提交中...").start();
|
|
1970
1973
|
try {
|
|
1971
1974
|
await u(`git add . && git commit -m 'chore: 删除了一些${n}(${o.join(", ")})'`), r.succeed("代码已提交 ✅");
|
|
@@ -1974,8 +1977,8 @@ async function Da(e, t) {
|
|
|
1974
1977
|
}
|
|
1975
1978
|
}
|
|
1976
1979
|
}
|
|
1977
|
-
x.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(
|
|
1978
|
-
async function
|
|
1980
|
+
x.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(xa, ...e));
|
|
1981
|
+
async function La(e, t) {
|
|
1979
1982
|
const n = (await Y(e.path)).filter((f) => f.type === "case");
|
|
1980
1983
|
let a;
|
|
1981
1984
|
if (t.targetId) {
|
|
@@ -2009,7 +2012,7 @@ async function xa(e, t) {
|
|
|
2009
2012
|
prefill: "editable"
|
|
2010
2013
|
}), o = w("用例重命名中...").start();
|
|
2011
2014
|
if (s !== a.displayName) {
|
|
2012
|
-
await
|
|
2015
|
+
await Bi({
|
|
2013
2016
|
id: Number(a.id),
|
|
2014
2017
|
name: s
|
|
2015
2018
|
});
|
|
@@ -2019,14 +2022,14 @@ async function xa(e, t) {
|
|
|
2019
2022
|
o.succeed("用例名称无变动");
|
|
2020
2023
|
const r = j.readJsonSync(l.join(a.path, "config.json"));
|
|
2021
2024
|
let c;
|
|
2022
|
-
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await
|
|
2025
|
+
t.casePriority ? Number.isInteger(t.casePriority) && Number(t.casePriority) > 0 && Number(t.casePriority) < 6 ? c = Number(t.casePriority) : c = await Oe({
|
|
2023
2026
|
message: "修改用例优先级",
|
|
2024
2027
|
min: 1,
|
|
2025
2028
|
max: 5,
|
|
2026
2029
|
required: !0,
|
|
2027
2030
|
default: r.priority,
|
|
2028
2031
|
validate: (f) => f > 0 && f < 6
|
|
2029
|
-
}) : c = await
|
|
2032
|
+
}) : c = await Oe({
|
|
2030
2033
|
message: "修改用例优先级",
|
|
2031
2034
|
min: 1,
|
|
2032
2035
|
max: 5,
|
|
@@ -2035,7 +2038,7 @@ async function xa(e, t) {
|
|
|
2035
2038
|
validate: (f) => f > 0 && f < 6
|
|
2036
2039
|
});
|
|
2037
2040
|
const p = w("用例优先级设置中...").start();
|
|
2038
|
-
c !== r.priority ? (await
|
|
2041
|
+
c !== r.priority ? (await Ui({
|
|
2039
2042
|
id: Number(a.id),
|
|
2040
2043
|
priority: c
|
|
2041
2044
|
}), j.writeJSONSync(
|
|
@@ -2053,7 +2056,7 @@ async function xa(e, t) {
|
|
|
2053
2056
|
prefill: "editable"
|
|
2054
2057
|
});
|
|
2055
2058
|
const y = w("用例前置条件设置中...").start();
|
|
2056
|
-
return d !== r.precondition ? (await
|
|
2059
|
+
return d !== r.precondition ? (await Ji({
|
|
2057
2060
|
id: Number(a.id),
|
|
2058
2061
|
precondition: d
|
|
2059
2062
|
}), j.writeJSONSync(
|
|
@@ -2065,7 +2068,7 @@ async function xa(e, t) {
|
|
|
2065
2068
|
{ spaces: 2 }
|
|
2066
2069
|
), y.succeed(`用例前置条件修改成功:${r.priority} -> ${c}`)) : y.succeed("用例前置条件无变动"), a.id;
|
|
2067
2070
|
}
|
|
2068
|
-
async function
|
|
2071
|
+
async function Pa(e, t) {
|
|
2069
2072
|
const n = (await Y(e.path)).filter((r) => r.type === "module");
|
|
2070
2073
|
let a;
|
|
2071
2074
|
if (t.targetId) {
|
|
@@ -2098,15 +2101,15 @@ async function La(e, t) {
|
|
|
2098
2101
|
validate: (r) => r.length > 0 && r.length < 255,
|
|
2099
2102
|
prefill: "editable"
|
|
2100
2103
|
}), o = w("模块重命名中...").start();
|
|
2101
|
-
return s !== a.displayName ? (await
|
|
2104
|
+
return s !== a.displayName ? (await _i({
|
|
2102
2105
|
id: Number(a.id),
|
|
2103
2106
|
name: s
|
|
2104
2107
|
}), await fe(a.path, s, "module", String(a.id)) && o.succeed(`模块重命名成功: ${a.displayName} -> ${s}`)) : o.succeed("模块名称无变动"), a.id;
|
|
2105
2108
|
}
|
|
2106
|
-
async function
|
|
2107
|
-
const { type: i, typeStr: n } = await ve("修改", e), { localProduct: a } = await
|
|
2109
|
+
async function Oa(e, t) {
|
|
2110
|
+
const { type: i, typeStr: n } = await ve("修改", e), { localProduct: a } = await De(t.productId);
|
|
2108
2111
|
let s;
|
|
2109
|
-
if (S.MODULE === i ? s = await
|
|
2112
|
+
if (S.MODULE === i ? s = await Pa(a, t) : S.CASE === i && (s = await La(a, t)), !t.disableAutoCommit && await u("git status -s")) {
|
|
2110
2113
|
const o = w("代码提交中...").start();
|
|
2111
2114
|
try {
|
|
2112
2115
|
await u(`git add . && git commit -m 'chore: 修改了一个${n}(${s})'`), o.succeed("代码已提交 ✅");
|
|
@@ -2115,16 +2118,16 @@ async function Pa(e, t) {
|
|
|
2115
2118
|
}
|
|
2116
2119
|
}
|
|
2117
2120
|
}
|
|
2118
|
-
x.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) => z(
|
|
2119
|
-
function
|
|
2121
|
+
x.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) => z(Oa, ...e));
|
|
2122
|
+
function Ma() {
|
|
2120
2123
|
process.on("unhandledRejection", (e) => {
|
|
2121
2124
|
}), process.on("uncaughtException", (e) => {
|
|
2122
2125
|
}), D.config.fatal = !0, D.config.silent = !0, D.config.verbose = !1;
|
|
2123
2126
|
}
|
|
2124
|
-
async function
|
|
2127
|
+
async function za() {
|
|
2125
2128
|
const e = pe("latestCheckVersionTimestamp"), t = pe("versionCheckDuring");
|
|
2126
2129
|
if (Date.now() - Number(e) > Number(t) * 24 * 3600 * 1e3) {
|
|
2127
|
-
const i = await
|
|
2130
|
+
const i = await et();
|
|
2128
2131
|
Te(i);
|
|
2129
2132
|
let n;
|
|
2130
2133
|
try {
|
|
@@ -2134,23 +2137,23 @@ async function Ma() {
|
|
|
2134
2137
|
n = await Promise.race([
|
|
2135
2138
|
s,
|
|
2136
2139
|
u(`npm view ${Q.name} version --registry https://registry.npmmirror.com/`)
|
|
2137
|
-
]), n !== a && n !== Q.version && (console.log(`${N.blue(Q.name)}本地版本为${Q.version},低于线上版本${n},开始升级`), await
|
|
2140
|
+
]), n !== a && n !== Q.version && (console.log(`${N.blue(Q.name)}本地版本为${Q.version},低于线上版本${n},开始升级`), await ct(n)), ne("latestCheckVersionTimestamp", Date.now()), te();
|
|
2138
2141
|
} catch (a) {
|
|
2139
2142
|
console.log("升级出错!请重试,或者手动升级"), m(a);
|
|
2140
2143
|
}
|
|
2141
2144
|
}
|
|
2142
2145
|
}
|
|
2143
|
-
async function
|
|
2146
|
+
async function Fa() {
|
|
2144
2147
|
const e = Ct(process.argv.slice(2));
|
|
2145
2148
|
if (!(e.h || e.help || e.v || e.version) && !(["init", "i"].includes(e._[0]) && ![".", "prepare"].includes(e._[1])))
|
|
2146
|
-
if (
|
|
2149
|
+
if (qe()) {
|
|
2147
2150
|
const t = j.readJSONSync(ye());
|
|
2148
|
-
L(t.profile), ne(t.main), Te(t.constants), await
|
|
2151
|
+
L(t.profile), ne(t.main), Te(t.constants), await za();
|
|
2149
2152
|
} else
|
|
2150
|
-
m(`请先初始化z-develop(执行 z i)。更多见${
|
|
2153
|
+
m(`请先初始化z-develop(执行 z i)。更多见${We}`);
|
|
2151
2154
|
}
|
|
2152
|
-
async function
|
|
2153
|
-
|
|
2155
|
+
async function _a() {
|
|
2156
|
+
Ma(), await Fa();
|
|
2154
2157
|
}
|
|
2155
|
-
x.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${N.blue(
|
|
2158
|
+
x.name("z-develop").alias("z").description(`z-develop, 开发流程管理工具。了解更多: ${N.blue(We)}`).usage("<command> [options]").hook("preAction", _a).version(Q.version, "-v, --version", "当前版本号").helpOption("-h, --help", "帮助").showHelpAfterError("可以使用z -h查看帮助。");
|
|
2156
2159
|
x.parse();
|