const fs = require('fs'); const path = require('path'); // 获取manifest.json文件路径 const manifestPath = path.resolve(__dirname, 'src/manifest.json'); // 读取manifest.json内容 const manifestContent = fs.readFileSync(manifestPath, 'utf8'); const manifest = JSON.parse(manifestContent); // 获取当前版本号 const currentVersion = manifest.versionName; const versionParts = currentVersion.split('.').map(Number); // 版本号加1,这里简单地对最后一位加1,可根据需求调整逻辑 versionParts[2] = (versionParts[2] || 0) + 1; const newVersion = versionParts.join('.'); // 更新manifest中的版本号 manifest.versionName = newVersion; // 将更新后的内容写回manifest.json fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2)); console.log(`版本号已更新为 ${newVersion}`);