@done-coding/cli-git 0.3.2-alpha.0 → 0.4.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 CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-da471e5e.js";
2
+ import { c as m } from "./index-aab46de7.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "@done-coding/request-axios";
5
5
  import "axios";
6
6
  import "node:fs";
7
7
  import "node:path";
8
8
  import "node:child_process";
9
+ import "node:os";
9
10
  m();
@@ -0,0 +1,248 @@
1
+ #!/usr/bin/env node
2
+ import { lookForParentTarget as _, log as a, decryptAES as B, encryptAES as F, xPrompts as g, getRootDirOptions as x, _curry as $, createSubcommand as y, createMainCommand as A } from "@done-coding/cli-utils";
3
+ import { createRequest as I } from "@done-coding/request-axios";
4
+ import R from "axios";
5
+ import f from "node:fs";
6
+ import h from "node:path";
7
+ import { execSync as D } from "node:child_process";
8
+ import H from "node:os";
9
+ var l = /* @__PURE__ */ ((e) => (e.INIT = "init", e.CLONE = "clone", e))(l || {}), p = /* @__PURE__ */ ((e) => (e.GITHUB = "github", e.GITEE = "gitee", e))(p || {});
10
+ const L = 3e4, C = Math.random(), E = {
11
+ timeout: L,
12
+ getBusinessCode() {
13
+ return C;
14
+ },
15
+ getBusinessMsg(e) {
16
+ return e.statusText;
17
+ },
18
+ getBusinessData(e) {
19
+ return e.data;
20
+ },
21
+ businessSuccessCodeList: [C],
22
+ axios: R
23
+ }, U = I({
24
+ basePath: " https://gitee.com",
25
+ ...E
26
+ }), b = I({
27
+ basePath: "https://api.github.com",
28
+ ...E
29
+ }), M = ({
30
+ username: e
31
+ }) => U({
32
+ url: `/api/v5/users/${e}/repos`,
33
+ method: "GET"
34
+ }), q = ({
35
+ accessToken: e
36
+ }) => U({
37
+ url: "/api/v5/user/repos",
38
+ method: "GET",
39
+ params: {
40
+ access_token: e,
41
+ per_page: 100,
42
+ page: 1,
43
+ sort: "updated"
44
+ }
45
+ }), K = ({
46
+ username: e
47
+ }) => b({
48
+ url: `/users/${e}/repos`,
49
+ method: "GET"
50
+ }), j = ({
51
+ accessToken: e
52
+ }) => b({
53
+ url: "/user/repos",
54
+ method: "GET",
55
+ headers: {
56
+ Authorization: `Bearer ${e}`
57
+ },
58
+ params: {
59
+ per_page: 100,
60
+ page: 1,
61
+ sort: "updated"
62
+ }
63
+ }), G = {
64
+ name: "@done-coding/cli-git",
65
+ version: "0.4.0",
66
+ description: "git跨平台操作命令行工具",
67
+ cliConfig: {
68
+ namespaceDir: ".done-coding",
69
+ moduleName: "git"
70
+ }
71
+ }, {
72
+ cliConfig: { namespaceDir: J, moduleName: z }
73
+ } = G, V = `./${J}/${z}`, S = (e) => `${V}/.${e}`, w = ({ platform: e, username: t }) => `${e}/${t}`, Q = (e) => {
74
+ const { platform: t } = e, s = S(t), o = _(s, {
75
+ isFindFarthest: !1
76
+ });
77
+ if (!o) {
78
+ a.warn("配置文件不存在");
79
+ return;
80
+ }
81
+ const r = `${o}/${s}`, c = f.readFileSync(r, "utf-8"), i = w(e), u = B({ encryptedText: c, secretKey: i });
82
+ if (!u) {
83
+ a.warn("配置文件解密失败");
84
+ return;
85
+ }
86
+ return JSON.parse(u);
87
+ }, W = ({
88
+ rootDir: e,
89
+ username: t,
90
+ platform: s,
91
+ accessToken: o
92
+ }) => {
93
+ const r = S(s), i = JSON.stringify({
94
+ accessToken: o
95
+ }), u = w({ platform: s, username: t }), m = F({ text: i, secretKey: u }), d = h.join(e, r);
96
+ f.mkdirSync(h.dirname(d), {
97
+ recursive: !0
98
+ }), f.writeFileSync(d, m, "utf-8"), a.success(`配置信息保存成功 ${d}`);
99
+ }, X = [
100
+ { title: "GitHub", value: p.GITHUB },
101
+ { title: "Gitee", value: p.GITEE }
102
+ ], N = {
103
+ type: "select",
104
+ name: "platform",
105
+ message: "选择git平台",
106
+ choices: X
107
+ }, k = {
108
+ type: "text",
109
+ name: "username",
110
+ message: "请输入用户名",
111
+ format: (e) => e.trim(),
112
+ validate: (e) => e.length > 0 || "用户名不能为空"
113
+ }, Y = {
114
+ type: "password",
115
+ name: "accessToken",
116
+ message: "请输入git access token",
117
+ format: (e) => e.trim(),
118
+ validate: (e) => e.length > 0 || "access token不能为空"
119
+ }, Z = async ({
120
+ platform: e,
121
+ username: t
122
+ } = {}) => {
123
+ const s = {
124
+ platform: e,
125
+ username: t
126
+ };
127
+ e || (s.platform = (await g(N)).platform), t || (s.username = (await g(k)).username);
128
+ const { platform: o, username: r } = s;
129
+ let c = [];
130
+ const i = Q({
131
+ username: r,
132
+ platform: o
133
+ });
134
+ let u = i == null ? void 0 : i.accessToken;
135
+ a.stage(`正在获取${r}的${o}仓库列表...`);
136
+ const m = {
137
+ username: r,
138
+ accessToken: u
139
+ };
140
+ switch (s.platform) {
141
+ case p.GITHUB: {
142
+ c = (await (m.accessToken ? j : K)(m)).data.map((n) => ({
143
+ name: n.name,
144
+ httpUrl: n.clone_url,
145
+ sshUrl: n.ssh_url,
146
+ description: n.description || ""
147
+ }));
148
+ break;
149
+ }
150
+ case p.GITEE: {
151
+ c = (await (m.accessToken ? q : M)(m)).data.map((n) => ({
152
+ name: n.name,
153
+ httpUrl: n.html_url,
154
+ sshUrl: n.ssh_url,
155
+ description: n.description || ""
156
+ }));
157
+ break;
158
+ }
159
+ default:
160
+ return a.error(`未知平台${o}`), process.exit(1);
161
+ }
162
+ if (a.success(`获取${r}的${o}仓库列表成功`), c.length === 0) {
163
+ a.warn(`${r} 可获取${o}仓库列表为空`);
164
+ return;
165
+ } else
166
+ a.stage(`共${c.length}个仓库`);
167
+ const { repoUrl: d } = await g({
168
+ name: "repoUrl",
169
+ type: "select",
170
+ message: "选择仓库",
171
+ choices: c.map((n) => ({
172
+ title: `${n.name} ${n.description}`,
173
+ value: n.sshUrl
174
+ }))
175
+ });
176
+ return d;
177
+ }, ee = () => x(H.homedir()), te = async (e) => {
178
+ const { rootDir: t } = e, { platform: s } = await g(N), { username: o } = await g(k), { accessToken: r } = await g(Y);
179
+ await W({
180
+ rootDir: t,
181
+ platform: s,
182
+ username: o,
183
+ accessToken: r
184
+ });
185
+ }, se = () => ({
186
+ platform: {
187
+ describe: "选择git平台",
188
+ type: "string",
189
+ choices: [p.GITHUB, p.GITEE]
190
+ },
191
+ username: {
192
+ describe: "git平台用户名",
193
+ type: "string"
194
+ }
195
+ }), ne = async (e) => {
196
+ const t = await Z(e);
197
+ D(`git clone ${t}`, {
198
+ stdio: "inherit"
199
+ }), a.success(`克隆${t}成功`);
200
+ }, P = async (e, t) => {
201
+ switch (e) {
202
+ case l.INIT:
203
+ return te(t);
204
+ case l.CLONE:
205
+ return ne(t);
206
+ default:
207
+ return a.error(`无效的命令: ${e}`), process.exit(1);
208
+ }
209
+ }, {
210
+ version: oe,
211
+ description: re,
212
+ cliConfig: { moduleName: T }
213
+ } = G, ae = {
214
+ command: l.INIT,
215
+ describe: "初始化git配置文件",
216
+ options: ee(),
217
+ handler: $(P)(
218
+ l.INIT
219
+ )
220
+ }, ce = {
221
+ command: `${l.CLONE} <platform> <username>`,
222
+ describe: "从选择的git平台克隆代码",
223
+ positionals: se(),
224
+ handler: $(P)(
225
+ l.CLONE
226
+ )
227
+ }, v = {
228
+ describe: re,
229
+ version: oe,
230
+ subcommands: [ae, ce].map(y),
231
+ demandCommandCount: 1
232
+ }, O = (e = !1) => {
233
+ const t = e ? T : void 0, s = `$0${e ? ` ${T}` : ""} <command> [options]`;
234
+ return { command: t, usage: s };
235
+ }, fe = async () => A({
236
+ ...v,
237
+ ...O()
238
+ }), he = () => y({
239
+ ...v,
240
+ ...O(!0)
241
+ });
242
+ export {
243
+ he as a,
244
+ ne as b,
245
+ fe as c,
246
+ Z as g,
247
+ P as h
248
+ };
package/es/index.mjs CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { a as n, g as s, b as g, h as b } from "./index-da471e5e.js";
2
+ import { b as s, a as d, g as l, h as b } from "./index-aab46de7.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "@done-coding/request-axios";
5
5
  import "axios";
