Skip to content

Commit

Permalink
chore(monorepo): setup monorepo
Browse files Browse the repository at this point in the history
* docs: add github issue and pr template

* add `.github/ISSUE_TEMPLATE/feature-request.md`

* add `.github/pull_request_template.md`

Refs: https://github.com/younho9/dotfiles/tree/main/.github

* chore: yarn workspace init

* chore: setup commitlint

* commitlint 설정

* husky 설정

Refs:
- https://github.com/conventional-changelog/commitlint#getting-started
- https://typicode.github.io/husky

* chore: setup prettier

* chore: setup eslint

* chore(`eslint`): modify eslint-plugin-import rules

- `import/no-unresolved` 활성화
- `import/order`
  - 에러 레벨 `warn`으로 낮춤
  - `pathGroupsExcludedImportTypes` 옵션 제거 (해당 옵션 이해하지 못함)
  - PnP mode에서, 외부 모듈이 제대로 정렬되지 않는 이슈 있음
    - `pathGroups`에 외부 모듈을 직접 나열하면 해결 가능

See:
- import-js/eslint-plugin-import#2164

* docs(`.github`): update issue templates

* chore: setup babel build process for modules

* chore: setup babel build process

See:
- https://krasimirtsonev.com/blog/article/transpile-to-esm-with-babel
- https://ui.toast.com/weekly-pick/ko_20180716

* chore: add license

* chore: modify monorepo setup

- Update .gitignore
- Add .gitattributes
- Add dist and tsconfig.json of root to .prettierignore
- Add yarn berry workspace-tool plugin

* feat(`prettier-config`): add prettier config

* feat(`prettier-config`): change to module.exports

* feat(`prettier-config`): modify babel config

* chore: add prettier-config to root dev deps

* chore(`release`): change git commit message

* chore: install prettier config

* chore(`prettier-config`): add build cycle

* chore(`monorepo`): change name and add version & repo

* chore(`lerna`): configure changelog preset
  • Loading branch information
younho9 committed Sep 11, 2021
1 parent 341e1d3 commit 8d18a0c
Show file tree
Hide file tree
Showing 22 changed files with 7,883 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
insert_final_newline = true
end_of_line = lf
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
ignorePatterns: ['**/dist/*'],
parser: '@typescript-eslint/parser',
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
env: {
node: true, // defines things like process.env when generating through node
},
extends: [
'eslint:recommended', // use recommended configs
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
],
plugins: ['prettier'],
rules: {
'import/order': [
'warn',
{
'newlines-between': 'always',
'alphabetize': {
order: 'asc',
caseInsensitive: true,
},
},
],
},
};
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Bug report
about: Create a report to help us improve
title: "\U0001F41B Bug report"
labels: bug
assignees: younho9
---

## Summary

<!-- 이슈 요약 -->

## Reference

<!-- 참고자료 링크 -->

## Related Issues

<!-- 관련 이슈 링크 -->
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Feature request
about: Suggest an idea for this project
title: "\U0001F680 Feature request"
labels: enhancement
assignees: younho9
---

## Summary

<!-- 이슈 요약 -->

## Reference

<!-- 참고자료 링크 -->

## Related Issues

<!-- 관련 이슈 링크 -->
23 changes: 23 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Summary

<!-- PR 요약 -->

## Reference

<!-- 참고자료 링크 -->

## Related Issues

<!--
관련 이슈 링크
PR이 머지될 때, 이슈를 닫는 키워드 (close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved)
- Issue in the same repository: KEYWORD #ISSUE-NUMBER ex) Closes #10
- Issue in a different repository: KEYWORD OWNER/REPOSITORY#ISSUE-NUMBER ex) Fixes octo-org/octo-repo#100
- Multiple issues: ex) Resolves #10, resolves #123, resolves octo-org/octo-repo#100
참고: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

resolve #{issue_number}
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Logs
logs
*.log
yarn-debug.log*
yarn-error.log*

# Dependency directories
node_modules/

# TypeScript cache
*.tsbuildinfo

