fix(companion): resolve fixtures path correctly in Electron runtime
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { app } from 'electron';
|
||||||
|
import * as path from 'path';
|
||||||
import { InMemorySessionRepository } from '@/packages/infrastructure/repositories/InMemorySessionRepository';
|
import { InMemorySessionRepository } from '@/packages/infrastructure/repositories/InMemorySessionRepository';
|
||||||
import { MockBrowserAutomationAdapter } from '@/packages/infrastructure/adapters/automation/MockBrowserAutomationAdapter';
|
import { MockBrowserAutomationAdapter } from '@/packages/infrastructure/adapters/automation/MockBrowserAutomationAdapter';
|
||||||
import { BrowserDevToolsAdapter } from '@/packages/infrastructure/adapters/automation/BrowserDevToolsAdapter';
|
import { BrowserDevToolsAdapter } from '@/packages/infrastructure/adapters/automation/BrowserDevToolsAdapter';
|
||||||
@@ -165,6 +167,24 @@ export class DIContainer {
|
|||||||
return this.permissionService;
|
return this.permissionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve the fixtures path relative to the monorepo root.
|
||||||
|
* In Electron, app.getAppPath() returns the path to the app's main directory
|
||||||
|
* (e.g., apps/companion/dist/main in development, or the asar in production).
|
||||||
|
* We navigate up to find the monorepo root and then join with the resources path.
|
||||||
|
*/
|
||||||
|
private resolveFixturesPath(configuredPath: string): string {
|
||||||
|
if (path.isAbsolute(configuredPath)) {
|
||||||
|
return configuredPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
const appPath = app.getAppPath();
|
||||||
|
const projectRoot = path.resolve(appPath, '../../../');
|
||||||
|
const resolvedPath = path.join(projectRoot, configuredPath);
|
||||||
|
|
||||||
|
return resolvedPath;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize fixture server for development mode.
|
* Initialize fixture server for development mode.
|
||||||
* Starts an embedded HTTP server serving static HTML fixtures.
|
* Starts an embedded HTTP server serving static HTML fixtures.
|
||||||
@@ -185,7 +205,13 @@ export class DIContainer {
|
|||||||
|
|
||||||
this.fixtureServer = new FixtureServerService();
|
this.fixtureServer = new FixtureServerService();
|
||||||
const port = config.fixtureServer.port;
|
const port = config.fixtureServer.port;
|
||||||
const fixturesPath = config.fixtureServer.fixturesPath;
|
const fixturesPath = this.resolveFixturesPath(config.fixtureServer.fixturesPath);
|
||||||
|
|
||||||
|
this.logger.debug('Fixture server path resolution', {
|
||||||
|
configuredPath: config.fixtureServer.fixturesPath,
|
||||||
|
appPath: app.getAppPath(),
|
||||||
|
resolvedPath: fixturesPath
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.fixtureServer.start(port, fixturesPath);
|
await this.fixtureServer.start(port, fixturesPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user