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