6
6
  import "node:fs";
7
7
  import "node:path";
8
8
  import "node:child_process";
9
+ import "node:os";
9
10
  export {
10
- n as crateAsSubcommand,
11
- s as getTargetRepoUrl,
12
- g as gitClone,
11
+ s as cloneHandler,
12
+ d as crateAsSubcommand,
13
+ l as getTargetRepoUrl,
13
14
  b as handler
14
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-git",
3
- "version": "0.3.2-alpha.0",
3
+ "version": "0.4.0",
4
4
  "description": "git跨平台操作命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "license": "MIT",
41
41
  "sideEffects": false,
42
42
  "devDependencies": {
43
- "@done-coding/cli-inject": "^0.5.1-alpha.0",
43
+ "@done-coding/cli-inject": "^0.5.2",
44
44
  "@types/node": "^18.0.0",
45
45
  "@types/yargs": "^17.0.28",
46
46
  "rimraf": "^6.0.1",
@@ -52,9 +52,9 @@
52
52
  "node": ">=18.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@done-coding/cli-utils": "^0.3.1-alpha.0",
55
+ "@done-coding/cli-utils": "^0.3.2",
56
56
  "@done-coding/request-axios": "^1.1.1",
57
57
  "axios": "^1.8.4"
58
58
  },
59
- "gitHead": "ec6957606bbae68d7268159b38b9d36dab4a2731"
59
+ "gitHead": "7a8d554748b844c8b7694c587983b21af902d5d1"
60
60
  }
