mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-22 08:34:21 +01:00
fix windows native uvx (#1775)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
|
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
|
||||||
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
|
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
|
||||||
|
const { resolve } = require('path');
|
||||||
|
|
||||||
let cfg = {
|
let cfg = {
|
||||||
asar: true,
|
asar: true,
|
||||||
@@ -73,19 +74,14 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
name: '@electron-forge/plugin-vite',
|
name: '@electron-forge/plugin-vite',
|
||||||
config: {
|
config: {
|
||||||
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
|
|
||||||
// If you are familiar with Vite configuration, it will look really familiar.
|
|
||||||
build: [
|
build: [
|
||||||
{
|
{
|
||||||
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
|
|
||||||
entry: 'src/main.ts',
|
entry: 'src/main.ts',
|
||||||
config: 'vite.main.config.ts',
|
config: 'vite.main.config.ts',
|
||||||
target: 'main',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
entry: 'src/preload.ts',
|
entry: 'src/preload.ts',
|
||||||
config: 'vite.preload.config.ts',
|
config: 'vite.preload.config.ts',
|
||||||
target: 'preload',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
renderer: [
|
renderer: [
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"package": "electron-forge package",
|
"package": "electron-forge package",
|
||||||
"make": "electron-forge make",
|
"make": "electron-forge make",
|
||||||
"bundle:default": "npm run make && cd out/Goose-darwin-arm64 && ditto -c -k --sequesterRsrc --keepParent Goose.app Goose.zip",
|
"bundle:default": "npm run make && cd out/Goose-darwin-arm64 && ditto -c -k --sequesterRsrc --keepParent Goose.app Goose.zip",
|
||||||
"bundle:windows": "npm run make -- --platform=win32 --arch=x64 && node scripts/copy-windows-dlls.js",
|
"bundle:windows": "node scripts/build-main.js && npm run make -- --platform=win32 --arch=x64 && node scripts/copy-windows-dlls.js",
|
||||||
"bundle:intel": "npm run make -- --arch=x64 && cd out/Goose-darwin-x64 && ditto -c -k --sequesterRsrc --keepParent Goose.app Goose_intel_mac.zip",
|
"bundle:intel": "npm run make -- --arch=x64 && cd out/Goose-darwin-x64 && ditto -c -k --sequesterRsrc --keepParent Goose.app Goose_intel_mac.zip",
|
||||||
"debug": "echo 'run --remote-debugging-port=8315' && lldb out/Goose-darwin-arm64/Goose.app",
|
"debug": "echo 'run --remote-debugging-port=8315' && lldb out/Goose-darwin-arm64/Goose.app",
|
||||||
"test-e2e": "electron-forge start > /tmp/out.txt & ELECTRON_PID=$! && sleep 12 && if grep -q 'renderer: ChatWindow loaded' /tmp/out.txt; then echo 'process is running'; pkill -f electron; else echo 'not starting correctly'; cat /tmp/out.txt; pkill -f electron; exit 1; fi",
|
"test-e2e": "electron-forge start > /tmp/out.txt & ELECTRON_PID=$! && sleep 12 && if grep -q 'renderer: ChatWindow loaded' /tmp/out.txt; then echo 'process is running'; pkill -f electron; else echo 'not starting correctly'; cat /tmp/out.txt; pkill -f electron; exit 1; fi",
|
||||||
|
|||||||
48
ui/desktop/scripts/build-main.js
Normal file
48
ui/desktop/scripts/build-main.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
const { build } = require('vite');
|
||||||
|
const { resolve } = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
async function buildMain() {
|
||||||
|
try {
|
||||||
|
const outDir = resolve(__dirname, '../.vite/build');
|
||||||
|
|
||||||
|
// Ensure output directory exists
|
||||||
|
if (!fs.existsSync(outDir)) {
|
||||||
|
fs.mkdirSync(outDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
await build({
|
||||||
|
configFile: resolve(__dirname, '../vite.main.config.ts'),
|
||||||
|
build: {
|
||||||
|
outDir,
|
||||||
|
emptyOutDir: false,
|
||||||
|
ssr: true,
|
||||||
|
rollupOptions: {
|
||||||
|
input: resolve(__dirname, '../src/main.ts'),
|
||||||
|
output: {
|
||||||
|
format: 'cjs',
|
||||||
|
entryFileNames: 'main.js'
|
||||||
|
},
|
||||||
|
external: [
|
||||||
|
'electron',
|
||||||
|
'electron-squirrel-startup',
|
||||||
|
'path',
|
||||||
|
'fs',
|
||||||
|
'url',
|
||||||
|
'child_process',
|
||||||
|
'crypto',
|
||||||
|
'os',
|
||||||
|
'util'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Main process build complete');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error building main process:', e);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildMain();
|
||||||
@@ -414,6 +414,11 @@ ipcMain.handle('check-ollama', async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle binary path requests
|
||||||
|
ipcMain.handle('get-binary-path', (event, binaryName) => {
|
||||||
|
return getBinaryPath(app, binaryName);
|
||||||
|
});
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
// Test error feature - only enabled with GOOSE_TEST_ERROR=true
|
// Test error feature - only enabled with GOOSE_TEST_ERROR=true
|
||||||
if (process.env.GOOSE_TEST_ERROR === 'true') {
|
if (process.env.GOOSE_TEST_ERROR === 'true') {
|
||||||
|
|||||||
@@ -8,39 +8,38 @@ export const getBinaryPath = (app: Electron.App, binaryName: string): string =>
|
|||||||
const isPackaged = app.isPackaged;
|
const isPackaged = app.isPackaged;
|
||||||
const isWindows = process.platform === 'win32';
|
const isWindows = process.platform === 'win32';
|
||||||
|
|
||||||
// On Windows, use .cmd for npx and .exe for uvx
|
|
||||||
const executableName = isWindows
|
const executableName = isWindows
|
||||||
? binaryName === 'npx'
|
? binaryName === 'npx'
|
||||||
? 'npx.cmd'
|
? 'npx.cmd'
|
||||||
: `${binaryName}.exe`
|
: `${binaryName}.exe`
|
||||||
: binaryName;
|
: binaryName;
|
||||||
|
|
||||||
// List of possible paths to check
|
|
||||||
const possiblePaths = [];
|
const possiblePaths = [];
|
||||||
|
|
||||||
if (isDev && !isPackaged) {
|
if (isDev && !isPackaged) {
|
||||||
// In development, check multiple possible locations
|
|
||||||
possiblePaths.push(
|
possiblePaths.push(
|
||||||
path.join(process.cwd(), 'src', 'bin', executableName),
|
path.join(process.cwd(), 'src', 'bin', executableName),
|
||||||
path.join(process.cwd(), 'bin', executableName),
|
path.join(process.cwd(), 'bin', executableName),
|
||||||
path.join(process.cwd(), '..', '..', 'target', 'release', executableName)
|
path.join(process.cwd(), '..', '..', 'target', 'release', executableName)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// In production, check resources paths
|
|
||||||
possiblePaths.push(
|
possiblePaths.push(
|
||||||
path.join(process.resourcesPath, 'bin', executableName),
|
path.join(process.resourcesPath, 'bin', executableName),
|
||||||
path.join(app.getAppPath(), 'resources', 'bin', executableName)
|
path.join(app.getAppPath(), 'resources', 'bin', executableName)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isWindows) {
|
||||||
|
possiblePaths.push(
|
||||||
|
path.join(process.resourcesPath, executableName),
|
||||||
|
path.join(app.getAppPath(), 'resources', executableName),
|
||||||
|
path.join(app.getPath('exe'), '..', 'bin', executableName)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log all paths we're checking
|
|
||||||
log.info('Checking binary paths:', possiblePaths);
|
|
||||||
|
|
||||||
// Try each path and return the first one that exists
|
|
||||||
for (const binPath of possiblePaths) {
|
for (const binPath of possiblePaths) {
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(binPath)) {
|
if (fs.existsSync(binPath)) {
|
||||||
log.info(`Found binary at: ${binPath}`);
|
|
||||||
return binPath;
|
return binPath;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -48,8 +47,7 @@ export const getBinaryPath = (app: Electron.App, binaryName: string): string =>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here, we couldn't find the binary
|
throw new Error(
|
||||||
const error = `Could not find ${binaryName} binary in any of the expected locations: ${possiblePaths.join(', ')}`;
|
`Could not find ${binaryName} binary in any of the expected locations: ${possiblePaths.join(', ')}`
|
||||||
log.error(error);
|
);
|
||||||
throw new Error(error);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,17 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
// https://vitejs.dev/config
|
// https://vitejs.dev/config
|
||||||
export default defineConfig({});
|
export default defineConfig({
|
||||||
|
build: {
|
||||||
|
ssr: true,
|
||||||
|
outDir: '.vite/build',
|
||||||
|
rollupOptions: {
|
||||||
|
input: 'src/preload.ts',
|
||||||
|
output: {
|
||||||
|
format: 'cjs',
|
||||||
|
entryFileNames: 'preload.js'
|
||||||
|
},
|
||||||
|
external: ['electron']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user