-
Notifications
You must be signed in to change notification settings - Fork 52
Enhance bezier-figma-plugin by using github action
#1596
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
Enhance bezier-figma-plugin by using github action
#1596
Conversation
🦋 Changeset detectedLatest commit: 4d45640 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #1596 +/- ##
=======================================
Coverage 87.00% 87.00%
=======================================
Files 281 281
Lines 3879 3879
Branches 817 817
=======================================
Hits 3375 3375
Misses 430 430
Partials 74 74 ☔ View full report in Codecov by Sentry. |
| githubToken: string | ||
| progress: ReturnType<typeof useProgress>['progress'] | ||
| }) { | ||
| const githubAPI = useGithubAPI({ |
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.
useGithubAPI가 굳이 hook일 필요는 없을 것 같은데 혹시 이유가 있었는지 궁금합니다 @sungik-choi
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.
그러게요..? 굳이 훅이여야될 이유는 없는 거 같아요. 그 당시 함수형 컴포넌트 안에서 써야지 -> 훅으로 만들자 라는 사고회로를 통해 훅으로 만들었던게 아닐까 싶어요 😅
| restore-keys: | | ||
| ${{ runner.os }}-yarn- | ||
| - name: Install Dependencies |
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.
이 과정에서 거의 대부분의 시간을 할애하고 있었어서 yarn script 대신 node 로 직접 실행하는 걸로 변경합니다.
sungik-choi
left a comment
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.
👍 너무 멋집니다~!
마무리되면 피그마에 배포하고, Bezier 방에도 릴리즈 내용 공유해보시죠!
| githubToken: string | ||
| progress: ReturnType<typeof useProgress>['progress'] | ||
| }) { | ||
| const githubAPI = useGithubAPI({ |
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.
그러게요..? 굳이 훅이여야될 이유는 없는 거 같아요. 그 당시 함수형 컴포넌트 안에서 써야지 -> 훅으로 만들자 라는 사고회로를 통해 훅으로 만들었던게 아닐까 싶어요 😅
| on: | ||
| push: | ||
| branches: | ||
| - icon-update-* |
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.
아하.. 브랜치 이름 + 변경 파일로 필터를 거셨군요 👍 생각 못했네요.
- icon-update 브랜치명이 피그마 플러그인의 newBranchName 과 같아야한다는 주석이 있어도 좋을 거 같습니다.
| - name: Generate Svg files from icons.json | ||
| run: | | ||
| node packages/bezier-icons/scripts/generate-icon-files.js | ||
| git add . | ||
| git commit -m "feat(bezier-icons): generate icon files from icons.json" | ||
| - name: Delete icons.json files | ||
| run: | | ||
| git rm packages/bezier-icons/icons.json | ||
| git commit -m 'feat(bezier-icons): remove icons.json' | ||
| git push |
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.
👍👍👍
매우 마이너: 커밋 메세지의 따옴표를 ' -> " 로 통일하면 좋겠습니다 ㅎㅎ
|
|
||
| const generateSVGFilesFromMap = () => { | ||
| Object.entries(svgByName) | ||
| .sort(([iconName1], [iconName2]) => iconName1.localeCompare(iconName2)) |
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.
정렬 하고 안하고의 차이가 있나요? 궁금합니다
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.
안해도 됩니다! 착각한 것 같습니다
| const generateSVGFilesFromMap = () => { | ||
| Object.entries(svgByName) | ||
| .sort(([iconName1], [iconName2]) => iconName1.localeCompare(iconName2)) | ||
| .map(makeSvgFiles) |
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.
forEach ?
| const createPRWithSvgMap = useCallback(async (svgByName: SvgByName) => { | ||
| const mainBranch = await progress({ | ||
| callback: getMainBranch('main'), | ||
| title: '📦 깃헙에서 아이콘 정보를 읽는 중...', |
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.
마이너: '깃헙에서 정보를 가져오는 중', '깃헙에 접속 중' 같은 문구가 함수가 하는 일에 더 적절해보였어요. 아이콘 정보를 읽지는 않아서..!
이건 확인해봤는데 아이콘이 실제로 디자인 변경이 있어서 그런 거 같아요. 우측변이 우측으로 약~~간 이동했네요. |
2fd34d2 to
0e3ce8f
Compare
…to svg by FigmaAPI
- run icon generate script after push event to "update-icons-*" branch
- conventional commit message - add `feat:icon` label
…ating script in job
- 깃헙에서 아이콘 정보를 읽는 중... -> 깃헙에서 정보를 가져오는 중...
0e3ce8f to
4d45640
Compare
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @channel.io/[email protected] ### Minor Changes - Add Banner to iconName transformation target ([#1562](#1562)) by @yangwooseong ## @channel.io/[email protected] ### Minor Changes - Add script for generating svg file from icons.json ([#1596](#1596)) by @yangwooseong ## @channel.io/[email protected] ### Minor Changes - Allow `iconName` prop of `Button`, `Banner`, `SectionLabel` component to include `BezierIcon` type ([#1562](#1562)) by @yangwooseong ### Patch Changes - Fixed a rendering bug that occurs when using `react-resize-detector` and `asChild`prop of `radix-ui` simultaneously. ([#1577](#1577)) by @yangwooseong - Removed indicator adjusting logic by `react-resize-detector` using css transform property - Replace `@channel.io/react-docgen-typescript-plugin` with Storybook's `reactDocgen` option ([#1594](#1594)) by @Dogdriip ## [email protected] ### Minor Changes - Enhance bezier-figma-plugin running performance ([#1596](#1596)) by @yangwooseong - Remove svg extract process using FigmaAPI and merely send json file that contains svg string - Make icon files based on given json file during Github Action ### Patch Changes - Updated dependencies - @channel.io/[email protected] - @channel.io/[email protected] Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Self Checklist
[Component] I wrote a unit test about the implementation.[Component] I wrote a storybook document about the implementation.[Component] I tested the implementation in various browsers.[New Component] I added my username to the correct directory in theCODEOWNERSfile.Related Issue
bezier-figma-plugin#863Summary
bezier-figma-pluain의 실행 속도와 구조를 개선합니다.Demo
개인 레포지토리 타겟으로 동작 시연 영상
2023-09-05.4.55.03.mov
깃헙 액션 다 돌고난 후
Details
기존의 플러그인 동작방식은, 플러그인 피그마 API 를 통해 선택한 아이콘들을 모두 svg 로 변환하여 이걸 git blob 으로 변환한 후 github REST API 를 통해 pr 을 만드는 과정을 거쳤습니다. 그런데 500개가 넘는 아이콘에 대하여
/git/blobsAPI를 모두 호출해야 해서 시간이 많이 소요되었습니다. (대략 9분정도 소요)이번 pr 로 동작방식이 다음과 같이 변경되었습니다.
Node.exportAsync메서드를 통해 선택한 아이콘들을 svg string으로 변환icons.json)생성icons.json만 변경사항으로 가지는 pr 생성icons.json파일로부터 각 아이콘 이름을 파일 이름으로, svg string 을 파일 내용으로 하여 아이콘 파일을 생성하는 스크립트(generate-icon-files.js) 실행icons.json삭제하는 커밋 생성이 과정이 다 도는데 10초 정도가 걸리게 됩니다. 또한,
icons.json을 보고 추가로 github action 을 트리거할 수 있기 때문에, changeset 생성이나 적절한 description 생성같은 기능도 추후에 덧붙이기 용이한 구조로 변경되었습니다.기존의 플러그인이 생성한 icon 파일과 변경사항이 없기를 원했지만,
devices.svg파일 한개에 대해서는 diff 가 발생하는 것을 막지 못했습니다(#). 아마 figmaAPI를 호출해서 svg 로 변환하는 것과 이번에 사용한Node.exportAsync의 결과물이 완전히 일치하지 않아서 그런 것 같습니다. 겉으로 보이는 것은 완전히 동일해서 diff 가 생겨도 무방하지 않을까 생각합니다만, 새로운 플러그인이 배포되면 한번 조정하는 작업이 필요해 보입니다.Breaking change or not (Yes/No)
No
References