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

[공통] ts-monorepo-template 를 최신화합니다. #10

Merged
merged 15 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@naverpay/eslint-config/front"
"extends": "@naverpay/eslint-config/typescript",
}
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Enable corepack
run: corepack enable
- uses: pnpm/action-setup@v3
with:
version: 8
run_install: true
- run: pnpm run prettier
- run: pnpm run lint
Expand All @@ -21,8 +22,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Enable corepack
run: corepack enable
- uses: pnpm/action-setup@v3
with:
version: 8
run_install: true
- run: pnpm run test
47 changes: 47 additions & 0 deletions .github/workflows/detect-changed-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: detect changed packages

on:
pull_request:
branches: ['**']
types: [opened, reopened, labeled, unlabeled, synchronize]

concurrency:
group: detect-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
detect:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.ACTION_TOKEN }}
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'

- name: Enable corepack
run: corepack enable

- name: setup pnpm and install dependencies
uses: pnpm/action-setup@v3
with:
run_install: true

- name: install dependencies
run: pnpm install --frozen-lockfile

- name: 'detect changed packages'
uses: NaverPayDev/changeset-actions/detect-add@main
with:
github_token: ${{ secrets.ACTION_TOKEN }}
packages_dir: packages,share
skip_label: skip-detect-change
skip_branches: main
formatting_script: pnpm run markdownlint:fix
34 changes: 22 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,35 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.ACTION_TOKEN }}
fetch-depth: 0

- name: Setup Node.js 20.x
uses: actions/setup-node@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: '22.x'

- name: Enable corepack
run: corepack enable

- name: Install dependencies
- name: setup pnpm and install dependencies
uses: pnpm/action-setup@v3
with:
version: 8
run_install: true

- name: Create Release Pull Request or Publish to npm
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
uses: NaverPayDev/changeset-actions/publish@main
with:
title: '🚀 version changed packages'
commit: '📦 bump changed packages version'
publish: pnpm release
github_token: ${{ secrets.ACTION_TOKEN }}
npm_token: ${{ secrets.NPM_TOKEN }}
git_username: npayfebot
git_email: npay.fe.bot@navercorp.com
publish_script: pnpm release
pr_title: '🚀 version changed packages'
commit_message: '📦 bump changed packages version'
create_github_release_tag: true
formatting_script: pnpm run markdownlint:fix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/size-limit.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

3 changes: 3 additions & 0 deletions .lefthook/commit-msg/commit-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COMMIT_MSG_FILE=$1

npx --yes @naverpay/commit-helper@latest $1
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.github
.changeset
.husky
.husky
.lefthook
18 changes: 0 additions & 18 deletions .size-limit.js

This file was deleted.

119 changes: 118 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,118 @@
## ts-monorepo-template
# ts-monorepo-template

**@NaverPayDev/frontend**에서 제공하는 **TypeScript Monorepo Template**입니다. 이 템플릿은 Turbo, ESLint, Prettier, TypeScript와 같은 도구를 사용하여 Monorepo 프로젝트를 효율적으로 관리할 수 있도록 설계되었습니다.

---

## 주요 특징

