fix: separate client and server utilities to fix build error

Split lib/utils.ts into:
- lib/utils.ts: Client-safe utilities only (no Node.js imports)
- lib/project-utils.ts: Server-only utilities with Node.js imports

This fixes the Next.js build error where client components were importing
modules that contained Node.js dependencies (fs, path).

All tests pass and build succeeds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 21:43:38 +08:00
parent 08f9015101
commit edc4cb770f
6 changed files with 66 additions and 63 deletions

19
lib/project-utils.ts Normal file
View File

@@ -0,0 +1,19 @@
// lib/project-utils.ts
// Server-only utility functions
import * as fs from 'fs';
import * as path from 'path';
/**
* 获取项目显示名称(从别名配置)
*/
export function getProjectDisplayName(projectName: string): string {
try {
const aliasesPath = path.join(process.cwd(), 'lib', 'project-aliases.json');
const aliasesContent = fs.readFileSync(aliasesPath, 'utf-8');
const aliases = JSON.parse(aliasesContent);
return aliases[projectName] || projectName;
} catch {
// If file doesn't exist or is invalid, return original name
return projectName;
}
}