Skip to content
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

협업용 husky 설정 및 package.json app alias 설정 #281

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Orchemi
Copy link
Member

@Orchemi Orchemi commented Feb 13, 2025

💡 기능

  • web / admin 까지 터미널을 이동하지 않고, root terminal에서 app별 command를 지원하도록 alias를 설정했습니다.
  • husky 및 lint-staged 의존성 설치, pre-commit git hook을 설정했습니다.

🔎 기타

  • turbo.json의 경우, 크게 변경사항이 없었음에도 저장 시에 formatting이 되어 전체가 reformat되었습니다.
  • 기타 format on save에 의해 변경되는 형식이 로컬과 프로젝트 설정 간 충돌이 있는 것 같아 해결방안을 찾고 있습니다.

Summary by CodeRabbit

  • 새로운 기능

    • 사전 커밋 시 자동 타입 체크와 코드 린팅 기능이 추가되었습니다. 이로 인해 서비스의 코드 품질이 강화되어 전반적인 안정성과 신뢰성이 향상되었습니다.
  • 작업 개선

    • 개발 워크플로우를 간소화하기 위해 스크립트와 설정이 업데이트되었습니다. 이를 통해 내부 유지보수와 업데이트 작업이 보다 효율적으로 진행됩니다.

Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

이번 변경 사항은 pre-commit 훅을 강화하여 커밋 전 타입 검사와 린트 작업을 자동으로 수행하도록 합니다. 이를 위해 .husky/pre-commit에 두 개의 새로운 명령어가 추가되었으며, 관련 스크립트와 의존성이 apps/web/package.json과 루트 package.json에 추가되었습니다. 또한, turbo.json 파일의 구조가 재포맷되고, tasks 섹션에 type-check와 lint-staged 작업이 추가되었습니다.

Changes

파일 변경 사항
.husky/pre-commit 새 pre-commit 명령어 추가: pnpm dlx turbo type-checkpnpm dlx turbo lint-staged
apps/web/package.json, package.json - apps/web: lint-staged (eslint 'src/**/*.{js,jsx,ts,tsx}' --fix) 및 type-check (tsc --noEmit) 스크립트 추가, JSON 구문(쉼표) 수정
- 루트: web, admin, prepare 스크립트 추가 및 Husky, lint-staged 의존성과 lint-staged 설정 추가
turbo.json JSON 구조 재포맷 및 tasks 섹션에 새 작업 추가: type-check (dependsOn: ["^type-check"])와 lint-staged (dependsOn: ["^lint-staged"])

Sequence Diagram(s)

sequenceDiagram
  participant Dev as 개발자
  participant Husky as pre-commit 훅
  participant Turbo as Turbo CLI
  participant TS as 타입 체커 (tsc)
  participant Lint as 린트 도구 (ESLint)

  Dev->>Husky: 커밋 실행
  Husky->>Turbo: "pnpm dlx turbo type-check" 실행
  Turbo->>TS: 타입 체크 수행
  TS-->>Turbo: 결과 반환
  Husky->>Turbo: "pnpm dlx turbo lint-staged" 실행
  Turbo->>Lint: staged 파일 린트 실행
  Lint-->>Turbo: 결과 반환
  Husky-->>Dev: 커밋 완료
Loading

Suggested reviewers

  • sumi-0011
  • hyesungoh

Poem

나는 작은 토끼, 코드의 숲 속에서
당근처럼 새로워진 pre-commit이 반짝이네 🥕
타입와 린트가 춤추며 빛을 더하면
package.json 들에 희망의 스크립트가 피어나고
turbo.json에도 새로운 꿈을 심었지
소중한 변경들에 모두 행복이 깃들길!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

coderabbitai bot commented Feb 13, 2025

워크스루

이번 변경 사항은 커밋 전에 실행되는 체크 프로세스에 새로운 명령어들을 추가하는 작업을 포함합니다. .husky/pre-commit 스크립트에 타입 검사와 린트 처리를 위한 명령어가 추가되었으며, 관련 스크립트와 설정을 포함하도록 apps/web/package.json, 루트 package.json, 그리고 turbo.json 파일이 수정되었습니다. 이로써 코드의 품질 검증 프로세스가 강화되었습니다.

변경 내용

파일 변경 요약
.husky/pre-commit 커밋 전 훅에 pnpm dlx turbo type-checkpnpm dlx turbo lint-staged 명령어 추가
apps/web/package.json, package.json ESLint와 TypeScript 검사를 위한 스크립트 추가 (lint-staged, type-check, web, admin, prepare); 쉼표 추가 등 문법 수정; devDependency 및 lint-staged 설정 추가
turbo.json 배열 포맷 변경 및 type-check, lint-staged 작업 추가 (각 작업은 해당 명령어에 의존)

시퀀스 다이어그램

