mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-19 16:47:21 -05:00
bundle standalone node runtime and fix updater prompt race condition
This commit is contained in:
40
release.js
40
release.js
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user