Skip to content

Commit 2744c55

Browse files
committed
feat(cli): sync 的 github 仓库改为用户自定义
1 parent 5caff70 commit 2744c55

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/cli/src/libs/sync.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import puppeteer from "puppeteer";
1010

1111
// 获取本地用户配置
1212
const localUserConfigs = getAllUserConfigs();
13-
console.log("localUserConfigs", localUserConfigs);
1413

1514
const TEMP_FOLDER_NAME = "sync_temp_workspace";
15+
// GCM 配置目录
16+
const GCM_CONFIG_DIR = path.join(os.homedir(), ".gcm")
1617
// 创建临时工作目录,准备同步配置
17-
const tempDir = path.join(os.homedir(), ".gcm", TEMP_FOLDER_NAME);
18+
const tempDir = path.join(GCM_CONFIG_DIR, TEMP_FOLDER_NAME);
1819
// 如果已存在,则递归清除目录
1920
if (fs.existsSync(tempDir)) {
2021
fs.rmSync(tempDir, { recursive: true });
@@ -24,8 +25,16 @@ fs.mkdirSync(tempDir);
2425
// 下载远程用户配置
2526
const cloneConfigRepo = async () => {
2627
console.log("开始下载远程配置");
27-
// TODO 更换为用户的配置仓库
28-
execSync("git clone git@github.com:lexmin0412/config.git", {
28+
29+
// 获取用户配置仓库
30+
const { configRepoUrl } = await inquirer.prompt([
31+
{
32+
type: "input",
33+
name: "configRepo",
34+
message: "请输入配置仓库地址(建议使用 SSH 地址)",
35+
}
36+
])
37+
execSync(`git clone ${configRepoUrl}`, {
2938
cwd: tempDir,
3039
});
3140
console.log("下载远程配置成功");

0 commit comments

Comments
 (0)