yymaxapi 1.0.6 → 1.0.7
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 +68 -4
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -2798,6 +2798,57 @@ async function viewConfig(paths) {
|
|
|
2798
2798
|
console.log(` ${fs.existsSync(backupPath) ? chalk.green('✓ 已备份') : chalk.gray('未备份')}`);
|
|
2799
2799
|
}
|
|
2800
2800
|
|
|
2801
|
+
// ============ Windows 自动安装 Git ============
|
|
2802
|
+
async function autoInstallGitWindows() {
|
|
2803
|
+
// 方式1: 尝试 winget(Windows 10/11 自带)
|
|
2804
|
+
const wingetCheck = safeExec('winget --version');
|
|
2805
|
+
if (wingetCheck.ok) {
|
|
2806
|
+
const spinner = ora({ text: '正在通过 winget 安装 Git...', spinner: 'dots' }).start();
|
|
2807
|
+
try {
|
|
2808
|
+
execSync('winget install --id Git.Git -e --source winget --accept-package-agreements --accept-source-agreements', {
|
|
2809
|
+
stdio: 'pipe', timeout: 300000
|
|
2810
|
+
});
|
|
2811
|
+
spinner.succeed('Git 安装完成 (winget)');
|
|
2812
|
+
// 刷新 PATH
|
|
2813
|
+
const gitPath = safeExec('where.exe git');
|
|
2814
|
+
if (gitPath.ok) {
|
|
2815
|
+
console.log(chalk.green(` ${gitPath.output.split('\n')[0].trim()}`));
|
|
2816
|
+
return true;
|
|
2817
|
+
}
|
|
2818
|
+
// winget 安装后可能需要重启终端才能找到 git
|
|
2819
|
+
console.log(chalk.yellow(' Git 已安装,但需要重新打开终端使 PATH 生效'));
|
|
2820
|
+
console.log(chalk.gray(' 请关闭当前终端,重新打开后再运行此工具'));
|
|
2821
|
+
return false;
|
|
2822
|
+
} catch (e) {
|
|
2823
|
+
spinner.fail('winget 安装 Git 失败,尝试下载安装包...');
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
// 方式2: 下载 Git 安装包
|
|
2828
|
+
const spinner = ora({ text: '正在下载 Git 安装包...', spinner: 'dots' }).start();
|
|
2829
|
+
const installerPath = path.join(os.tmpdir(), 'git-installer.exe');
|
|
2830
|
+
const downloadUrl = 'https://github.com/git-for-windows/git/releases/latest/download/Git-2.47.1.2-64-bit.exe';
|
|
2831
|
+
|
|
2832
|
+
try {
|
|
2833
|
+
execSync(`powershell -Command "Invoke-WebRequest -Uri '${downloadUrl}' -OutFile '${installerPath}'"`, {
|
|
2834
|
+
stdio: 'pipe', timeout: 300000
|
|
2835
|
+
});
|
|
2836
|
+
spinner.succeed('Git 安装包下载完成');
|
|
2837
|
+
|
|
2838
|
+
const installSpinner = ora({ text: '正在静默安装 Git...', spinner: 'dots' }).start();
|
|
2839
|
+
execSync(`"${installerPath}" /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS="icons,ext\\reg\\shellhere,assoc,assoc_sh"`, {
|
|
2840
|
+
stdio: 'pipe', timeout: 300000
|
|
2841
|
+
});
|
|
2842
|
+
installSpinner.succeed('Git 安装完成');
|
|
2843
|
+
console.log(chalk.yellow(' 请关闭当前终端,重新打开后再运行此工具'));
|
|
2844
|
+
return false;
|
|
2845
|
+
} catch (e) {
|
|
2846
|
+
spinner.fail('Git 下载/安装失败');
|
|
2847
|
+
console.log(chalk.cyan(' 请手动安装: https://git-scm.com/download/win'));
|
|
2848
|
+
return false;
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2801
2852
|
// ============ 安装/更新 OpenClaw ============
|
|
2802
2853
|
async function installOrUpdateOpenClaw() {
|
|
2803
2854
|
// 检测当前版本
|
|
@@ -2856,14 +2907,27 @@ async function installOrUpdateOpenClaw() {
|
|
|
2856
2907
|
// 检测 git(openclaw 的依赖需要 git)
|
|
2857
2908
|
const gitCheck = safeExec('git --version');
|
|
2858
2909
|
if (!gitCheck.ok) {
|
|
2859
|
-
console.log(chalk.
|
|
2910
|
+
console.log(chalk.yellow('\n⚠ 未检测到 Git,OpenClaw 安装需要 Git'));
|
|
2911
|
+
|
|
2860
2912
|
if (process.platform === 'win32') {
|
|
2861
|
-
|
|
2862
|
-
|
|
2913
|
+
const { autoInstallGit } = await inquirer.prompt([{
|
|
2914
|
+
type: 'confirm',
|
|
2915
|
+
name: 'autoInstallGit',
|
|
2916
|
+
message: '是否自动安装 Git?',
|
|
2917
|
+
default: true
|
|
2918
|
+
}]);
|
|
2919
|
+
|
|
2920
|
+
if (autoInstallGit) {
|
|
2921
|
+
const gitInstalled = await autoInstallGitWindows();
|
|
2922
|
+
if (!gitInstalled) return;
|
|
2923
|
+
} else {
|
|
2924
|
+
console.log(chalk.cyan(' 请手动安装 Git: https://git-scm.com/download/win'));
|
|
2925
|
+
return;
|
|
2926
|
+
}
|
|
2863
2927
|
} else {
|
|
2864
2928
|
console.log(chalk.gray(' 请先安装 Git: sudo apt install git / brew install git'));
|
|
2929
|
+
return;
|
|
2865
2930
|
}
|
|
2866
|
-
return;
|
|
2867
2931
|
}
|
|
2868
2932
|
|
|
2869
2933
|
const spinner = ora({ text: `正在${actionLabel} OpenClaw...`, spinner: 'dots' }).start();
|