@@ -1,8 +1,5 @@
1
- /** 获取 gitee 用户公开的仓库列表 */
2
- export declare const getGiteeUserPublicRepos: ({ username, }: {
3
- username: string;
4
- accessToken?: string | undefined;
5
- }) => Promise<import("@done-coding/request-axios").RequestResult<{
1
+ /** 获取 gitee 仓库信息 */
2
+ export interface GiteeRepoInfo {
6
3
  /** 仓库名 */
7
4
  name: string;
8
5
  /** ssh */
@@ -10,19 +7,15 @@ export declare const getGiteeUserPublicRepos: ({ username, }: {
10
7
  /** https */
11
8
  html_url: string;
12
9
  /** 描述 */
13
- description?: string | null | undefined;
14
- }[]>>;
10
+ description?: string | null;
11
+ }
12
+ /** 获取 gitee 用户公开的仓库列表 */
13
+ export declare const getGiteeUserPublicRepos: ({ username, }: {
14
+ username: string;
15
+ accessToken?: string | undefined;
16
+ }) => Promise<import("@done-coding/request-axios").RequestResult<GiteeRepoInfo[]>>;
15
17
  /** 获取 gitee 用户的所有仓库列表 */
16
18
  export declare const getGiteeUserAllRepos: ({ accessToken, }: {
17
19
  username: string;
18
20
  accessToken?: string | undefined;
19
- }) => Promise<import("@done-coding/request-axios").RequestResult<{
20
- /** 仓库名 */
21
- name: string;
22
- /** ssh */
23
- ssh_url: string;
24
- /** https */
25
- html_url: string;
26
- /** 描述 */
27
- description?: string | null | undefined;
28
- }[]>>;
21
+ }) => Promise<import("@done-coding/request-axios").RequestResult<GiteeRepoInfo[]>>;
@@ -1,8 +1,5 @@
1
- /** 获取 github 用户公开仓库列表 */
2
- export declare const getGithubUserPublicRepos: ({ username, }: {
3
- username: string;
4
- accessToken?: string | undefined;
5
- }) => Promise<import("@done-coding/request-axios").RequestResult<{
1
+ /** 获取 github 仓库信息 */
2
+ export interface GithubRepoInfo {
6
3
  /** 仓库名 */
7
4
  name: string;
8
5
  /** ssh */
@@ -10,5 +7,15 @@ export declare const getGithubUserPublicRepos: ({ username, }: {
10
7
  /** https */
11
8
  clone_url: string;
12
9
  /** 描述 */
13
- description?: string | null | undefined;
14
- }[]>>;
10
+ description?: string | null;
11
+ }
12
+ /** 获取 github 用户公开仓库列表 */
13
+ export declare const getGithubUserPublicRepos: ({ username, }: {
14
+ username: string;
15
+ accessToken?: string | undefined;
16
+ }) => Promise<import("@done-coding/request-axios").RequestResult<GithubRepoInfo[]>>;
17
+ /** 获取 github 用户所有仓库列表 */
18
+ export declare const getGithubUserAllRepos: ({ accessToken, }: {
19
+ username: string;
20
+ accessToken?: string | undefined;
21
+ }) => Promise<import("@done-coding/request-axios").RequestResult<GithubRepoInfo[]>>;
@@ -1,5 +1,5 @@
1
1
  import { SubcommandEnum } from './utils';
2
- import type { Options } from './utils';
2
+ import type { InitOptions, CloneOptions } from './utils';
3
3
  import type { CliHandlerArgv } from "@done-coding/cli-utils";
4
4
  /** 子命令处理函数 */
5
- export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<Options>) => Promise<void>;
5
+ export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<InitOptions | CloneOptions>) => Promise<void>;
package/types/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { handler } from "./handler";
2
2
  export { crateAsSubcommand } from "./main";
