done-coding-git 0.6.5-alpha.0 → 0.6.6
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
CHANGED
package/es/helpers.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { lookForParentTarget as Y, log as i, decryptAES as Z, encryptAES as W, xPrompts as
|
|
2
|
+
import { lookForParentTarget as Y, log as i, decryptAES as Z, encryptAES as W, xPrompts as d, HooksNameEnum as f, 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
3
|
import { execSync as N } from "node:child_process";
|
|
4
4
|
import _ from "node:fs";
|
|
5
5
|
import w from "node:path";
|
|
6
6
|
import { createRequest as L } from "@done-coding/request-axios";
|
|
7
|
-
import
|
|
8
|
-
var l = /* @__PURE__ */ ((e) => (e.INIT = "init", e.CLONE = "clone", e.HOOKS = "hooks", e.CHECK = "check", e))(l || {}),
|
|
9
|
-
const
|
|
10
|
-
timeout:
|
|
7
|
+
import fe from "axios";
|
|
8
|
+
var l = /* @__PURE__ */ ((e) => (e.INIT = "init", e.CLONE = "clone", e.HOOKS = "hooks", e.CHECK = "check", e))(l || {}), h = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.CLONE_CONFIG = "cloneConfig", e))(h || {}), 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 pe = 3e4, y = Math.random(), U = {
|
|
10
|
+
timeout: pe,
|
|
11
11
|
getBusinessCode() {
|
|
12
12
|
return y;
|
|
13
13
|
},
|
|
@@ -18,7 +18,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
18
18
|
return e.data;
|
|
19
19
|
},
|
|
20
20
|
businessSuccessCodeList: [y],
|
|
21
|
-
axios:
|
|
21
|
+
axios: fe
|
|
22
22
|
}, x = L({
|
|
23
23
|
basePath: " https://gitee.com",
|
|
24
24
|
...U
|
|
@@ -46,7 +46,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
46
46
|
}) => A({
|
|
47
47
|
url: `/users/${e}/repos`,
|
|
48
48
|
method: "GET"
|
|
49
|
-
}),
|
|
49
|
+
}), de = ({
|
|
50
50
|
accessToken: e
|
|
51
51
|
}) => A({
|
|
52
52
|
url: "/user/repos",
|
|
@@ -61,7 +61,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
61
61
|
}
|
|
62
62
|
}), T = {
|
|
63
63
|
name: "@done-coding/cli-git",
|
|
64
|
-
version: "0.6.
|
|
64
|
+
version: "0.6.6",
|
|
65
65
|
description: "git跨平台操作命令行工具",
|
|
66
66
|
bin: {
|
|
67
67
|
"dc-git": "es/cli.mjs"
|
|
@@ -71,8 +71,8 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
71
71
|
moduleName: "git"
|
|
72
72
|
}
|
|
73
73
|
}, {
|
|
74
|
-
cliConfig: { namespaceDir:
|
|
75
|
-
} = T, F = `./${
|
|
74
|
+
cliConfig: { namespaceDir: he, moduleName: Re }
|
|
75
|
+
} = T, F = `./${he}/${Re}`, S = `${F}.json`, H = (e) => `${F}/.${e}`, D = ({ platform: e, username: t }) => `${e}/${t}`, Me = (e) => {
|
|
76
76
|
const { platform: t } = e, s = H(t), r = Y(s, {
|
|
77
77
|
isFindFarthest: !1
|
|
78
78
|
});
|
|
@@ -94,10 +94,10 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
94
94
|
}) => {
|
|
95
95
|
const o = H(s), n = JSON.stringify({
|
|
96
96
|
accessToken: r
|
|
97
|
-
}), g = D({ platform: s, username: t }),
|
|
97
|
+
}), g = D({ platform: s, username: t }), p = W({ text: n, secretKey: g }), a = w.join(e, o);
|
|
98
98
|
_.mkdirSync(w.dirname(a), {
|
|
99
99
|
recursive: !0
|
|
100
|
-
}), _.writeFileSync(a,
|
|
100
|
+
}), _.writeFileSync(a, p, "utf-8"), i.success(`配置信息保存成功 ${a}`);
|
|
101
101
|
}, B = [
|
|
102
102
|
{ title: "GitHub", value: E.GITHUB },
|
|
103
103
|
{ title: "Gitee", value: E.GITEE }
|
|
@@ -137,7 +137,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
137
137
|
platform: e,
|
|
138
138
|
username: t
|
|
139
139
|
};
|
|
140
|
-
e || (s.platform = (await
|
|
140
|
+
e || (s.platform = (await d(v())).platform), t || (s.username = (await d(K())).username);
|
|
141
141
|
const { platform: r, username: o } = s;
|
|
142
142
|
let c = [];
|
|
143
143
|
const n = Me({
|
|
@@ -146,13 +146,13 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
146
146
|
});
|
|
147
147
|
let g = n == null ? void 0 : n.accessToken;
|
|
148
148
|
i.stage(`正在获取${o}的${r}仓库列表...`);
|
|
149
|
-
const
|
|
149
|
+
const p = {
|
|
150
150
|
username: o,
|
|
151
151
|
accessToken: g
|
|
152
152
|
};
|
|
153
153
|
switch (s.platform) {
|
|
154
154
|
case E.GITHUB: {
|
|
155
|
-
c = (await (
|
|
155
|
+
c = (await (p.accessToken ? de : Ee)(p)).data.map((m) => ({
|
|
156
156
|
name: m.name,
|
|
157
157
|
httpUrl: m.clone_url,
|
|
158
158
|
sshUrl: m.ssh_url,
|
|
@@ -161,7 +161,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
163
|
case E.GITEE: {
|
|
164
|
-
c = (await (
|
|
164
|
+
c = (await (p.accessToken ? ue : le)(p)).data.map((m) => ({
|
|
165
165
|
name: m.name,
|
|
166
166
|
httpUrl: m.html_url,
|
|
167
167
|
sshUrl: m.ssh_url,
|
|
@@ -177,7 +177,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
177
177
|
return;
|
|
178
178
|
} else
|
|
179
179
|
i.stage(`共${c.length}个仓库`);
|
|
180
|
-
const { repoUrl: a } = await
|
|
180
|
+
const { repoUrl: a } = await d({
|
|
181
181
|
name: "repoUrl",
|
|
182
182
|
type: "select",
|
|
183
183
|
message: "选择仓库",
|
|
@@ -188,20 +188,20 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
188
188
|
});
|
|
189
189
|
return a;
|
|
190
190
|
}, _e = [
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
191
|
+
f.PRE_COMMIT,
|
|
192
|
+
f.PRE_MERGE_COMMIT,
|
|
193
|
+
f.PREPARE_COMMIT_MSG,
|
|
194
|
+
f.COMMIT_MSG,
|
|
195
|
+
f.PRE_REBASE,
|
|
196
|
+
f.POST_COMMIT,
|
|
197
|
+
f.POST_MERGE,
|
|
198
|
+
f.PRE_PUSH
|
|
199
199
|
], Ie = [
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
f.PRE_MERGE_COMMIT,
|
|
201
|
+
f.PREPARE_COMMIT_MSG,
|
|
202
|
+
f.POST_MERGE,
|
|
203
|
+
f.PRE_PUSH,
|
|
204
|
+
f.PRE_REBASE
|
|
205
205
|
], $ = (e) => {
|
|
206
206
|
const {
|
|
207
207
|
[l.CHECK]: { [C.REVERSE_MERGE]: t }
|
|
@@ -214,7 +214,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
214
214
|
(s, [r, { afterHash: o, logCount: c }]) => {
|
|
215
215
|
let n = c - 1;
|
|
216
216
|
if (o) {
|
|
217
|
-
const g = t.findIndex((
|
|
217
|
+
const g = t.findIndex((p) => p.hash === o);
|
|
218
218
|
g !== -1 && (i.info(
|
|
219
219
|
`${r} 设置 只检测 ${o} 之后的日志 即 下标 [0 - ${g})`
|
|
220
220
|
), n = Math.min(n, g - 1));
|
|
@@ -257,15 +257,15 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
257
257
|
type: {
|
|
258
258
|
alias: "t",
|
|
259
259
|
describe: "初始化类型",
|
|
260
|
-
choices: [
|
|
261
|
-
default:
|
|
260
|
+
choices: [h.DEFAULT, h.CLONE_CONFIG],
|
|
261
|
+
default: h.DEFAULT
|
|
262
262
|
}
|
|
263
263
|
}), ke = (e) => {
|
|
264
264
|
N(`npm pkg set scripts.postprepare="${e} init"`);
|
|
265
265
|
}, j = async (e) => {
|
|
266
266
|
const { type: t } = e;
|
|
267
267
|
switch (t) {
|
|
268
|
-
case
|
|
268
|
+
case h.DEFAULT: {
|
|
269
269
|
const { rootDir: s, isSubCommand: r, _: o } = e, c = `${e.$0}${r ? ` ${o[0]}` : ""}`;
|
|
270
270
|
return await ee({
|
|
271
271
|
hookNames: Ie,
|
|
@@ -277,8 +277,8 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
277
277
|
}
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
|
-
case
|
|
281
|
-
const { rootDir: s } = e, { platform: r } = await
|
|
280
|
+
case h.CLONE_CONFIG: {
|
|
281
|
+
const { rootDir: s } = e, { platform: r } = await d(v()), { username: o } = await d(K()), { accessToken: c } = await d($e);
|
|
282
282
|
return Ce({
|
|
283
283
|
rootDir: s,
|
|
284
284
|
platform: r,
|
|
@@ -370,7 +370,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
370
370
|
configMap: c,
|
|
371
371
|
currentBranch: t
|
|
372
372
|
})) {
|
|
373
|
-
const { fromBranch: g, toBranch:
|
|
373
|
+
const { fromBranch: g, toBranch: p = t } = o, a = `禁止${g}被合并: ${g} => ${p}
|
|
374
374
|
|
|
375
375
|
--------- 建议 ---------
|
|
376
376
|
可以通过
|
|
@@ -388,7 +388,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
388
388
|
const s = $(e), r = Te(s);
|
|
389
389
|
if (!r)
|
|
390
390
|
return;
|
|
391
|
-
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), p = ie({
|
|
392
392
|
/** 考虑reflog存在往复切换 */
|
|
393
393
|
count: r + 30,
|
|
394
394
|
filterItem: (a) => n.includes(a.hash)
|
|
@@ -398,7 +398,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
398
398
|
);
|
|
399
399
|
o.forEach((a, m) => {
|
|
400
400
|
var P;
|
|
401
|
-
const O = a.mergeInfo || ((P =
|
|
401
|
+
const O = a.mergeInfo || ((P = p[a.hash]) == null ? void 0 : P.mergeInfo);
|
|
402
402
|
O && Object.entries(s).forEach(([k]) => {
|
|
403
403
|
const b = c[k];
|
|
404
404
|
if (m > b) {
|
|
@@ -516,7 +516,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
516
516
|
}), J = async (e) => {
|
|
517
517
|
const { name: t, rootDir: s, args: r } = e;
|
|
518
518
|
switch (t) {
|
|
519
|
-
case
|
|
519
|
+
case f.PRE_MERGE_COMMIT: {
|
|
520
520
|
const o = await R(e);
|
|
521
521
|
M({
|
|
522
522
|
config: o,
|
|
@@ -525,7 +525,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
525
525
|
});
|
|
526
526
|
break;
|
|
527
527
|
}
|
|
528
|
-
case
|
|
528
|
+
case f.PREPARE_COMMIT_MSG: {
|
|
529
529
|
const o = await R(e);
|
|
530
530
|
M({
|
|
531
531
|
config: o,
|
|
@@ -535,8 +535,8 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
535
535
|
});
|
|
536
536
|
break;
|
|
537
537
|
}
|
|
538
|
-
case
|
|
539
|
-
case
|
|
538
|
+
case f.POST_MERGE:
|
|
539
|
+
case f.PRE_PUSH: {
|
|
540
540
|
const o = await R(e);
|
|
541
541
|
M({
|
|
542
542
|
config: o,
|
|
@@ -545,7 +545,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
545
545
|
});
|
|
546
546
|
break;
|
|
547
547
|
}
|
|
548
|
-
case
|
|
548
|
+
case f.PRE_REBASE: {
|
|
549
549
|
const o = await R(e);
|
|
550
550
|
M({
|
|
551
551
|
config: o,
|
|
@@ -591,7 +591,7 @@ const fe = 3e4, y = Math.random(), U = {
|
|
|
591
591
|
export {
|
|
592
592
|
C,
|
|
593
593
|
E as G,
|
|
594
|
-
|
|
594
|
+
h as I,
|
|
595
595
|
l as S,
|
|
596
596
|
K as a,
|
|
597
597
|
Oe as b,
|
package/es/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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-
|
|
3
|
-
import { a as T } from "./index-
|
|
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-7315360a.js";
|
|
3
|
+
import { a as T } from "./index-3f895167.js";
|
|
4
4
|
import "@done-coding/cli-utils";
|
|
5
5
|
import "node:child_process";
|
|
6
6
|
import "node:fs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "done-coding-git",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "git跨平台操作命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"bin": "es/cli.mjs",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"import": "./es/index.mjs"
|
|
12
|
+
"import": "./es/index.mjs",
|
|
13
|
+
"types": "./types/index.d.ts"
|
|
13
14
|
},
|
|
14
15
|
"./helpers": {
|
|
15
16
|
"import": "./es/helpers.mjs",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"license": "MIT",
|
|
42
43
|
"sideEffects": false,
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@done-coding/cli-inject": "^0.5.
|
|
45
|
+
"@done-coding/cli-inject": "^0.5.14",
|
|
45
46
|
"@types/node": "^18.0.0",
|
|
46
47
|
"@types/yargs": "^17.0.28",
|
|
47
48
|
"rimraf": "^6.0.1",
|
|
@@ -53,10 +54,10 @@
|
|
|
53
54
|
"node": ">=18.0.0"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@done-coding/cli-utils": "^0.7.
|
|
57
|
+
"@done-coding/cli-utils": "^0.7.5",
|
|
57
58
|
"@done-coding/request-axios": "^1.1.1",
|
|
58
59
|
"axios": "^1.8.4"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "fb405d55a9fe10014863d725b1f4e3bcd45412af",
|
|
61
62
|
"scripts": {}
|
|
62
63
|
}
|