run method
명령어 실행
Implementation
Future<void> run() async {
try {
logger.info('🚀 Flutter 프로젝트 초기화를 시작합니다...\n');
// 1. 프로젝트 이름 입력
final projectName = _getProjectName();
logger.detail('프로젝트 이름: $projectName');
// 2. 패키지 ID 입력
final packageId = _getPackageId();
logger.detail('패키지 ID: $packageId');
// 3. 플랫폼 선택 (멀티셀렉트)
final platforms = _selectPlatforms();
logger.detail('선택된 플랫폼: ${platforms.join(", ")}');
// 4. Flutter 프로젝트 생성
logger.info('\n📦 Flutter 프로젝트를 생성하는 중...');
final projectPath = await FlutterRunner.createProject(
projectName: projectName,
packageId: packageId,
platforms: platforms,
);
if (projectPath == null) {
logger.err('❌ Flutter 프로젝트 생성에 실패했습니다.');
exit(1);
}
logger.success('✅ Flutter 프로젝트가 생성되었습니다: $projectPath');
// 5. sample 폴더 구조로 프로젝트 초기화
logger.info('\n🔧 프로젝트 구조를 초기화하는 중...');
// 실제 sample 폴더 경로 찾기
// 로컬 개발 환경과 전역 설치 환경 모두 지원
final actualSamplePath = _findSamplePath();
if (actualSamplePath == null || !Directory(actualSamplePath).existsSync()) {
logger.err('❌ sample 폴더를 찾을 수 없습니다.');
if (actualSamplePath != null) {
logger.detail('검색한 경로: $actualSamplePath');
}
exit(1);
}
logger.detail('sample 폴더 경로: $actualSamplePath');
await ProjectInitializer.initialize(
targetPath: projectPath,
samplePath: actualSamplePath,
projectName: projectName,
packageId: packageId,
platforms: platforms,
);
logger.success('✅ 프로젝트 초기화가 완료되었습니다!');
logger.info('\n📝 다음 단계:');
logger.info(' cd $projectName');
logger.info(' flutter pub get');
logger.info(' flutter run');
// 명시적으로 종료
exit(0);
} catch (e, stackTrace) {
logger.err('❌ 오류 발생: $e');
logger.detail('스택 트레이스: $stackTrace');
exit(1);
}
}