3
- export { getTargetRepoUrl, gitClone } from "./utils";
3
+ export { getTargetRepoUrl, cloneHandler } from "./utils";
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@done-coding/cli-git",
3
- "version": "0.3.2-alpha.0",
3
+ "version": "0.4.0",
4
4
  "description": "git跨平台操作命令行工具",
5
5
  "cliConfig": {
6
6
  "namespaceDir": ".done-coding",
@@ -1,3 +1,6 @@
1
- import type { Options } from "./types";
1
+ import { type CloneOptions } from "./types";
2
+ import type { CliInfo } from "@done-coding/cli-utils";
3
+ /** 获取克隆命令的位置参数 */
4
+ export declare const getClonePositionals: () => CliInfo["positionals"];
2
5
  /** 克隆目标仓库 */
3
- export declare const gitClone: (options: Options) => Promise<void>;
6
+ export declare const cloneHandler: (options: CloneOptions) => Promise<void>;
@@ -1,20 +1,14 @@
1
- import type { GitConfigInfo, GitPlatformEnum } from "./types";
1
+ import type { GitConfigInfo, GitParamsInfo } from "./types";
2
2
  /**
3
3
  * 获取配置信息
4
4
  */
5
- export declare const getGitConfigInfo: ({ secretKey, platform, }: {
6
- /** 秘钥 */
7
- secretKey: string;
8
- /** 平台 */
9
- platform: GitPlatformEnum;
10
- }) => GitConfigInfo | undefined;
5
+ export declare const getGitConfigInfo: (params: GitParamsInfo) => GitConfigInfo | undefined;
11
6
  /**
12
7
  * 设置配置信息
13
8
  */
14
- export declare const setGitConfigInfo: ({ secretKey, platform, accessToken, }: {
9
+ export declare const setGitConfigInfo: ({ rootDir, username, platform, accessToken, }: {
10
+ /** 根目录 */
11
+ rootDir: string;
12
+ /** 访问令牌 */
15
13
  accessToken: string;
16
- /** 秘钥 */
17
- secretKey: string;
18
- /** 平台 */
19
- platform: GitPlatformEnum;
20
- }) => void;
14
+ } & GitParamsInfo) => void;
@@ -1,3 +1,3 @@
1
- import { type Options } from "./types";
1
+ import { type GitParamsInfo } from "./types";
2
2
  /** 获取目标仓库地址 */
3
- export declare const getTargetRepoUrl: ({ platform: platformInit, username: usernameInit, }?: Partial<Options>) => Promise<any>;
3
+ export declare const getTargetRepoUrl: ({ platform: platformInit, username: usernameInit, }?: Partial<GitParamsInfo>) => Promise<any>;
@@ -1,3 +1,6 @@
1
1
  export * from "./types";
2
2
  export * from "./get-repo";
3
+ export * from "./init";
3
4
  export * from "./clone";
5
+ export * from "./path";
6
+ export * from "./config";
@@ -0,0 +1,9 @@
1
+ /// <reference types="yargs" />
2
+ import type { CliHandlerArgv } from "@done-coding/cli-utils";
3
+ import type { InitOptions } from "./types";
4
+ /** 获取初始化选项 */
5
+ export declare const getInitOptions: () => {
6
+ rootDir: import("yargs").Options;
7
+ };
8
+ /** 初始化命令处理器 */
9
+ export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ /** 模块配置相对路径 */
2
+ export declare const MODULE_CONFIG_RELATIVE_PATH: string;
@@ -0,0 +1,7 @@
1
+ import type { PromptObject } from "@done-coding/cli-utils";
2
+ /** git平台选择表单 */
3
+ export declare const platformForm: PromptObject<string>;
4
+ /** git用户名表单 */
5
+ export declare const gitUsernameForm: PromptObject<string>;
6
+ /** git access token表单 */
7
+ export declare const gitAccessTokenForm: PromptObject<string>;
@@ -1,8 +1,13 @@
1
+ import type { InitConfigFileOptions } from "@done-coding/cli-utils";
1
2
  /** 子命令枚举 */
2
3
  export declare enum SubcommandEnum {
4
+ /** 初始化配置文件 */
5
+ INIT = "init",
3
6
  /** 克隆 */
4
7
  CLONE = "clone"
5
8
  }
9
+ /** 初始化选项 */
10
+ export type InitOptions = Pick<InitConfigFileOptions, "rootDir">;
6
11
  /** Git 平台枚举 */
7
12
  export declare enum GitPlatformEnum {
8
13
  /** GitHub */
@@ -10,12 +15,15 @@ export declare enum GitPlatformEnum {
10
15
  /** Gitee */
11
16
  GITEE = "gitee"
12
17
  }
13
- export interface Options {
18
+ /** git参数信息 */
19
+ export interface GitParamsInfo {
14
20
  /** 平台 */
15
21
  platform: GitPlatformEnum;
16
22
  /** 用户名 */
17
23
  username: string;
18
24
  }
25
+ /** 可控选项 */
26
+ export type CloneOptions = GitParamsInfo;
19
27
  /** Git 配置信息 */
20
28
  export interface GitConfigInfo {
21
29
  /** token */
@@ -1,193 +0,0 @@
1
- #!/usr/bin/env node
2
- import { lookForParentTarget as y, log as n, decryptAES as I, xPrompts as p, _curry as S, createSubcommand as h, createMainCommand as v } from "@done-coding/cli-utils";
3
- import { createRequest as C } from "@done-coding/request-axios";
4
- import N from "axios";
5
- import w from "node:fs";
6
- import "node:path";
7
- import { execSync as B } from "node:child_process";
8
- var u = /* @__PURE__ */ ((e) => (e.CLONE = "clone", e))(u || {}), i = /* @__PURE__ */ ((e) => (e.GITHUB = "github", e.GITEE = "gitee", e))(i || {});
9
- const P = 1e4, d = Math.random(), $ = {
10
- timeout: P,
11
- getBusinessCode() {
12
- return d;
13
- },
14
- getBusinessMsg(e) {
15
- return e.statusText;
16
- },
17
- getBusinessData(e) {
18
- return e.data;
19
- },
20
- businessSuccessCodeList: [d],
21
- axios: N
22
- }, b = C({
23
- basePath: " https://gitee.com",
24
- ...$
25
- }), _ = C({
26
- basePath: "https://api.github.com",
27
- ...$
28
- }), x = ({
29
- username: e
30
- }) => b({
31
- url: `/api/v5/users/${e}/repos`,
32
- method: "GET"
33
- }), O = ({
34
- accessToken: e
35
- }) => b({
36
- url: "/api/v5/user/repos",
37
- method: "GET",
38
- params: {
39
- access_token: e,
40
- per_page: 100,
41
- page: 1,
42
- sort: "updated"
43
- }
44
- }), R = ({
45
- username: e
46
- }) => _({
47
- url: `/users/${e}/repos`,
48
- method: "GET"
49
- }), T = {
50
- name: "@done-coding/cli-git",
51
- version: "0.3.2-alpha.0",
52
- description: "git跨平台操作命令行工具",
53
- cliConfig: {
54
- namespaceDir: ".done-coding",
55
- moduleName: "git"
56
- }
57
- }, { namespaceDir: k, moduleName: D } = T.cliConfig, H = `${k}/${D}`, L = (e) => `${H}/.${e}`, A = ({
58
- secretKey: e,
59
- platform: s
60
- }) => {
61
- const r = L(s), o = y(r);
62
- if (!o) {
63
- n.warn("配置文件不存在");
64
- return;
65
- }
66
- const a = `${o}/${r}`, c = w.readFileSync(a, "utf-8"), m = I({ encryptedText: c, secretKey: e });
67
- if (!m) {
68
- n.warn("配置文件解密失败");
69
- return;
70
- }
71
- return JSON.parse(m);
72
- }, F = async ({
73
- platform: e,
74
- username: s
75
- } = {}) => {
76
- const r = {
77
- platform: e,
78
- username: s
79
- };
80
- if (!e) {
81
- const t = [
82
- { title: "GitHub", value: i.GITHUB },
83
- { title: "Gitee", value: i.GITEE }
84
- ];
85
- r.platform = (await p({
86
- type: "select",
87
- name: "platform",
88
- message: "选择git平台",
89
- choices: t
90
- })).platform;
91
- }
92
- s || (r.username = (await p({
93
- type: "text",
94
- name: "username",
95
- message: "请输入用户名",
96
- format: (t) => t.trim(),
97
- validate: (t) => t.length > 0 || "用户名不能为空"
98
- })).username);
99
- const { platform: o, username: a } = r;
100
- let c = [];
101
- const m = A({
102
- secretKey: a,
103
- platform: o
104
- });
105
- let g = m == null ? void 0 : m.accessToken;
106
- n.stage(`正在获取${a}的${o}仓库列表...`);
107
- const l = {
108
- username: a,
109
- accessToken: g
110
- };
111
- switch (r.platform) {
112
- case i.GITHUB: {
113
- c = (await R(l)).data.map((t) => ({
114
- name: t.name,
115
- httpUrl: t.clone_url,
116
- sshUrl: t.ssh_url,
117
- description: t.description || ""
118
- }));
119
- break;
120
- }
121
- case i.GITEE: {
122
- c = (await (l.accessToken ? O : x)(l)).data.map((t) => ({
123
- name: t.name,
124
- httpUrl: t.html_url,
125
- sshUrl: t.ssh_url,
126
- description: t.description || ""
127
- }));
128
- break;
129
- }
130
- default:
131
- return n.error(`未知平台${o}`), process.exit(1);
132
- }
133
- if (n.success(`获取${a}的${o}仓库列表成功`), c.length === 0) {
134
- n.warn(`${a} 可获取${o}仓库列表为空`);
135
- return;
136
- } else
137
- n.stage(`共${c.length}个仓库`);
138
- const { repoUrl: G } = await p({
139
- name: "repoUrl",
140
- type: "select",
141
- message: "选择仓库",
142
- choices: c.map((t) => ({
143
- title: `${t.name} ${t.description}`,
144
- value: t.sshUrl
145
- }))
146
- });
147
- return G;
148
- }, M = async (e) => {
149
- const s = await F(e);
150
- B(`git clone ${s} 1>&2`), n.success(`克隆${s}成功`);
151
- }, q = async (e, s) => e === u.CLONE ? M(s) : (n.error(`无效的命令: ${e}`), process.exit(1)), {
152
- version: j,
153
- description: J,
154
- cliConfig: { moduleName: f }
155
- } = T, K = {
156
- command: `${u.CLONE} <platform> <username>`,
157
- describe: "从选择的git平台克隆代码",
158
- positionals: {
159
- platform: {
160
- describe: "选择git平台",
161
- type: "string",
162
- choices: [i.GITHUB, i.GITEE]
163
- },
164
- username: {
165
- describe: "git平台用户名",
166
- type: "string"
167
- }
168
- },
169
- handler: S(q)(
170
- u.CLONE
171
- )
172
- }, U = {
173
- describe: J,
174
- version: j,
175
- subcommands: [K].map(h),
176
- demandCommandCount: 1
177
- }, E = (e = !1) => {
178
- const s = e ? f : void 0, r = `$0${e ? ` ${f}` : ""} <command> [options]`;
179
- return { command: s, usage: r };
180
- }, Z = async () => v({
181
- ...U,
182
- ...E()
183
- }), ee = () => h({
184
- ...U,
185
- ...E(!0)
186
- });
187
- export {
188
- ee as a,
189
- M as b,
190
- Z as c,
191
- F as g,
192
- q as h
193
- };