Fix Mac Node architecture and resources bundle

This commit is contained in:
2026-09-04 19:30:40 -07:00
parent 5dab61b359
commit 8b29c9e3c7
2 changed files with 46 additions and 24 deletions

View File

@@ -247,8 +247,11 @@ async function main() {
}
function ensureBundledNode() {
const os = require('os');
const binDir = path.join(__dirname, 'bin');
const nodeExePath = path.join(binDir, 'node.exe');
const isWin = os.platform() === 'win32';
const nodeExeName = isWin ? 'node.exe' : 'node';
const nodeExePath = path.join(binDir, nodeExeName);
const nodeVersion = 'v22.14.0';
const versionMarker = path.join(binDir, `node-${nodeVersion}.marker`);
@@ -260,35 +263,53 @@ function ensureBundledNode() {
fs.mkdirSync(binDir, { recursive: true });
console.log(`Downloading standalone Node.js ${nodeVersion} runtime for bundling...`);
const nodeUrl = `https://nodejs.org/dist/${nodeVersion}/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();
fs.writeFileSync(versionMarker, nodeVersion, 'utf8');
resolve();
});
}).on('error', reject);
return;
}
res.pipe(fileStream);
fileStream.on('finish', () => {
fileStream.close();
const download = (url, dest, cb) => {
https.get(url, (res) => {
if (res.statusCode === 302 || res.statusCode === 301) {
return download(res.headers.location, dest, cb);
}
const fileStream = fs.createWriteStream(dest);
res.pipe(fileStream);
fileStream.on('finish', () => {
fileStream.close();
cb();
});
}).on('error', reject);
};
if (isWin) {
const nodeUrl = `https://nodejs.org/dist/${nodeVersion}/win-x64/node.exe`;
download(nodeUrl, nodeExePath, () => {
fs.writeFileSync(versionMarker, nodeVersion, 'utf8');
resolve();
});
}).on('error', (err) => {
try { fs.unlinkSync(nodeExePath); } catch (e) { }
reject(err);
});
} else {
const arch = os.arch() === 'arm64' ? 'arm64' : 'x64';
const platform = os.platform() === 'darwin' ? 'darwin' : 'linux';
const tarName = `node-${nodeVersion}-${platform}-${arch}`;
const nodeUrl = `https://nodejs.org/dist/${nodeVersion}/${tarName}.tar.gz`;
const tarPath = path.join(binDir, 'node.tar.gz');
download(nodeUrl, tarPath, () => {
try {
execSync(`tar -xzf node.tar.gz ${tarName}/bin/node --strip-components=2`, { cwd: binDir });
fs.unlinkSync(tarPath);
execSync(`chmod +x node`, { cwd: binDir });
fs.writeFileSync(versionMarker, nodeVersion, 'utf8');
resolve();
} catch (e) {
reject(e);
}
});
}
});
}
function ensureWebView2Loader() {
const os = require('os');
if (os.platform() !== 'win32') return Promise.resolve();
const releaseDir = path.join(__dirname, 'src-tauri', 'target', 'release');
const rootDllPath = path.join(__dirname, 'src-tauri', 'WebView2Loader.dll');
fs.mkdirSync(releaseDir, { recursive: true });

View File

@@ -29,8 +29,9 @@
},
"resources": [
"WebView2Loader.dll",
"../bin/*",
"../bin/**/*",
"../main.js",
"../preload.js",
"../service-manager.js",
"../patcher.js",
"../crypto-utils.js",
@@ -40,4 +41,4 @@
"../node_modules/**/*"
]
}
}
}