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.
- package/bin/yymaxapi.js +34 -18
- 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
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
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
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
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
|
}
|