Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

[none] refactoring: 읽기 편하게 구조 개선, 소소한 기능 추가 #7

Merged
merged 7 commits into from Dec 12, 2022

Conversation

rhea-so
Copy link
Contributor

@rhea-so rhea-so commented Dec 2, 2022

작업 내용

구조 개선

  • 폴더 구조를 변경했습니다.
    • 기존: decorators, storages, utils
    • 신규: adapter, decorator, domain, usecase
  • 로직 분리를 했습니다.
    • 기존에는 EnvSafe 데코레이터에 모든 로직들이 하드코딩 식으로 구현되어있었습니다.
  • 테스트 코드들을 src에서 바깥으로 빼냈습니다.
  • 테스트 코드들을 새로 작성했습니다.

소소한 기능 추가

  • nullable option을 추가했습니다.
@EnvSafe()
class Env {
  @EnvKey({ nullable: true })
  static TEST_VALUE: string | null;
}

.env에 없으면 null이 반환됩니다.

  • 한번에 모든 에러를 다 보여주도록 개선했습니다.

image

  • .env 파일이 없는 경우 자동으로 빈 템플릿 파일을 만들어주는 기능을 추가했습니다.
2022-12-02.6.07.25.mov

@github-actions
Copy link

github-actions bot commented Dec 2, 2022

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
92.47% (+4.72% 🔼)
86/93
🟢 Branches
83.33% (+5.56% 🔼)
20/24
🟢 Functions
85% (-7.31% 🔻)
17/20
🟢 Lines
92.94% (+2.24% 🔼)
79/85
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / env-safe.ts
100% 0% 100% 100%
🟢 usecase/load-env.ts 80% 0% 50% 88.89%
🟢 domain/env.ts 97.83% 94.44% 100% 97.62%
🔴 adapter/process.ts 25% 100% 0% 25%
🟢 adapter/dotenv.ts 100% 50% 100% 100%
🟡
... / file-system.ts
75% 100% 50% 75%
🟢
... / key-storage.ts
100% 100% 100% 100%
🟢
... / env-key.ts
100% 100% 100% 100%
🟢
... / set-env-key-declaration.ts
100% 100% 100% 100%

Test suite run success

5 tests passing in 5 suites.

Report generated by 🧪jest coverage report action from 9a9b23a

@rhea-so rhea-so requested a review from fuzes December 5, 2022 02:28
Copy link

@fuzes fuzes left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~

@@ -1,11 +1,11 @@
{
"name": "@creatrip/env-safe",
"version": "0.1.4",
"version": "0.2.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

리팩토링으로 인해 로직이 많이 바뀌었고, 신규 기능도 추가되었기 때문에 0.2.0 으로 마이너 버전을 올렸습니당.

"description": "🔑 Loads environment variables from .env for nodejs projects with safe",
"main": "index.js",
"types": "index.d.js",
"scripts": {
"build": "tsc",
"build": "tsc -p ./tsconfig.build.json",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

빌드용 json 파일을 따로 만들어서 관리를 하는게 좋은 것 같습니당.

예:

  • tsconfig.json → IDE에서 사용, test 코드 포함
  • tsconfig.build.json → 빌드에서만 사용, test 코드 제외

Copy link

@gyuwseong gyuwseong left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~

Copy link

@TimJLee TimJLee left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@saegeullee saegeullee left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~~

@rhea-so rhea-so merged commit 109ccce into latest Dec 12, 2022
@rhea-so rhea-so deleted the refactoring branch December 12, 2022 02:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants