Skip to content

Commit 389ca67

Browse files
authored
�dotenv -> dotenv-safe로 변경 (#18)
* chore(schema): changeToUpperCaseFirstChar 제거 * chore(client): EMAIL_DOMAIN_NAME env 추가 * chore(server,cli): dotenv -> dotenv-safe로 변경 * chore(server,cli): allowEmptyValues CI 환경에서 true로 제공 * chore: CI env GITHUB_ACTION_CI 추가 * chore: CI 변경 * chore: .env.ci.example 추가 * chore: dotenv example 파일 경로 수정 * chore: .env.ci.example 내용 없애기
1 parent aef1cb0 commit 389ca67

13 files changed

Lines changed: 53 additions & 22 deletions

File tree

.env.ci.example

Whitespace-only changes.

.env.example

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ VITE_BASE_SERVER_URL_DEV=
22
VITE_BASE_SERVER_URL_PROD=
33
VITE_AUTH0_DOMAIN=
44
VITE_AUTH0_CLIENT_ID=
5+
VITE_EMAIL_DOMAIN_NAME=
56

67
BASE_SERVER_URL_DEV=
78
BASE_SERVER_URL_PROD=
@@ -15,5 +16,8 @@ CODEPOCKET_CHANNEL_ID_PROD=
1516
CHAPTER_FRONTED_CHANNEL_ID_DEV=
1617
CHAPTER_FRONTED_CHANNEL_ID_PROD=
1718

18-
MONGO_DB_URI=
19-
MONGO_DB_NAME=
19+
MONGO_DB_URI_DEV=
20+
MONGO_DB_URI_PROD=
21+
22+
MONGO_DB_NAME_DEV=
23+
MONGO_DB_NAME_PROD=

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ jobs:
1212
- uses: actions/checkout@v2
1313
- name: yarn
1414
run: yarn
15+
1516
- name: generate .env
1617
run: |
1718
echo "POCKET_DEV_SERVER=$POCKET_DEV_SERVER" >> .env
1819
env:
1920
POCKET_DEV_SERVER: ${{ secrets.POCKET_DEV_SERVER }}
21+
2022
- name: test all
2123
run: yarn test
24+
2225
- name: if fail
2326
uses: actions/github-script@v6
2427
with:

cli/lib/config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import dotenv from 'dotenv';
1+
import dotenv from 'dotenv-safe';
22
import path from 'path';
33

44
(() => {
5-
const result = dotenv.config({ path: path.join(__dirname, '../..', '.env') });
5+
const result = dotenv.config({
6+
path: path.join(__dirname, '../..', '.env'),
7+
example: path.join(__dirname, '../..', process.env.CI ? '.env.ci.example' : '.env.example'),
8+
allowEmptyValues: !!process.env.CI,
9+
});
610
if (!result.parsed) throw new Error('.env 환경변수 파일 읽기를 실패했어요');
711
})();

cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
"axios": "^0.27.2",
3030
"chalk": "^5.0.1",
3131
"commander": "^9.3.0",
32-
"dotenv": "^16.0.1"
32+
"dotenv-safe": "^8.2.0"
3333
},
3434
"devDependencies": {
3535
"@swc/core": "^1.2.211",
3636
"@swc/jest": "^0.2.21",
37+
"@types/dotenv-safe": "^8",
3738
"@types/jest": "^28.1.4",
3839
"@types/node": "^18.0.3",
3940
"jest": "^28.1.2",

client/src/auth/Auth.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { EMAIL_DOMAIN_NAME } from '@shared/constant';
12
import React, { useEffect } from 'react';
23
import { useLocation, useNavigate } from 'react-router-dom';
34

@@ -17,7 +18,7 @@ const AuthPage: React.FC = () => {
1718
const navigate = useNavigate();
1819
const { verifyUser } = useVerifyUser({ path: location?.path || pocketPath });
1920
const { isAuthenticated, user, logout, loginWithPopup, isValidEmailDomain } = useCustomAuth0({
20-
domain: 'daangn.com',
21+
domain: EMAIL_DOMAIN_NAME,
2122
});
2223
const { createUser } = useCreateUser({
2324
userName: user?.nickname,

client/src/env.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
interface ImportMetaEnv {
22
readonly VITE_BASE_SERVER_URL_DEV: string;
33
readonly VITE_BASE_SERVER_URL_PROD: string;
4+
readonly VITE_AUTH0_DOMAIN: string;
5+
readonly VITE_AUTH0_CLIENT_ID: string;
6+
readonly VITE_EMAIL_DOMAIN_NAME: string;
47
}
58

69
interface ImportMeta {

client/src/shared/constant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ export const BASE_PROD_SERVER_URL = import.meta.env.VITE_BASE_SERVER_URL_PROD;
33

44
export const AUTH0_DOMAIN = import.meta.env.VITE_AUTH0_DOMAIN;
55
export const AUTH0_CLIENT_ID = import.meta.env.VITE_AUTH0_CLIENT_ID;
6+
7+
export const EMAIL_DOMAIN_NAME = import.meta.env.VITE_EMAIL_DOMAIN_NAME;

schema/compile.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
addAsConst,
33
alignFormat,
44
capitalizeFront,
5-
changeToUpperCaseFirstChar,
65
changeTypeName,
76
changeValidatorName,
87
go,
@@ -38,9 +37,7 @@ const generateType = (fileName: string) => {
3837

3938
const generateIndexText = (acc: string, fileName: string) => {
4039
generateType(fileName);
41-
return `${acc}export * from '${TYPE_DIR}/${changeToUpperCaseFirstChar(
42-
removeFileExtension(fileName),
43-
)}';\n`;
40+
return `${acc}export * from '${TYPE_DIR}/${removeFileExtension(fileName)}';\n`;
4441
};
4542

4643
(() => {

schema/utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export const replaceExtension = (fileName: string, extension: string) =>
1414

1515
export const removeBlank = (text: string) => text.replace(/\s/g, '');
1616
export const addAsConst = (text: string) => `${text}as const`;
17-
export const changeToUpperCaseFirstChar = (text: string) =>
18-
text.charAt(0).toUpperCase() + text.slice(1);
1917
export const injectObject = (target: string) => (text: string) => text.replace(/\{\}/, target);
2018
export const changeTypeName = (name: string) => (text: string) => text.replace(typeRegex, name);
2119
export const changeValidatorName = (name: string) => (text: string) =>

0 commit comments

Comments
 (0)