@boses/github-clone 1.2.1 → 1.3.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/README.md +12 -9
- package/dist/config/mirror-store.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/main.js +27 -19
- package/dist/main.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,14 +19,14 @@ g clone https://github.com/owner/repo
|
|
|
19
19
|
## 工作原理
|
|
20
20
|
|
|
21
21
|
```text
|
|
22
|
-
输入 URL
|
|
22
|
+
输入 URL →(若已配置镜像)替换为镜像地址 → git clone → git remote set-url origin(恢复官方地址)
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
1. 若已通过 `g mirror set` 配置镜像,将 URL 中的 `github.com`
|
|
25
|
+
1. 若已通过 `g mirror set` 配置镜像,将 URL 中的 `github.com` 替换为镜像地址
|
|
26
26
|
2. 执行 `git clone`
|
|
27
27
|
3. 使用镜像时,克隆完成后将 `origin` 改回 `https://github.com/<owner>/<repo>.git`
|
|
28
28
|
|
|
29
|
-
镜像配置保存在 `~/.g.config
|
|
29
|
+
镜像配置保存在 `~/.g.config`(纯文本,内容为域名或域名/路径,如 `kgithub.com`、`gitclone.com/github.com`)。
|
|
30
30
|
|
|
31
31
|
## 安装
|
|
32
32
|
|
|
@@ -116,24 +116,27 @@ g clone git@github.com:bosens-China/github-clone.git
|
|
|
116
116
|
| 命令 | 说明 |
|
|
117
117
|
|------|------|
|
|
118
118
|
| `g mirror list`(`ls`) | 列出内置镜像预设,标注当前使用的镜像 |
|
|
119
|
-
| `g mirror set <
|
|
119
|
+
| `g mirror set <address\|preset>` | 设置镜像地址或预设名(`kgithub` / `moeyy` / `gitclone`) |
|
|
120
120
|
| `g mirror get` | 查看 `~/.g.config` 中的自定义镜像 |
|
|
121
|
-
| `g mirror test [
|
|
121
|
+
| `g mirror test [address]` | 对镜像发起 HTTP HEAD 探测是否可达(超时 10 秒) |
|
|
122
122
|
| `g mirror unset` | 删除 `~/.g.config` |
|
|
123
123
|
|
|
124
124
|
**内置预设:**
|
|
125
125
|
|
|
126
|
-
| 预设名 |
|
|
126
|
+
| 预设名 | 地址 | 说明 |
|
|
127
127
|
|--------|------|------|
|
|
128
128
|
| `kgithub` | `kgithub.com` | KGitHub 镜像(域名替换) |
|
|
129
129
|
| `moeyy` | `github.moeyy.xyz` | Moeyy 镜像(域名替换) |
|
|
130
|
+
| `gitclone` | `gitclone.com/github.com` | GitClone 缓存(路径前缀) |
|
|
131
|
+
|
|
132
|
+
例如,`g mirror set gitclone` 会将 `https://github.com/owner/repo.git` 转换为 `https://gitclone.com/github.com/owner/repo.git`。
|
|
130
133
|
|
|
131
134
|
**镜像与克隆的关系:**
|
|
132
135
|
|
|
133
136
|
| 场景 | `g mirror get` | `g clone` 行为 |
|
|
134
137
|
|------|----------------|----------------|
|
|
135
138
|
| 未配置镜像 | 提示未配置 | 直连 GitHub |
|
|
136
|
-
| 已 `mirror set` |
|
|
139
|
+
| 已 `mirror set` | 显示配置的地址 | 使用配置的镜像 |
|
|
137
140
|
| 已 `mirror unset` | 提示未配置 | 直连 GitHub |
|
|
138
141
|
| 已配置镜像 + `--no-mirror` | — | 强制直连 GitHub |
|
|
139
142
|
|
|
@@ -167,7 +170,7 @@ try {
|
|
|
167
170
|
|------|------|------|
|
|
168
171
|
| `dirName` | `string` | 本地目录名 |
|
|
169
172
|
| `branch` | `string` | 分支名 |
|
|
170
|
-
| `mirrorHost` | `string` |
|
|
173
|
+
| `mirrorHost` | `string` | 镜像地址,支持域名或域名/路径(API 不会读取 `~/.g.config`,需显式传入) |
|
|
171
174
|
| `cwd` | `string` | 执行目录,默认 `process.cwd()` |
|
|
172
175
|
| `silence` | `boolean` | 静默模式,不继承 Git 输出 |
|
|
173
176
|
| `depth` | `number` | 浅克隆深度 |
|
|
@@ -252,7 +255,7 @@ feat!: ...
|
|
|
252
255
|
## 限制
|
|
253
256
|
|
|
254
257
|
- 仅支持 GitHub(`github.com`),不支持 GitLab / Gitee / GitHub Enterprise
|
|
255
|
-
-
|
|
258
|
+
- 支持域名替换型及 `gitclone.com/github.com/...` 路径前缀型镜像,不支持 `ghproxy.com/https://github.com/...` 这类嵌套完整 URL
|
|
256
259
|
- 不支持 `git pull` / `git fetch` 加速
|
|
257
260
|
- `mirror test` 仅验证 HTTP 可达,不保证 `git clone` 一定成功
|
|
258
261
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mirror-store.d.ts","sourceRoot":"","sources":["../../src/config/mirror-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mirror-store.d.ts","sourceRoot":"","sources":["../../src/config/mirror-store.ts"],"names":[],"mappings":"AAgBA,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,SAAoB;IAE3D,aAAa,IAAI,MAAM,GAAG,SAAS;IAQnC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKjC,eAAe,IAAI,IAAI;IAMvB,aAAa,IAAI,MAAM;CAGxB;AAED,eAAO,MAAM,kBAAkB,aAAoB,CAAC"}
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAgBxC,CAAC;AAEX,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,wBAAwB,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -35,10 +35,10 @@ let node_path = require("node:path");
|
|
|
35
35
|
node_path = __toESM(node_path);
|
|
36
36
|
let execa = require("execa");
|
|
37
37
|
//#region package.json
|
|
38
|
-
var version = "1.
|
|
38
|
+
var version = "1.3.0";
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/config/mirror-store.ts
|
|
41
|
-
const mirrorHostSchema = zod.z.string().trim().min(1, "镜像地址不能为空").regex(/^[a-zA-Z0-9][-a-zA-Z0-9.]*[a-zA-Z0-9]
|
|
41
|
+
const mirrorHostSchema = zod.z.string().trim().min(1, "镜像地址不能为空").regex(/^[a-zA-Z0-9](?:[-a-zA-Z0-9.]*[a-zA-Z0-9])?(?:\/[a-zA-Z0-9](?:[-a-zA-Z0-9.]*[a-zA-Z0-9])?)*$/, "镜像地址格式无效,请输入域名或域名/路径,例如 kgithub.com 或 gitclone.com/github.com");
|
|
42
42
|
const defaultConfigPath = node_path.default.join(node_os.default.homedir(), ".g.config");
|
|
43
43
|
var ConfigStore = class {
|
|
44
44
|
configPath;
|
|
@@ -213,15 +213,23 @@ function runCloneCommand(url, dirName, options) {
|
|
|
213
213
|
}
|
|
214
214
|
//#endregion
|
|
215
215
|
//#region src/constants.ts
|
|
216
|
-
const MIRROR_PRESETS = [
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
216
|
+
const MIRROR_PRESETS = [
|
|
217
|
+
{
|
|
218
|
+
name: "kgithub",
|
|
219
|
+
host: "kgithub.com",
|
|
220
|
+
description: "KGitHub 镜像(域名替换)"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "moeyy",
|
|
224
|
+
host: "github.moeyy.xyz",
|
|
225
|
+
description: "Moeyy 镜像(域名替换)"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "gitclone",
|
|
229
|
+
host: "gitclone.com/github.com",
|
|
230
|
+
description: "GitClone 缓存(路径前缀)"
|
|
231
|
+
}
|
|
232
|
+
];
|
|
225
233
|
/** 用于 mirror test 的探测仓库路径(GitHub 官方示例仓库,长期稳定) */
|
|
226
234
|
const MIRROR_PROBE_REPO = "octocat/Hello-World";
|
|
227
235
|
//#endregion
|
|
@@ -255,14 +263,14 @@ function runMirrorList() {
|
|
|
255
263
|
if (current && !isPresetCurrent) console.log(`当前配置:${picocolors.default.cyan(current)} ${picocolors.default.dim("(自定义镜像,非内置预设)")}`);
|
|
256
264
|
else if (!current) {
|
|
257
265
|
console.log(picocolors.default.dim("当前未配置镜像,克隆将直连 GitHub"));
|
|
258
|
-
console.log(picocolors.default.dim("提示:使用 g mirror set <
|
|
266
|
+
console.log(picocolors.default.dim("提示:使用 g mirror set <address> 或 g mirror set <预设名> 进行配置"));
|
|
259
267
|
}
|
|
260
268
|
}
|
|
261
269
|
function formatProbeError(error, mirrorHost) {
|
|
262
270
|
if (error instanceof Error) {
|
|
263
271
|
if (error.name === "TimeoutError") return `镜像 ${mirrorHost} 探测超时(>${PROBE_TIMEOUT_MS / 1e3}s),可能不可用`;
|
|
264
272
|
const code = error.cause?.code;
|
|
265
|
-
if (code === "ENOTFOUND" || code === "EAI_AGAIN") return
|
|
273
|
+
if (code === "ENOTFOUND" || code === "EAI_AGAIN") return `无法解析镜像地址 ${mirrorHost},请检查配置是否正确`;
|
|
266
274
|
if (code === "ECONNREFUSED" || code === "ECONNRESET") return `连接 ${mirrorHost} 被拒绝或重置,镜像可能不可用`;
|
|
267
275
|
if (error.message === "fetch failed") return `无法连接 ${mirrorHost},请检查网络或镜像是否可用`;
|
|
268
276
|
}
|
|
@@ -270,7 +278,7 @@ function formatProbeError(error, mirrorHost) {
|
|
|
270
278
|
}
|
|
271
279
|
async function runMirrorTest(host) {
|
|
272
280
|
const mirrorHost = host ?? defaultConfigStore.getMirrorHost();
|
|
273
|
-
if (!mirrorHost) throw new Error("未配置镜像,请先执行 g mirror set <
|
|
281
|
+
if (!mirrorHost) throw new Error("未配置镜像,请先执行 g mirror set <address> 或指定测试地址");
|
|
274
282
|
const probeUrl = buildMirrorProbeUrl(mirrorHost, MIRROR_PROBE_REPO);
|
|
275
283
|
console.log(picocolors.default.dim(`正在探测 ${probeUrl}⋯⋯`));
|
|
276
284
|
let response;
|
|
@@ -311,9 +319,9 @@ program.command("clone <url> [dir]").description("克隆 GitHub 仓库。若已
|
|
|
311
319
|
`).action(async (url, dir, options) => {
|
|
312
320
|
runCloneCommand(url, dir, options);
|
|
313
321
|
});
|
|
314
|
-
const mirror = program.command("mirror").description("管理 GitHub 镜像配置(保存在 ~/.g.config
|
|
315
|
-
mirror.command("set <
|
|
316
|
-
runMirrorSet(resolveMirrorHostInput(
|
|
322
|
+
const mirror = program.command("mirror").description("管理 GitHub 镜像配置(保存在 ~/.g.config,如 kgithub.com 或 gitclone.com/github.com)");
|
|
323
|
+
mirror.command("set <address>").description("设置镜像地址,或传入预设名(kgithub / moeyy / gitclone)。执行 g mirror list 查看预设").action(async (address) => {
|
|
324
|
+
runMirrorSet(resolveMirrorHostInput(address));
|
|
317
325
|
});
|
|
318
326
|
mirror.command("get").description("查看 ~/.g.config 中保存的镜像;未配置时克隆将直连 GitHub").action(async () => {
|
|
319
327
|
printMirror(defaultConfigStore.getMirrorHost());
|
|
@@ -324,8 +332,8 @@ mirror.command("list").alias("ls").description("列出内置镜像预设及说
|
|
|
324
332
|
mirror.command("unset").description("删除 ~/.g.config,清除镜像配置(克隆将直连 GitHub)").action(async () => {
|
|
325
333
|
runMirrorUnset();
|
|
326
334
|
});
|
|
327
|
-
mirror.command("test [
|
|
328
|
-
await runMirrorTest(
|
|
335
|
+
mirror.command("test [address]").description("探测镜像是否可达:对镜像站发起 HTTP HEAD 请求。省略 address 时测试当前配置;可传镜像地址或预设名").action(async (address) => {
|
|
336
|
+
await runMirrorTest(address ? resolveMirrorHostInput(address) : void 0);
|
|
329
337
|
});
|
|
330
338
|
program.parseAsync(node_process.default.argv).catch((error) => {
|
|
331
339
|
console.error(picocolors.default.red(`错误:${formatCliError(error)}`));
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["z","path","os","fs","path","process","pc","pc","ZodError","Command","process","pc"],"sources":["../package.json","../src/config/mirror-store.ts","../src/core/git-client.ts","../src/core/github-url.ts","../src/core/clone-repo.ts","../src/cli/commands/clone-command.ts","../src/constants.ts","../src/cli/commands/mirror-command.ts","../src/cli/index.ts"],"sourcesContent":["","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { z } from 'zod';\n\nconst mirrorHostSchema = z\n .string()\n .trim()\n .min(1, '镜像地址不能为空')\n .regex(/^[a-zA-Z0-9][-a-zA-Z0-9.]*[a-zA-Z0-9]$/, '镜像地址格式无效,请输入域名,例如 kgithub.com');\n\nconst defaultConfigPath = path.join(os.homedir(), '.g.config');\n\nexport class ConfigStore {\n constructor(private readonly configPath = defaultConfigPath) {}\n\n getMirrorHost(): string | undefined {\n if (!fs.existsSync(this.configPath)) {\n return undefined;\n }\n const raw = fs.readFileSync(this.configPath, 'utf-8').trim();\n return raw || undefined;\n }\n\n setMirrorHost(host: string): void {\n const parsed = mirrorHostSchema.parse(host);\n fs.writeFileSync(this.configPath, parsed, 'utf-8');\n }\n\n unsetMirrorHost(): void {\n if (fs.existsSync(this.configPath)) {\n fs.unlinkSync(this.configPath);\n }\n }\n\n getConfigPath(): string {\n return this.configPath;\n }\n}\n\nexport const defaultConfigStore = new ConfigStore();\n","import path from 'node:path';\nimport { execaSync } from 'execa';\n\nexport interface GitCloneParams {\n url: string;\n dirName?: string;\n branch?: string;\n depth?: number;\n singleBranch?: boolean;\n cwd?: string;\n silence?: boolean;\n}\n\nfunction toExecaStdio(silence?: boolean): 'pipe' | 'inherit' {\n return silence ? 'pipe' : 'inherit';\n}\n\nfunction buildCloneArgs(params: GitCloneParams): string[] {\n const args = ['clone', params.url];\n if (params.branch) {\n args.push('--branch', params.branch);\n }\n if (params.depth !== undefined) {\n args.push('--depth', String(params.depth));\n }\n if (params.singleBranch) {\n args.push('--single-branch');\n }\n if (params.dirName) {\n args.push(params.dirName);\n }\n return args;\n}\n\nfunction assertGitSuccess(result: { failed: boolean; exitCode?: number; stderr?: string }): void {\n if (result.failed || (result.exitCode !== undefined && result.exitCode !== 0)) {\n const stderr = result.stderr?.trim();\n throw new Error(stderr || `Git 命令执行失败,退出码 ${result.exitCode ?? '未知'}`);\n }\n}\n\nexport function gitExists(): boolean {\n try {\n execaSync('git', ['--version']);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function runGitClone(params: GitCloneParams): void {\n const result = execaSync('git', buildCloneArgs(params), {\n cwd: params.cwd,\n stdio: toExecaStdio(params.silence),\n reject: false,\n });\n assertGitSuccess(result);\n}\n\nexport function setRemoteOrigin(dir: string, url: string, cwd: string): void {\n const dirPath = path.join(cwd, dir);\n const result = execaSync('git', ['remote', 'set-url', 'origin', url], {\n cwd: dirPath,\n stdio: 'pipe',\n reject: false,\n });\n assertGitSuccess(result);\n}\n","const GITHUB_HTTPS_RE = /^https:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/;\nconst GITHUB_SSH_RE = /^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/;\n\nexport interface ParsedGithubUrl {\n owner: string;\n repo: string;\n normalizedHttps: string;\n}\n\nexport function isGithubLink(url: string): boolean {\n const trimmed = url.trim();\n return GITHUB_HTTPS_RE.test(trimmed) || GITHUB_SSH_RE.test(trimmed);\n}\n\nexport function parseGithubUrl(url: string): ParsedGithubUrl {\n const trimmed = url.trim();\n const httpsMatch = GITHUB_HTTPS_RE.exec(trimmed);\n if (httpsMatch) {\n const [, owner, repo] = httpsMatch as RegExpExecArray & [string, string, string];\n return {\n owner,\n repo,\n normalizedHttps: `https://github.com/${owner}/${repo}.git`,\n };\n }\n\n const sshMatch = GITHUB_SSH_RE.exec(trimmed);\n if (sshMatch) {\n const [, owner, repo] = sshMatch as RegExpExecArray & [string, string, string];\n return {\n owner,\n repo,\n normalizedHttps: `https://github.com/${owner}/${repo}.git`,\n };\n }\n\n throw new Error(`无效的 GitHub 仓库地址:${url}`);\n}\n\nexport function replaceMirrorHost(url: string, mirrorHost: string): string {\n const { normalizedHttps } = parseGithubUrl(url);\n return normalizedHttps.replace('github.com', mirrorHost);\n}\n\nexport function getRepoDirName(url: string): string {\n const { repo } = parseGithubUrl(url);\n return repo;\n}\n\nexport function buildMirrorProbeUrl(mirrorHost: string, repoPath: string): string {\n return `https://${mirrorHost}/${repoPath}`;\n}\n","import process from 'node:process';\nimport type { CloneOptions } from '../types';\nimport { gitExists, runGitClone, setRemoteOrigin } from './git-client';\nimport { getRepoDirName, parseGithubUrl, replaceMirrorHost } from './github-url';\n\nexport function cloneGithubRepo(url: string, options?: CloneOptions): void {\n if (!gitExists()) {\n throw new Error('未检测到 Git,请先安装 Git,并确保其在 PATH 中可用');\n }\n\n const { normalizedHttps } = parseGithubUrl(url);\n const mirrorHost = options?.mirrorHost;\n const cloneUrl = mirrorHost ? replaceMirrorHost(url, mirrorHost) : normalizedHttps;\n\n const {\n dirName,\n branch,\n cwd = process.cwd(),\n silence,\n depth,\n singleBranch,\n } = options ?? {};\n\n const requestedDir = dirName?.trim() ? dirName.trim() : undefined;\n const targetDir = requestedDir ?? getRepoDirName(url);\n\n runGitClone({\n url: cloneUrl,\n dirName: requestedDir,\n branch,\n depth,\n singleBranch,\n cwd,\n silence,\n });\n\n if (mirrorHost) {\n setRemoteOrigin(targetDir, normalizedHttps, cwd);\n }\n}\n\nexport default cloneGithubRepo;\n","import pc from 'picocolors';\nimport { defaultConfigStore } from '../../config/mirror-store';\nimport { cloneGithubRepo } from '../../core/clone-repo';\nimport { getRepoDirName, parseGithubUrl, replaceMirrorHost } from '../../core/github-url';\n\nexport interface CloneCommandOptions {\n branch?: string;\n depth?: number;\n singleBranch?: boolean;\n /** commander 由 --no-mirror 写入 false;未传时为 true 或 undefined */\n mirror?: boolean;\n verbose?: boolean;\n}\n\nfunction normalizeDirName(dir: string | undefined): string | undefined {\n const trimmed = dir?.trim();\n return trimmed ? trimmed : undefined;\n}\n\nfunction printVerboseClonePlan(\n url: string,\n dirName: string | undefined,\n options: CloneCommandOptions,\n mirrorHost: string | undefined,\n): void {\n const { normalizedHttps } = parseGithubUrl(url);\n const cloneUrl = mirrorHost ? replaceMirrorHost(url, mirrorHost) : normalizedHttps;\n const targetDir = normalizeDirName(dirName) ?? getRepoDirName(url);\n\n console.log(pc.bold('克隆计划'));\n console.log(pc.dim(` 模式 : ${mirrorHost ? `镜像(${mirrorHost})` : '直连 GitHub'}`));\n console.log(pc.dim(` 克隆地址 : ${cloneUrl}`));\n if (mirrorHost) {\n console.log(pc.dim(` 恢复 origin: ${normalizedHttps}`));\n }\n console.log(pc.dim(` 本地目录 : ${targetDir}`));\n\n const gitFlags: string[] = [];\n if (options.branch) {\n gitFlags.push(`--branch ${options.branch}`);\n }\n if (options.depth !== undefined) {\n gitFlags.push(`--depth ${options.depth}`);\n }\n if (options.singleBranch) {\n gitFlags.push('--single-branch');\n }\n if (gitFlags.length > 0) {\n console.log(pc.dim(` Git 参数 : ${gitFlags.join(' ')}`));\n } else {\n console.log(pc.dim(' Git 参数 : (无额外参数,完整克隆)'));\n }\n console.log('');\n}\n\nexport function runCloneCommand(\n url: string,\n dirName: string | undefined,\n options: CloneCommandOptions,\n): void {\n const useMirror = options.mirror !== false;\n const mirrorHost = useMirror ? defaultConfigStore.getMirrorHost() : undefined;\n const requestedDir = normalizeDirName(dirName);\n\n if (options.verbose) {\n printVerboseClonePlan(url, requestedDir, options, mirrorHost);\n } else {\n console.log(pc.dim(mirrorHost ? `→ 使用镜像 ${mirrorHost}` : '→ 直连 github.com'));\n }\n\n try {\n cloneGithubRepo(url, {\n dirName: requestedDir,\n branch: options.branch,\n mirrorHost,\n depth: options.depth,\n singleBranch: options.singleBranch,\n });\n } catch (error) {\n if (mirrorHost) {\n console.error(\n pc.yellow(`提示:镜像 ${mirrorHost} 可能不可用,可执行 g mirror test 验证,或加 --no-mirror 直连`),\n );\n }\n throw error;\n }\n\n const repoDir = requestedDir ?? getRepoDirName(url);\n const branchInfo = options.branch ? `,分支 ${options.branch}` : '';\n console.log(pc.green(`✓ 克隆完成:${repoDir}${branchInfo}`));\n if (mirrorHost && !options.verbose) {\n console.log(pc.dim(` 已恢复 origin 为 GitHub 官方地址`));\n }\n}\n","/** 域名替换型镜像:将 URL 中的 github.com 替换为镜像主机 */\nexport interface MirrorPreset {\n name: string;\n host: string;\n description: string;\n}\n\nexport const MIRROR_PRESETS: readonly MirrorPreset[] = [\n {\n name: 'kgithub',\n host: 'kgithub.com',\n description: 'KGitHub 镜像(域名替换)',\n },\n {\n name: 'moeyy',\n host: 'github.moeyy.xyz',\n description: 'Moeyy 镜像(域名替换)',\n },\n] as const;\n\n/** 用于 mirror test 的探测仓库路径(GitHub 官方示例仓库,长期稳定) */\nexport const MIRROR_PROBE_REPO = 'octocat/Hello-World';\n","import pc from 'picocolors';\nimport { defaultConfigStore } from '../../config/mirror-store';\nimport { MIRROR_PRESETS, MIRROR_PROBE_REPO, type MirrorPreset } from '../../constants';\nimport { buildMirrorProbeUrl } from '../../core/github-url';\n\nconst PROBE_TIMEOUT_MS = 10_000;\n\nexport function printMirror(host: string | undefined): void {\n if (host) {\n console.log(`当前镜像:${pc.cyan(host)}`);\n return;\n }\n console.log(pc.yellow('当前未配置镜像,克隆将直连 GitHub'));\n}\n\nexport function runMirrorSet(host: string): void {\n defaultConfigStore.setMirrorHost(host);\n console.log(pc.green(`镜像已设置为 ${host}`));\n console.log(pc.dim('提示:执行 g mirror test 验证镜像是否可用'));\n}\n\nexport function runMirrorUnset(): void {\n defaultConfigStore.unsetMirrorHost();\n console.log(pc.green('已清除镜像配置,克隆将直连 GitHub'));\n}\n\nexport function runMirrorList(): void {\n const current = defaultConfigStore.getMirrorHost();\n const isPresetCurrent = current ? MIRROR_PRESETS.some((p) => p.host === current) : false;\n\n console.log(pc.bold('可用镜像预设:'));\n for (const preset of MIRROR_PRESETS) {\n const marker = current === preset.host ? pc.green(' (当前)') : '';\n console.log(\n ` ${pc.cyan(preset.name.padEnd(8))} ${preset.host} ${pc.dim(`— ${preset.description}`)}${marker}`,\n );\n }\n console.log('');\n if (current && !isPresetCurrent) {\n console.log(`当前配置:${pc.cyan(current)} ${pc.dim('(自定义镜像,非内置预设)')}`);\n } else if (!current) {\n console.log(pc.dim('当前未配置镜像,克隆将直连 GitHub'));\n console.log(pc.dim('提示:使用 g mirror set <host> 或 g mirror set <预设名> 进行配置'));\n }\n}\n\nfunction formatProbeError(error: unknown, mirrorHost: string): string {\n if (error instanceof Error) {\n // AbortSignal.timeout 触发的错误名为 'TimeoutError'\n if (error.name === 'TimeoutError') {\n return `镜像 ${mirrorHost} 探测超时(>${PROBE_TIMEOUT_MS / 1000}s),可能不可用`;\n }\n const cause = (error as Error & { cause?: { code?: string } }).cause;\n const code = cause?.code;\n if (code === 'ENOTFOUND' || code === 'EAI_AGAIN') {\n return `无法解析域名 ${mirrorHost},请检查镜像地址是否正确`;\n }\n if (code === 'ECONNREFUSED' || code === 'ECONNRESET') {\n return `连接 ${mirrorHost} 被拒绝或重置,镜像可能不可用`;\n }\n if (error.message === 'fetch failed') {\n return `无法连接 ${mirrorHost},请检查网络或镜像是否可用`;\n }\n }\n return `镜像 ${mirrorHost} 探测失败:${error instanceof Error ? error.message : String(error)}`;\n}\n\nexport async function runMirrorTest(host?: string): Promise<void> {\n const mirrorHost = host ?? defaultConfigStore.getMirrorHost();\n if (!mirrorHost) {\n throw new Error('未配置镜像,请先执行 g mirror set <host> 或指定测试主机');\n }\n\n const probeUrl = buildMirrorProbeUrl(mirrorHost, MIRROR_PROBE_REPO);\n console.log(pc.dim(`正在探测 ${probeUrl}⋯⋯`));\n\n let response: Response;\n try {\n response = await fetch(probeUrl, {\n method: 'HEAD',\n signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),\n });\n } catch (error) {\n throw new Error(formatProbeError(error, mirrorHost), { cause: error });\n }\n if (!response.ok) {\n throw new Error(`镜像 ${mirrorHost} 返回 HTTP ${response.status},可能不可用`);\n }\n console.log(pc.green(`镜像 ${mirrorHost} 可用`));\n}\n\nexport function resolveMirrorHostInput(input: string): string {\n const preset = MIRROR_PRESETS.find((item: MirrorPreset) => item.name === input || item.host === input);\n return preset?.host ?? input;\n}\n","#!/usr/bin/env node\n\nimport process from 'node:process';\nimport { Command } from 'commander';\nimport pc from 'picocolors';\nimport { ZodError } from 'zod';\nimport { version } from '../../package.json';\nimport { defaultConfigStore } from '../config/mirror-store';\nimport { runCloneCommand, type CloneCommandOptions } from './commands/clone-command';\nimport {\n printMirror,\n resolveMirrorHostInput,\n runMirrorList,\n runMirrorSet,\n runMirrorTest,\n runMirrorUnset,\n} from './commands/mirror-command';\n\nfunction formatCliError(error: unknown): string {\n if (error instanceof ZodError) {\n return error.issues.map((item) => item.message).join(';');\n }\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n}\n\nconst program = new Command();\n\nprogram\n .name('g')\n .description('加速国内 GitHub clone:通过镜像拉取代码,完成后自动将 origin 恢复为 GitHub 官方地址')\n .version(version, '-v, --version', '输出版本号')\n .addHelpText(\n 'after',\n `\n快速开始:\n $ g mirror set kgithub # 配置镜像(首次使用)\n $ g mirror test # 验证镜像可用\n $ g clone https://github.com/owner/repo # 克隆仓库\n`,\n );\n\nprogram\n .command('clone <url> [dir]')\n .description(\n '克隆 GitHub 仓库。若已通过 g mirror set 配置镜像,将经镜像加速下载;' +\n '克隆结束后将 origin 改回 github.com,便于后续 push。',\n )\n .option(\n '-b, --branch <name>',\n '只检出指定分支(传给 git clone --branch)。例如 -b dev 表示克隆 dev 分支的工作区',\n )\n .option(\n '--depth <n>',\n '浅克隆:只拉取最近 n 次提交(传给 git clone --depth)。' +\n '如 --depth 1 表示只要最新版本,体积更小、速度更快,但本地没有完整 Git 历史',\n (value: string) => Number.parseInt(value, 10),\n )\n .option(\n '--single-branch',\n '只克隆单个分支,不下载其他远程分支(传给 git clone --single-branch)。' +\n '常与 -b 联用;单独使用时默认只拉远程默认分支(通常是 main)',\n )\n .option(\n '--no-mirror',\n '忽略 ~/.g.config 中的镜像配置,强制直连 github.com 克隆',\n )\n .option(\n '--verbose',\n '输出克隆前的详细信息:镜像/直连模式、实际克隆地址、分支与 Git 参数等(不改变 Git 本身的输出)',\n )\n .addHelpText(\n 'after',\n `\n示例:\n $ g clone https://github.com/owner/repo\n $ g clone https://github.com/owner/repo my-dir -b dev\n $ g clone https://github.com/owner/repo -b main --single-branch --depth 1\n $ g clone https://github.com/owner/repo --no-mirror --verbose\n`,\n )\n .action(async (url: string, dir: string | undefined, options: CloneCommandOptions) => {\n runCloneCommand(url, dir, options);\n });\n\nconst mirror = program\n .command('mirror')\n .description('管理 GitHub 镜像配置(保存在 ~/.g.config,值为镜像域名,如 kgithub.com)');\n\nmirror\n .command('set <host>')\n .description('设置镜像域名,或传入预设名(kgithub / moeyy)。执行 g mirror list 查看预设')\n .action(async (host: string) => {\n runMirrorSet(resolveMirrorHostInput(host));\n });\n\nmirror\n .command('get')\n .description('查看 ~/.g.config 中保存的镜像;未配置时克隆将直连 GitHub')\n .action(async () => {\n printMirror(defaultConfigStore.getMirrorHost());\n });\n\nmirror\n .command('list')\n .alias('ls')\n .description('列出内置镜像预设及说明,并标注当前正在使用的镜像')\n .action(async () => {\n runMirrorList();\n });\n\nmirror\n .command('unset')\n .description('删除 ~/.g.config,清除镜像配置(克隆将直连 GitHub)')\n .action(async () => {\n runMirrorUnset();\n });\n\nmirror\n .command('test [host]')\n .description(\n '探测镜像是否可达:对镜像站发起 HTTP HEAD 请求。' +\n '省略 host 时测试当前配置;可传域名或预设名',\n )\n .action(async (host?: string) => {\n await runMirrorTest(host ? resolveMirrorHostInput(host) : undefined);\n });\n\nvoid program.parseAsync(process.argv).catch((error: unknown) => {\n console.error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Ae;AACjB,CAAC;AAEH,OACG,QAAQ,aAAa,CAAC,CACtB,YACC,uDAEF,CAAC,CACA,OAAO,OAAO,SAAkB;CAC/B,MAAM,cAAc,OAAO,uBAAuB,IAAI,IAAI,KAAA,CAAS;AACrE,CAAC;AAEE,QAAQ,WAAWC,aAAAA,QAAQ,IAAI,CAAC,CAAC,OAAO,UAAmB;CAC9D,QAAQ,MAAMC,WAAAA,QAAG,IAAI,MAAM,eAAe,KAAK,GAAG,CAAC;CACnD,aAAA,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"main.js","names":["z","path","os","fs","path","process","pc","pc","ZodError","Command","process","pc"],"sources":["../package.json","../src/config/mirror-store.ts","../src/core/git-client.ts","../src/core/github-url.ts","../src/core/clone-repo.ts","../src/cli/commands/clone-command.ts","../src/constants.ts","../src/cli/commands/mirror-command.ts","../src/cli/index.ts"],"sourcesContent":["","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { z } from 'zod';\n\nconst mirrorHostSchema = z\n .string()\n .trim()\n .min(1, '镜像地址不能为空')\n .regex(\n /^[a-zA-Z0-9](?:[-a-zA-Z0-9.]*[a-zA-Z0-9])?(?:\\/[a-zA-Z0-9](?:[-a-zA-Z0-9.]*[a-zA-Z0-9])?)*$/,\n '镜像地址格式无效,请输入域名或域名/路径,例如 kgithub.com 或 gitclone.com/github.com',\n );\n\nconst defaultConfigPath = path.join(os.homedir(), '.g.config');\n\nexport class ConfigStore {\n constructor(private readonly configPath = defaultConfigPath) {}\n\n getMirrorHost(): string | undefined {\n if (!fs.existsSync(this.configPath)) {\n return undefined;\n }\n const raw = fs.readFileSync(this.configPath, 'utf-8').trim();\n return raw || undefined;\n }\n\n setMirrorHost(host: string): void {\n const parsed = mirrorHostSchema.parse(host);\n fs.writeFileSync(this.configPath, parsed, 'utf-8');\n }\n\n unsetMirrorHost(): void {\n if (fs.existsSync(this.configPath)) {\n fs.unlinkSync(this.configPath);\n }\n }\n\n getConfigPath(): string {\n return this.configPath;\n }\n}\n\nexport const defaultConfigStore = new ConfigStore();\n","import path from 'node:path';\nimport { execaSync } from 'execa';\n\nexport interface GitCloneParams {\n url: string;\n dirName?: string;\n branch?: string;\n depth?: number;\n singleBranch?: boolean;\n cwd?: string;\n silence?: boolean;\n}\n\nfunction toExecaStdio(silence?: boolean): 'pipe' | 'inherit' {\n return silence ? 'pipe' : 'inherit';\n}\n\nfunction buildCloneArgs(params: GitCloneParams): string[] {\n const args = ['clone', params.url];\n if (params.branch) {\n args.push('--branch', params.branch);\n }\n if (params.depth !== undefined) {\n args.push('--depth', String(params.depth));\n }\n if (params.singleBranch) {\n args.push('--single-branch');\n }\n if (params.dirName) {\n args.push(params.dirName);\n }\n return args;\n}\n\nfunction assertGitSuccess(result: { failed: boolean; exitCode?: number; stderr?: string }): void {\n if (result.failed || (result.exitCode !== undefined && result.exitCode !== 0)) {\n const stderr = result.stderr?.trim();\n throw new Error(stderr || `Git 命令执行失败,退出码 ${result.exitCode ?? '未知'}`);\n }\n}\n\nexport function gitExists(): boolean {\n try {\n execaSync('git', ['--version']);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function runGitClone(params: GitCloneParams): void {\n const result = execaSync('git', buildCloneArgs(params), {\n cwd: params.cwd,\n stdio: toExecaStdio(params.silence),\n reject: false,\n });\n assertGitSuccess(result);\n}\n\nexport function setRemoteOrigin(dir: string, url: string, cwd: string): void {\n const dirPath = path.join(cwd, dir);\n const result = execaSync('git', ['remote', 'set-url', 'origin', url], {\n cwd: dirPath,\n stdio: 'pipe',\n reject: false,\n });\n assertGitSuccess(result);\n}\n","const GITHUB_HTTPS_RE = /^https:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/;\nconst GITHUB_SSH_RE = /^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/;\n\nexport interface ParsedGithubUrl {\n owner: string;\n repo: string;\n normalizedHttps: string;\n}\n\nexport function isGithubLink(url: string): boolean {\n const trimmed = url.trim();\n return GITHUB_HTTPS_RE.test(trimmed) || GITHUB_SSH_RE.test(trimmed);\n}\n\nexport function parseGithubUrl(url: string): ParsedGithubUrl {\n const trimmed = url.trim();\n const httpsMatch = GITHUB_HTTPS_RE.exec(trimmed);\n if (httpsMatch) {\n const [, owner, repo] = httpsMatch as RegExpExecArray & [string, string, string];\n return {\n owner,\n repo,\n normalizedHttps: `https://github.com/${owner}/${repo}.git`,\n };\n }\n\n const sshMatch = GITHUB_SSH_RE.exec(trimmed);\n if (sshMatch) {\n const [, owner, repo] = sshMatch as RegExpExecArray & [string, string, string];\n return {\n owner,\n repo,\n normalizedHttps: `https://github.com/${owner}/${repo}.git`,\n };\n }\n\n throw new Error(`无效的 GitHub 仓库地址:${url}`);\n}\n\nexport function replaceMirrorHost(url: string, mirrorHost: string): string {\n const { normalizedHttps } = parseGithubUrl(url);\n return normalizedHttps.replace('github.com', mirrorHost);\n}\n\nexport function getRepoDirName(url: string): string {\n const { repo } = parseGithubUrl(url);\n return repo;\n}\n\nexport function buildMirrorProbeUrl(mirrorHost: string, repoPath: string): string {\n return `https://${mirrorHost}/${repoPath}`;\n}\n","import process from 'node:process';\nimport type { CloneOptions } from '../types';\nimport { gitExists, runGitClone, setRemoteOrigin } from './git-client';\nimport { getRepoDirName, parseGithubUrl, replaceMirrorHost } from './github-url';\n\nexport function cloneGithubRepo(url: string, options?: CloneOptions): void {\n if (!gitExists()) {\n throw new Error('未检测到 Git,请先安装 Git,并确保其在 PATH 中可用');\n }\n\n const { normalizedHttps } = parseGithubUrl(url);\n const mirrorHost = options?.mirrorHost;\n const cloneUrl = mirrorHost ? replaceMirrorHost(url, mirrorHost) : normalizedHttps;\n\n const {\n dirName,\n branch,\n cwd = process.cwd(),\n silence,\n depth,\n singleBranch,\n } = options ?? {};\n\n const requestedDir = dirName?.trim() ? dirName.trim() : undefined;\n const targetDir = requestedDir ?? getRepoDirName(url);\n\n runGitClone({\n url: cloneUrl,\n dirName: requestedDir,\n branch,\n depth,\n singleBranch,\n cwd,\n silence,\n });\n\n if (mirrorHost) {\n setRemoteOrigin(targetDir, normalizedHttps, cwd);\n }\n}\n\nexport default cloneGithubRepo;\n","import pc from 'picocolors';\nimport { defaultConfigStore } from '../../config/mirror-store';\nimport { cloneGithubRepo } from '../../core/clone-repo';\nimport { getRepoDirName, parseGithubUrl, replaceMirrorHost } from '../../core/github-url';\n\nexport interface CloneCommandOptions {\n branch?: string;\n depth?: number;\n singleBranch?: boolean;\n /** commander 由 --no-mirror 写入 false;未传时为 true 或 undefined */\n mirror?: boolean;\n verbose?: boolean;\n}\n\nfunction normalizeDirName(dir: string | undefined): string | undefined {\n const trimmed = dir?.trim();\n return trimmed ? trimmed : undefined;\n}\n\nfunction printVerboseClonePlan(\n url: string,\n dirName: string | undefined,\n options: CloneCommandOptions,\n mirrorHost: string | undefined,\n): void {\n const { normalizedHttps } = parseGithubUrl(url);\n const cloneUrl = mirrorHost ? replaceMirrorHost(url, mirrorHost) : normalizedHttps;\n const targetDir = normalizeDirName(dirName) ?? getRepoDirName(url);\n\n console.log(pc.bold('克隆计划'));\n console.log(pc.dim(` 模式 : ${mirrorHost ? `镜像(${mirrorHost})` : '直连 GitHub'}`));\n console.log(pc.dim(` 克隆地址 : ${cloneUrl}`));\n if (mirrorHost) {\n console.log(pc.dim(` 恢复 origin: ${normalizedHttps}`));\n }\n console.log(pc.dim(` 本地目录 : ${targetDir}`));\n\n const gitFlags: string[] = [];\n if (options.branch) {\n gitFlags.push(`--branch ${options.branch}`);\n }\n if (options.depth !== undefined) {\n gitFlags.push(`--depth ${options.depth}`);\n }\n if (options.singleBranch) {\n gitFlags.push('--single-branch');\n }\n if (gitFlags.length > 0) {\n console.log(pc.dim(` Git 参数 : ${gitFlags.join(' ')}`));\n } else {\n console.log(pc.dim(' Git 参数 : (无额外参数,完整克隆)'));\n }\n console.log('');\n}\n\nexport function runCloneCommand(\n url: string,\n dirName: string | undefined,\n options: CloneCommandOptions,\n): void {\n const useMirror = options.mirror !== false;\n const mirrorHost = useMirror ? defaultConfigStore.getMirrorHost() : undefined;\n const requestedDir = normalizeDirName(dirName);\n\n if (options.verbose) {\n printVerboseClonePlan(url, requestedDir, options, mirrorHost);\n } else {\n console.log(pc.dim(mirrorHost ? `→ 使用镜像 ${mirrorHost}` : '→ 直连 github.com'));\n }\n\n try {\n cloneGithubRepo(url, {\n dirName: requestedDir,\n branch: options.branch,\n mirrorHost,\n depth: options.depth,\n singleBranch: options.singleBranch,\n });\n } catch (error) {\n if (mirrorHost) {\n console.error(\n pc.yellow(`提示:镜像 ${mirrorHost} 可能不可用,可执行 g mirror test 验证,或加 --no-mirror 直连`),\n );\n }\n throw error;\n }\n\n const repoDir = requestedDir ?? getRepoDirName(url);\n const branchInfo = options.branch ? `,分支 ${options.branch}` : '';\n console.log(pc.green(`✓ 克隆完成:${repoDir}${branchInfo}`));\n if (mirrorHost && !options.verbose) {\n console.log(pc.dim(` 已恢复 origin 为 GitHub 官方地址`));\n }\n}\n","/** 将 URL 中的 github.com 替换为镜像地址(域名或域名/路径) */\nexport interface MirrorPreset {\n name: string;\n host: string;\n description: string;\n}\n\nexport const MIRROR_PRESETS: readonly MirrorPreset[] = [\n {\n name: 'kgithub',\n host: 'kgithub.com',\n description: 'KGitHub 镜像(域名替换)',\n },\n {\n name: 'moeyy',\n host: 'github.moeyy.xyz',\n description: 'Moeyy 镜像(域名替换)',\n },\n {\n name: 'gitclone',\n host: 'gitclone.com/github.com',\n description: 'GitClone 缓存(路径前缀)',\n },\n] as const;\n\n/** 用于 mirror test 的探测仓库路径(GitHub 官方示例仓库,长期稳定) */\nexport const MIRROR_PROBE_REPO = 'octocat/Hello-World';\n","import pc from 'picocolors';\nimport { defaultConfigStore } from '../../config/mirror-store';\nimport { MIRROR_PRESETS, MIRROR_PROBE_REPO, type MirrorPreset } from '../../constants';\nimport { buildMirrorProbeUrl } from '../../core/github-url';\n\nconst PROBE_TIMEOUT_MS = 10_000;\n\nexport function printMirror(host: string | undefined): void {\n if (host) {\n console.log(`当前镜像:${pc.cyan(host)}`);\n return;\n }\n console.log(pc.yellow('当前未配置镜像,克隆将直连 GitHub'));\n}\n\nexport function runMirrorSet(host: string): void {\n defaultConfigStore.setMirrorHost(host);\n console.log(pc.green(`镜像已设置为 ${host}`));\n console.log(pc.dim('提示:执行 g mirror test 验证镜像是否可用'));\n}\n\nexport function runMirrorUnset(): void {\n defaultConfigStore.unsetMirrorHost();\n console.log(pc.green('已清除镜像配置,克隆将直连 GitHub'));\n}\n\nexport function runMirrorList(): void {\n const current = defaultConfigStore.getMirrorHost();\n const isPresetCurrent = current ? MIRROR_PRESETS.some((p) => p.host === current) : false;\n\n console.log(pc.bold('可用镜像预设:'));\n for (const preset of MIRROR_PRESETS) {\n const marker = current === preset.host ? pc.green(' (当前)') : '';\n console.log(\n ` ${pc.cyan(preset.name.padEnd(8))} ${preset.host} ${pc.dim(`— ${preset.description}`)}${marker}`,\n );\n }\n console.log('');\n if (current && !isPresetCurrent) {\n console.log(`当前配置:${pc.cyan(current)} ${pc.dim('(自定义镜像,非内置预设)')}`);\n } else if (!current) {\n console.log(pc.dim('当前未配置镜像,克隆将直连 GitHub'));\n console.log(pc.dim('提示:使用 g mirror set <address> 或 g mirror set <预设名> 进行配置'));\n }\n}\n\nfunction formatProbeError(error: unknown, mirrorHost: string): string {\n if (error instanceof Error) {\n // AbortSignal.timeout 触发的错误名为 'TimeoutError'\n if (error.name === 'TimeoutError') {\n return `镜像 ${mirrorHost} 探测超时(>${PROBE_TIMEOUT_MS / 1000}s),可能不可用`;\n }\n const cause = (error as Error & { cause?: { code?: string } }).cause;\n const code = cause?.code;\n if (code === 'ENOTFOUND' || code === 'EAI_AGAIN') {\n return `无法解析镜像地址 ${mirrorHost},请检查配置是否正确`;\n }\n if (code === 'ECONNREFUSED' || code === 'ECONNRESET') {\n return `连接 ${mirrorHost} 被拒绝或重置,镜像可能不可用`;\n }\n if (error.message === 'fetch failed') {\n return `无法连接 ${mirrorHost},请检查网络或镜像是否可用`;\n }\n }\n return `镜像 ${mirrorHost} 探测失败:${error instanceof Error ? error.message : String(error)}`;\n}\n\nexport async function runMirrorTest(host?: string): Promise<void> {\n const mirrorHost = host ?? defaultConfigStore.getMirrorHost();\n if (!mirrorHost) {\n throw new Error('未配置镜像,请先执行 g mirror set <address> 或指定测试地址');\n }\n\n const probeUrl = buildMirrorProbeUrl(mirrorHost, MIRROR_PROBE_REPO);\n console.log(pc.dim(`正在探测 ${probeUrl}⋯⋯`));\n\n let response: Response;\n try {\n response = await fetch(probeUrl, {\n method: 'HEAD',\n signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),\n });\n } catch (error) {\n throw new Error(formatProbeError(error, mirrorHost), { cause: error });\n }\n if (!response.ok) {\n throw new Error(`镜像 ${mirrorHost} 返回 HTTP ${response.status},可能不可用`);\n }\n console.log(pc.green(`镜像 ${mirrorHost} 可用`));\n}\n\nexport function resolveMirrorHostInput(input: string): string {\n const preset = MIRROR_PRESETS.find((item: MirrorPreset) => item.name === input || item.host === input);\n return preset?.host ?? input;\n}\n","#!/usr/bin/env node\n\nimport process from 'node:process';\nimport { Command } from 'commander';\nimport pc from 'picocolors';\nimport { ZodError } from 'zod';\nimport { version } from '../../package.json';\nimport { defaultConfigStore } from '../config/mirror-store';\nimport { runCloneCommand, type CloneCommandOptions } from './commands/clone-command';\nimport {\n printMirror,\n resolveMirrorHostInput,\n runMirrorList,\n runMirrorSet,\n runMirrorTest,\n runMirrorUnset,\n} from './commands/mirror-command';\n\nfunction formatCliError(error: unknown): string {\n if (error instanceof ZodError) {\n return error.issues.map((item) => item.message).join(';');\n }\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n}\n\nconst program = new Command();\n\nprogram\n .name('g')\n .description('加速国内 GitHub clone:通过镜像拉取代码,完成后自动将 origin 恢复为 GitHub 官方地址')\n .version(version, '-v, --version', '输出版本号')\n .addHelpText(\n 'after',\n `\n快速开始:\n $ g mirror set kgithub # 配置镜像(首次使用)\n $ g mirror test # 验证镜像可用\n $ g clone https://github.com/owner/repo # 克隆仓库\n`,\n );\n\nprogram\n .command('clone <url> [dir]')\n .description(\n '克隆 GitHub 仓库。若已通过 g mirror set 配置镜像,将经镜像加速下载;' +\n '克隆结束后将 origin 改回 github.com,便于后续 push。',\n )\n .option(\n '-b, --branch <name>',\n '只检出指定分支(传给 git clone --branch)。例如 -b dev 表示克隆 dev 分支的工作区',\n )\n .option(\n '--depth <n>',\n '浅克隆:只拉取最近 n 次提交(传给 git clone --depth)。' +\n '如 --depth 1 表示只要最新版本,体积更小、速度更快,但本地没有完整 Git 历史',\n (value: string) => Number.parseInt(value, 10),\n )\n .option(\n '--single-branch',\n '只克隆单个分支,不下载其他远程分支(传给 git clone --single-branch)。' +\n '常与 -b 联用;单独使用时默认只拉远程默认分支(通常是 main)',\n )\n .option(\n '--no-mirror',\n '忽略 ~/.g.config 中的镜像配置,强制直连 github.com 克隆',\n )\n .option(\n '--verbose',\n '输出克隆前的详细信息:镜像/直连模式、实际克隆地址、分支与 Git 参数等(不改变 Git 本身的输出)',\n )\n .addHelpText(\n 'after',\n `\n示例:\n $ g clone https://github.com/owner/repo\n $ g clone https://github.com/owner/repo my-dir -b dev\n $ g clone https://github.com/owner/repo -b main --single-branch --depth 1\n $ g clone https://github.com/owner/repo --no-mirror --verbose\n`,\n )\n .action(async (url: string, dir: string | undefined, options: CloneCommandOptions) => {\n runCloneCommand(url, dir, options);\n });\n\nconst mirror = program\n .command('mirror')\n .description('管理 GitHub 镜像配置(保存在 ~/.g.config,如 kgithub.com 或 gitclone.com/github.com)');\n\nmirror\n .command('set <address>')\n .description('设置镜像地址,或传入预设名(kgithub / moeyy / gitclone)。执行 g mirror list 查看预设')\n .action(async (address: string) => {\n runMirrorSet(resolveMirrorHostInput(address));\n });\n\nmirror\n .command('get')\n .description('查看 ~/.g.config 中保存的镜像;未配置时克隆将直连 GitHub')\n .action(async () => {\n printMirror(defaultConfigStore.getMirrorHost());\n });\n\nmirror\n .command('list')\n .alias('ls')\n .description('列出内置镜像预设及说明,并标注当前正在使用的镜像')\n .action(async () => {\n runMirrorList();\n });\n\nmirror\n .command('unset')\n .description('删除 ~/.g.config,清除镜像配置(克隆将直连 GitHub)')\n .action(async () => {\n runMirrorUnset();\n });\n\nmirror\n .command('test [address]')\n .description(\n '探测镜像是否可达:对镜像站发起 HTTP HEAD 请求。' +\n '省略 address 时测试当前配置;可传镜像地址或预设名',\n )\n .action(async (address?: string) => {\n await runMirrorTest(address ? resolveMirrorHostInput(address) : undefined);\n });\n\nvoid program.parseAsync(process.argv).catch((error: unknown) => {\n console.error(pc.red(`错误:${formatCliError(error)}`));\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACKA,MAAM,mBAAmBA,IAAAA,EACtB,OAAO,CAAC,CACR,KAAK,CAAC,CACN,IAAI,GAAG,UAAU,CAAC,CAClB,MACC,+FACA,+DACF;AAEF,MAAM,oBAAoBC,UAAAA,QAAK,KAAKC,QAAAA,QAAG,QAAQ,GAAG,WAAW;AAE7D,IAAa,cAAb,MAAyB;CACM;CAA7B,YAAY,aAA8B,mBAAmB;EAAhC,KAAA,aAAA;CAAiC;CAE9D,gBAAoC;EAClC,IAAI,CAACC,QAAAA,QAAG,WAAW,KAAK,UAAU,GAChC;EAGF,OADYA,QAAAA,QAAG,aAAa,KAAK,YAAY,OAAO,CAAC,CAAC,KAC7C,KAAK,KAAA;CAChB;CAEA,cAAc,MAAoB;EAChC,MAAM,SAAS,iBAAiB,MAAM,IAAI;EAC1C,QAAA,QAAG,cAAc,KAAK,YAAY,QAAQ,OAAO;CACnD;CAEA,kBAAwB;EACtB,IAAIA,QAAAA,QAAG,WAAW,KAAK,UAAU,GAC/B,QAAA,QAAG,WAAW,KAAK,UAAU;CAEjC;CAEA,gBAAwB;EACtB,OAAO,KAAK;CACd;AACF;AAEA,MAAa,qBAAqB,IAAI,YAAY;;;AC9BlD,SAAS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,CAAC,CACxB,YAAY,iEAAiE,CAAC,CAC9E,OAAO,OAAO,YAAoB;CACjC,aAAa,uBAAuB,OAAO,CAAC;AAC9C,CAAC;AAEH,OACG,QAAQ,KAAK,CAAC,CACd,YAAY,wCAAwC,CAAC,CACrD,OAAO,YAAY;CAClB,YAAY,mBAAmB,cAAc,CAAC;AAChD,CAAC;AAEH,OACG,QAAQ,MAAM,CAAC,CACf,MAAM,IAAI,CAAC,CACX,YAAY,0BAA0B,CAAC,CACvC,OAAO,YAAY;CAClB,cAAc;AAChB,CAAC;AAEH,OACG,QAAQ,OAAO,CAAC,CAChB,YAAY,qCAAqC,CAAC,CAClD,OAAO,YAAY;CAClB,eAAe;AACjB,CAAC;AAEH,OACG,QAAQ,gBAAgB,CAAC,CACzB,YACC,4DAEF,CAAC,CACA,OAAO,OAAO,YAAqB;CAClC,MAAM,cAAc,UAAU,uBAAuB,OAAO,IAAI,KAAA,CAAS;AAC3E,CAAC;AAEE,QAAQ,WAAWC,aAAAA,QAAQ,IAAI,CAAC,CAAC,OAAO,UAAmB;CAC9D,QAAQ,MAAMC,WAAAA,QAAG,IAAI,MAAM,eAAe,KAAK,GAAG,CAAC;CACnD,aAAA,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,iBAAiB;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,iBAAiB;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
|