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>
20 lines
598 B
TypeScript
20 lines
598 B
TypeScript
// 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;
|
|
}
|
|
}
|