import fs from 'node:fs'; import path from 'node:path'; export interface DashboardAssets { directory: string; indexFile: string; } export type FileExists = (filePath: string) => boolean; export function resolveDashboardAssets( workspaceDirectory: string, fileExists: FileExists = fs.existsSync, ): DashboardAssets { const reactDirectory = path.join(workspaceDirectory, 'apps', 'dashboard', 'dist'); const reactIndexFile = path.join(reactDirectory, 'index.html'); if (fileExists(reactIndexFile)) { return { directory: reactDirectory, indexFile: reactIndexFile, }; } throw new Error( `React dashboard build is missing at ${reactIndexFile}. Run npm run dashboard:build before starting the web server.`, ); }