New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asset 관리 Codegen 빌드 스크립트 + 커스텀 린트 작성 #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이전 PR 확인후, 이 PR 확인 부탁드립니다 :)
작성하시느라 너무 수고하셨어요~
try { | ||
final Directory scriptLocationDir = | ||
Directory.fromUri(Platform.script).parent; | ||
final assetsDirectory = Directory('${scriptLocationDir.path}/assets'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scriptLocationDir.path
이것도 static string 으로 뺄 수 있을 것 같네요!
final genDirectory = Directory('${scriptLocationDir.path}/lib/gen'); | ||
final outputFile = File('${genDirectory.path}/asset_paths.dart'); | ||
|
||
// 'gen' 디렉토리가 없는 경우 생성 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주석 감사합니다 :)
} catch (e, s) { | ||
// ignore: avoid_print | ||
print('Error: $e\nStacktrace: $s'); | ||
exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
컴파일단계에서 어차피 한번 qa 를 통해 검증할 테니까.. 유저 앱이 강제종료가 될 경우는 없겠죠? 없을듯!
|
||
// 'gen' 디렉토리가 없는 경우 생성 | ||
if (!genDirectory.existsSync()) { | ||
genDirectory.createSync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 이 부분은 사용을 해보지 않아서, 잘 모르는 함수이지만..
existsSync() 와 createSync(), deleteSync() 등
위 함수들이 비동기처리를 해야하는 함수들은 아니죠?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수 이름처럼 말그대로 sync 라 처리해줄 필요는 없어보이지만
혹시나 여쭤봅니다!
* Custom Lint 의 이름과, Codegen된 asset enum을 사용해야만 하도록 변경하였습니다. * Codegen script 가 재귀적으로 에셋 파일들을 탐색하도록 변경하였습니다.
11dd5b0
to
b61ce0d
Compare
구두 협의 후, 모든 사항에 대한 논의가 끝났으므로 PR 을 병합합니다! |
이전에는 Asset 을 String 리터럴로 관리하였기 떄문에 오타, 파일 이동, 이름 변경등에 취약했습니다.
이제 이를 Codegen 되는 Script 로 관리 하고, Image.asset() 혹슨 SvgImage.asset() 의 생성자 함수 호출시,
바로 String 리터럴를 주입 할 때 lint Warn 을 내 관리 할 수 있도록 커스텀 린트를 같이 작업 하였습니다.