Skip to content

Commit fe44bc9

Browse files
committed
feat: dev bypass 실행 모드와 env 기반 설정 추가
1 parent 133f4d3 commit fe44bc9

9 files changed

Lines changed: 386 additions & 1 deletion

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ node_modules/
33
**/node_modules/
44

55
# Environment variables
6+
**/.env
7+
**/.env.*
8+
!**/.env*.example
69

710
# Build outputs
811
dist/
@@ -27,3 +30,4 @@ coverage/
2730
# Misc
2831

2932
# ETC
33+
local
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INSTALL_MODE=normal
2+
# INSTALL_MODE=bypass

apps/api/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
"version": "0.0.0",
55
"main": "dist/index.js",
66
"scripts": {
7-
"dev": "tsx watch src/index.ts",
7+
"dev": "NODE_ENV=development pnpm exec tsx watch src/index.ts",
8+
"dev:bypass": "NODE_ENV=development INSTALL_MODE=bypass pnpm exec tsx watch src/index.ts",
89
"build": "tsc",
910
"start": "node dist/index.js",
1011
"test": "vitest run",
1112
"typecheck": "tsc --noEmit"
1213
},
1314
"devDependencies": {
15+
"tsx": "^4.21.0",
1416
"vitest": "^2.1.9"
17+
},
18+
"dependencies": {
19+
"dotenv": "^17.3.1"
1520
}
1621
}

apps/api/src/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
import "dotenv/config";
2+
3+
type InstallMode = "normal" | "bypass";
4+
15
const BOOTSTRAP_MESSAGE = "Fieldstack API bootstrap initialized";
26

7+
function resolveInstallMode(env: NodeJS.ProcessEnv): InstallMode {
8+
const requestedMode = env.INSTALL_MODE;
9+
const isDevelopment = env.NODE_ENV === "development";
10+
11+
if (requestedMode === "bypass") {
12+
if (isDevelopment) {
13+
return "bypass";
14+
}
15+
16+
console.warn("[fieldstack][api] INSTALL_MODE=bypass ignored outside development");
17+
}
18+
19+
return "normal";
20+
}
21+
22+
const installMode = resolveInstallMode(process.env);
23+
324
console.log(BOOTSTRAP_MESSAGE);
25+
console.log(`[fieldstack][api] install mode: ${installMode}`);
26+
27+
if (installMode === "bypass") {
28+
console.warn("[fieldstack][api] DEV INSTALL BYPASS ACTIVE");
29+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VITE_INSTALL_MODE=normal
2+
# VITE_INSTALL_MODE=bypass

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "0.0.0",
55
"scripts": {
66
"dev": "vite",
7+
"dev:bypass": "VITE_INSTALL_MODE=bypass vite",
78
"build": "tsc && vite build",
89
"preview": "vite preview",
910
"test": "vitest run --passWithNoTests",

apps/web/src/main.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
type InstallMode = "normal" | "bypass";
2+
3+
interface WebRuntimeEnv {
4+
MODE?: string;
5+
DEV?: boolean;
6+
VITE_INSTALL_MODE?: string;
7+
}
8+
19
const WEB_BOOTSTRAP_MESSAGE = "Fieldstack Web bootstrap initialized";
210

11+
function resolveInstallMode(runtimeEnv: WebRuntimeEnv): InstallMode {
12+
const requestedMode = runtimeEnv.VITE_INSTALL_MODE;
13+
const isDevelopment = runtimeEnv.DEV === true || runtimeEnv.MODE === "development";
14+
15+
if (requestedMode === "bypass") {
16+
if (isDevelopment) {
17+
return "bypass";
18+
}
19+
20+
console.warn("[fieldstack][web] VITE_INSTALL_MODE=bypass ignored outside development");
21+
}
22+
23+
return "normal";
24+
}
25+
26+
const runtimeEnv = (import.meta as ImportMeta & { env?: WebRuntimeEnv }).env ?? {};
27+
const installMode = resolveInstallMode(runtimeEnv);
28+
329
console.log(WEB_BOOTSTRAP_MESSAGE);
30+
console.log(`[fieldstack][web] install mode: ${installMode}`);
31+
32+
if (installMode === "bypass") {
33+
console.warn("[fieldstack][web] DEV INSTALL BYPASS ACTIVE");
34+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
},
1111
"scripts": {
1212
"dev": "pnpm --parallel dev",
13+
"dev:bypass": "INSTALL_MODE=bypass pnpm --parallel dev",
1314
"dev:api": "pnpm --filter api dev",
15+
"dev:api:bypass": "pnpm --filter api dev:bypass",
1416
"dev:web": "pnpm --filter web dev",
17+
"dev:web:bypass": "pnpm --filter web dev:bypass",
1518
"build": "pnpm build:web && pnpm build:api && pnpm postbuild",
1619
"build:web": "pnpm --filter web build",
1720
"build:api": "pnpm --filter api build",

0 commit comments

Comments
 (0)