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

[#1] 프로젝트 셋업 / TDD를 위한 deeplyCopy 테스트 코드 작성 / Dual Package 지원 #2

Merged
merged 65 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ea9f003
feat: project setup typescript, jest, babel installed
kleekich21 Jun 19, 2024
1304812
chore: add .gitignore file
kleekich21 Jun 19, 2024
736d691
chore: appy ignore files
kleekich21 Jun 19, 2024
d8ea175
chore: update package.json for script using npm. Now, pnpm is used. m…
kleekich21 Jun 19, 2024
e8e38a4
chore: eslint is installed and config file is added
kleekich21 Jun 19, 2024
21d56f3
chore: add additional configs recommended by typescript-eslint
kleekich21 Jun 19, 2024
4de26c8
chore: fix scirpt for eslint
kleekich21 Jun 19, 2024
e6ea7b9
test: setup jest with ts-jest instead of babel
kleekich21 Jun 19, 2024
9e146c0
feat: make boilerplate file for deeplyCopy
kleekich21 Jun 19, 2024
f649e03
test: add test cases
kleekich21 Jun 19, 2024
7ef9050
chore: cleanup
kleekich21 Jun 19, 2024
36ea769
chore: Update README
kleekich21 Jun 20, 2024
e903d81
chore: add github actions
kleekich21 Jun 20, 2024
105697d
chore: update github actions file to use pnpm
kleekich21 Jun 20, 2024
1acf714
chore: remove on push because first PR fails tests due to TDD
kleekich21 Jun 20, 2024
a49aef7
chore: update target branch for pull_request to "main"
kleekich21 Jun 20, 2024
8488cee
chore: support dual CJS and ESM
kleekich21 Jun 20, 2024
286a806
fix: import error path
kleekich21 Jun 21, 2024
6d6fea8
chore: install prettier
kleekich21 Jun 21, 2024
8bc6b59
chore: add eslint-config-prettier plugin to turn off all rules confli…
kleekich21 Jun 21, 2024
10fa9a0
chore: update script for eslint fix
kleekich21 Jun 21, 2024
5309b6a
refactor: use ESM for exporting babel.config.js
kleekich21 Jun 21, 2024
ce8cf22
style: prettier 룰 적용
kleekich21 Jun 21, 2024
2f56ff4
chore: add build:clean script and update packages
kleekich21 Jun 22, 2024
0de589e
test: remove import jest functions by adding @types/jest
kleekich21 Jun 22, 2024
e7f5606
chore: update lock file
kleekich21 Jun 22, 2024
59f6a0c
chore: switch config module and moduleResolution value for build
kleekich21 Jun 22, 2024
94d663a
test: test script change target path
kleekich21 Jun 22, 2024
4acee48
fix: path updated
kleekich21 Jun 22, 2024
bc52d64
Update run-test-actions.yml
kleekich21 Jun 22, 2024
ce5c519
Update run-test-actions.yml
kleekich21 Jun 22, 2024
0712d1f
fix: import error
kleekich21 Jun 23, 2024
d9930b6
chore: update file structure to support dual package
kleekich21 Jun 23, 2024
5f4442e
chore: update jest config for setting ./src to test
kleekich21 Jun 23, 2024
6721aa9
chore: add prettier plugin to eslint config
kleekich21 Jun 25, 2024
57e3e51
1.0.1-canary.0
kleekich21 Jun 25, 2024
515582b
chore: add build directory for publish
kleekich21 Jun 26, 2024
6c2ac4c
1.0.1-canary.1
kleekich21 Jun 26, 2024
3c5e096
chore: add types directory path
kleekich21 Jun 26, 2024
c2e19af
chore: add .npmignore
kleekich21 Jun 26, 2024
ece442e
1.0.1-canary.3.0
kleekich21 Jun 26, 2024
cfb0aa5
chore: add package.json to .npmignore
kleekich21 Jun 26, 2024
8290f54
1.0.1-canary.4.0
kleekich21 Jun 26, 2024
3f7a41d
chore: add type declaration to esm and cjs build directory
kleekich21 Jul 2, 2024
b65fb92
chore: update import entry points according to updating build directory
kleekich21 Jul 2, 2024
059b43a
chore: add test file to ignore
kleekich21 Jul 2, 2024
6f43cae
chore: update build files
kleekich21 Jul 2, 2024
268bd78
1.0.1-canary.5.0
kleekich21 Jul 2, 2024
194b832
chore: add ./package.json entry point to use to most package.json file
kleekich21 Jul 2, 2024
4661b1e
1.0.1-canary.6.0
kleekich21 Jul 2, 2024
772cf2e
chore: assign different package.json entry point for cjs and esm
kleekich21 Jul 2, 2024
76f861d
1.0.1-canary.7.0
kleekich21 Jul 2, 2024
ec7bb7f
chore: add renameFiles to change extension from .js to .cjs
kleekich21 Jul 2, 2024
6060781
1.0.1-canary.8.0
kleekich21 Jul 2, 2024
c1ae79c
chore: fix extension for cjs
kleekich21 Jul 2, 2024
31c55fa
1.0.1-canary.9.0
kleekich21 Jul 2, 2024
a8e836b
chore: implement renameFiles as typescript, and update script accordi…
kleekich21 Jul 2, 2024
765bc20
chore: update packages
kleekich21 Jul 2, 2024
90f1799
1.0.1-canary.10.0
kleekich21 Jul 2, 2024
1a30259
chore: chore: use ts-node as loader to run renameFiles.ts
kleekich21 Jul 2, 2024
00ed5cb
1.0.1-canary.11.0
kleekich21 Jul 2, 2024
96456c3
chore: add build directory
kleekich21 Jul 2, 2024
79dccb5
chore: apply minor changes
kleekich21 Jul 4, 2024
4099d42
chore: remove build folder
kleekich21 Jul 4, 2024
4195f40
chore: cleanup project
kleekich21 Jul 5, 2024
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
34 changes: 34 additions & 0 deletions .github/workflows/run-test-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Jest Tests on Pull Request

on:
# Triggers the workflow on pull request events but only for the "feature/*" branch
pull_request:
branches: ["main"]
paths-ignore: # Ensure this is also considered to ignore certain paths if needed
- '!feature/1' # Exclude the specific branch

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
if: github.head_ref != 'feature/1' # Condition to exclude the branch
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install

- name: Run Jest tests
run: pnpm test -- --coverage
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Node.js 관련 무시 파일
node_modules/
npm-debug.log

# OS별 무시 파일
.DS_Store
Thumbs.db

# 특정 IDE 및 편집기 관련 무시 파일
.vscode/
.idea/

# 로그 파일
*.log

# 환경 설정 파일
.env

# 빌드관련
build/

# test file
src/foo.*

1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"arrowParens": "always",
"endOfLine": "lf"
}
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# deeply-copy
custom deep copy function to make a brand new immutable object