sequenceDiagram
    participant 개발자 as 개발자
    participant Git as Git
    participant Husky as .husky/pre-commit
    participant TypeCheck as 타입 검사
    participant LintStaged as 린트 스테이징

    개발자->>Git: 커밋 시도
    Git->>Husky: pre-commit 훅 실행
    Husky->>TypeCheck: pnpm dlx turbo type-check 실행
    TypeCheck-->>Husky: 타입 검사 결과 반환
    Husky->>LintStaged: pnpm dlx turbo lint-staged 실행
    LintStaged-->>Husky: 린트 결과 반환
    Husky-->>Git: 훅 완료, 커밋 진행
    Git-->>개발자: 커밋 성공 또는 오류 피드백
Loading

제안 리뷰어

  • sumi-0011
  • hyesungoh

깡총깡총 토끼가 말하네,
코드 속에 새로운 빛이 비치네.
타입검사와 린트의 춤사위,
커밋 전의 깔끔한 기적!
당근처럼 달콤한 코드 향연,
모두를 위해 축하해요 🥕🐇!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/web/package.json (1)

13-16: 스크립트 중복을 개선할 수 있습니다.

다음과 같은 개선 사항을 고려해주세요:

  1. lint-staged 스크립트가 lint:fix와 거의 동일한 기능을 수행합니다. 중복을 피하기 위해 하나로 통합하는 것이 좋습니다.
  2. 루트의 lint-staged 설정과 web 패키지의 lint-staged 스크립트가 서로 다른 동작을 수행할 수 있습니다. 일관성 있는 처리를 위해 설정을 통일하는 것이 좋습니다.

다음과 같이 수정을 제안드립니다:

-    "lint-staged": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
+    "lint:staged": "lint:fix",
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc0d33 and 8755960.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .husky/pre-commit (1 hunks)
  • apps/web/package.json (2 hunks)
  • package.json (2 hunks)
  • turbo.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • turbo.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Install Dependencies
🔇 Additional comments (2)
.husky/pre-commit (1)

1-2: pre-commit 훅 설정이 적절합니다.

타입 체크와 린트 검사가 커밋 전에 실행되도록 잘 구성되어 있습니다.

단, 다음 사항을 확인해 주시면 좋겠습니다:

  • type-check가 lint-staged 이전에 실행되는 것이 의도된 순서인지 확인
  • 각 명령어가 실패할 경우 커밋이 중단되는지 테스트
package.json (1)

12-14: 앱별 명령어 별칭이 잘 설정되었습니다.

web과 admin 패키지에 대한 명령어 별칭이 편리하게 구성되어 있습니다.

Comment on lines +23 to +28
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [
"eslint --cache --fix",
"prettier --cache --write"
]
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

lint-staged 설정을 검토해주세요.

현재 lint-staged 패턴이 src/**/*.{js,jsx,ts,tsx}로 설정되어 있는데, 이는 루트 디렉토리의 src 폴더만을 대상으로 합니다. 모노레포 구조에서는 각 앱의 src 폴더를 포함하도록 패턴을 수정하는 것이 좋습니다.