- **TypeScript**: 최신 JavaScript 개발을 위한 핵심 언어 지원.
- **Monorepo 관리**: [Turbo](https://turbo.build/)를 활용한 빠르고 효율적인 작업 실행.
- **Linting**: [ESLint](https://eslint.org/)로 코드 품질 관리.
- **코드 포맷팅**: [Prettier](https://prettier.io/)로 일관된 코드 스타일 유지.
- **Markdown Linting**: 문서의 표준을 준수하도록 설정.
- **릴리스 관리**: [Changesets](https://github.com/changesets/changesets)로 간단한 버전 관리 및 배포.
- **자동화**: [Lefthook](https://github.com/evilmartians/lefthook)과 lint-staged를 활용한 Git 훅 사전 설정.
- **템플릿 활용성**: 개발 및 CI/CD 워크플로를 위한 사전 구성 스크립트 제공.

---

## 사전 요구 사항

- **Node.js**: 버전 `22.11.0`
- **pnpm**: 버전 `9.12.3` (기본 패키지 매니저로 설정)

환경 확인:

```bash
node -v
pnpm -v
```

---

## 설치 방법

1. **레포지토리 클론** 혹은 **use this template**:

```bash
git clone https://github.com/NaverPayDev/ts-monorepo-template.git
cd ts-monorepo-template
```

2. **의존성 설치**:

```bash
pnpm install
```

---

## 스크립트

다양한 작업을 위한 사전 정의된 스크립트가 포함되어 있습니다:

| 스크립트 | 설명 |
|-------------------------|----------------------------------------------------------------------|
| `pnpm start` | 모든 패키지에서 시작 스크립트를 실행. |
| `pnpm build` | Monorepo의 모든 패키지를 빌드. |
| `pnpm test` | 모든 패키지에서 테스트 실행. |
| `pnpm lint` | ESLint로 코드 린트. |
| `pnpm lint:fix` | 린트 문제를 자동으로 수정. |
| `pnpm prettier` | Prettier로 포맷 확인. |
| `pnpm prettier:fix` | Prettier로 코드 포맷 자동 수정. |
| `pnpm markdownlint` | Markdown 파일 린트 실행. |
| `pnpm markdownlint:fix` | Markdown 린트 문제 자동 수정. |
| `pnpm clean` | 작업 공간 초기화 및 의존성 재설치. |
| `pnpm release:canary` | Canary 릴리스 빌드 및 배포 (Git 태그 없음). |
| `pnpm release` | 안정 릴리스 빌드 및 배포. |

---

## 린트 및 포맷팅

**ESLint**와 **Prettier**가 린트와 코드 포맷팅을 위해 설정되어 있습니다. 커스텀 설정은 다음과 같습니다:

- **ESLint Config**: `@naverpay/eslint-config`
- **Prettier Config**: `@naverpay/prettier-config`

Git 커밋 전 `lint-staged`를 통해 자동으로 린트 및 포맷팅이 적용됩니다.

---

## Markdown 린트

Markdown 파일의 일관성을 유지하기 위해 `@naverpay/markdown-lint`를 사용합니다.

수동 실행:

```bash
pnpm markdownlint
pnpm markdownlint:fix
```

---

## Changeset 및 릴리스 관리

버전 관리 및 배포는 [Changesets](https://github.com/changesets/changesets)를 사용합니다.

---

## Contribution Guide

1. 레포지토리를 포크하고 새 브랜치를 생성합니다.
2. 모든 린트 및 테스트를 통과하도록 코드를 수정합니다.
3. 풀 리퀘스트를 제출합니다.

개선점이나 문제점이 있다면 레포지토리에 Issue를 열어주세요.

---

## 라이선스

이 템플릿은 네이버 파이낸셜 유저플랫폼 산하 공통개발TF (@NaverPayDev/frontend)에 의해 관리되며, 해당 라이선스 정책을 따릅니다.

---

`ts-monorepo-template`로 생산적인 Monorepo 개발 환경을 경험해보세요! 🎉
12 changes: 12 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pre-commit:
parallel: true
commands:
lint:
skip:
- ref: main
- ref: develop
run: npx lint-staged
commit-msg:
scripts:
"commit-helper.sh":
runner: bash
36 changes: 23 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"name": "ts-monorepo-template",
"author": "@NaverPayDev/frontend",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/NaverPayDev/ts-monorepo-template.git"
},
"description": "ts-monorepo-template",
"version": "0.0.0",
"keywords": [
"naver",
"naver-financial",
"monorepo",
"monorepo-template",
"template",
"typescript"
],
"scripts": {
"start": "turbo run start",
"build": "turbo run build",
Expand All @@ -26,17 +34,19 @@
"**/*.{ts,tsx,js,jsx}": "eslint"
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@naverpay/eslint-config": "^0.2.0",
"@naverpay/markdown-lint": "^0.0.2",
"@naverpay/prettier-config": "^0.0.2",
"@size-limit/preset-big-lib": "^11.0.2",
"glob": "^9.3.4",
"husky": "^8.0.3",
"lint-staged": "^15.0.1",
"size-limit": "^11.0.2",
"turbo": "^1.10.16",
"typescript": "^5.2.2"
"eslint": "^8.57.0",
"@changesets/cli": "^2.27.9",
"@naverpay/eslint-config": "^1.0.7",
"@naverpay/markdown-lint": "^0.0.3",
"@naverpay/prettier-config": "^1.0.0",
"lefthook": "^1.8.2",
"lint-staged": "^15.2.10",
"turbo": "^2.2.3",
"typescript": "^5.6.3"
},
"packageManager": "pnpm@8.14.3"
"packageManager": "pnpm@9.12.3",
"engines": {
"node": "22.11.0",
"pnpm": "9.12.3"
}
}
Loading
Loading