# Optional eslint cache
.eslintcache

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# babel build output
dist

# yarn v2
/.yarn/*
!/.yarn/patches
!/.yarn/plugins
!/.yarn/releases
!/.yarn/sdks

# Swap the comments on the following lines if you don't wish to use zero-installs
# Documentation here: https://yarnpkg.com/features/zero-installs
!/.yarn/cache
#/.pnp.*
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn git:commit-msg
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn git:pre-commit
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/dist/*
/tsconfig.json
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License Copyright (c) 2021 Younho Choo

Permission is hereby granted, free of
charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice
(including the next paragraph) shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @younho9/lib
25 changes: 25 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const BABEL_ENV = process.env.BABEL_ENV;
const isCJS = BABEL_ENV !== undefined && BABEL_ENV === 'cjs';
const isESM = BABEL_ENV !== undefined && BABEL_ENV === 'esm';

module.exports = function (api) {
api.cache(true);

const presets = [
[
'@babel/env',
{
modules: isCJS ? 'commonjs' : false,
targets: {
esmodules: isESM ? true : undefined,
},
},
],
'@babel/preset-typescript',
'@babel/preset-react',
];

return {
presets,
};
};
78 changes: 78 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"packages": ["packages/*"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"registry": "https://registry.npmjs.org/",
"command": {
"version": {
"conventionalCommits": true,
"exact": true,
"message": "chore(`release`): publish",
"changelogPreset": {
"name": "conventional-changelog-conventionalcommits",
"types": [
{
"type": "feat",
"section": ":rocket: New Features",
"hidden": false
},
{
"type": "fix",
"section": ":bug: Bug Fix",
"hidden": false
},
{
"type": "build",
"section": ":hammer: Build System",
"hidden": false
},
{
"type": "chore",
"section": ":broom: Other",
"hidden": false
},
{
"type": "refactor",
"section": ":recycle: Code Refactoring",
"hidden": false
},
{
"type": "docs",
"section": ":memo: Documentation",
"hidden": false
},
{
"type": "test",
"section": ":test_tube: Test",
"hidden": false
},
{
"type": "style",
"section": ":nail_care: Styling",
"hidden": false
},
{
"type": "perf",
"section": ":racing_car: Performance",
"hidden": false
},
{
"type": "ci",
"section": ":vertical_traffic_light: CI",
"hidden": false
}
],
"issuePrefixes": ["#"],
"issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
"commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
"compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}",
"userUrlFormat": "{{host}}/{{user}}"
}
},
"publish": {
"conventionalCommits": true,
"allowBranch": "main"
}
}
}
64 changes: 64 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "@younho9/lib",
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/younho9/lib.git"
},
"license": "MIT",
"author": "Younho Choo <younho9.choo@gmail.com>",
"workspaces": [
"packages/*"
],
"scripts": {
"build": "lerna run build --no-private --stream",
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts,.tsx -d dist/cjs --source-maps",
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx -d dist/esm --source-maps",
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
"format:code": "prettier --write packages/**/*.{js,jsx,ts,tsx,json,css,md,mdx}",
"format:pack": "sort-package-json",
"git:install-hooks": "husky install",
"git:pre-commit": "lint-staged",
"git:commit-msg": "commitlint --edit",
"lint": "eslint .",
"lint:fix": "yarn lint --fix",
"prepare": "yarn git:install-hooks && yarn build"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,json,css,md,mdx}": [
"prettier --write"
],
"*.{js,jsx,ts,tsx}": [
"eslint --fix"
],
"package.json": [
"sort-package-json"
]
},
"prettier": "./packages/prettier-config/dist/index.js",
"devDependencies": {
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.4",
"@babel/preset-env": "^7.15.4",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@types/node": "^16.7.10",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"concurrently": "^6.2.1",
"cross-env": "^7.0.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-node": "^0.3.4",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^7.0.1",
"lerna": "^4.0.0",
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"sort-package-json": "1.50.0",
"typescript": "^4.3.5"
}
}
Loading

0 comments on commit 8d18a0c

Please sign in to comment.