다음과 같이 수정을 제안드립니다:

   "lint-staged": {
-    "src/**/*.{js,jsx,ts,tsx}": [
+    "{apps,packages}/**/src/**/*.{js,jsx,ts,tsx}": [
       "eslint --cache --fix",
       "prettier --cache --write"
     ]
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [
"eslint --cache --fix",
"prettier --cache --write"
]
},
"lint-staged": {
"{apps,packages}/**/src/**/*.{js,jsx,ts,tsx}": [
"eslint --cache --fix",
"prettier --cache --write"
]
},

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc0d33 and 8755960.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .husky/pre-commit (1 hunks)
  • apps/web/package.json (2 hunks)
  • package.json (2 hunks)
  • turbo.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Install Dependencies
🔇 Additional comments (5)
.husky/pre-commit (1)

1-2: 훌륭한 pre-commit 훅 설정입니다!

타입 체크와 린트 검사를 커밋 전에 실행하도록 설정하여 코드 품질을 보장하는 좋은 접근 방식입니다.

turbo.json (1)

23-28: 새로운 태스크가 올바르게 구성되었습니다.

type-check와 lint-staged 태스크가 각각의 의존성과 함께 적절하게 설정되었습니다.

package.json (2)

12-14: 편리한 앱별 명령어 단축키가 추가되었습니다.

web과 admin 패키지에 대한 단축 명령어가 추가되어 개발 생산성이 향상될 것으로 보입니다.


23-28: lint-staged 설정이 적절합니다.

ESLint와 Prettier를 캐시와 함께 사용하도록 설정되어 있어 효율적인 코드 품질 관리가 가능해 보입니다.

apps/web/package.json (1)

15-16: 타입 체크 스크립트가 적절히 추가되었습니다.

TypeScript 타입 체크를 위한 스크립트가 올바르게 구성되었습니다.

"NODE_ENV",
"SLACK_ERROR_CHANNEL_WEBHOOK_URL"
]
"env": ["NODE_ENV", "SLACK_ERROR_CHANNEL_WEBHOOK_URL"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

환경 변수 보안 검토가 필요합니다.

SLACK_ERROR_CHANNEL_WEBHOOK_URL과 같은 민감한 환경 변수가 dev 태스크에 노출되어 있습니다. 이러한 URL은 보안상 위험할 수 있습니다.

Comment on lines 12 to +13
"lint:fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
"lint-staged": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

중복된 린트 스크립트를 정리해주세요.

lint:fixlint-staged 스크립트가 동일한 명령을 수행하고 있습니다. 중복을 제거하고 하나의 스크립트만 유지하는 것이 좋겠습니다.

다음과 같이 수정하는 것을 제안합니다:

-    "lint:fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
-    "lint-staged": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
+    "lint:fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"lint:fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
"lint-staged": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
"lint:fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix"

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.husky/pre-commit (1)

1-2: 타입 체크와 린트 작업을 병렬로 실행하는 것을 고려해보세요.

현재 타입 체크와 린트 작업이 순차적으로 실행되고 있습니다. 이를 병렬로 실행하면 커밋 속도를 개선할 수 있습니다.

다음과 같이 수정을 제안드립니다:

-pnpm dlx turbo type-check
-pnpm dlx turbo lint-staged
+pnpm dlx turbo type-check lint-staged --parallel
apps/web/package.json (1)

12-13: 중복된 린트 스크립트를 정리해주세요.

lint:fixlint-staged 스크립트가 동일한 기능을 수행하고 있습니다. 유지보수를 위해 하나로 통일하는 것이 좋습니다.

다음과 같이 수정을 제안드립니다:

-  "lint:fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
-  "lint-staged": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
+  "lint:fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix"

그리고 lint-staged 설정에서 이 스크립트를 재사용할 수 있습니다:

{
  "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx}": "pnpm lint:fix"
  }
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc0d33 and 8755960.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .husky/pre-commit (1 hunks)
  • apps/web/package.json (2 hunks)
  • package.json (2 hunks)
  • turbo.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • turbo.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build application
🔇 Additional comments (3)
package.json (2)

23-28: lint-staged 설정을 검토해주세요.

현재 lint-staged 패턴이 src/**/*.{js,jsx,ts,tsx}로 설정되어 있는데, 이는 루트 디렉토리의 src 폴더만을 대상으로 합니다. 모노레포 구조에서는 각 앱의 src 폴더를 포함하도록 패턴을 수정하는 것이 좋습니다.


12-13: workspace 명령어 추가에 대해 LGTM!

workspace 명령어를 통해 각 앱 디렉토리로 이동하지 않고도 명령을 실행할 수 있어 편리해졌습니다.

apps/web/package.json (1)

16-16: 타입 체크 스크립트 추가에 대해 LGTM!

타입 체크 스크립트가 추가되어 타입 안정성을 보장하는데 도움이 될 것 같습니다.

Copy link
Member

@sumi-0011 sumi-0011 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코멘트 확인 부탁드립니다~

Comment on lines +12 to +13
"web": "pnpm -F @gitanimals/web",
"admin": "pnpm -F @gitanimals/admin",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분은 이미 dev:web dev:admin 커멘드로 가능한 상태입니다!
저는 같은 역할을 한다면 turbo로 실행하는 기존 커멘드가 더 적합할 것 같다고 생각해요 👀 어떻게 생각하시나요?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말씀하신 dev:web, dev:admin의 경우 dev script에 대해서만 적용이 가능합니다.
저의 경우 type-check, lint fix 등의 커맨드는 항상 /apps/web/ 내부로 터미널을 옮겨서 사용하는 게 불편한 방법이지 않나 생각했습니다.

추가로 turbo 커맨드를 사용하게 되면 모든 app이 같은 스크립트를 타는 것으로 알고 있는데 그렇다면 alias를 지정한 기능과는 다른 의도 아닌가 싶은데 제가 잘 이해한 게 맞을까요?

Comment on lines -3 to +4
"globalEnv": [
"NODE_ENV"
],
"globalDependencies": [
".env",
".env.*"
],
"globalEnv": ["NODE_ENV"],
"globalDependencies": [".env", ".env.*"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분은 혹시 eslint 설정이 다르게 되어있던 부분은 아닌지 확인 가능할까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsx 파일의 코드 레벨에서는 프로젝트 eslint 설정과 맞추는 데에 성공했는데 json은 잘 안 되더라고요🥲
line break 정도의 변경이어서 당장은 크리티컬하지 않다고 판단했고, 계속 방법 찾아보겠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants