getPackageName method
패키지명을 추출합니다.
Implementation
@override
String getPackageName(String projectRoot) {
try {
// 프로젝트 루트 디렉토리의 pubspec.yaml 파일 찾기
final File pubspecFile = File(path.join(projectRoot, 'pubspec.yaml'));
if (!pubspecFile.existsSync()) {
print('Warning: pubspec.yaml file not found.');
return 'app'; // 기본값
}
final String content = pubspecFile.readAsStringSync();
final RegExp nameRegex = RegExp(r'name:\s*([^\s]+)');
final Match? match = nameRegex.firstMatch(content);
final String packageName = match != null ? match.group(1)! : 'app';
print('Package name: $packageName');
return packageName;
} catch (e) {
print('Warning: Error occurred while extracting package name: $e');
return 'app'; // 오류 발생 시 기본값
}
}