create-entity-server 0.7.11 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,70 +1,70 @@
1
- # Init Entity Tables - Windows PowerShell
2
- # Add, reset, or truncate one entity's data/index/history tables
3
-
4
- $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
5
- $ProjectRoot = Split-Path -Parent $ScriptDir
6
-
7
- Set-Location $ProjectRoot
8
-
9
- # Load language from .env
10
- $Language = "ko"
11
- $EnvFile = Join-Path $ProjectRoot ".env"
12
- if (Test-Path $EnvFile) {
13
- $LangLine = Get-Content $EnvFile | Where-Object { $_ -match '^LANGUAGE=' } | Select-Object -First 1
14
- if ($LangLine) { $Language = $LangLine -replace '^LANGUAGE=', '' }
15
- }
16
-
17
- function Show-Help {
18
- if ($Language -eq "en") {
19
- Write-Host "Init Entity Tables"
20
- Write-Host "=================="
21
- Write-Host ""
22
- Write-Host "Add, reset, or truncate one entity's data/index/history tables."
23
- Write-Host ""
24
- Write-Host "Usage: .\entity.ps1 --entity=<name> [--reset|--truncate] [--apply]"
25
- Write-Host ""
26
- Write-Host "Options:"
27
- Write-Host " --entity=<name> Entity name (required)"
28
- Write-Host " --reset Drop this entity tables and recreate"
29
- Write-Host " --truncate Delete all rows and reset AUTO_INCREMENT=1"
30
- Write-Host " --apply Execute (default is dry-run)"
31
- Write-Host ""
32
- Write-Host "Examples:"
33
- Write-Host " .\entity.ps1 --entity=license --apply"
34
- Write-Host " .\entity.ps1 --entity=account --reset --apply"
35
- Write-Host " .\entity.ps1 --entity=account --truncate --apply"
36
- } else {
37
- Write-Host "단일 엔티티 테이블 초기화"
38
- Write-Host "====================="
39
- Write-Host ""
40
- Write-Host "하나의 엔티티(data/index/history) 테이블을 추가/재생성/비우기(truncate) 합니다."
41
- Write-Host ""
42
- Write-Host "사용법: .\entity.ps1 --entity=<name> [--reset|--truncate] [--apply]"
43
- Write-Host ""
44
- Write-Host "옵션:"
45
- Write-Host " --entity=<name> 엔티티명 (필수)"
46
- Write-Host " --reset 해당 엔티티 테이블 드롭 후 재생성"
47
- Write-Host " --truncate 데이터 전체 삭제 + AUTO_INCREMENT=1 초기화"
48
- Write-Host " --apply 실제 실행 (기본은 dry-run)"
49
- Write-Host ""
50
- Write-Host "예제:"
51
- Write-Host " .\entity.ps1 --entity=license --apply"
52
- Write-Host " .\entity.ps1 --entity=account --reset --apply"
53
- Write-Host " .\entity.ps1 --entity=account --truncate --apply"
54
- }
55
- }
56
-
57
- if ($args.Count -eq 0) {
58
- Show-Help
59
- exit 0
60
- }
61
-
62
- $CliBin = Join-Path $ProjectRoot "bin\entity-cli.exe"
63
- if (-not (Test-Path $CliBin)) {
64
- if ($Language -eq "en") { Write-Host "X bin/entity-cli.exe not found" }
65
- else { Write-Host "X bin/entity-cli.exe 파일이 없습니다" }
66
- exit 1
67
- }
68
-
69
- # Pass-through to CLI
70
- & $CliBin init-entity @args
1
+ # Init Entity Tables - Windows PowerShell
2
+ # Add, reset, or truncate one entity's data/index/history tables
3
+
4
+ $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
5
+ $ProjectRoot = Split-Path -Parent $ScriptDir
6
+
7
+ Set-Location $ProjectRoot
8
+
9
+ # Load language from .env
10
+ $Language = "ko"
11
+ $EnvFile = Join-Path $ProjectRoot ".env"
12
+ if (Test-Path $EnvFile) {
13
+ $LangLine = Get-Content $EnvFile | Where-Object { $_ -match '^LANGUAGE=' } | Select-Object -First 1
14
+ if ($LangLine) { $Language = $LangLine -replace '^LANGUAGE=', '' }
15
+ }
16
+
17
+ function Show-Help {
18
+ if ($Language -eq "en") {
19
+ Write-Host "Init Entity Tables"
20
+ Write-Host "=================="
21
+ Write-Host ""
22
+ Write-Host "Add, reset, or truncate one entity's data/index/history tables."
23
+ Write-Host ""
24
+ Write-Host "Usage: .\entity.ps1 --entity=<name> [--reset|--truncate] [--apply]"
25
+ Write-Host ""
26
+ Write-Host "Options:"
27
+ Write-Host " --entity=<name> Entity name (required)"
28
+ Write-Host " --reset Drop this entity tables and recreate"
29
+ Write-Host " --truncate Delete all rows and reset AUTO_INCREMENT=1"
30
+ Write-Host " --apply Execute (default is dry-run)"
31
+ Write-Host ""
32
+ Write-Host "Examples:"
33
+ Write-Host " .\entity.ps1 --entity=license --apply"
34
+ Write-Host " .\entity.ps1 --entity=account --reset --apply"
35
+ Write-Host " .\entity.ps1 --entity=account --truncate --apply"
36
+ } else {
37
+ Write-Host "단일 엔티티 테이블 초기화"
38
+ Write-Host "====================="
39
+ Write-Host ""
40
+ Write-Host "하나의 엔티티(data/index/history) 테이블을 추가/재생성/비우기(truncate) 합니다."
41
+ Write-Host ""
42
+ Write-Host "사용법: .\entity.ps1 --entity=<name> [--reset|--truncate] [--apply]"
43
+ Write-Host ""
44
+ Write-Host "옵션:"
45
+ Write-Host " --entity=<name> 엔티티명 (필수)"
46
+ Write-Host " --reset 해당 엔티티 테이블 드롭 후 재생성"
47
+ Write-Host " --truncate 데이터 전체 삭제 + AUTO_INCREMENT=1 초기화"
48
+ Write-Host " --apply 실제 실행 (기본은 dry-run)"
49
+ Write-Host ""
50
+ Write-Host "예제:"
51
+ Write-Host " .\entity.ps1 --entity=license --apply"
52
+ Write-Host " .\entity.ps1 --entity=account --reset --apply"
53
+ Write-Host " .\entity.ps1 --entity=account --truncate --apply"
54
+ }
55
+ }
56
+
57
+ if ($args.Count -eq 0) {
58
+ Show-Help
59
+ exit 0
60
+ }
61
+
62
+ $CliBin = Join-Path $ProjectRoot "bin\entity-cli.exe"
63
+ if (-not (Test-Path $CliBin)) {
64
+ if ($Language -eq "en") { Write-Host "X bin/entity-cli.exe not found" }
65
+ else { Write-Host "X bin/entity-cli.exe 파일이 없습니다" }
66
+ exit 1
67
+ }
68
+
69
+ # Pass-through to CLI
70
+ & $CliBin init-entity @args
@@ -1,125 +1,125 @@
1
- # Generate Environment Keys/Secrets - Windows PowerShell
2
- # Generates ENCRYPTION_KEY and JWT_SECRET random values
3
- param(
4
- [switch]$Create,
5
- [switch]$Export,
6
- [switch]$Apply
7
- )
8
-
9
- $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
10
- $ProjectRoot = Split-Path -Parent $ScriptDir
11
-
12
- # Load language from .env (env var takes priority)
13
- $Language = $env:LANGUAGE
14
- if (-not $Language) {
15
- $EnvFile = Join-Path $ProjectRoot ".env"
16
- if (Test-Path $EnvFile) {
17
- $LangLine = Get-Content $EnvFile | Where-Object { $_ -match '^LANGUAGE=' } | Select-Object -Last 1
18
- if ($LangLine) { $Language = $LangLine -replace '^LANGUAGE=', '' }
19
- }
20
- }
21
- if (-not $Language) { $Language = "ko" }
22
-
23
- function Show-Help {
24
- if ($Language -eq "en") {
25
- Write-Host "Generate Environment Keys/Secrets"
26
- Write-Host "==================================="
27
- Write-Host ""
28
- Write-Host "Generates random values for ENCRYPTION_KEY and JWT_SECRET."
29
- Write-Host ""
30
- Write-Host "Note: API keys (api_keys entity) are managed via DB commands:"
31
- Write-Host " .\scripts\api-key.ps1 add --role=admin --apply"
32
- Write-Host ""
33
- Write-Host "Usage: .\generate-env-keys.ps1 [-Create|-Export|-Apply]"
34
- Write-Host ""
35
- Write-Host "Options:"
36
- Write-Host " -Create Print copy/paste format for .env"
37
- Write-Host " -Export Print shell export format"
38
- Write-Host " -Apply Apply values directly to project .env"
39
- Write-Host ""
40
- Write-Host "Examples:"
41
- Write-Host " .\generate-env-keys.ps1 -Create"
42
- Write-Host " .\generate-env-keys.ps1 -Export"
43
- Write-Host " .\generate-env-keys.ps1 -Apply"
44
- } else {
45
- Write-Host "환경 변수 키/시크릿 생성"
46
- Write-Host "======================="
47
- Write-Host ""
48
- Write-Host "ENCRYPTION_KEY, JWT_SECRET 랜덤 값을 생성합니다."
49
- Write-Host ""
50
- Write-Host "참고: API 키(api_keys 엔티티)는 DB 명령으로 관리합니다:"
51
- Write-Host " .\scripts\api-key.ps1 add --role=admin --apply"
52
- Write-Host ""
53
- Write-Host "사용법: .\generate-env-keys.ps1 [-Create|-Export|-Apply]"
54
- Write-Host ""
55
- Write-Host "옵션:"
56
- Write-Host " -Create .env 복붙 형식으로 출력"
57
- Write-Host " -Export export 형식으로 출력"
58
- Write-Host " -Apply 프로젝트 루트 .env 파일에 즉시 반영"
59
- Write-Host ""
60
- Write-Host "예제:"
61
- Write-Host " .\generate-env-keys.ps1 -Create"
62
- Write-Host " .\generate-env-keys.ps1 -Export"
63
- Write-Host " .\generate-env-keys.ps1 -Apply"
64
- }
65
- }
66
-
67
- if (-not $Create -and -not $Export -and -not $Apply) {
68
- Show-Help
69
- exit 0
70
- }
71
-
72
- function New-RandomHex {
73
- param([int]$Bytes)
74
- $rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
75
- $buf = New-Object byte[] $Bytes
76
- $rng.GetBytes($buf)
77
- return ($buf | ForEach-Object { $_.ToString("x2") }) -join ""
78
- }
79
-
80
- $EncryptionKey = New-RandomHex 16
81
- $JwtSecret = New-RandomHex 32
82
-
83
- if ($Export) {
84
- Write-Host "SET ENCRYPTION_KEY=$EncryptionKey"
85
- Write-Host "SET JWT_SECRET=$JwtSecret"
86
- Write-Host ""
87
- Write-Host "# PowerShell:"
88
- Write-Host "`$env:ENCRYPTION_KEY=`"$EncryptionKey`""
89
- Write-Host "`$env:JWT_SECRET=`"$JwtSecret`""
90
- } elseif ($Create) {
91
- if ($Language -eq "en") { Write-Host "# Copy & paste to .env" }
92
- else { Write-Host "# .env에 복사해서 붙여넣기" }
93
- Write-Host "ENCRYPTION_KEY=$EncryptionKey"
94
- Write-Host "JWT_SECRET=$JwtSecret"
95
- } elseif ($Apply) {
96
- $EnvFile = Join-Path $ProjectRoot ".env"
97
- if (-not (Test-Path $EnvFile)) { New-Item -ItemType File -Path $EnvFile | Out-Null }
98
-
99
- function Update-EnvKey {
100
- param([string]$File, [string]$Key, [string]$Value)
101
- $content = Get-Content $File
102
- $found = $false
103
- $newContent = $content | ForEach-Object {
104
- if ($_ -match "^$Key=") {
105
- $found = $true
106
- "$Key=$Value"
107
- } else { $_ }
108
- }
109
- if (-not $found) { $newContent += "$Key=$Value" }
110
- $newContent | Set-Content $File
111
- }
112
-
113
- Update-EnvKey $EnvFile "ENCRYPTION_KEY" $EncryptionKey
114
- Update-EnvKey $EnvFile "JWT_SECRET" $JwtSecret
115
-
116
- if ($Language -eq "en") {
117
- Write-Host "OK Updated: $EnvFile"
118
- Write-Host " - ENCRYPTION_KEY"
119
- Write-Host " - JWT_SECRET"
120
- } else {
121
- Write-Host "OK 업데이트 완료: $EnvFile"
122
- Write-Host " - ENCRYPTION_KEY"
123
- Write-Host " - JWT_SECRET"
124
- }
125
- }
1
+ # Generate Environment Keys/Secrets - Windows PowerShell
2
+ # Generates ENCRYPTION_KEY and JWT_SECRET random values
3
+ param(
4
+ [switch]$Create,
5
+ [switch]$Export,
6
+ [switch]$Apply
7
+ )
8
+
9
+ $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
10
+ $ProjectRoot = Split-Path -Parent $ScriptDir
11
+
12
+ # Load language from .env (env var takes priority)
13
+ $Language = $env:LANGUAGE
14
+ if (-not $Language) {
15
+ $EnvFile = Join-Path $ProjectRoot ".env"
16
+ if (Test-Path $EnvFile) {
17
+ $LangLine = Get-Content $EnvFile | Where-Object { $_ -match '^LANGUAGE=' } | Select-Object -Last 1
18
+ if ($LangLine) { $Language = $LangLine -replace '^LANGUAGE=', '' }
19
+ }
20
+ }
21
+ if (-not $Language) { $Language = "ko" }
22
+
23
+ function Show-Help {
24
+ if ($Language -eq "en") {
25
+ Write-Host "Generate Environment Keys/Secrets"
26
+ Write-Host "==================================="
27
+ Write-Host ""
28
+ Write-Host "Generates random values for ENCRYPTION_KEY and JWT_SECRET."
29
+ Write-Host ""
30
+ Write-Host "Note: API keys (api_keys entity) are managed via DB commands:"
31
+ Write-Host " .\scripts\api-key.ps1 add --role=admin --apply"
32
+ Write-Host ""
33
+ Write-Host "Usage: .\generate-env-keys.ps1 [-Create|-Export|-Apply]"
34
+ Write-Host ""
35
+ Write-Host "Options:"
36
+ Write-Host " -Create Print copy/paste format for .env"
37
+ Write-Host " -Export Print shell export format"
38
+ Write-Host " -Apply Apply values directly to project .env"
39
+ Write-Host ""
40
+ Write-Host "Examples:"
41
+ Write-Host " .\generate-env-keys.ps1 -Create"
42
+ Write-Host " .\generate-env-keys.ps1 -Export"
43
+ Write-Host " .\generate-env-keys.ps1 -Apply"
44
+ } else {
45
+ Write-Host "환경 변수 키/시크릿 생성"
46
+ Write-Host "======================="
47
+ Write-Host ""
48
+ Write-Host "ENCRYPTION_KEY, JWT_SECRET 랜덤 값을 생성합니다."
49
+ Write-Host ""
50
+ Write-Host "참고: API 키(api_keys 엔티티)는 DB 명령으로 관리합니다:"
51
+ Write-Host " .\scripts\api-key.ps1 add --role=admin --apply"
52
+ Write-Host ""
53
+ Write-Host "사용법: .\generate-env-keys.ps1 [-Create|-Export|-Apply]"
54
+ Write-Host ""
55
+ Write-Host "옵션:"
56
+ Write-Host " -Create .env 복붙 형식으로 출력"
57
+ Write-Host " -Export export 형식으로 출력"
58
+ Write-Host " -Apply 프로젝트 루트 .env 파일에 즉시 반영"
59
+ Write-Host ""
60
+ Write-Host "예제:"
61
+ Write-Host " .\generate-env-keys.ps1 -Create"
62
+ Write-Host " .\generate-env-keys.ps1 -Export"
63
+ Write-Host " .\generate-env-keys.ps1 -Apply"
64
+ }
65
+ }
66
+
67
+ if (-not $Create -and -not $Export -and -not $Apply) {
68
+ Show-Help
69
+ exit 0
70
+ }
71
+
72
+ function New-RandomHex {
73
+ param([int]$Bytes)
74
+ $rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
75
+ $buf = New-Object byte[] $Bytes
76
+ $rng.GetBytes($buf)
77
+ return ($buf | ForEach-Object { $_.ToString("x2") }) -join ""
78
+ }
79
+
80
+ $EncryptionKey = New-RandomHex 16
81
+ $JwtSecret = New-RandomHex 32
82
+
83
+ if ($Export) {
84
+ Write-Host "SET ENCRYPTION_KEY=$EncryptionKey"
85
+ Write-Host "SET JWT_SECRET=$JwtSecret"
86
+ Write-Host ""
87
+ Write-Host "# PowerShell:"
88
+ Write-Host "`$env:ENCRYPTION_KEY=`"$EncryptionKey`""
89
+ Write-Host "`$env:JWT_SECRET=`"$JwtSecret`""
90
+ } elseif ($Create) {
91
+ if ($Language -eq "en") { Write-Host "# Copy & paste to .env" }
92
+ else { Write-Host "# .env에 복사해서 붙여넣기" }
93
+ Write-Host "ENCRYPTION_KEY=$EncryptionKey"
94
+ Write-Host "JWT_SECRET=$JwtSecret"
95
+ } elseif ($Apply) {
96
+ $EnvFile = Join-Path $ProjectRoot ".env"
97
+ if (-not (Test-Path $EnvFile)) { New-Item -ItemType File -Path $EnvFile | Out-Null }
98
+
99
+ function Update-EnvKey {
100
+ param([string]$File, [string]$Key, [string]$Value)
101
+ $content = Get-Content $File
102
+ $found = $false
103
+ $newContent = $content | ForEach-Object {
104
+ if ($_ -match "^$Key=") {
105
+ $found = $true
106
+ "$Key=$Value"
107
+ } else { $_ }
108
+ }
109
+ if (-not $found) { $newContent += "$Key=$Value" }
110
+ $newContent | Set-Content $File
111
+ }
112
+
113
+ Update-EnvKey $EnvFile "ENCRYPTION_KEY" $EncryptionKey
114
+ Update-EnvKey $EnvFile "JWT_SECRET" $JwtSecret
115
+
116
+ if ($Language -eq "en") {
117
+ Write-Host "OK Updated: $EnvFile"
118
+ Write-Host " - ENCRYPTION_KEY"
119
+ Write-Host " - JWT_SECRET"
120
+ } else {
121
+ Write-Host "OK 업데이트 완료: $EnvFile"
122
+ Write-Host " - ENCRYPTION_KEY"
123
+ Write-Host " - JWT_SECRET"
124
+ }
125
+ }
@@ -1,87 +1,87 @@
1
- # normalize-entities.ps1 — 엔티티 JSON 정규화
2
- #
3
- # 사용법:
4
- # .\scripts\normalize-entities.ps1 # 도움말
5
- # .\scripts\normalize-entities.ps1 -Apply # 전체 정규화
6
- # .\scripts\normalize-entities.ps1 -Entity account # account dry-run
7
- # .\scripts\normalize-entities.ps1 -Entity account -Apply # account 정규화
8
-
9
- param(
10
- [string]$Entity = "",
11
- [switch]$Apply
12
- )
13
-
14
- $ErrorActionPreference = "Stop"
15
-
16
- $ProjectRoot = Split-Path -Parent $PSScriptRoot
17
- Set-Location $ProjectRoot
18
-
19
- # LANGUAGE 로드
20
- $Lang = $env:LANGUAGE
21
- if (-not $Lang) {
22
- $EnvFile = Join-Path $ProjectRoot ".env"
23
- if (Test-Path $EnvFile) {
24
- $line = Get-Content $EnvFile | Where-Object { $_ -match '^LANGUAGE=' } | Select-Object -Last 1
25
- if ($line) { $Lang = $line -replace '^LANGUAGE=', '' }
26
- }
27
- }
28
- if (-not $Lang) { $Lang = "ko" }
29
-
30
- function Show-Help {
31
- if ($Lang -eq "en") {
32
- Write-Host "Normalize Entity JSON"
33
- Write-Host "====================="
34
- Write-Host ""
35
- Write-Host "Remove redundant default values and reorder keys in entity JSON files."
36
- Write-Host "Also auto-creates missing required entities (api_keys, rbac_roles, and account/user when JWT is enabled)."
37
- Write-Host ""
38
- Write-Host "Usage: .\scripts\normalize-entities.ps1 [-Entity <name>] [-Apply]"
39
- Write-Host ""
40
- Write-Host "Options:"
41
- Write-Host " -Apply Apply changes (default is dry-run)"
42
- Write-Host " -Entity <name> Normalize a single entity only"
43
- Write-Host ""
44
- Write-Host "Examples:"
45
- Write-Host " .\scripts\normalize-entities.ps1 # Dry-run all"
46
- Write-Host " .\scripts\normalize-entities.ps1 -Apply # Normalize all"
47
- Write-Host " .\scripts\normalize-entities.ps1 -Entity account # Dry-run account"
48
- Write-Host " .\scripts\normalize-entities.ps1 -Entity account -Apply # Normalize account"
49
- } else {
50
- Write-Host "엔티티 JSON 정규화"
51
- Write-Host "=================="
52
- Write-Host ""
53
- Write-Host "엔티티 JSON 파일에서 불필요한 기본값을 제거하고 키 순서를 정렬합니다."
54
- Write-Host "전체 모드에서는 필수 엔티티(api_keys, rbac_roles, JWT 사용 시 account/user)가 없으면 자동 생성합니다."
55
- Write-Host ""
56
- Write-Host "사용법: .\scripts\normalize-entities.ps1 [-Entity <이름>] [-Apply]"
57
- Write-Host ""
58
- Write-Host "옵션:"
59
- Write-Host " -Apply 실제 파일 수정 (기본은 dry-run)"
60
- Write-Host " -Entity <이름> 단일 엔티티만 정규화"
61
- Write-Host ""
62
- Write-Host "예제:"
63
- Write-Host " .\scripts\normalize-entities.ps1 # 전체 dry-run"
64
- Write-Host " .\scripts\normalize-entities.ps1 -Apply # 전체 정규화"
65
- Write-Host " .\scripts\normalize-entities.ps1 -Entity account # account dry-run"
66
- Write-Host " .\scripts\normalize-entities.ps1 -Entity account -Apply # account 정규화"
67
- }
68
- }
69
-
70
- # 인자 없으면 도움말
71
- if (-not $Apply -and -not $Entity) {
72
- Show-Help
73
- exit 0
74
- }
75
-
76
- $CliBin = Join-Path $ProjectRoot "entity-cli.exe"
77
- if (-not (Test-Path $CliBin)) {
78
- if ($Lang -eq "en") { Write-Error "❌ entity-cli.exe not found. Run scripts\build.sh first." }
79
- else { Write-Error "❌ entity-cli.exe 파일이 없습니다. scripts\build.sh 를 먼저 실행하세요." }
80
- exit 1
81
- }
82
-
83
- $Args = @("normalize-entities")
84
- if ($Entity) { $Args += "--entity=$Entity" }
85
- if ($Apply) { $Args += "--apply" }
86
-
87
- & $CliBin @Args
1
+ # normalize-entities.ps1 — 엔티티 JSON 정규화
2
+ #
3
+ # 사용법:
4
+ # .\scripts\normalize-entities.ps1 # 도움말
5
+ # .\scripts\normalize-entities.ps1 -Apply # 전체 정규화
6
+ # .\scripts\normalize-entities.ps1 -Entity account # account dry-run
7
+ # .\scripts\normalize-entities.ps1 -Entity account -Apply # account 정규화
8
+
9
+ param(
10
+ [string]$Entity = "",
11
+ [switch]$Apply
12
+ )
13
+
14
+ $ErrorActionPreference = "Stop"
15
+
16
+ $ProjectRoot = Split-Path -Parent $PSScriptRoot
17
+ Set-Location $ProjectRoot
18
+
19
+ # LANGUAGE 로드
20
+ $Lang = $env:LANGUAGE
21
+ if (-not $Lang) {
22
+ $EnvFile = Join-Path $ProjectRoot ".env"
23
+ if (Test-Path $EnvFile) {
24
+ $line = Get-Content $EnvFile | Where-Object { $_ -match '^LANGUAGE=' } | Select-Object -Last 1
25
+ if ($line) { $Lang = $line -replace '^LANGUAGE=', '' }
26
+ }
27
+ }
28
+ if (-not $Lang) { $Lang = "ko" }
29
+
30
+ function Show-Help {
31
+ if ($Lang -eq "en") {
32
+ Write-Host "Normalize Entity JSON"
33
+ Write-Host "====================="
34
+ Write-Host ""
35
+ Write-Host "Remove redundant default values and reorder keys in entity JSON files."
36
+ Write-Host "Also auto-creates missing required entities (api_keys, rbac_roles, and account/user when JWT is enabled)."
37
+ Write-Host ""
38
+ Write-Host "Usage: .\scripts\normalize-entities.ps1 [-Entity <name>] [-Apply]"
39
+ Write-Host ""
40
+ Write-Host "Options:"
41
+ Write-Host " -Apply Apply changes (default is dry-run)"
42
+ Write-Host " -Entity <name> Normalize a single entity only"
43
+ Write-Host ""
44
+ Write-Host "Examples:"
45
+ Write-Host " .\scripts\normalize-entities.ps1 # Dry-run all"
46
+ Write-Host " .\scripts\normalize-entities.ps1 -Apply # Normalize all"
47
+ Write-Host " .\scripts\normalize-entities.ps1 -Entity account # Dry-run account"
48
+ Write-Host " .\scripts\normalize-entities.ps1 -Entity account -Apply # Normalize account"
49
+ } else {
50
+ Write-Host "엔티티 JSON 정규화"
51
+ Write-Host "=================="
52
+ Write-Host ""
53
+ Write-Host "엔티티 JSON 파일에서 불필요한 기본값을 제거하고 키 순서를 정렬합니다."
54
+ Write-Host "전체 모드에서는 필수 엔티티(api_keys, rbac_roles, JWT 사용 시 account/user)가 없으면 자동 생성합니다."
55
+ Write-Host ""
56
+ Write-Host "사용법: .\scripts\normalize-entities.ps1 [-Entity <이름>] [-Apply]"
57
+ Write-Host ""
58
+ Write-Host "옵션:"
59
+ Write-Host " -Apply 실제 파일 수정 (기본은 dry-run)"
60
+ Write-Host " -Entity <이름> 단일 엔티티만 정규화"
61
+ Write-Host ""
62
+ Write-Host "예제:"
63
+ Write-Host " .\scripts\normalize-entities.ps1 # 전체 dry-run"
64
+ Write-Host " .\scripts\normalize-entities.ps1 -Apply # 전체 정규화"
65
+ Write-Host " .\scripts\normalize-entities.ps1 -Entity account # account dry-run"
66
+ Write-Host " .\scripts\normalize-entities.ps1 -Entity account -Apply # account 정규화"
67
+ }
68
+ }
69
+
70
+ # 인자 없으면 도움말
71
+ if (-not $Apply -and -not $Entity) {
72
+ Show-Help
73
+ exit 0
74
+ }
75
+
76
+ $CliBin = Join-Path $ProjectRoot "entity-cli.exe"
77
+ if (-not (Test-Path $CliBin)) {
78
+ if ($Lang -eq "en") { Write-Error "❌ entity-cli.exe not found. Run scripts\build.sh first." }
79
+ else { Write-Error "❌ entity-cli.exe 파일이 없습니다. scripts\build.sh 를 먼저 실행하세요." }
80
+ exit 1
81
+ }
82
+
83
+ $Args = @("normalize-entities")
84
+ if ($Entity) { $Args += "--entity=$Entity" }
85
+ if ($Apply) { $Args += "--apply" }
86
+
87
+ & $CliBin @Args