refactor: remove Windows prebuilt native module download step and update package handling in build process
Some checks failed
Release Electron App / release-desktop (push) Failing after 3m40s
Some checks failed
Release Electron App / release-desktop (push) Failing after 3m40s
This commit is contained in:
@@ -37,22 +37,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
WINEDEBUG: '-all'
|
WINEDEBUG: '-all'
|
||||||
|
|
||||||
- name: Download Windows prebuilt native modules
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
ELECTRON_VERSION=$(node -e "console.log(require('electron/package.json').version)")
|
|
||||||
echo "Downloading prebuilt native modules for Electron ${ELECTRON_VERSION} (win32/x64)..."
|
|
||||||
|
|
||||||
# better-sqlite3
|
|
||||||
cd node_modules/better-sqlite3
|
|
||||||
npx --yes prebuild-install -r electron -t ${ELECTRON_VERSION} --platform win32 --arch x64 --verbose
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
# keytar
|
|
||||||
cd node_modules/keytar
|
|
||||||
npx --yes prebuild-install -r electron -t ${ELECTRON_VERSION} --platform win32 --arch x64 --verbose || echo "keytar prebuilt not available, skipping"
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
- name: Make App (Windows)
|
- name: Make App (Windows)
|
||||||
run: npm run make -- --platform=win32 --arch=x64
|
run: npm run make -- --platform=win32 --arch=x64
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -7,15 +7,69 @@ import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-nati
|
|||||||
import { VitePlugin } from '@electron-forge/plugin-vite';
|
import { VitePlugin } from '@electron-forge/plugin-vite';
|
||||||
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
||||||
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
||||||
|
import path from 'node:path';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import { execSync } from 'node:child_process';
|
||||||
|
|
||||||
|
// Packages externalized in vite.main.config.mts that must be installed at runtime.
|
||||||
|
// Keep this list in sync with the Vite external array.
|
||||||
|
const externalPackages = [
|
||||||
|
'better-sqlite3',
|
||||||
|
'keytar',
|
||||||
|
'@github/copilot-sdk',
|
||||||
|
'@langchain/core',
|
||||||
|
'@langchain/langgraph',
|
||||||
|
'@langchain/openai',
|
||||||
|
'@langchain/anthropic',
|
||||||
|
'vectordb',
|
||||||
|
'electron-squirrel-startup',
|
||||||
|
'electron-store',
|
||||||
|
];
|
||||||
|
|
||||||
const config: ForgeConfig = {
|
const config: ForgeConfig = {
|
||||||
packagerConfig: {
|
packagerConfig: {
|
||||||
asar: {
|
asar: {
|
||||||
unpack: '**/node_modules/{better-sqlite3,keytar}/**',
|
unpack: '**/{*.node,*.dll,*.so,*.dylib}',
|
||||||
},
|
},
|
||||||
name: 'adiuva',
|
name: 'adiuva',
|
||||||
},
|
},
|
||||||
rebuildConfig: {},
|
rebuildConfig: {},
|
||||||
|
hooks: {
|
||||||
|
packageAfterCopy: async (_forgeConfig, buildPath) => {
|
||||||
|
// The VitePlugin's ignore filter only copies .vite/ into the build.
|
||||||
|
// Externalized packages need to be installed into node_modules here.
|
||||||
|
// At this point, only .vite/ exists. The VitePlugin writes package.json
|
||||||
|
// in its own afterCopy hook (which may run after ours). Read from source.
|
||||||
|
const srcPjPath = path.resolve(__dirname, 'package.json');
|
||||||
|
const pjPath = path.resolve(buildPath, 'package.json');
|
||||||
|
const pj = JSON.parse(fs.readFileSync(srcPjPath, 'utf-8'));
|
||||||
|
|
||||||
|
// Keep only externalized packages in dependencies
|
||||||
|
const filtered: Record<string, string> = {};
|
||||||
|
for (const pkg of externalPackages) {
|
||||||
|
if (pj.dependencies?.[pkg]) {
|
||||||
|
filtered[pkg] = pj.dependencies[pkg];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pj.dependencies = filtered;
|
||||||
|
delete pj.devDependencies;
|
||||||
|
fs.writeFileSync(pjPath, JSON.stringify(pj, null, 2));
|
||||||
|
|
||||||
|
// Copy lockfile for reproducible installs
|
||||||
|
const lockSrc = path.resolve(buildPath, '..', '..', 'package-lock.json');
|
||||||
|
if (fs.existsSync(lockSrc)) {
|
||||||
|
fs.copyFileSync(lockSrc, path.resolve(buildPath, 'package-lock.json'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Install only the externalized runtime deps
|
||||||
|
console.log('[forge] Installing externalized dependencies...');
|
||||||
|
execSync('npm install --omit=dev', {
|
||||||
|
cwd: buildPath,
|
||||||
|
stdio: 'inherit',
|
||||||
|
env: { ...process.env, npm_config_nodedir: '' },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
makers: [
|
makers: [
|
||||||
new MakerSquirrel({}),
|
new MakerSquirrel({}),
|
||||||
new MakerZIP({}, ['darwin']),
|
new MakerZIP({}, ['darwin']),
|
||||||
|
|||||||
Reference in New Issue
Block a user