fix(companion): resolve fixtures path correctly in Electron runtime
This commit is contained in:
@@ -18,6 +18,33 @@ import type { IAutomationEngine } from '@/packages/application/ports/IAutomation
|
||||
import type { ILogger } from '@/packages/application/ports/ILogger';
|
||||
import type { IFixtureServerService } from '@/packages/infrastructure/adapters/automation/FixtureServerService';
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Path breakdown from apps/companion/dist/main:
|
||||
* - Level 1: apps/companion/dist (../)
|
||||
* - Level 2: apps/companion (../../)
|
||||
* - Level 3: apps (../../../)
|
||||
* - Level 4: gridpilot (monorepo root) (../../../../)
|
||||
*
|
||||
* @param configuredPath - The path configured (may be relative or absolute)
|
||||
* @param appPath - The app path from electron (app.getAppPath())
|
||||
* @returns Resolved absolute path
|
||||
*/
|
||||
export function resolveFixturesPath(configuredPath: string, appPath: string): string {
|
||||
if (path.isAbsolute(configuredPath)) {
|
||||
return configuredPath;
|
||||
}
|
||||
|
||||
const projectRoot = path.resolve(appPath, '../../../../');
|
||||
const resolvedPath = path.join(projectRoot, configuredPath);
|
||||
|
||||
return resolvedPath;
|
||||
}
|
||||
|
||||
export interface BrowserConnectionResult {
|
||||
success: boolean;
|
||||
error?: string;
|
||||
@@ -169,20 +196,10 @@ export class DIContainer {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Uses the exported resolveFixturesPath function with app.getAppPath().
|
||||
*/
|
||||
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;
|
||||
private resolveFixturesPathInternal(configuredPath: string): string {
|
||||
return resolveFixturesPath(configuredPath, app.getAppPath());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +222,7 @@ export class DIContainer {
|
||||
|
||||
this.fixtureServer = new FixtureServerService();
|
||||
const port = config.fixtureServer.port;
|
||||
const fixturesPath = this.resolveFixturesPath(config.fixtureServer.fixturesPath);
|
||||
const fixturesPath = this.resolveFixturesPathInternal(config.fixtureServer.fixturesPath);
|
||||
|
||||
this.logger.debug('Fixture server path resolution', {
|
||||
configuredPath: config.fixtureServer.fixturesPath,
|
||||
|
||||
Reference in New Issue
Block a user