A custom deep copy function to make a brand new immutable object. It handles copying self reference object or array. It supports dual packages (CJS/ESM)

깊은 복사를 해 불변 객체로 반환한다. 모든 데이터 타입 복사가 가능하고, 객체나 배열의 순환 참조도 핸들링한다. 듀얼 패키지를 지원한다.

# 프로젝트 인스톨 방법

[pnpm 설치](https://pnpm.io/installation) 후 `pnpm install` 실행

# Dual Package (CJS/ESM) 지원

듀얼 패키지 지원을 위한 라이브러리나 모듈러를 별도로 사용하지 않고, TSC와 pacakge.json만을 사용하여 CJS, ESM을 모두 지원하고 있음.
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
};
3 changes: 3 additions & 0 deletions cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
7 changes: 7 additions & 0 deletions cjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "../build/cjs"
}
}
22 changes: 22 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @ts-check
import { includeIgnoreFile } from '@eslint/compat';
import path from 'node:path';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import { fileURLToPath } from 'node:url';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const gitignorePath = path.resolve(__dirname, '.gitignore');

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
eslintConfigPrettier,
includeIgnoreFile(gitignorePath),
eslintPluginPrettierRecommended,
);
3 changes: 3 additions & 0 deletions esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
8 changes: 8 additions & 0 deletions esm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "ES2020",
"moduleResolution": "Node",
"outDir": "../build/esm"
}
}
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: './src',
};
60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "deeply-copy",
"version": "1.0.1-canary.11.0",
"description": "custom deep copy function to make a brand new immutable object",
"type": "module",
"main": "./build/esm/index.js",
"exports": {
".": {
"import": {
"types": "./build/esm/index.d.ts",
"default": "./build/esm/index.js"
},
"require": {
"types": "./build/cjs/index.d.js",
"default": "./build/cjs/index.cjs"
}
}
},
"scripts": {
"test": "jest",
"build": "npm run build:cjs && npm run build:esm && npm run rename",
"build:cjs": "tsc --p ./cjs/tsconfig.json",
"build:esm": "tsc --p ./esm/tsconfig.json",
"build:clean": "rm -rf ./build",
"rename": "node --no-warnings=ExperimentalWarning --loader ts-node/esm renameFiles.ts",
"lint": "pnpm eslint",
"lint:fix": "pnpm eslint . --fix"
},
"repository": {
"type": "git",
"url": "git+https://github.com/f-lab-edu/deeply-copy.git"
},
"keywords": [
"deepCopy",
"deepClone"
],
"author": "Kangsik Kevin Lee",
"license": "ISC",
"bugs": {
"url": "https://github.com/f-lab-edu/deeply-copy/issues"
},
"homepage": "https://github.com/f-lab-edu/deeply-copy#readme",
"devDependencies": {
"@eslint/compat": "^1.1.0",
"@eslint/js": "^9.5.0",
"@jest/globals": "^29.7.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.9",
"eslint": "^9.5.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"prettier": "3.3.2",
"ts-jest": "^29.1.5",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typescript-eslint": "^7.13.1"
}
}
Loading
Loading