94 lines
4.1 KiB
Markdown
94 lines
4.1 KiB
Markdown
# Refactoring History 001 — command_data.dart 도메인 분리
|
|
|
|
## 목표
|
|
AI(Claude 등)가 코드베이스를 더 효율적으로 읽고 수정할 수 있도록
|
|
하나의 거대한 파일에 집중된 데이터 클래스들을 도메인별로 분리한다.
|
|
|
|
## 배경
|
|
`command_data.dart` 파일에 100개 이상의 JSON 직렬화 데이터 클래스가
|
|
단일 파일에 존재했다. `json_serializable`의 `build_runner`가 하나의
|
|
`command_data.g.dart`를 생성하는 구조라 관리 편의상 통합되어 있었으나,
|
|
AI가 단일 커맨드를 수정할 때도 전체 파일을 읽어야 해서 컨텍스트 낭비가 컸다.
|
|
|
|
AI가 코드 관리를 지원하는 환경에서는 파일 파편화 비용이 사라지므로
|
|
도메인 분리 결정을 내렸다.
|
|
|
|
## 변경 내용
|
|
|
|
### 새로 생성된 파일
|
|
|
|
| 파일 | 내용 | 클래스 수 |
|
|
|------|------|-----------|
|
|
| `lib/oto/data/base_data.dart` | DataParam, DataFile (모든 커맨드 데이터의 베이스) | 2 |
|
|
| `lib/oto/data/build_data.dart` | iOS/Flutter/MSBuild/Xcode/Testflight 등 빌드 관련 | 19 |
|
|
| `lib/oto/data/file_data.dart` | Copy/Delete/Rename/Zip/FileRead/FileWrite 등 | 10 |
|
|
| `lib/oto/data/git_data.dart` | Git/GitHub 커맨드 데이터 | 15 |
|
|
| `lib/oto/data/notification_data.dart` | Slack, Mattermost 발송 데이터 | 5 |
|
|
| `lib/oto/data/integration_data.dart` | Jira, Jenkins 연동 데이터 | 3 |
|
|
| `lib/oto/data/network_data.dart` | FTP, Web 요청 데이터 | 3 |
|
|
| `lib/oto/data/infra_data.dart` | Docker, AWS CLI, Gradle, Protobuf | 4 |
|
|
| `lib/oto/data/util_data.dart` | Shell, String, JSON, Process, SMB, Timer 등 | 20 |
|
|
|
|
### 수정된 파일
|
|
|
|
**`lib/oto/data/command_data.dart`**
|
|
- DataParam, DataBuildFlutter 등 모든 도메인 클래스 제거
|
|
- DataBuild, DataScheduler, DataCommand 3개만 유지 (파이프라인 루트 데이터)
|
|
- 도메인 파일 9개를 `export`하는 barrel 파일로 전환
|
|
|
|
### 영향받은 파일
|
|
없음. 기존 48개 파일의 `import 'package:oto_cli/oto/data/command_data.dart'`가
|
|
barrel export를 통해 그대로 동작하므로 import 수정 불필요.
|
|
|
|
### 생성된 .g.dart 파일
|
|
`build_runner build --delete-conflicting-outputs` 실행으로 자동 생성됨:
|
|
- `base_data.g.dart`
|
|
- `build_data.g.dart`
|
|
- `file_data.g.dart`
|
|
- `git_data.g.dart`
|
|
- `notification_data.g.dart`
|
|
- `integration_data.g.dart`
|
|
- `network_data.g.dart`
|
|
- `infra_data.g.dart`
|
|
- `util_data.g.dart`
|
|
|
|
## 결과
|
|
- `dart analyze` 에러 0개 (기존 warning 1개 그대로)
|
|
- `build_runner` 278 outputs 성공
|
|
- AI가 특정 도메인 커맨드 수정 시 읽어야 할 코드량 대폭 감소
|
|
- 예: Flutter 빌드 수정 → `build_data.dart` (~330줄) 만 읽으면 됨
|
|
- 이전: `command_data.dart` (1300+ 줄) 전체를 읽어야 했음
|
|
|
|
## 현재 data/ 디렉토리 구조
|
|
```
|
|
lib/oto/data/
|
|
├── command_data.dart ← barrel (DataBuild, DataScheduler, DataCommand + exports)
|
|
├── command_data.g.dart
|
|
├── base_data.dart ← DataParam, DataFile 베이스 클래스
|
|
├── base_data.g.dart
|
|
├── build_data.dart ← 빌드 관련 (iOS, Flutter, MSBuild 등)
|
|
├── build_data.g.dart
|
|
├── file_data.dart ← 파일 시스템 operations
|
|
├── file_data.g.dart
|
|
├── git_data.dart ← Git, GitHub
|
|
├── git_data.g.dart
|
|
├── notification_data.dart ← Slack, Mattermost
|
|
├── notification_data.g.dart
|
|
├── integration_data.dart ← Jira, Jenkins
|
|
├── integration_data.g.dart
|
|
├── network_data.dart ← FTP, Web
|
|
├── network_data.g.dart
|
|
├── infra_data.dart ← Docker, AWS, Gradle, Protobuf
|
|
├── infra_data.g.dart
|
|
├── util_data.dart ← Shell, String, JSON, Process, Timer 등
|
|
├── util_data.g.dart
|
|
├── pipeline_data.dart ← 기존 파이프라인 구조 데이터 (변경 없음)
|
|
├── pipeline_data.g.dart
|
|
├── jenkins_data.dart ← Jenkins 환경변수 응답 데이터 (변경 없음)
|
|
├── jenkins_data.g.dart
|
|
├── jira_data.dart ← Jira API 응답 데이터 (변경 없음)
|
|
└── jira_data.g.dart
|
|
```
|
|
|
|
## 다음 작업
|
|
`refactoring/to-do.md` 참조
|