Skip to content

Commit 18b0182

Browse files
author
seunghyun.lee
committed
feat: windows 환경에서 local server setting script 및 명령어 추가
1 parent b6676a0 commit 18b0182

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"scripts": {
55
"dev": "turbo dev",
66
"setup": "scripts/local-server-setup.sh",
7+
"setup:windows": "powershell -File scripts/local-server-setup.ps1",
78
"dev:client": "turbo dev --filter client",
89
"dev:admin": "turbo dev --filter admin",
910
"dev:native": "pnpm --filter @dpm-core/native start",

scripts/local-server-setup.ps1

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# PowerShell 스크립트 - 로컬 개발 환경 SSL 설정
2+
# 관리자 권한으로 실행 필요
3+
4+
# 로컬 호스트명 설정
5+
$CLIENT_HOST = "local-core.depromeet.shop"
6+
$ADMIN_HOST = "local-admin.depromeet.shop"
7+
# Windows hosts 파일 경로
8+
$HOSTS_FILE = "$env:SystemRoot\System32\drivers\etc\hosts"
9+
10+
###############################################################################
11+
12+
Write-Host "🔧 로컬 개발 환경 SSL 설정을 진행합니다. (클라이언트: $CLIENT_HOST, 어드민: $ADMIN_HOST)" -ForegroundColor Cyan
13+
14+
###############################################################################
15+
16+
# 관리자 권한 확인 및 자동 상승
17+
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
18+
if (-not $isAdmin) {
19+
Write-Host "🔐 관리자 권한이 필요합니다. UAC 프롬프트를 확인해주세요..." -ForegroundColor Yellow
20+
21+
# 관리자 권한으로 재시작
22+
$scriptPath = $MyInvocation.MyCommand.Path
23+
Start-Process powershell.exe -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"" -Wait
24+
exit 0
25+
}
26+
27+
###############################################################################
28+
29+
# mkcert가 설치되어 있는지 확인
30+
$mkcertInstalled = $null -ne (Get-Command mkcert -ErrorAction SilentlyContinue)
31+
32+
if (-not $mkcertInstalled) {
33+
Write-Host "📦 mkcert가 설치되어 있지 않습니다. 설치를 진행합니다..." -ForegroundColor Yellow
34+
35+
# Chocolatey 확인
36+
$chocoInstalled = $null -ne (Get-Command choco -ErrorAction SilentlyContinue)
37+
# Scoop 확인
38+
$scoopInstalled = $null -ne (Get-Command scoop -ErrorAction SilentlyContinue)
39+
40+
if ($chocoInstalled) {
41+
Write-Host "📦 Chocolatey를 사용하여 mkcert를 설치합니다..." -ForegroundColor Cyan
42+
choco install mkcert -y
43+
}
44+
elseif ($scoopInstalled) {
45+
Write-Host "📦 Scoop을 사용하여 mkcert를 설치합니다..." -ForegroundColor Cyan
46+
scoop install mkcert
47+
}
48+
else {
49+
Write-Host "❌ 패키지 매니저가 설치되어 있지 않습니다." -ForegroundColor Red
50+
Write-Host "💡 다음 중 하나를 설치해주세요:" -ForegroundColor Yellow
51+
Write-Host " - Chocolatey: https://chocolatey.org/install" -ForegroundColor Yellow
52+
Write-Host " - Scoop: https://scoop.sh" -ForegroundColor Yellow
53+
Write-Host "" -ForegroundColor Yellow
54+
Write-Host " 또는 수동으로 mkcert를 설치하세요:" -ForegroundColor Yellow
55+
Write-Host " https://github.com/FiloSottile/mkcert/releases" -ForegroundColor Yellow
56+
exit 1
57+
}
58+
59+
# 설치 후 다시 확인
60+
$mkcertInstalled = $null -ne (Get-Command mkcert -ErrorAction SilentlyContinue)
61+
if (-not $mkcertInstalled) {
62+
Write-Host "❌ mkcert 설치에 실패했습니다." -ForegroundColor Red
63+
exit 1
64+
}
65+
}
66+
else {
67+
Write-Host "✅ mkcert가 이미 설치되어 있습니다." -ForegroundColor Green
68+
}
69+
70+
# mkcert를 로컬 CA로 설정
71+
Write-Host "🔐 mkcert를 로컬 CA로 설정합니다..." -ForegroundColor Cyan
72+
mkcert -install
73+
74+
###############################################################################
75+
76+
# hosts 파일에 로컬 호스트가 등록되어 있는지 확인
77+
$hostsContent = Get-Content $HOSTS_FILE -Raw
78+
$clientHostExists = $hostsContent -match [regex]::Escape($CLIENT_HOST)
79+
$adminHostExists = $hostsContent -match [regex]::Escape($ADMIN_HOST)
80+
81+
if ($clientHostExists -and $adminHostExists) {
82+
Write-Host "✅ hosts 파일에 호스트명들이 이미 등록되어 있습니다." -ForegroundColor Green
83+
}
84+
else {
85+
Write-Host ""
86+
Write-Host "📝 로컬 호스트들을 hosts 파일에 등록합니다..." -ForegroundColor Cyan
87+
88+
$hostsEntries = @()
89+
90+
if (-not $clientHostExists) {
91+
$hostsEntries += "127.0.0.1`t$CLIENT_HOST"
92+
Write-Host "✅ hosts 파일에 $CLIENT_HOST 를 등록했습니다." -ForegroundColor Green
93+
}
94+
95+
if (-not $adminHostExists) {
96+
$hostsEntries += "127.0.0.1`t$ADMIN_HOST"
97+
Write-Host "✅ hosts 파일에 $ADMIN_HOST 를 등록했습니다." -ForegroundColor Green
98+
}
99+
100+
if ($hostsEntries.Count -gt 0) {
101+
# hosts 파일에 추가
102+
Add-Content -Path $HOSTS_FILE -Value "`n$($hostsEntries -join "`n")" -Encoding ASCII
103+
}
104+
}
105+
106+
###############################################################################
107+
108+
# HTTPS 인증서 생성
109+
Write-Host ""
110+
Write-Host "🔐 SSL 인증서를 생성하는 중입니다..." -ForegroundColor Cyan
111+
112+
# 프로젝트 루트 디렉토리로 이동 (스크립트 위치 기준)
113+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
114+
$projectRoot = Split-Path -Parent $scriptDir
115+
Set-Location $projectRoot
116+
117+
# 인증서 생성
118+
mkcert -key-file "$CLIENT_HOST-key.pem" -cert-file "$CLIENT_HOST.pem" $CLIENT_HOST
119+
mkcert -key-file "$ADMIN_HOST-key.pem" -cert-file "$ADMIN_HOST.pem" $ADMIN_HOST
120+
121+
Write-Host ""
122+
Write-Host "🎉 로컬 개발 환경 설정이 완료되었습니다!" -ForegroundColor Green
123+
Write-Host "💡 이제 'pnpm dev' 명령어를 사용하여 개발 서버를 실행할 수 있습니다." -ForegroundColor Cyan
124+
Write-Host ""
125+
Write-Host "계속하려면 아무 키나 누르세요..." -ForegroundColor Gray
126+
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

0 commit comments

Comments
 (0)