@done-coding/cli-git 0.2.0 → 0.2.2-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 +2 -2
- package/es/{index-20b2b104.js → index-e8efef08.js} +78 -73
- package/es/index.mjs +2 -2
- package/package.json +4 -4
- package/types/injectInfo.json.d.ts +1 -1
package/es/cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as r } from "./index-
|
|
2
|
+
import { c as r } from "./index-e8efef08.js";
|
|
3
3
|
import "chalk";
|
|
4
4
|
import "@done-coding/request-axios";
|
|
5
5
|
import "axios";
|
|
6
6
|
import "prompts";
|
|
7
|
-
import "@done-coding/
|
|
7
|
+
import "@done-coding/cli-utils";
|
|
8
8
|
import "node:fs";
|
|
9
9
|
import "node:path";
|
|
10
10
|
import "node:child_process";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import s from "chalk";
|
|
3
|
-
import { createRequest as
|
|
4
|
-
import
|
|
3
|
+
import { createRequest as C } from "@done-coding/request-axios";
|
|
4
|
+
import S from "axios";
|
|
5
5
|
import g from "prompts";
|
|
6
|
-
import { lookForParentTarget as
|
|
7
|
-
import
|
|
6
|
+
import { lookForParentTarget as v, decryptAES as w, onPromptFormStateForSigint as d } from "@done-coding/cli-utils";
|
|
7
|
+
import B from "node:fs";
|
|
8
8
|
import "node:path";
|
|
9
|
-
import { execSync as
|
|
10
|
-
import
|
|
11
|
-
import { hideBin as
|
|
12
|
-
import
|
|
9
|
+
import { execSync as I } from "node:child_process";
|
|
10
|
+
import N from "yargs";
|
|
11
|
+
import { hideBin as x } from "yargs/helpers";
|
|
12
|
+
import P from "lodash.curry";
|
|
13
13
|
var m = /* @__PURE__ */ ((e) => (e.CLONE = "clone", e))(m || {}), i = /* @__PURE__ */ ((e) => (e.GITHUB = "github", e.GITEE = "gitee", e))(i || {});
|
|
14
|
-
const
|
|
15
|
-
timeout:
|
|
14
|
+
const _ = 1e4, h = Math.random(), $ = {
|
|
15
|
+
timeout: _,
|
|
16
16
|
getBusinessCode() {
|
|
17
|
-
return
|
|
17
|
+
return h;
|
|
18
18
|
},
|
|
19
19
|
getBusinessMsg(e) {
|
|
20
20
|
return e.statusText;
|
|
@@ -22,22 +22,22 @@ const x = 1e4, f = Math.random(), $ = {
|
|
|
22
22
|
getBusinessData(e) {
|
|
23
23
|
return e.data;
|
|
24
24
|
},
|
|
25
|
-
businessSuccessCodeList: [
|
|
26
|
-
axios:
|
|
27
|
-
},
|
|
25
|
+
businessSuccessCodeList: [h],
|
|
26
|
+
axios: S
|
|
27
|
+
}, U = C({
|
|
28
28
|
basePath: " https://gitee.com",
|
|
29
29
|
...$
|
|
30
|
-
}), O =
|
|
30
|
+
}), O = C({
|
|
31
31
|
basePath: "https://api.github.com",
|
|
32
32
|
...$
|
|
33
33
|
}), k = ({
|
|
34
34
|
username: e
|
|
35
|
-
}) =>
|
|
35
|
+
}) => U({
|
|
36
36
|
url: `/api/v5/users/${e}/repos`,
|
|
37
37
|
method: "GET"
|
|
38
38
|
}), D = ({
|
|
39
39
|
accessToken: e
|
|
40
|
-
}) =>
|
|
40
|
+
}) => U({
|
|
41
41
|
url: "/api/v5/user/repos",
|
|
42
42
|
method: "GET",
|
|
43
43
|
params: {
|
|
@@ -46,35 +46,35 @@ const x = 1e4, f = Math.random(), $ = {
|
|
|
46
46
|
page: 1,
|
|
47
47
|
sort: "updated"
|
|
48
48
|
}
|
|
49
|
-
}),
|
|
49
|
+
}), R = ({
|
|
50
50
|
username: e
|
|
51
51
|
}) => O({
|
|
52
52
|
url: `/users/${e}/repos`,
|
|
53
53
|
method: "GET"
|
|
54
|
-
}),
|
|
55
|
-
version: "0.2.0",
|
|
54
|
+
}), p = {
|
|
55
|
+
version: "0.2.2-alpha.0",
|
|
56
56
|
name: "@done-coding/cli-git",
|
|
57
57
|
description: "git跨平台操作命令行工具",
|
|
58
58
|
cliConfig: {
|
|
59
59
|
namespaceDir: ".done-coding",
|
|
60
60
|
moduleName: "git"
|
|
61
61
|
}
|
|
62
|
-
}, { namespaceDir:
|
|
62
|
+
}, { namespaceDir: H, moduleName: F } = p.cliConfig, L = `${H}/${F}`, q = (e) => `${L}/.${e}`, M = ({
|
|
63
63
|
secretKey: e,
|
|
64
64
|
platform: o
|
|
65
65
|
}) => {
|
|
66
|
-
const n =
|
|
66
|
+
const n = q(o), r = v(n);
|
|
67
67
|
if (!r) {
|
|
68
68
|
console.log(s.yellow("配置文件不存在"));
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const a = `${r}/${n}`, c =
|
|
71
|
+
const a = `${r}/${n}`, c = B.readFileSync(a, "utf-8"), l = w({ encryptedText: c, secretKey: e });
|
|
72
72
|
if (!l) {
|
|
73
73
|
console.log(s.yellow("配置文件解密失败"));
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
return JSON.parse(l);
|
|
77
|
-
},
|
|
77
|
+
}, A = async ({
|
|
78
78
|
platform: e,
|
|
79
79
|
username: o
|
|
80
80
|
} = {}) => {
|
|
@@ -82,42 +82,42 @@ const x = 1e4, f = Math.random(), $ = {
|
|
|
82
82
|
platform: e,
|
|
83
83
|
username: o
|
|
84
84
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
validate: (t) => t === void 0 ? "请选择git平台" : !0
|
|
100
|
-
})).platform), o || (n.username = (await g({
|
|
85
|
+
if (!e) {
|
|
86
|
+
const t = [
|
|
87
|
+
{ title: "GitHub", value: i.GITHUB },
|
|
88
|
+
{ title: "Gitee", value: i.GITEE }
|
|
89
|
+
];
|
|
90
|
+
n.platform = (await g({
|
|
91
|
+
type: "select",
|
|
92
|
+
name: "platform",
|
|
93
|
+
message: "选择git平台",
|
|
94
|
+
choices: t,
|
|
95
|
+
onState: d
|
|
96
|
+
})).platform;
|
|
97
|
+
}
|
|
98
|
+
o || (n.username = (await g({
|
|
101
99
|
type: "text",
|
|
102
100
|
name: "username",
|
|
103
101
|
message: "请输入用户名",
|
|
104
|
-
|
|
102
|
+
format: (t) => t.trim(),
|
|
103
|
+
validate: (t) => t.length > 0 || "用户名不能为空",
|
|
104
|
+
onState: d
|
|
105
105
|
})).username);
|
|
106
106
|
const { platform: r, username: a } = n;
|
|
107
107
|
let c = [];
|
|
108
|
-
const l =
|
|
108
|
+
const l = M({
|
|
109
109
|
secretKey: a,
|
|
110
110
|
platform: r
|
|
111
111
|
});
|
|
112
|
-
let
|
|
112
|
+
let f = l == null ? void 0 : l.accessToken;
|
|
113
113
|
console.log(s.blue(`正在获取${a}的${r}仓库列表...`));
|
|
114
|
-
const
|
|
114
|
+
const u = {
|
|
115
115
|
username: a,
|
|
116
|
-
accessToken:
|
|
116
|
+
accessToken: f
|
|
117
117
|
};
|
|
118
118
|
switch (n.platform) {
|
|
119
119
|
case i.GITHUB: {
|
|
120
|
-
c = (await
|
|
120
|
+
c = (await R(u)).data.map((t) => ({
|
|
121
121
|
name: t.name,
|
|
122
122
|
httpUrl: t.clone_url,
|
|
123
123
|
sshUrl: t.ssh_url,
|
|
@@ -126,7 +126,7 @@ const x = 1e4, f = Math.random(), $ = {
|
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
128
|
case i.GITEE: {
|
|
129
|
-
c = (await (
|
|
129
|
+
c = (await (u.accessToken ? D : k)(u)).data.map((t) => ({
|
|
130
130
|
name: t.name,
|
|
131
131
|
httpUrl: t.html_url,
|
|
132
132
|
sshUrl: t.ssh_url,
|
|
@@ -142,23 +142,24 @@ const x = 1e4, f = Math.random(), $ = {
|
|
|
142
142
|
return;
|
|
143
143
|
} else
|
|
144
144
|
console.log(s.blue(`共${c.length}个仓库`));
|
|
145
|
-
const { repoUrl:
|
|
145
|
+
const { repoUrl: G } = await g({
|
|
146
146
|
name: "repoUrl",
|
|
147
147
|
type: "select",
|
|
148
148
|
message: "选择仓库",
|
|
149
149
|
choices: c.map((t) => ({
|
|
150
150
|
title: `${t.name} ${t.description}`,
|
|
151
151
|
value: t.sshUrl
|
|
152
|
-
}))
|
|
152
|
+
})),
|
|
153
|
+
onState: d
|
|
153
154
|
});
|
|
154
|
-
return
|
|
155
|
-
},
|
|
156
|
-
const o = await
|
|
157
|
-
|
|
158
|
-
},
|
|
159
|
-
},
|
|
155
|
+
return G;
|
|
156
|
+
}, j = async (e) => {
|
|
157
|
+
const o = await A(e);
|
|
158
|
+
I(`git clone ${o} 1>&2`), console.log(s.green(`克隆${o}成功`));
|
|
159
|
+
}, J = async (e, o) => e === m.CLONE ? j(o) : (console.log(s.red(`无效的命令: ${e}`)), process.exit(1)), y = async (e) => {
|
|
160
|
+
}, T = p.cliConfig.moduleName, K = (e, o) => {
|
|
160
161
|
console.log(e ? s.red(e) : s.red(o.message)), process.exit(1);
|
|
161
|
-
},
|
|
162
|
+
}, z = p.description, Q = `Usage: $0 ${T} <command> [options]`, V = "Usage: $0 <command> [options]", W = {
|
|
162
163
|
command: `${m.CLONE} <platform> <username>`,
|
|
163
164
|
describe: "从选择的git平台克隆代码",
|
|
164
165
|
builder: (e) => e.positional("platform", {
|
|
@@ -170,23 +171,27 @@ const x = 1e4, f = Math.random(), $ = {
|
|
|
170
171
|
type: "string"
|
|
171
172
|
}),
|
|
172
173
|
/** @ts-ignore */
|
|
173
|
-
handler
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
async handler(e) {
|
|
175
|
+
return await P(J)(m.CLONE)(
|
|
176
|
+
e
|
|
177
|
+
), process.exit(0);
|
|
178
|
+
}
|
|
179
|
+
}, b = (e) => e.command(W).demandCommand(1), E = (e, o = !1) => o ? b(e.strict().usage(Q)) : b(
|
|
180
|
+
e.strict().usage(V).help("help").version(p.version).alias("v", "version").alias("h", "help")
|
|
181
|
+
).fail(K).argv, X = (e) => E(e, !0), le = {
|
|
182
|
+
command: T,
|
|
183
|
+
describe: z,
|
|
184
|
+
builder: X,
|
|
185
|
+
handler: y
|
|
186
|
+
}, me = async () => {
|
|
187
|
+
const e = N(x(process.argv));
|
|
188
|
+
return await E(e), y();
|
|
184
189
|
};
|
|
185
190
|
export {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
le as a,
|
|
192
|
+
A as b,
|
|
193
|
+
me as c,
|
|
194
|
+
j as d,
|
|
195
|
+
W as g,
|
|
196
|
+
y as h
|
|
192
197
|
};
|
package/es/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as C, b, d as h, g as c, h as f } from "./index-
|
|
2
|
+
import { a as C, b, d as h, g as c, h as f } from "./index-e8efef08.js";
|
|
3
3
|
import "chalk";
|
|
4
4
|
import "@done-coding/request-axios";
|
|
5
5
|
import "axios";
|
|
6
6
|
import "prompts";
|
|
7
|
-
import "@done-coding/
|
|
7
|
+
import "@done-coding/cli-utils";
|
|
8
8
|
import "node:fs";
|
|
9
9
|
import "node:path";
|
|
10
10
|
import "node:child_process";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-git",
|
|
3
|
-
"version": "0.2.0",
|
|
3
|
+
"version": "0.2.2-alpha.0",
|
|
4
4
|
"description": "git跨平台操作命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@done-coding/cli-inject": "^0.4.
|
|
44
|
+
"@done-coding/cli-inject": "^0.4.6-alpha.0",
|
|
45
45
|
"@types/lodash.curry": "^4.1.8",
|
|
46
46
|
"@types/node": "^16.0.0",
|
|
47
47
|
"@types/prompts": "^2.4.6",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"node": ">=16.0.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@done-coding/
|
|
58
|
+
"@done-coding/cli-utils": "^0.2.1-alpha.0",
|
|
59
59
|
"@done-coding/request-axios": "^1.1.1",
|
|
60
60
|
"axios": "^1.8.4",
|
|
61
61
|
"chalk": "^5.3.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"prompts": "^2.4.2",
|
|
64
64
|
"yargs": "^17.7.2"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "21eb698f64179882cfec979bd8f19920b047dacb"
|
|
67
67
|
}
|