@done-coding/cli-git 0.6.13-alpha.1 → 0.6.14-alpha.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/es/cli.mjs +3 -2
- package/es/helpers.mjs +11 -10
- package/es/{index-ce13e9d5.js → index-9578a6a4.js} +35 -34
- package/es/index-ca1229e1.js +21 -0
- package/es/index.mjs +19 -18
- package/package.json +8 -12
- package/es/index-f36fe1a6.js +0 -19
package/es/cli.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as m } from "./index-
|
|
3
|
-
import "./index-
|
|
2
|
+
import { c as m } from "./index-ca1229e1.js";
|
|
3
|
+
import "./index-9578a6a4.js";
|
|
4
4
|
import "@done-coding/cli-utils";
|
|
5
|
+
import "node:child_process";
|
|
5
6
|
import "node:fs";
|
|
6
7
|
import "node:path";
|
|
7
8
|
import "@done-coding/request-axios";
|
package/es/helpers.mjs
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { g as i, G as
|
|
3
|
-
import {
|
|
2
|
+
import { g as i, G as n, a as m, h as s } from "./index-9578a6a4.js";
|
|
3
|
+
import { outputConsole as o, xPrompts as a } from "@done-coding/cli-utils";
|
|
4
|
+
import "node:child_process";
|
|
4
5
|
import "node:fs";
|
|
5
6
|
import "node:path";
|
|
6
7
|
import "@done-coding/request-axios";
|
|
7
8
|
import "axios";
|
|
8
|
-
const
|
|
9
|
+
const G = async (e) => {
|
|
9
10
|
o.info("克隆done-coding系列项目"), o.stage("选择平台:");
|
|
10
|
-
const { platform: t } = await
|
|
11
|
+
const { platform: t } = await a(i(n.GITEE));
|
|
11
12
|
o.stage("选择用户名:");
|
|
12
|
-
const { username:
|
|
13
|
+
const { username: r } = await a(
|
|
13
14
|
m(
|
|
14
15
|
{
|
|
15
|
-
[
|
|
16
|
-
[
|
|
16
|
+
[n.GITHUB]: "done-coding",
|
|
17
|
+
[n.GITEE]: "justsosu"
|
|
17
18
|
}[t]
|
|
18
19
|
)
|
|
19
20
|
);
|
|
20
|
-
o.info("platform:", t), o.info("username:",
|
|
21
|
+
o.info("platform:", t), o.info("username:", r), await s({
|
|
21
22
|
platform: t,
|
|
22
|
-
username:
|
|
23
|
+
username: r,
|
|
23
24
|
projectName: e
|
|
24
25
|
});
|
|
25
26
|
};
|
|
26
27
|
export {
|
|
27
|
-
|
|
28
|
+
G as cloneDoneCodingSeries
|
|
28
29
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { lookForParentTarget as Y,
|
|
2
|
+
import { lookForParentTarget as Y, outputConsole as i, decryptAES as Z, encryptAES as W, xPrompts as h, HooksNameEnum as p, addHuskyHooks as ee, initHandlerCommon as te, getConfigFileCommonOptions as I, readConfigFile as R, getCurrentBranchName as se, getCommitByHookName as oe, resolveMergeInfoByGitReflogAction as re, checkCurrentIsRebasing as ne, resolveMergeInfoByCommitMsg as ce, getCurrentBranchLastCommitList as ae, getLastReflogList as ie, createSubcommand as ge, getRootScriptName as me } from "@done-coding/cli-utils";
|
|
3
|
+
import { execSync as N } from "node:child_process";
|
|
3
4
|
import _ from "node:fs";
|
|
4
5
|
import w from "node:path";
|
|
5
6
|
import { createRequest as L } from "@done-coding/request-axios";
|
|
6
7
|
import pe from "axios";
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
timeout:
|
|
8
|
+
var l = /* @__PURE__ */ ((e) => (e.INIT = "init", e.CLONE = "clone", e.HOOKS = "hooks", e.CHECK = "check", e))(l || {}), d = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.CLONE_CONFIG = "cloneConfig", e))(d || {}), E = /* @__PURE__ */ ((e) => (e.GITHUB = "github", e.GITEE = "gitee", e))(E || {}), C = /* @__PURE__ */ ((e) => (e.REVERSE_MERGE = "reverseMerge", e))(C || {}), u = /* @__PURE__ */ ((e) => (e.REFLOG_ACTION = "reflog-action", e.COMMIT_MSG = "commit-msg", e.COMMIT_RECORD = "commit-record", e.PRE_REBASE = "pre-rebase", e))(u || {});
|
|
9
|
+
const fe = 3e4, y = Math.random(), U = {
|
|
10
|
+
timeout: fe,
|
|
10
11
|
getBusinessCode() {
|
|
11
12
|
return y;
|
|
12
13
|
},
|
|
@@ -24,7 +25,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
24
25
|
}), A = L({
|
|
25
26
|
basePath: "https://api.github.com",
|
|
26
27
|
...U
|
|
27
|
-
}),
|
|
28
|
+
}), le = ({
|
|
28
29
|
username: e
|
|
29
30
|
}) => x({
|
|
30
31
|
url: `/api/v5/users/${e}/repos`,
|
|
@@ -60,7 +61,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
60
61
|
}
|
|
61
62
|
}), T = {
|
|
62
63
|
name: "@done-coding/cli-git",
|
|
63
|
-
version: "0.6.
|
|
64
|
+
version: "0.6.14-alpha.0",
|
|
64
65
|
description: "git跨平台操作命令行工具",
|
|
65
66
|
bin: {
|
|
66
67
|
"dc-git": "es/cli.mjs"
|
|
@@ -93,10 +94,10 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
93
94
|
}) => {
|
|
94
95
|
const o = H(s), n = JSON.stringify({
|
|
95
96
|
accessToken: r
|
|
96
|
-
}), g = D({ platform: s, username: t }),
|
|
97
|
+
}), g = D({ platform: s, username: t }), f = W({ text: n, secretKey: g }), a = w.join(e, o);
|
|
97
98
|
_.mkdirSync(w.dirname(a), {
|
|
98
99
|
recursive: !0
|
|
99
|
-
}), _.writeFileSync(a,
|
|
100
|
+
}), _.writeFileSync(a, f, "utf-8"), i.success(`配置信息保存成功 ${a}`);
|
|
100
101
|
}, B = [
|
|
101
102
|
{ title: "GitHub", value: E.GITHUB },
|
|
102
103
|
{ title: "Gitee", value: E.GITEE }
|
|
@@ -145,13 +146,13 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
145
146
|
});
|
|
146
147
|
let g = n == null ? void 0 : n.accessToken;
|
|
147
148
|
i.stage(`正在获取${o}的${r}仓库列表...`);
|
|
148
|
-
const
|
|
149
|
+
const f = {
|
|
149
150
|
username: o,
|
|
150
151
|
accessToken: g
|
|
151
152
|
};
|
|
152
153
|
switch (s.platform) {
|
|
153
154
|
case E.GITHUB: {
|
|
154
|
-
c = (await (
|
|
155
|
+
c = (await (f.accessToken ? he : Ee)(f)).data.map((m) => ({
|
|
155
156
|
name: m.name,
|
|
156
157
|
httpUrl: m.clone_url,
|
|
157
158
|
sshUrl: m.ssh_url,
|
|
@@ -160,7 +161,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
160
161
|
break;
|
|
161
162
|
}
|
|
162
163
|
case E.GITEE: {
|
|
163
|
-
c = (await (
|
|
164
|
+
c = (await (f.accessToken ? ue : le)(f)).data.map((m) => ({
|
|
164
165
|
name: m.name,
|
|
165
166
|
httpUrl: m.html_url,
|
|
166
167
|
sshUrl: m.ssh_url,
|
|
@@ -203,7 +204,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
203
204
|
p.PRE_REBASE
|
|
204
205
|
], $ = (e) => {
|
|
205
206
|
const {
|
|
206
|
-
[
|
|
207
|
+
[l.CHECK]: { [C.REVERSE_MERGE]: t }
|
|
207
208
|
} = e;
|
|
208
209
|
return t;
|
|
209
210
|
}, Te = (e) => Math.max(
|
|
@@ -213,7 +214,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
213
214
|
(s, [r, { afterHash: o, logCount: c }]) => {
|
|
214
215
|
let n = c - 1;
|
|
215
216
|
if (o) {
|
|
216
|
-
const g = t.findIndex((
|
|
217
|
+
const g = t.findIndex((f) => f.hash === o);
|
|
217
218
|
g !== -1 && (i.info(
|
|
218
219
|
`${r} 设置 只检测 ${o} 之后的日志 即 下标 [0 - ${g})`
|
|
219
220
|
), n = Math.min(n, g - 1));
|
|
@@ -240,7 +241,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
240
241
|
);
|
|
241
242
|
return n || i.skip(`跳过: 允许${r} => ${o}`), n;
|
|
242
243
|
}, Ge = {
|
|
243
|
-
[
|
|
244
|
+
[l.CHECK]: {
|
|
244
245
|
[C.REVERSE_MERGE]: {
|
|
245
246
|
[/^test$/.source]: {
|
|
246
247
|
includeRebase: !0,
|
|
@@ -260,9 +261,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
260
261
|
default: d.DEFAULT
|
|
261
262
|
}
|
|
262
263
|
}), ke = (e) => {
|
|
263
|
-
N(
|
|
264
|
-
`npm pkg set scripts.postprepare="${e} init"`
|
|
265
|
-
);
|
|
264
|
+
N(`npm pkg set scripts.postprepare="${e} init"`);
|
|
266
265
|
}, j = async (e) => {
|
|
267
266
|
const { type: t } = e;
|
|
268
267
|
switch (t) {
|
|
@@ -291,7 +290,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
291
290
|
throw new Error(`未知的初始化类型: ${t}`);
|
|
292
291
|
}
|
|
293
292
|
}, be = {
|
|
294
|
-
command:
|
|
293
|
+
command: l.INIT,
|
|
295
294
|
describe: "初始化配置文件",
|
|
296
295
|
options: Pe(),
|
|
297
296
|
handler: j
|
|
@@ -318,7 +317,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
318
317
|
{ stdio: "inherit" }
|
|
319
318
|
), i.success(`克隆${t}成功`);
|
|
320
319
|
}, Be = {
|
|
321
|
-
command: `${
|
|
320
|
+
command: `${l.CLONE} <platform> <username>`,
|
|
322
321
|
describe: "从选择的git平台克隆代码",
|
|
323
322
|
options: we(),
|
|
324
323
|
positionals: ye(),
|
|
@@ -371,7 +370,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
371
370
|
configMap: c,
|
|
372
371
|
currentBranch: t
|
|
373
372
|
})) {
|
|
374
|
-
const { fromBranch: g, toBranch:
|
|
373
|
+
const { fromBranch: g, toBranch: f = t } = o, a = `禁止${g}被合并: ${g} => ${f}
|
|
375
374
|
|
|
376
375
|
--------- 建议 ---------
|
|
377
376
|
可以通过
|
|
@@ -389,7 +388,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
389
388
|
const s = $(e), r = Te(s);
|
|
390
389
|
if (!r)
|
|
391
390
|
return;
|
|
392
|
-
const o = ae({ count: r }), c = Se(s, o), n = o.map((a) => a.hash),
|
|
391
|
+
const o = ae({ count: r }), c = Se(s, o), n = o.map((a) => a.hash), f = ie({
|
|
393
392
|
/** 考虑reflog存在往复切换 */
|
|
394
393
|
count: r + 30,
|
|
395
394
|
filterItem: (a) => n.includes(a.hash)
|
|
@@ -399,11 +398,13 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
399
398
|
);
|
|
400
399
|
o.forEach((a, m) => {
|
|
401
400
|
var P;
|
|
402
|
-
const O = a.mergeInfo || ((P =
|
|
401
|
+
const O = a.mergeInfo || ((P = f[a.hash]) == null ? void 0 : P.mergeInfo);
|
|
403
402
|
O && Object.entries(s).forEach(([k]) => {
|
|
404
403
|
const b = c[k];
|
|
405
404
|
if (m > b) {
|
|
406
|
-
i.skip(
|
|
405
|
+
i.skip(
|
|
406
|
+
`${k} 只检测${b + 1}条, 超出不再检测`
|
|
407
|
+
);
|
|
407
408
|
return;
|
|
408
409
|
}
|
|
409
410
|
const z = G({
|
|
@@ -501,7 +502,7 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
501
502
|
throw new Error(`不支持的检测类型${s}`);
|
|
502
503
|
}
|
|
503
504
|
}, He = {
|
|
504
|
-
command: `${
|
|
505
|
+
command: `${l.CHECK} <type>`,
|
|
505
506
|
describe: "检查git操作",
|
|
506
507
|
options: Ne(),
|
|
507
508
|
positionals: Le(),
|
|
@@ -559,25 +560,25 @@ const le = 3e4, y = Math.random(), U = {
|
|
|
559
560
|
i.error(`${t} 当前未支持处理`);
|
|
560
561
|
}
|
|
561
562
|
}, Ke = {
|
|
562
|
-
command: `${
|
|
563
|
+
command: `${l.HOOKS} <name> [args...]`,
|
|
563
564
|
describe: "git钩子回调",
|
|
564
565
|
options: De(),
|
|
565
566
|
positionals: ve(),
|
|
566
567
|
handler: J
|
|
567
|
-
},
|
|
568
|
+
}, Ze = async (e, t) => {
|
|
568
569
|
switch (e) {
|
|
569
|
-
case
|
|
570
|
+
case l.INIT:
|
|
570
571
|
return j(t);
|
|
571
|
-
case
|
|
572
|
+
case l.CLONE:
|
|
572
573
|
return V(t);
|
|
573
|
-
case
|
|
574
|
+
case l.HOOKS:
|
|
574
575
|
return J(t);
|
|
575
|
-
case
|
|
576
|
+
case l.CHECK:
|
|
576
577
|
return q(t);
|
|
577
578
|
default:
|
|
578
579
|
throw new Error(`不支持的命令 ${e}`);
|
|
579
580
|
}
|
|
580
|
-
}, { version: je, description: Ve } = T,
|
|
581
|
+
}, { version: je, description: Ve } = T, We = {
|
|
581
582
|
describe: Ve,
|
|
582
583
|
version: je,
|
|
583
584
|
subcommands: [
|
|
@@ -593,10 +594,10 @@ export {
|
|
|
593
594
|
C,
|
|
594
595
|
E as G,
|
|
595
596
|
d as I,
|
|
596
|
-
|
|
597
|
+
l as S,
|
|
597
598
|
K as a,
|
|
598
599
|
Oe as b,
|
|
599
|
-
|
|
600
|
+
We as c,
|
|
600
601
|
j as d,
|
|
601
602
|
be as e,
|
|
602
603
|
Be as f,
|
|
@@ -607,6 +608,6 @@ export {
|
|
|
607
608
|
Ke as k,
|
|
608
609
|
q as l,
|
|
609
610
|
He as m,
|
|
610
|
-
|
|
611
|
+
Ze as n,
|
|
611
612
|
u as o
|
|
612
613
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { c as a, i as t } from "./index-9578a6a4.js";
|
|
3
|
+
import { createMainCommand as s, createSubcommand as r } from "@done-coding/cli-utils";
|
|
4
|
+
const {
|
|
5
|
+
cliConfig: { moduleName: o }
|
|
6
|
+
} = t, e = (n = !1) => {
|
|
7
|
+
const c = n ? o : void 0, m = `$0${n ? ` ${o}` : ""} <command> [options]`;
|
|
8
|
+
return { command: c, usage: m };
|
|
9
|
+
}, u = async () => s({
|
|
10
|
+
...a,
|
|
11
|
+
...e()
|
|
12
|
+
}), f = () => r({
|
|
13
|
+
...a,
|
|
14
|
+
...e(!0),
|
|
15
|
+
// git 子命令不显示描述信息 即不在父命令的描述信息中显示
|
|
16
|
+
describe: !1
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
f as a,
|
|
20
|
+
u as c
|
|
21
|
+
};
|
package/es/index.mjs
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { o as
|
|
3
|
-
import { a as
|
|
2
|
+
import { o as t, C as l, G as d, I as c, S as C, m as p, l as f, f as h, h as u, c as k, b as I, n as E, k as b, j as H, e as g, d as y } from "./index-9578a6a4.js";
|
|
3
|
+
import { a as T } from "./index-ca1229e1.js";
|
|
4
4
|
import "@done-coding/cli-utils";
|
|
5
|
+
import "node:child_process";
|
|
5
6
|
import "node:fs";
|
|
6
7
|
import "node:path";
|
|
7
8
|
import "@done-coding/request-axios";
|
|
8
9
|
import "axios";
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
+
t as CheckReverseMergeWayEnum,
|
|
11
12
|
l as CheckTypeEnum,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
d as GitPlatformEnum,
|
|
14
|
+
c as InitTypeEnum,
|
|
15
|
+
C as SubcommandEnum,
|
|
16
|
+
p as checkCommandCliInfo,
|
|
17
|
+
f as checkHandler,
|
|
18
|
+
h as cloneCommandCliInfo,
|
|
19
|
+
u as cloneHandler,
|
|
20
|
+
k as commandCliInfo,
|
|
21
|
+
T as crateAsSubcommand,
|
|
22
|
+
I as getTargetRepoUrl,
|
|
23
|
+
E as handler,
|
|
24
|
+
b as hooksCommandCliInfo,
|
|
25
|
+
H as hooksHandler,
|
|
26
|
+
g as initCommandCliInfo,
|
|
27
|
+
y as initHandler
|
|
27
28
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-git",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14-alpha.0",
|
|
4
4
|
"description": "git跨平台操作命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -32,10 +32,7 @@
|
|
|
32
32
|
"types"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"predev": "pnpm run clean",
|
|
37
|
-
"dev": "vite build --watch",
|
|
38
|
-
"prebuild": "pnpm run clean",
|
|
35
|
+
"dev": "vite build -w -m hotBuild",
|
|
39
36
|
"build": "vite build",
|
|
40
37
|
"prepack": "pnpm build"
|
|
41
38
|
},
|
|
@@ -52,21 +49,20 @@
|
|
|
52
49
|
"license": "MIT",
|
|
53
50
|
"sideEffects": false,
|
|
54
51
|
"devDependencies": {
|
|
55
|
-
"@done-coding/cli-inject": "0.5.
|
|
52
|
+
"@done-coding/cli-inject": "0.5.22-alpha.0",
|
|
56
53
|
"@types/node": "^18.0.0",
|
|
57
54
|
"@types/yargs": "^17.0.28",
|
|
58
|
-
"rimraf": "^6.0.1",
|
|
59
55
|
"typescript": "^5.8.3",
|
|
60
56
|
"vite": "^4.4.11",
|
|
61
57
|
"vite-plugin-dts": "^3.6.0"
|
|
62
58
|
},
|
|
63
|
-
"engines": {
|
|
64
|
-
"node": ">=18.0.0"
|
|
65
|
-
},
|
|
66
59
|
"dependencies": {
|
|
67
|
-
"@done-coding/cli-utils": "0.8.
|
|
60
|
+
"@done-coding/cli-utils": "0.8.3-alpha.0",
|
|
68
61
|
"@done-coding/request-axios": "^1.2.2",
|
|
69
62
|
"axios": "^1.8.4"
|
|
70
63
|
},
|
|
71
|
-
"
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=18.0.0"
|
|
66
|
+
},
|
|
67
|
+
"gitHead": "906b7683d9e4dc75fb07806b12e5507827122a16"
|
|
72
68
|
}
|
package/es/index-f36fe1a6.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { c as a, i as t } from "./index-ce13e9d5.js";
|
|
3
|
-
import { createMainCommand as r, createSubcommand as s } from "@done-coding/cli-utils";
|
|
4
|
-
const {
|
|
5
|
-
cliConfig: { moduleName: o }
|
|
6
|
-
} = t, c = (n = !1) => {
|
|
7
|
-
const e = n ? o : void 0, m = `$0${n ? ` ${o}` : ""} <command> [options]`;
|
|
8
|
-
return { command: e, usage: m };
|
|
9
|
-
}, u = async () => r({
|
|
10
|
-
...a,
|
|
11
|
-
...c()
|
|
12
|
-
}), f = () => s({
|
|
13
|
-
...a,
|
|
14
|
-
...c(!0)
|
|
15
|
-
});
|
|
16
|
-
export {
|
|
17
|
-
f as a,
|
|
18
|
-
u as c
|
|
19
|
-
};
|