Skip to content

Commit

Permalink
Merge pull request #2 from f-lab-edu/feature/1
Browse files Browse the repository at this point in the history
[#1] 프로젝트 셋업 /  TDD를 위한 deeplyCopy 테스트 코드 작성 / Dual Package 지원
  • Loading branch information
kleekich21 committed Jul 5, 2024
2 parents db2448f + 4195f40 commit 4b6ff28
Show file tree
Hide file tree
Showing 18 changed files with 5,200 additions and 1 deletion.
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

0 comments on commit 4b6ff28

Please sign in to comment.