mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-21 01:25:39 -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;
|
let installerUploadName = null;
|
||||||
|
|
||||||
if (isFullBuild) {
|
if (isFullBuild) {
|
||||||
|
console.log('[Optional] Ensuring bundled Node.js runtime...');
|
||||||
|
await ensureBundledNode();
|
||||||
|
|
||||||
console.log('[Optional] Compiling Windows Tauri installer locally...');
|
console.log('[Optional] Compiling Windows Tauri installer locally...');
|
||||||
execSync('npm run build', { stdio: 'inherit' });
|
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})`);
|
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 => {
|
main().catch(err => {
|
||||||
console.error('Release failed:', err.message);
|
console.error('Release failed:', err.message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ fn clean_path(path: &std::path::Path) -> String {
|
|||||||
fn find_node_binary(app: &tauri::App) -> Option<String> {
|
fn find_node_binary(app: &tauri::App) -> Option<String> {
|
||||||
if let Ok(resource_dir) = app.path().resource_dir() {
|
if let Ok(resource_dir) = app.path().resource_dir() {
|
||||||
let candidates = [
|
let candidates = [
|
||||||
resource_dir.join("node.exe"),
|
|
||||||
resource_dir.join("bin").join("node.exe"),
|
resource_dir.join("bin").join("node.exe"),
|
||||||
|
resource_dir.join("node.exe"),
|
||||||
|
resource_dir.join("_up_").join("bin").join("node.exe"),
|
||||||
resource_dir.join("_up_").join("node.exe"),
|
resource_dir.join("_up_").join("node.exe"),
|
||||||
];
|
];
|
||||||
for candidate in candidates {
|
for candidate in candidates {
|
||||||
@@ -46,19 +47,28 @@ fn find_node_binary(app: &tauri::App) -> Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Ok(exe_path) = std::env::current_exe() {
|
||||||
|
if let Some(parent) = exe_path.parent() {
|
||||||
|
let candidates = [
|
||||||
|
parent.join("bin").join("node.exe"),
|
||||||
|
parent.join("node.exe"),
|
||||||
|
parent.join("resources").join("bin").join("node.exe"),
|
||||||
|
parent.join("resources").join("node.exe"),
|
||||||
|
];
|
||||||
|
for candidate in candidates {
|
||||||
|
if candidate.exists() {
|
||||||
|
return Some(clean_path(&candidate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(path_var) = std::env::var("PATH") {
|
if let Ok(path_var) = std::env::var("PATH") {
|
||||||
for p in std::env::split_paths(&path_var) {
|
for p in std::env::split_paths(&path_var) {
|
||||||
let candidate = p.join("node.exe");
|
let candidate = p.join("node.exe");
|
||||||
if candidate.exists() {
|
if candidate.exists() {
|
||||||
return Some(clean_path(&candidate));
|
return Some(clean_path(&candidate));
|
||||||
}
|
}
|
||||||
#[cfg(not(windows))]
|
|
||||||
{
|
|
||||||
let candidate_unix = p.join("node");
|
|
||||||
if candidate_unix.exists() {
|
|
||||||
return Some(clean_path(&candidate_unix));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,15 +94,6 @@ fn find_node_binary(app: &tauri::App) -> Option<String> {
|
|||||||
return Some(clean_path(&candidate));
|
return Some(clean_path(&candidate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(app_data) = std::env::var("APPDATA") {
|
|
||||||
let candidate = std::path::PathBuf::from(app_data)
|
|
||||||
.join("npm")
|
|
||||||
.join("node.exe");
|
|
||||||
if candidate.exists() {
|
|
||||||
return Some(clean_path(&candidate));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"resources": [
|
"resources": [
|
||||||
|
"../bin/**/*",
|
||||||
"../main.js",
|
"../main.js",
|
||||||
"../service-manager.js",
|
"../service-manager.js",
|
||||||
"../patcher.js",
|
"../patcher.js",
|
||||||
@@ -38,4 +39,4 @@
|
|||||||
"../node_modules/**/*"
|
"../node_modules/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user