feat: Add CI/CD pipeline and code quality improvements

- Add GitHub Actions workflow for automated CI/CD
- Configure Node.js 18.x and 20.x matrix testing
- Add TypeScript type checking step
- Add ESLint code quality checks with enhanced rules
- Add Prettier formatting verification
- Add production build validation
- Upload build artifacts for deployment
- Set up automated testing on push/PR
- Replace console.log with environment-aware logger
- Add pre-commit hooks for code quality
- Exclude archive folder from linting

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hansoo
2025-07-12 15:27:54 +09:00
parent 6a208d6b06
commit 9851627ff1
411 changed files with 14458 additions and 8680 deletions

100
src/utils/logger.ts Normal file
View File

@@ -0,0 +1,100 @@
/**
* 환경별 로깅 시스템
*
* 개발 환경에서는 상세한 로그를 출력하고
* 프로덕션 환경에서는 console.log를 제거하여 성능 최적화
*/
// 환경 변수로 로그 레벨 결정
const isDevelopment = import.meta.env.DEV;
const isProduction = import.meta.env.PROD;
// 로거 인터페이스 정의
interface Logger {
debug: (message: string, meta?: any) => void;
info: (message: string, meta?: any) => void;
warn: (message: string, meta?: any) => void;
error: (message: string, error?: any) => void;
}
// 메시지 포맷터
const formatMessage = (level: string, message: string, meta?: any): string => {
const timestamp = new Date().toISOString();
const metaStr = meta ? ` ${JSON.stringify(meta)}` : "";
return `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;
};
// 환경별 로거 구현
const createLogger = (): Logger => {
if (isDevelopment) {
// 개발 환경: 모든 로그 레벨 출력
return {
debug: (message: string, meta?: any) => {
console.debug(formatMessage("debug", message, meta));
},
info: (message: string, meta?: any) => {
console.info(formatMessage("info", message, meta));
},
warn: (message: string, meta?: any) => {
console.warn(formatMessage("warn", message, meta));
},
error: (message: string, error?: any) => {
console.error(formatMessage("error", message, error));
},
};
} else {
// 프로덕션 환경: 에러만 로깅, 나머지는 무시
return {
debug: () => {}, // 프로덕션에서는 무시
info: () => {}, // 프로덕션에서는 무시
warn: () => {}, // 프로덕션에서는 무시
error: (message: string, error?: any) => {
// 프로덕션에서도 에러는 기록 (향후 Sentry 연동)
console.error(formatMessage("error", message, error));
},
};
}
};
// 전역 로거 인스턴스
export const logger = createLogger();
// 레거시 console.log 대체를 위한 헬퍼 함수들
export const logDebug = (message: string, data?: any) => {
logger.debug(message, data);
};
export const logInfo = (message: string, data?: any) => {
logger.info(message, data);
};
export const logWarning = (message: string, data?: any) => {
logger.warn(message, data);
};
export const logError = (message: string, error?: any) => {
logger.error(message, error);
};
// 특정 도메인별 로거 팩토리
export const createDomainLogger = (domain: string) => {
return {
debug: (message: string, data?: any) =>
logger.debug(`[${domain}] ${message}`, data),
info: (message: string, data?: any) =>
logger.info(`[${domain}] ${message}`, data),
warn: (message: string, data?: any) =>
logger.warn(`[${domain}] ${message}`, data),
error: (message: string, error?: any) =>
logger.error(`[${domain}] ${message}`, error),
};
};
// 도메인별 로거 인스턴스들
export const syncLogger = createDomainLogger("SYNC");
export const authLogger = createDomainLogger("AUTH");
export const networkLogger = createDomainLogger("NETWORK");
export const storageLogger = createDomainLogger("STORAGE");
export const appwriteLogger = createDomainLogger("APPWRITE");
export default logger;