Files
zellyy-finance/scripts/build-env.cjs
hansoo 8343b25439 feat: Stage 2 TypeScript 타입 안전성 개선 - any 타입 83개 → 62개 대폭 감소
 주요 개선사항:
- any 타입 83개에서 62개로 21개 수정 (25% 감소)
- 모든 ESLint 에러 11개 → 0개 완전 해결
- 타입 안전성 대폭 향상으로 런타임 오류 가능성 감소

🔧 수정된 파일들:
• PWADebug.tsx - 사용하지 않는 import들에 _ prefix 추가
• categoryUtils.ts - 불필요한 any 캐스트 제거
• TransactionsHeader.tsx - BudgetData 인터페이스 정의
• storageUtils.ts - generic 타입과 unknown 타입 적용
• 각종 error handler들 - Error | {message?: string} 타입 적용
• test 파일들 - 적절한 mock 인터페이스 정의
• 유틸리티 파일들 - any → unknown 또는 적절한 타입으로 교체

🏆 성과:
- 코드 품질 크게 향상 (280 → 80 문제로 71% 감소)
- TypeScript 컴파일러의 타입 체크 효과성 증대
- 개발자 경험 개선 (IDE 자동완성, 타입 추론 등)

🧹 추가 정리:
- ESLint no-console/no-alert 경고 해결
- Prettier 포맷팅 적용으로 코드 스타일 통일

🎯 다음 단계: 남은 62개 any 타입 계속 개선 예정

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-14 10:08:51 +09:00

178 lines
4.5 KiB
JavaScript
Executable File

#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
/**
* 환경별 빌드 설정 스크립트
* 개발/스테이징/프로덕션 환경에 따라 다른 설정을 적용합니다.
*/
const environments = {
development: {
appName: "Zellyy Finance (Dev)",
appId: "com.zellyy.finance.dev",
backgroundColor: "#FEF3C7", // 노란색 톤
scheme: "ZellyyFinanceDev",
},
staging: {
appName: "Zellyy Finance (Beta)",
appId: "com.zellyy.finance.beta",
backgroundColor: "#DBEAFE", // 파란색 톤
scheme: "ZellyyFinanceBeta",
},
production: {
appName: "Zellyy Finance",
appId: "com.zellyy.finance",
backgroundColor: "#F8FAFC", // 기본 색상
scheme: "ZellyyFinance",
},
};
const env = process.argv[2] || "production";
if (!environments[env]) {
console.error(`❌ Invalid environment: ${env}`);
console.log("Available environments:", Object.keys(environments).join(", "));
process.exit(1);
}
const config = environments[env];
console.log(`🔧 Configuring for ${env} environment...`);
// Capacitor 설정 업데이트
const capacitorConfigPath = path.join(__dirname, "..", "capacitor.config.ts");
if (fs.existsSync(capacitorConfigPath)) {
console.log("⚡ Updating Capacitor config...");
let configContent = fs.readFileSync(capacitorConfigPath, "utf8");
// 앱 ID 업데이트
configContent = configContent.replace(
/appId:\s*"[^"]*"/,
`appId: "${config.appId}"`
);
// 앱 이름 업데이트
configContent = configContent.replace(
/appName:\s*"[^"]*"/,
`appName: "${config.appName}"`
);
// 스플래시 배경색 업데이트
configContent = configContent.replace(
/backgroundColor:\s*"[^"]*"/,
`backgroundColor: "${config.backgroundColor}"`
);
// iOS 스킴 업데이트
configContent = configContent.replace(
/scheme:\s*"[^"]*"/,
`scheme: "${config.scheme}"`
);
fs.writeFileSync(capacitorConfigPath, configContent);
console.log(`✅ Capacitor config updated for ${env}`);
}
// Android strings.xml 업데이트 (앱 이름)
const androidStringsPath = path.join(
__dirname,
"..",
"android",
"app",
"src",
"main",
"res",
"values",
"strings.xml"
);
if (fs.existsSync(androidStringsPath)) {
console.log("📱 Updating Android strings.xml...");
let stringsContent = fs.readFileSync(androidStringsPath, "utf8");
stringsContent = stringsContent.replace(
/<string name="app_name">[^<]*<\/string>/,
`<string name="app_name">${config.appName}</string>`
);
fs.writeFileSync(androidStringsPath, stringsContent);
console.log(`✅ Android app name updated: ${config.appName}`);
}
// iOS Info.plist 업데이트 (Bundle Display Name)
const iosInfoPlistPath = path.join(
__dirname,
"..",
"ios",
"App",
"App",
"Info.plist"
);
if (fs.existsSync(iosInfoPlistPath)) {
console.log("🍎 Updating iOS Info.plist...");
try {
const { execSync } = require("child_process");
// CFBundleDisplayName 업데이트
execSync(
`/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName ${config.appName}" "${iosInfoPlistPath}"`,
{
stdio: "pipe",
}
);
console.log(`✅ iOS app name updated: ${config.appName}`);
} catch (error) {
console.log(
"⚠️ Could not update iOS Info.plist (requires macOS), skipping..."
);
}
}
// 환경별 .env 파일 복사
const envFilePath = path.join(__dirname, "..", `.env.${env}`);
const targetEnvPath = path.join(__dirname, "..", ".env.local");
if (fs.existsSync(envFilePath)) {
console.log(`📄 Copying .env.${env} to .env.local...`);
fs.copyFileSync(envFilePath, targetEnvPath);
console.log("✅ Environment variables updated");
} else {
console.log(`⚠️ .env.${env} not found, using existing .env`);
}
console.log("");
console.log("🎉 Environment configuration completed!");
console.log(`📱 App Name: ${config.appName}`);
console.log(`📦 App ID: ${config.appId}`);
console.log(`🎨 Background: ${config.backgroundColor}`);
console.log(`🍎 iOS Scheme: ${config.scheme}`);
console.log("");
console.log("Next steps:");
console.log("1. Run: npm run mobile:sync");
console.log("2. Build: npm run android:build (or ios:build)");
console.log("3. Test on devices");
// 환경 정보를 JSON으로 저장 (CI/CD에서 사용 가능)
const envInfoPath = path.join(__dirname, "..", "build-env.json");
fs.writeFileSync(
envInfoPath,
JSON.stringify(
{
environment: env,
config: config,
timestamp: new Date().toISOString(),
},
null,
2
)
);
console.log(`📋 Environment info saved to build-env.json`);