yymaxapi 1.0.18 → 1.0.19

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.
Files changed (2) hide show
  1. package/bin/yymaxapi.js +34 -18
  2. package/package.json +1 -1
package/bin/yymaxapi.js CHANGED
@@ -3040,28 +3040,44 @@ async function autoInstallGitWindows() {
3040
3040
  }
3041
3041
  }
3042
3042
 
3043
- // 方式2: 下载 Git 安装包(动态获取最新版本号)
3043
+ // 方式2: 下载 Git 安装包(优先国内镜像,fallback GitHub)
3044
3044
  const spinner = ora({ text: '正在获取 Git 最新版本...', spinner: 'dots' }).start();
3045
3045
  const installerPath = path.join(os.tmpdir(), 'git-installer.exe');
3046
- let downloadUrl;
3047
- try {
3048
- const tagJson = execSync('powershell -Command "(Invoke-RestMethod https://api.github.com/repos/git-for-windows/git/releases/latest).tag_name"', { stdio: 'pipe', timeout: 30000 }).toString().trim();
3049
- // tag 格式: v2.48.1.windows.1 → 需要转成 Git-2.48.1-64-bit.exe
3050
- const ver = tagJson.replace(/^v/, '').replace(/\.windows\.\d+$/, '');
3051
- downloadUrl = `https://github.com/git-for-windows/git/releases/latest/download/Git-${ver}-64-bit.exe`;
3052
- spinner.text = `正在下载 Git ${ver}...`;
3053
- } catch (e) {
3054
- // fallback: 用固定版本
3055
- downloadUrl = 'https://github.com/git-for-windows/git/releases/download/v2.48.1.windows.1/Git-2.48.1-64-bit.exe';
3056
- spinner.text = '正在下载 Git 安装包...';
3046
+ const GIT_VER = '2.48.1';
3047
+ const fileName = `Git-${GIT_VER}-64-bit.exe`;
3048
+ const mirrors = [
3049
+ `https://registry.npmmirror.com/-/binary/git-for-windows/v${GIT_VER}.windows.1/${fileName}`,
3050
+ `https://github.com/git-for-windows/git/releases/download/v${GIT_VER}.windows.1/${fileName}`,
3051
+ ];
3052
+ let downloadUrl = mirrors[0];
3053
+ spinner.text = `正在下载 Git ${GIT_VER}(国内镜像)...`;
3054
+
3055
+ let downloaded = false;
3056
+ for (let i = 0; i < mirrors.length; i++) {
3057
+ downloadUrl = mirrors[i];
3058
+ if (i > 0) spinner.text = `正在下载 Git ${GIT_VER}(GitHub)...`;
3059
+ try {
3060
+ execSync(`powershell -Command "Invoke-WebRequest -Uri '${downloadUrl}' -OutFile '${installerPath}'"`, {
3061
+ stdio: 'pipe', timeout: 300000
3062
+ });
3063
+ downloaded = true;
3064
+ break;
3065
+ } catch (e) {
3066
+ if (i < mirrors.length - 1) {
3067
+ spinner.text = '国内镜像下载失败,切换 GitHub...';
3068
+ }
3069
+ }
3057
3070
  }
3058
3071
 
3059
- try {
3060
- execSync(`powershell -Command "Invoke-WebRequest -Uri '${downloadUrl}' -OutFile '${installerPath}'"`, {
3061
- stdio: 'pipe', timeout: 300000
3062
- });
3063
- spinner.succeed('Git 安装包下载完成');
3072
+ if (!downloaded) {
3073
+ spinner.fail('Git 下载失败(所有镜像均不可达)');
3074
+ console.log(chalk.cyan(' 请手动安装: https://git-scm.com/download/win'));
3075
+ return false;
3076
+ }
3064
3077
 
3078
+ spinner.succeed('Git 安装包下载完成');
3079
+
3080
+ try {
3065
3081
  const installSpinner = ora({ text: '正在静默安装 Git...', spinner: 'dots' }).start();
3066
3082
  execSync(`"${installerPath}" /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS="icons,ext\\reg\\shellhere,assoc,assoc_sh"`, {
3067
3083
  stdio: 'pipe', timeout: 300000
@@ -3070,7 +3086,7 @@ async function autoInstallGitWindows() {
3070
3086
  console.log(chalk.yellow(' 请关闭当前终端,重新打开后再运行此工具'));
3071
3087
  return false;
3072
3088
  } catch (e) {
3073
- spinner.fail('Git 下载/安装失败');
3089
+ spinner.fail('Git 安装失败');
3074
3090
  console.log(chalk.cyan(' 请手动安装: https://git-scm.com/download/win'));
3075
3091
  return false;
3076
3092
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yymaxapi",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "bin/yymaxapi.js",
6
6
  "bin": {