bundle standalone node runtime and fix updater prompt race condition

This commit is contained in:
2026-08-22 14:36:16 -07:00
parent c801bb7668
commit af7f236c7e
3 changed files with 60 additions and 18 deletions

View File

@@ -153,6 +153,9 @@ async function main() {
let installerUploadName = null;
if (isFullBuild) {
console.log('[Optional] Ensuring bundled Node.js runtime...');
await ensureBundledNode();
console.log('[Optional] Compiling Windows Tauri installer locally...');
execSync('npm run build', { stdio: 'inherit' });
@@ -190,6 +193,43 @@ async function main() {
console.log(`[4/4] Release successfully created: ${release.name} (${release.tag_name})`);
}
function ensureBundledNode() {
const binDir = path.join(__dirname, 'bin');
const nodeExePath = path.join(binDir, 'node.exe');
if (fs.existsSync(nodeExePath) && fs.statSync(nodeExePath).size > 10000000) {
return Promise.resolve();
}
fs.mkdirSync(binDir, { recursive: true });
console.log('Downloading standalone Node.js runtime for bundling...');
const nodeUrl = 'https://nodejs.org/dist/v20.18.0/win-x64/node.exe';
return new Promise((resolve, reject) => {
const fileStream = fs.createWriteStream(nodeExePath);
https.get(nodeUrl, (res) => {
if (res.statusCode === 302 || res.statusCode === 301) {
https.get(res.headers.location, (redirectRes) => {
redirectRes.pipe(fileStream);
fileStream.on('finish', () => {
fileStream.close();
resolve();
});
}).on('error', reject);
return;
}
res.pipe(fileStream);
fileStream.on('finish', () => {
fileStream.close();
resolve();
});
}).on('error', (err) => {
try { fs.unlinkSync(nodeExePath); } catch (e) { }
reject(err);
});
});
}
main().catch(err => {
console.error('Release failed:', err.message);
process.exit(1);