mirror of
https://github.com/nexu-io/open-design.git
synced 2026-06-01 03:14:35 +07:00
Fix daemon project-root resolution when launched from src via tsx (#162)
resolveProjectRoot only stripped a 'dist' suffix from the caller's module directory, so when the daemon sidecar is started by tools-dev (which runs apps/daemon/src/server.ts directly through tsx) the computed PROJECT_ROOT pointed at apps/ instead of the repo root. That made SKILLS_DIR, DESIGN_SYSTEMS_DIR, STATIC_DIR and the default RUNTIME_DATA_DIR all resolve to non-existent paths, so /api/skills returned an empty list and the web "examples" page reported "No skills available. Is the daemon running?". Treat 'src' the same as 'dist' so resolution works for both the tsx source entry and the compiled build, and add a regression test for the src case alongside the existing dist/daemon-root cases.
This commit is contained in:
parent
53722bb545
commit
7294929490
2 changed files with 8 additions and 1 deletions
|
|
@ -70,7 +70,8 @@ import {
|
|||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
export function resolveProjectRoot(moduleDir: string): string {
|
||||
const daemonDir = path.basename(moduleDir) === 'dist'
|
||||
const base = path.basename(moduleDir);
|
||||
const daemonDir = base === 'dist' || base === 'src'
|
||||
? path.dirname(moduleDir)
|
||||
: moduleDir;
|
||||
return path.resolve(daemonDir, '../..');
|
||||
|
|
|
|||
|
|
@ -14,4 +14,10 @@ describe('resolveProjectRoot', () => {
|
|||
|
||||
expect(resolveProjectRoot(path.join(root, 'apps', 'daemon', 'dist'))).toBe(root);
|
||||
});
|
||||
|
||||
it('resolves the repository root from the daemon src directory (tsx entry)', () => {
|
||||
const root = path.resolve(import.meta.dirname, '../../..');
|
||||
|
||||
expect(resolveProjectRoot(path.join(root, 'apps', 'daemon', 'src'))).toBe(root);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue