feat(install): 新增安装脚本模块化重构

This commit is contained in:
zhang1106
2026-05-09 15:54:43 +08:00
parent d60f5bf808
commit 7f4602d465
15 changed files with 2192 additions and 2492 deletions
+35
View File
@@ -0,0 +1,35 @@
const { execSync } = require('child_process');
const crypto = require('crypto');
function runCommand(command, options = {}) {
try {
const result = execSync(command, {
encoding: 'utf8',
stdio: options.silent ? 'pipe' : 'inherit',
cwd: options.cwd || process.cwd(),
shell: true
});
return { success: true, output: result };
} catch (error) {
return { success: false, error: error.message };
}
}
function commandExists(command) {
try {
execSync(`${command} --version`, { stdio: 'pipe', shell: true });
return true;
} catch {
return false;
}
}
function generateSecretKey(length = 64) {
return crypto.randomBytes(length).toString('hex');
}
module.exports = {
runCommand,
commandExists,
generateSecretKey,
};