done-coding-git 0.5.5-alpha.1 → 0.6.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 +5 -6
- package/es/helpers.mjs +9 -9
- package/es/index-8bd8ff1f.js +19 -0
- package/es/index-964abda4.js +603 -0
- package/es/index.mjs +17 -10
- package/package.json +5 -5
- package/types/config/index.d.ts +3 -0
- package/types/handlers/check.d.ts +51 -0
- package/types/handlers/clone.d.ts +8 -0
- package/types/handlers/hooks.d.ts +7 -0
- package/types/handlers/index.d.ts +9 -0
- package/types/handlers/init.d.ts +19 -0
- package/types/index.d.ts +2 -2
- package/types/injectInfo.json.d.ts +1 -1
- package/types/types/check.d.ts +40 -0
- package/types/{utils/types.d.ts → types/clone.d.ts} +0 -10
- package/types/types/hooks.d.ts +5 -0
- package/types/types/index.d.ts +5 -0
- package/types/types/init.d.ts +10 -0
- package/types/types/subcommand.d.ts +13 -0
- package/types/utils/check.d.ts +20 -0
- package/types/utils/config.d.ts +1 -1
- package/types/utils/get-repo.d.ts +1 -1
- package/types/utils/hooks.d.ts +7 -0
- package/types/utils/index.d.ts +2 -3
- package/types/utils/path.d.ts +2 -0
- package/types/utils/question.d.ts +1 -1
- package/es/clone-11819b7f.js +0 -222
- package/es/index-49e07bde.js +0 -60
- package/types/handler.d.ts +0 -5
- package/types/utils/clone.d.ts +0 -7
- package/types/utils/init.d.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "done-coding-git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "git跨平台操作命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"lib",
|
|
29
29
|
"types"
|
|
30
30
|
],
|
|
31
|
-
"scripts": {},
|
|
32
31
|
"repository": {
|
|
33
32
|
"type": "git",
|
|
34
33
|
"url": "https://gitee.com/justsosu/done-coding-cli.git",
|
|
@@ -42,7 +41,7 @@
|
|
|
42
41
|
"license": "MIT",
|
|
43
42
|
"sideEffects": false,
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@done-coding/cli-inject": "^0.5.8
|
|
44
|
+
"@done-coding/cli-inject": "^0.5.8",
|
|
46
45
|
"@types/node": "^18.0.0",
|
|
47
46
|
"@types/yargs": "^17.0.28",
|
|
48
47
|
"rimraf": "^6.0.1",
|
|
@@ -54,9 +53,10 @@
|
|
|
54
53
|
"node": ">=18.0.0"
|
|
55
54
|
},
|
|
56
55
|
"dependencies": {
|
|
57
|
-
"@done-coding/cli-utils": "^0.
|
|
56
|
+
"@done-coding/cli-utils": "^0.7.0",
|
|
58
57
|
"@done-coding/request-axios": "^1.1.1",
|
|
59
58
|
"axios": "^1.8.4"
|
|
60
59
|
},
|
|
61
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "b4fb4f2380a14f72597a1dbfd1bbce22287ef02f",
|
|
61
|
+
"scripts": {}
|
|
62
62
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CheckOptions, GitConfig } from '../types';
|
|
2
|
+
import { CheckReverseMergeWayEnum } from '../types';
|
|
3
|
+
import type { ArgumentsCamelCase, GitRebaseInfo, SubCliInfo, SupportGetCommitByHookName, YargsOptions } from "@done-coding/cli-utils";
|
|
4
|
+
import type { PositionalOptions } from "yargs";
|
|
5
|
+
export declare const getOptions: () => Record<string, YargsOptions>;
|
|
6
|
+
export declare const getPositionals: () => Record<string, PositionalOptions>;
|
|
7
|
+
/** 检测反向合并-通过git reflog action */
|
|
8
|
+
export declare const checkReverseMergeByReflogAction: ({ config, currentBranch, }: {
|
|
9
|
+
config: GitConfig;
|
|
10
|
+
currentBranch?: string | undefined;
|
|
11
|
+
}) => undefined;
|
|
12
|
+
/** 检测反向合并-通过提交信息 */
|
|
13
|
+
export declare const checkReverseMergeByCommitMsg: ({ config, currentBranch, commitMsg, rootDir, }: {
|
|
14
|
+
config: GitConfig;
|
|
15
|
+
currentBranch?: string | undefined;
|
|
16
|
+
commitMsg?: string | undefined;
|
|
17
|
+
rootDir: string;
|
|
18
|
+
}) => void;
|
|
19
|
+
/** 检测反向合并-通过提交记录 */
|
|
20
|
+
export declare const checkReverseMergeByCommitRecord: ({ config, currentBranch, }: {
|
|
21
|
+
config: GitConfig;
|
|
22
|
+
currentBranch?: string | undefined;
|
|
23
|
+
}) => void;
|
|
24
|
+
/** 检测反向变基 */
|
|
25
|
+
export declare const checkReverseRebase: ({ config, rebaseInfo, }: {
|
|
26
|
+
config: GitConfig;
|
|
27
|
+
rebaseInfo: GitRebaseInfo;
|
|
28
|
+
}) => undefined;
|
|
29
|
+
export type CheckReverseMergeHandlerParams = {
|
|
30
|
+
config: GitConfig;
|
|
31
|
+
rootDir: string;
|
|
32
|
+
way: CheckReverseMergeWayEnum.COMMIT_MSG;
|
|
33
|
+
hookName: SupportGetCommitByHookName;
|
|
34
|
+
} | {
|
|
35
|
+
config: GitConfig;
|
|
36
|
+
rootDir: string;
|
|
37
|
+
way: CheckReverseMergeWayEnum.REFLOG_ACTION;
|
|
38
|
+
} | {
|
|
39
|
+
config: GitConfig;
|
|
40
|
+
rootDir: string;
|
|
41
|
+
way: CheckReverseMergeWayEnum.COMMIT_RECORD;
|
|
42
|
+
} | {
|
|
43
|
+
config: GitConfig;
|
|
44
|
+
way: CheckReverseMergeWayEnum.PRE_REBASE;
|
|
45
|
+
args: string[];
|
|
46
|
+
};
|
|
47
|
+
/** 检测反向合并 */
|
|
48
|
+
export declare const checkReverseMergeHandler: (params: CheckReverseMergeHandlerParams) => Promise<void>;
|
|
49
|
+
/** 检测 */
|
|
50
|
+
export declare const handler: (argv: ArgumentsCamelCase<CheckOptions>) => Promise<void>;
|
|
51
|
+
export declare const commandCliInfo: SubCliInfo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CliHandlerArgv, CliInfo, SubCliInfo } from "@done-coding/cli-utils";
|
|
2
|
+
import type { CloneOptions } from '../types';
|
|
3
|
+
export declare const getOptions: () => CliInfo["options"];
|
|
4
|
+
/** 位置参数 */
|
|
5
|
+
export declare const getPositionals: () => CliInfo["positionals"];
|
|
6
|
+
/** 克隆目标仓库 */
|
|
7
|
+
export declare const handler: (options: CliHandlerArgv<CloneOptions>) => Promise<void>;
|
|
8
|
+
export declare const commandCliInfo: SubCliInfo;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, PositionalOptions } from "yargs";
|
|
2
|
+
import { type HooksOptions } from '../types';
|
|
3
|
+
import type { SubCliInfo, YargsOptions } from "@done-coding/cli-utils";
|
|
4
|
+
export declare const getOptions: () => Record<string, YargsOptions>;
|
|
5
|
+
export declare const getPositionals: () => Record<string, PositionalOptions>;
|
|
6
|
+
export declare const handler: (argv: ArgumentsCamelCase<HooksOptions>) => Promise<void>;
|
|
7
|
+
export declare const commandCliInfo: SubCliInfo;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { handler as initHandler, commandCliInfo as initCommandCliInfo } from "./init";
|
|
2
|
+
import { handler as cloneHandler, commandCliInfo as cloneCommandCliInfo } from "./clone";
|
|
3
|
+
import { handler as hooksHandler, commandCliInfo as hooksCommandCliInfo } from "./hooks";
|
|
4
|
+
import { handler as checkHandler, commandCliInfo as checkCommandCliInfo } from "./check";
|
|
5
|
+
import { SubcommandEnum } from '../types';
|
|
6
|
+
import { type CliHandlerArgv, type CliInfo } from "@done-coding/cli-utils";
|
|
7
|
+
export { initHandler, initCommandCliInfo, cloneHandler, cloneCommandCliInfo, hooksHandler, hooksCommandCliInfo, checkHandler, checkCommandCliInfo, };
|
|
8
|
+
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<any>) => Promise<void>;
|
|
9
|
+
export declare const commandCliInfo: Omit<CliInfo, "usage">;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="yargs" />
|
|
2
|
+
import type { ArgumentsCamelCase, SubCliInfo } from "@done-coding/cli-utils";
|
|
3
|
+
import { InitTypeEnum, type InitOptions } from '../types';
|
|
4
|
+
/** 获取初始化选项 */
|
|
5
|
+
export declare const getOptions: () => {
|
|
6
|
+
type: {
|
|
7
|
+
alias: string;
|
|
8
|
+
describe: string;
|
|
9
|
+
choices: InitTypeEnum[];
|
|
10
|
+
default: InitTypeEnum;
|
|
11
|
+
};
|
|
12
|
+
rootDir: import("yargs").Options;
|
|
13
|
+
configPath: import("yargs").Options;
|
|
14
|
+
};
|
|
15
|
+
export declare const handler: (argv: ArgumentsCamelCase<InitOptions> & {
|
|
16
|
+
/** 是否是子命令 */
|
|
17
|
+
isSubCommand?: boolean;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
export declare const commandCliInfo: SubCliInfo;
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './handlers';
|
|
2
2
|
export { crateAsSubcommand } from "./main";
|
|
3
|
-
export { getTargetRepoUrl
|
|
3
|
+
export { getTargetRepoUrl } from "./utils";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReadConfigFileOptions } from "@done-coding/cli-utils";
|
|
2
|
+
import { SubcommandEnum } from "./subcommand";
|
|
3
|
+
/** 检测类型 */
|
|
4
|
+
export declare enum CheckTypeEnum {
|
|
5
|
+
/** 反向提交 */
|
|
6
|
+
REVERSE_MERGE = "reverseMerge"
|
|
7
|
+
}
|
|
8
|
+
/** 检测反向方式枚举 */
|
|
9
|
+
export declare enum CheckReverseMergeWayEnum {
|
|
10
|
+
/** GIT_REFLOG_ACTION */
|
|
11
|
+
REFLOG_ACTION = "reflog-action",
|
|
12
|
+
/** 提交信息 */
|
|
13
|
+
COMMIT_MSG = "commit-msg",
|
|
14
|
+
/** 提交记录 */
|
|
15
|
+
COMMIT_RECORD = "commit-record",
|
|
16
|
+
/** 变基线 */
|
|
17
|
+
PRE_REBASE = "pre-rebase"
|
|
18
|
+
}
|
|
19
|
+
/** 检测反向 */
|
|
20
|
+
export type CheckOptions = ReadConfigFileOptions & {
|
|
21
|
+
type: CheckTypeEnum;
|
|
22
|
+
args: string[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 禁止合并某个分支的检测选项
|
|
26
|
+
*/
|
|
27
|
+
export interface GitConfigCheckReverseMergeBranchConfig {
|
|
28
|
+
/** 包括变基操作 */
|
|
29
|
+
includeRebase: boolean;
|
|
30
|
+
/** 某个hash之后的提交 */
|
|
31
|
+
afterHash?: string;
|
|
32
|
+
/** 最多(检查日志数量) */
|
|
33
|
+
logCount: number;
|
|
34
|
+
}
|
|
35
|
+
/** 螃蟹git配置 */
|
|
36
|
+
export interface GitConfig {
|
|
37
|
+
[SubcommandEnum.CHECK]: {
|
|
38
|
+
[CheckTypeEnum.REVERSE_MERGE]: Record<string, GitConfigCheckReverseMergeBranchConfig>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import type { InitConfigFileOptions } from "@done-coding/cli-utils";
|
|
2
|
-
/** 子命令枚举 */
|
|
3
|
-
export declare enum SubcommandEnum {
|
|
4
|
-
/** 初始化配置文件 */
|
|
5
|
-
INIT = "init",
|
|
6
|
-
/** 克隆 */
|
|
7
|
-
CLONE = "clone"
|
|
8
|
-
}
|
|
9
|
-
/** 初始化选项 */
|
|
10
|
-
export type InitOptions = Pick<InitConfigFileOptions, "rootDir">;
|
|
11
1
|
/** Git 平台枚举 */
|
|
12
2
|
export declare enum GitPlatformEnum {
|
|
13
3
|
/** GitHub */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InitConfigFileOptions } from "@done-coding/cli-utils";
|
|
2
|
+
/** 初始化类型 */
|
|
3
|
+
export declare enum InitTypeEnum {
|
|
4
|
+
DEFAULT = "default",
|
|
5
|
+
CLONE_CONFIG = "cloneConfig"
|
|
6
|
+
}
|
|
7
|
+
/** 初始化选项 */
|
|
8
|
+
export interface InitOptions extends InitConfigFileOptions {
|
|
9
|
+
type?: InitTypeEnum;
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GitConfig } from '../types';
|
|
2
|
+
import type { GitLogItemInfo, GitReflogItemInfo } from "@done-coding/cli-utils";
|
|
3
|
+
import { type GitMergeBranchInfo } from "@done-coding/cli-utils";
|
|
4
|
+
/** 获取检测反向合并配置map */
|
|
5
|
+
export declare const getCheckReverseMergeConfigMap: (config: GitConfig) => Record<string, import('../types').GitConfigCheckReverseMergeBranchConfig>;
|
|
6
|
+
/** 获取检测反向合并配置map类型 */
|
|
7
|
+
export type CheckReverseMergeConfigMap = ReturnType<typeof getCheckReverseMergeConfigMap>;
|
|
8
|
+
/** 获取检测反向合并配置的最大日志数量 */
|
|
9
|
+
export declare const getCheckReverseMergeMaxLogCount: (configMap: CheckReverseMergeConfigMap) => number;
|
|
10
|
+
/** 获取检测反向合并配置的最大索引map */
|
|
11
|
+
export declare const getCheckReverseMergeMaxIndexMap: (configMap: CheckReverseMergeConfigMap, logList: (GitLogItemInfo | GitReflogItemInfo)[]) => Record<string, number>;
|
|
12
|
+
/**
|
|
13
|
+
* 检测是否是反向合并
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare const checkIsReverseMerge: ({ mergeInfo, configMap, currentBranch, }: {
|
|
17
|
+
mergeInfo?: GitMergeBranchInfo | undefined;
|
|
18
|
+
configMap: CheckReverseMergeConfigMap;
|
|
19
|
+
currentBranch?: string | undefined;
|
|
20
|
+
}) => boolean | undefined;
|
package/types/utils/config.d.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HooksNameEnum } from "@done-coding/cli-utils";
|
|
2
|
+
/** 支持的git hooks名称 */
|
|
3
|
+
export declare const SUPPORT_HOOKS_NAME: HooksNameEnum[];
|
|
4
|
+
/** 支持的检查反向合并的git hooks名称 */
|
|
5
|
+
export declare const SUPPORT_CHECK_REVERSE_MERGE_HOOKS_NAME: readonly [HooksNameEnum.PRE_MERGE_COMMIT, HooksNameEnum.PREPARE_COMMIT_MSG, HooksNameEnum.POST_MERGE, HooksNameEnum.PRE_PUSH, HooksNameEnum.PRE_REBASE];
|
|
6
|
+
/** 支持的检查反向合并的git hooks名称类型 */
|
|
7
|
+
export type SupportCheckReverseMergeHooksNameType = (typeof SUPPORT_CHECK_REVERSE_MERGE_HOOKS_NAME)[number];
|
package/types/utils/index.d.ts
CHANGED
package/types/utils/path.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PromptObject } from "@done-coding/cli-utils";
|
|
2
|
-
import { GitPlatformEnum } from
|
|
2
|
+
import { GitPlatformEnum } from '../types';
|
|
3
3
|
/** git平台选择表单 */
|
|
4
4
|
export declare const getPlatformForm: (initialValue?: GitPlatformEnum) => PromptObject<string>;
|
|
5
5
|
/** git用户名表单 */
|
package/es/clone-11819b7f.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequest as $ } from "@done-coding/request-axios";
|
|
3
|
-
import C from "axios";
|
|
4
|
-
import { lookForParentTarget as S, log as a, decryptAES as I, encryptAES as P, xPrompts as m } from "@done-coding/cli-utils";
|
|
5
|
-
import f from "node:fs";
|
|
6
|
-
import d from "node:path";
|
|
7
|
-
import { execSync as k } from "node:child_process";
|
|
8
|
-
var v = /* @__PURE__ */ ((e) => (e.INIT = "init", e.CLONE = "clone", e))(v || {}), l = /* @__PURE__ */ ((e) => (e.GITHUB = "github", e.GITEE = "gitee", e))(l || {});
|
|
9
|
-
const w = 3e4, h = Math.random(), G = {
|
|
10
|
-
timeout: w,
|
|
11
|
-
getBusinessCode() {
|
|
12
|
-
return h;
|
|
13
|
-
},
|
|
14
|
-
getBusinessMsg(e) {
|
|
15
|
-
return e.statusText;
|
|
16
|
-
},
|
|
17
|
-
getBusinessData(e) {
|
|
18
|
-
return e.data;
|
|
19
|
-
},
|
|
20
|
-
businessSuccessCodeList: [h],
|
|
21
|
-
axios: C
|
|
22
|
-
}, y = $({
|
|
23
|
-
basePath: " https://gitee.com",
|
|
24
|
-
...G
|
|
25
|
-
}), U = $({
|
|
26
|
-
basePath: "https://api.github.com",
|
|
27
|
-
...G
|
|
28
|
-
}), B = ({
|
|
29
|
-
username: e
|
|
30
|
-
}) => y({
|
|
31
|
-
url: `/api/v5/users/${e}/repos`,
|
|
32
|
-
method: "GET"
|
|
33
|
-
}), F = ({
|
|
34
|
-
accessToken: e
|
|
35
|
-
}) => y({
|
|
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
|
-
}), _ = ({
|
|
45
|
-
username: e
|
|
46
|
-
}) => U({
|
|
47
|
-
url: `/users/${e}/repos`,
|
|
48
|
-
method: "GET"
|
|
49
|
-
}), x = ({
|
|
50
|
-
accessToken: e
|
|
51
|
-
}) => U({
|
|
52
|
-
url: "/user/repos",
|
|
53
|
-
method: "GET",
|
|
54
|
-
headers: {
|
|
55
|
-
Authorization: `Bearer ${e}`
|
|
56
|
-
},
|
|
57
|
-
params: {
|
|
58
|
-
per_page: 100,
|
|
59
|
-
page: 1,
|
|
60
|
-
sort: "updated"
|
|
61
|
-
}
|
|
62
|
-
}), N = {
|
|
63
|
-
name: "@done-coding/cli-git",
|
|
64
|
-
version: "0.5.5-alpha.1",
|
|
65
|
-
description: "git跨平台操作命令行工具",
|
|
66
|
-
cliConfig: {
|
|
67
|
-
namespaceDir: ".done-coding",
|
|
68
|
-
moduleName: "git"
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
cliConfig: { namespaceDir: O, moduleName: R }
|
|
72
|
-
} = N, A = `./${O}/${R}`, E = (e) => `${A}/.${e}`, b = ({ platform: e, username: t }) => `${e}/${t}`, D = (e) => {
|
|
73
|
-
const { platform: t } = e, s = E(t), n = S(s, {
|
|
74
|
-
isFindFarthest: !1
|
|
75
|
-
});
|
|
76
|
-
if (!n) {
|
|
77
|
-
a.warn("配置文件不存在");
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const o = `${n}/${s}`, c = f.readFileSync(o, "utf-8"), i = b(e), u = I({ encryptedText: c, secretKey: i });
|
|
81
|
-
if (!u) {
|
|
82
|
-
a.warn("配置文件解密失败");
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
return JSON.parse(u);
|
|
86
|
-
}, V = ({
|
|
87
|
-
rootDir: e,
|
|
88
|
-
username: t,
|
|
89
|
-
platform: s,
|
|
90
|
-
accessToken: n
|
|
91
|
-
}) => {
|
|
92
|
-
const o = E(s), i = JSON.stringify({
|
|
93
|
-
accessToken: n
|
|
94
|
-
}), u = b({ platform: s, username: t }), p = P({ text: i, secretKey: u }), g = d.join(e, o);
|
|
95
|
-
f.mkdirSync(d.dirname(g), {
|
|
96
|
-
recursive: !0
|
|
97
|
-
}), f.writeFileSync(g, p, "utf-8"), a.success(`配置信息保存成功 ${g}`);
|
|
98
|
-
}, T = [
|
|
99
|
-
{ title: "GitHub", value: l.GITHUB },
|
|
100
|
-
{ title: "Gitee", value: l.GITEE }
|
|
101
|
-
], H = (e) => {
|
|
102
|
-
let t = 0;
|
|
103
|
-
if (e) {
|
|
104
|
-
const s = T.findIndex(
|
|
105
|
-
(n) => n.value === e
|
|
106
|
-
);
|
|
107
|
-
s >= 0 && (t = s);
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
type: "select",
|
|
111
|
-
name: "platform",
|
|
112
|
-
message: "选择git平台",
|
|
113
|
-
choices: T,
|
|
114
|
-
initial: t
|
|
115
|
-
};
|
|
116
|
-
}, j = (e) => ({
|
|
117
|
-
type: "text",
|
|
118
|
-
name: "username",
|
|
119
|
-
message: "请输入用户名",
|
|
120
|
-
format: (t) => t.trim(),
|
|
121
|
-
validate: (t) => t.length > 0 || "用户名不能为空",
|
|
122
|
-
initial: e
|
|
123
|
-
}), W = {
|
|
124
|
-
type: "password",
|
|
125
|
-
name: "accessToken",
|
|
126
|
-
message: "请输入git access token",
|
|
127
|
-
format: (e) => e.trim(),
|
|
128
|
-
validate: (e) => e.length > 0 || "access token不能为空"
|
|
129
|
-
}, L = async ({
|
|
130
|
-
platform: e,
|
|
131
|
-
username: t
|
|
132
|
-
} = {}) => {
|
|
133
|
-
const s = {
|
|
134
|
-
platform: e,
|
|
135
|
-
username: t
|
|
136
|
-
};
|
|
137
|
-
e || (s.platform = (await m(H())).platform), t || (s.username = (await m(j())).username);
|
|
138
|
-
const { platform: n, username: o } = s;
|
|
139
|
-
let c = [];
|
|
140
|
-
const i = D({
|
|
141
|
-
username: o,
|
|
142
|
-
platform: n
|
|
143
|
-
});
|
|
144
|
-
let u = i == null ? void 0 : i.accessToken;
|
|
145
|
-
a.stage(`正在获取${o}的${n}仓库列表...`);
|
|
146
|
-
const p = {
|
|
147
|
-
username: o,
|
|
148
|
-
accessToken: u
|
|
149
|
-
};
|
|
150
|
-
switch (s.platform) {
|
|
151
|
-
case l.GITHUB: {
|
|
152
|
-
c = (await (p.accessToken ? x : _)(p)).data.map((r) => ({
|
|
153
|
-
name: r.name,
|
|
154
|
-
httpUrl: r.clone_url,
|
|
155
|
-
sshUrl: r.ssh_url,
|
|
156
|
-
description: r.description || ""
|
|
157
|
-
}));
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
case l.GITEE: {
|
|
161
|
-
c = (await (p.accessToken ? F : B)(p)).data.map((r) => ({
|
|
162
|
-
name: r.name,
|
|
163
|
-
httpUrl: r.html_url,
|
|
164
|
-
sshUrl: r.ssh_url,
|
|
165
|
-
description: r.description || ""
|
|
166
|
-
}));
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
default:
|
|
170
|
-
return a.error(`未知平台${n}`), process.exit(1);
|
|
171
|
-
}
|
|
172
|
-
if (a.success(`获取${o}的${n}仓库列表成功`), c.length === 0) {
|
|
173
|
-
a.warn(`${o} 可获取${n}仓库列表为空`);
|
|
174
|
-
return;
|
|
175
|
-
} else
|
|
176
|
-
a.stage(`共${c.length}个仓库`);
|
|
177
|
-
const { repoUrl: g } = await m({
|
|
178
|
-
name: "repoUrl",
|
|
179
|
-
type: "select",
|
|
180
|
-
message: "选择仓库",
|
|
181
|
-
choices: c.map((r) => ({
|
|
182
|
-
title: `${r.name} ${r.description}`,
|
|
183
|
-
value: r.sshUrl
|
|
184
|
-
}))
|
|
185
|
-
});
|
|
186
|
-
return g;
|
|
187
|
-
}, X = () => ({
|
|
188
|
-
projectName: {
|
|
189
|
-
type: "string",
|
|
190
|
-
alias: "p",
|
|
191
|
-
describe: "项目名称"
|
|
192
|
-
}
|
|
193
|
-
}), Y = () => ({
|
|
194
|
-
platform: {
|
|
195
|
-
describe: "选择git平台",
|
|
196
|
-
type: "string",
|
|
197
|
-
choices: [l.GITHUB, l.GITEE]
|
|
198
|
-
},
|
|
199
|
-
username: {
|
|
200
|
-
describe: "git平台用户名",
|
|
201
|
-
type: "string"
|
|
202
|
-
}
|
|
203
|
-
}), Z = async (e) => {
|
|
204
|
-
const t = await L(e), { projectName: s } = e;
|
|
205
|
-
k(
|
|
206
|
-
`git clone ${t} ${s ? `${s} ` : ""}--depth=1`,
|
|
207
|
-
{ stdio: "inherit" }
|
|
208
|
-
), a.success(`克隆${t}成功`);
|
|
209
|
-
};
|
|
210
|
-
export {
|
|
211
|
-
l as G,
|
|
212
|
-
v as S,
|
|
213
|
-
j as a,
|
|
214
|
-
W as b,
|
|
215
|
-
Z as c,
|
|
216
|
-
X as d,
|
|
217
|
-
Y as e,
|
|
218
|
-
L as f,
|
|
219
|
-
H as g,
|
|
220
|
-
N as i,
|
|
221
|
-
V as s
|
|
222
|
-
};
|
package/es/index-49e07bde.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { getRootDirOptions as p, xPrompts as e, log as C, _curry as r, createSubcommand as c, createMainCommand as f } from "@done-coding/cli-utils";
|
|
3
|
-
import { g, a as I, b, s as h, S as t, c as N, d as O, e as w, i as T } from "./clone-11819b7f.js";
|
|
4
|
-
import $ from "node:os";
|
|
5
|
-
const y = () => p($.homedir()), E = async (o) => {
|
|
6
|
-
const { rootDir: n } = o, { platform: s } = await e(g()), { username: l } = await e(I()), { accessToken: u } = await e(b);
|
|
7
|
-
await h({
|
|
8
|
-
rootDir: n,
|
|
9
|
-
platform: s,
|
|
10
|
-
username: l,
|
|
11
|
-
accessToken: u
|
|
12
|
-
});
|
|
13
|
-
}, i = async (o, n) => {
|
|
14
|
-
switch (o) {
|
|
15
|
-
case t.INIT:
|
|
16
|
-
return E(n);
|
|
17
|
-
case t.CLONE:
|
|
18
|
-
return N(n);
|
|
19
|
-
default:
|
|
20
|
-
return C.error(`无效的命令: ${o}`), process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
}, {
|
|
23
|
-
version: x,
|
|
24
|
-
description: A,
|
|
25
|
-
cliConfig: { moduleName: a }
|
|
26
|
-
} = T, F = {
|
|
27
|
-
command: t.INIT,
|
|
28
|
-
describe: "初始化git配置文件",
|
|
29
|
-
options: y(),
|
|
30
|
-
handler: r(i)(
|
|
31
|
-
t.INIT
|
|
32
|
-
)
|
|
33
|
-
}, L = {
|
|
34
|
-
command: `${t.CLONE} <platform> <username>`,
|
|
35
|
-
describe: "从选择的git平台克隆代码",
|
|
36
|
-
options: O(),
|
|
37
|
-
positionals: w(),
|
|
38
|
-
handler: r(i)(
|
|
39
|
-
t.CLONE
|
|
40
|
-
)
|
|
41
|
-
}, m = {
|
|
42
|
-
describe: A,
|
|
43
|
-
version: x,
|
|
44
|
-
subcommands: [F, L].map(c),
|
|
45
|
-
demandCommandCount: 1
|
|
46
|
-
}, d = (o = !1) => {
|
|
47
|
-
const n = o ? a : void 0, s = `$0${o ? ` ${a}` : ""} <command> [options]`;
|
|
48
|
-
return { command: n, usage: s };
|
|
49
|
-
}, v = async () => f({
|
|
50
|
-
...m,
|
|
51
|
-
...d()
|
|
52
|
-
}), D = () => c({
|
|
53
|
-
...m,
|
|
54
|
-
...d(!0)
|
|
55
|
-
});
|
|
56
|
-
export {
|
|
57
|
-
D as a,
|
|
58
|
-
v as c,
|
|
59
|
-
i as h
|
|
60
|
-
};
|
package/types/handler.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { SubcommandEnum } from './utils';
|
|
2
|
-
import type { InitOptions, CloneOptions } from './utils';
|
|
3
|
-
import type { CliHandlerArgv } from "@done-coding/cli-utils";
|
|
4
|
-
/** 子命令处理函数 */
|
|
5
|
-
export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<InitOptions | CloneOptions>) => Promise<void>;
|
package/types/utils/clone.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type CloneOptions } from "./types";
|
|
2
|
-
import type { CliInfo } from "@done-coding/cli-utils";
|
|
3
|
-
export declare const getCloneOptions: () => CliInfo["options"];
|
|
4
|
-
/** 获取克隆命令的位置参数 */
|
|
5
|
-
export declare const getClonePositionals: () => CliInfo["positionals"];
|
|
6
|
-
/** 克隆目标仓库 */
|
|
7
|
-
export declare const cloneHandler: (options: CloneOptions) => Promise<void>;
|
package/types/utils/init.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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>;
|