mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-21 00:21:30 +00:00
feat(build): implement afterPack hook to copy node.exe for Windows builds
This commit is contained in:
parent
76d50ca8e0
commit
4850be0838
3 changed files with 32 additions and 9 deletions
|
|
@ -34,14 +34,12 @@ extraResources:
|
|||
to: gitnexus/package.json
|
||||
asar: false
|
||||
npmRebuild: false
|
||||
afterPack: scripts/after-pack.mjs
|
||||
win:
|
||||
signAndEditExecutable: false
|
||||
icon: build/icon.png
|
||||
target:
|
||||
- nsis
|
||||
extraResources:
|
||||
- from: '${env.GITNEXUS_DESKTOP_NODE_BINARY}'
|
||||
to: runtime/node.exe
|
||||
mac:
|
||||
category: public.app-category.developer-tools
|
||||
icon: build/icon.png
|
||||
|
|
|
|||
21
gitnexus-desktop/scripts/after-pack.mjs
Normal file
21
gitnexus-desktop/scripts/after-pack.mjs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { copyFileSync, mkdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
/**
|
||||
* afterPack hook — runs after electron-builder assembles the app directory,
|
||||
* before any installer (NSIS, DMG, AppImage) is sealed.
|
||||
*
|
||||
* On Windows, lbugjs.node PE-imports "node.exe" by name. Electron's binary
|
||||
* is not named node.exe, so LoadLibrary fails. We copy the real node.exe into
|
||||
* resources/runtime/node.exe so main.ts can use it as the subprocess host.
|
||||
* This fires for both --dir and --win builds, fixing the smoke test and installer.
|
||||
*/
|
||||
export default async function afterPack(context) {
|
||||
if (context.electronPlatformName !== 'win32') return;
|
||||
|
||||
const runtimeDir = path.join(context.appOutDir, 'resources', 'runtime');
|
||||
mkdirSync(runtimeDir, { recursive: true });
|
||||
copyFileSync(process.execPath, path.join(runtimeDir, 'node.exe'));
|
||||
|
||||
console.log(`[after-pack] Copied node.exe → ${path.join(runtimeDir, 'node.exe')}`);
|
||||
}
|
||||
|
|
@ -155,12 +155,6 @@ const builderEnvironment = {
|
|||
GITNEXUS_DESKTOP_GITNEXUS_SKILLS: toBuilderRelativePath(path.join(gitnexusRoot, 'skills')),
|
||||
GITNEXUS_DESKTOP_GITNEXUS_VENDOR: toBuilderRelativePath(path.join(gitnexusRoot, 'vendor')),
|
||||
GITNEXUS_DESKTOP_WEB_DIST: toBuilderRelativePath(path.join(gitnexusWebRoot, 'dist')),
|
||||
// On Windows, lbugjs.node PE-imports node.exe by name, which fails under Electron's binary.
|
||||
// electron-builder copies this into resources/runtime/node.exe so it lands in both
|
||||
// win-unpacked (smoke test) and the NSIS installer (end-user install).
|
||||
// The extraResources entry in electron-builder.yml is platform: [win] so this value is
|
||||
// ignored on macOS/Linux (empty string prevents electron-builder from touching it there).
|
||||
GITNEXUS_DESKTOP_NODE_BINARY: process.platform === 'win32' ? process.execPath : '',
|
||||
};
|
||||
|
||||
const builderCliArgs = [
|
||||
|
|
@ -436,6 +430,16 @@ runCommand(process.execPath, ['scripts/ensure-gitnexus-runtime.mjs'], packageRoo
|
|||
|
||||
runCommand(npmCommand, ['run', 'bundle'], packageRoot);
|
||||
|
||||
const gitnexusSharedRoot = path.join(workspaceRoot, 'gitnexus-shared');
|
||||
if (!fs.existsSync(path.join(gitnexusSharedRoot, 'dist'))) {
|
||||
if (!fs.existsSync(path.join(gitnexusSharedRoot, 'node_modules'))) {
|
||||
runCommand(npmCommand, ['ci'], gitnexusSharedRoot);
|
||||
}
|
||||
runCommand(npmCommand, ['run', 'build'], gitnexusSharedRoot);
|
||||
}
|
||||
if (!fs.existsSync(path.join(gitnexusWebRoot, 'node_modules'))) {
|
||||
runCommand(npmCommand, ['ci'], gitnexusWebRoot);
|
||||
}
|
||||
runCommand(npmCommand, ['run', 'build'], gitnexusWebRoot);
|
||||
|
||||
runCommand(process.execPath, builderCliArgs, packageRoot, builderEnvironment);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue