create-entity-server 0.7.11 → 0.7.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,145 +1,145 @@
1
- # Sync entity index schema
2
-
3
- param(
4
- [string]$Target = "",
5
- [switch]$Apply,
6
- [switch]$WithData
7
- )
8
-
9
- $ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
10
- Set-Location $ProjectRoot
11
-
12
- # Load language from .env
13
- $Language = "ko"
14
- if (Test-Path ".env") {
15
- $EnvLine = Get-Content ".env" | Where-Object { $_ -match '^LANGUAGE=' }
16
- if ($EnvLine) { $Language = $EnvLine -replace '^LANGUAGE=', '' }
17
- }
18
-
19
- # Show usage if no arguments
20
- if (-not $Target) {
21
- if ($Language -eq "en") {
22
- Write-Host "Sync Entity Index Schema"
23
- Write-Host "========================"
24
- Write-Host ""
25
- Write-Host "Synchronize index table schema with entity configuration."
26
- Write-Host ""
27
- Write-Host "Usage: .\sync.ps1 <EntityName>|-All [-Apply] [-WithData]"
28
- Write-Host ""
29
- Write-Host "Arguments:"
30
- Write-Host " EntityName Name of the entity to sync (required)"
31
- Write-Host " -All Sync all entities in entities/"
32
- Write-Host ""
33
- Write-Host "Options:"
34
- Write-Host " -Apply Apply changes to database (default: dry-run)"
35
- Write-Host " -WithData Sync schema and backfill index rows from existing data"
36
- Write-Host ""
37
- Write-Host "Examples:"
38
- Write-Host " .\sync.ps1 user # Preview changes for user entity"
39
- Write-Host " .\sync.ps1 user -Apply # Apply changes for user entity"
40
- Write-Host " .\sync.ps1 user -Apply -WithData # Apply + backfill"
41
- Write-Host " .\sync.ps1 -All # Preview for all entities"
42
- Write-Host " .\sync.ps1 -All -Apply # Apply for all entities"
43
- Write-Host " .\sync.ps1 license -Apply # Sync license entity schema"
44
- } else {
45
- Write-Host "엔티티 인덱스 스키마 동기화"
46
- Write-Host "======================="
47
- Write-Host ""
48
- Write-Host "엔티티 설정과 인덱스 테이블 스키마를 동기화합니다."
49
- Write-Host ""
50
- Write-Host "사용법: .\sync.ps1 <엔티티명>|-All [-Apply] [-WithData]"
51
- Write-Host ""
52
- Write-Host "인자:"
53
- Write-Host " 엔티티명 동기화할 엔티티 이름 (필수)"
54
- Write-Host " -All entities/ 내 전체 엔티티 동기화"
55
- Write-Host ""
56
- Write-Host "옵션:"
57
- Write-Host " -Apply 데이터베이스에 변경사항 적용 (기본값: 미리보기)"
58
- Write-Host " -WithData 스키마 동기화 + 기존 데이터 인덱스 백필"
59
- Write-Host ""
60
- Write-Host "예제:"
61
- Write-Host " .\sync.ps1 user # user 엔티티 변경사항 미리보기"
62
- Write-Host " .\sync.ps1 user -Apply # user 엔티티 변경사항 적용"
63
- Write-Host " .\sync.ps1 user -Apply -WithData # 적용 + 기존 데이터 백필"
64
- Write-Host " .\sync.ps1 -All # 전체 엔티티 미리보기"
65
- Write-Host " .\sync.ps1 -All -Apply # 전체 엔티티 적용"
66
- Write-Host " .\sync.ps1 license -Apply # license 엔티티 스키마 동기화"
67
- }
68
- exit 0
69
- }
70
-
71
- # Validate --with-data requires --apply
72
- if ($WithData -and -not $Apply) {
73
- if ($Language -eq "en") {
74
- Write-Host "❌ -WithData requires -Apply"
75
- } else {
76
- Write-Host "❌ -WithData 는 -Apply 와 함께 사용해야 합니다"
77
- }
78
- exit 1
79
- }
80
-
81
- # Require prebuilt CLI binary
82
- $CliBin = Join-Path $ProjectRoot "entity-cli.exe"
83
- if (-not (Test-Path $CliBin)) {
84
- if ($Language -eq "en") {
85
- Write-Host "❌ entity-cli.exe not found"
86
- } else {
87
- Write-Host "❌ entity-cli.exe 파일이 없습니다"
88
- }
89
- exit 1
90
- }
91
-
92
- function Invoke-SyncEntity {
93
- param([string]$EntityName)
94
- $Args = @("sync-index", "--entity=$EntityName")
95
- if ($Apply) { $Args += "--apply" }
96
- if ($WithData) { $Args += "--with-data" }
97
- Write-Host "[sync] $EntityName"
98
- & $CliBin @Args
99
- return $LASTEXITCODE -eq 0
100
- }
101
-
102
- if ($Target -eq "-All" -or $Target -eq "--all") {
103
- $EntityFiles = Get-ChildItem -Path (Join-Path $ProjectRoot "entities") -Filter "*.json" -Recurse |
104
- Select-Object -ExpandProperty BaseName | Sort-Object -Unique
105
-
106
- if ($EntityFiles.Count -eq 0) {
107
- if ($Language -eq "en") {
108
- Write-Host "❌ No entity config files found in entities/"
109
- } else {
110
- Write-Host "❌ entities/ 에 엔티티 설정 파일이 없습니다"
111
- }
112
- exit 1
113
- }
114
-
115
- $TotalCount = $EntityFiles.Count
116
- $SuccessCount = 0
117
- $FailedCount = 0
118
-
119
- foreach ($Entity in $EntityFiles) {
120
- if (Invoke-SyncEntity $Entity) {
121
- $SuccessCount++
122
- } else {
123
- $FailedCount++
124
- }
125
- }
126
-
127
- $ApplyLabel = if ($Apply) { "apply" } else { "dry-run" }
128
- $ModeLabel = if ($WithData) { "with-data" } else { "index-only" }
129
- Write-Host ""
130
- Write-Host "[summary] target=all mode=$ModeLabel apply=$ApplyLabel total=$TotalCount success=$SuccessCount failed=$FailedCount"
131
-
132
- if ($FailedCount -gt 0) { exit 1 }
133
- } else {
134
- $ok = Invoke-SyncEntity $Target
135
- $ApplyLabel = if ($Apply) { "apply" } else { "dry-run" }
136
- $ModeLabel = if ($WithData) { "with-data" } else { "index-only" }
137
- if ($ok) {
138
- Write-Host ""
139
- Write-Host "[summary] target=$Target mode=$ModeLabel apply=$ApplyLabel total=1 success=1 failed=0"
140
- } else {
141
- Write-Host ""
142
- Write-Host "[summary] target=$Target mode=$ModeLabel apply=$ApplyLabel total=1 success=0 failed=1"
143
- exit 1
144
- }
145
- }
1
+ # Sync entity index schema
2
+
3
+ param(
4
+ [string]$Target = "",
5
+ [switch]$Apply,
6
+ [switch]$WithData
7
+ )
8
+
9
+ $ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
10
+ Set-Location $ProjectRoot
11
+
12
+ # Load language from .env
13
+ $Language = "ko"
14
+ if (Test-Path ".env") {
15
+ $EnvLine = Get-Content ".env" | Where-Object { $_ -match '^LANGUAGE=' }
16
+ if ($EnvLine) { $Language = $EnvLine -replace '^LANGUAGE=', '' }
17
+ }
18
+
19
+ # Show usage if no arguments
20
+ if (-not $Target) {
21
+ if ($Language -eq "en") {
22
+ Write-Host "Sync Entity Index Schema"
23
+ Write-Host "========================"
24
+ Write-Host ""
25
+ Write-Host "Synchronize index table schema with entity configuration."
26
+ Write-Host ""
27
+ Write-Host "Usage: .\sync.ps1 <EntityName>|-All [-Apply] [-WithData]"
28
+ Write-Host ""
29
+ Write-Host "Arguments:"
30
+ Write-Host " EntityName Name of the entity to sync (required)"
31
+ Write-Host " -All Sync all entities in entities/"
32
+ Write-Host ""
33
+ Write-Host "Options:"
34
+ Write-Host " -Apply Apply changes to database (default: dry-run)"
35
+ Write-Host " -WithData Sync schema and backfill index rows from existing data"
36
+ Write-Host ""
37
+ Write-Host "Examples:"
38
+ Write-Host " .\sync.ps1 user # Preview changes for user entity"
39
+ Write-Host " .\sync.ps1 user -Apply # Apply changes for user entity"
40
+ Write-Host " .\sync.ps1 user -Apply -WithData # Apply + backfill"
41
+ Write-Host " .\sync.ps1 -All # Preview for all entities"
42
+ Write-Host " .\sync.ps1 -All -Apply # Apply for all entities"
43
+ Write-Host " .\sync.ps1 license -Apply # Sync license entity schema"
44
+ } else {
45
+ Write-Host "엔티티 인덱스 스키마 동기화"
46
+ Write-Host "======================="
47
+ Write-Host ""
48
+ Write-Host "엔티티 설정과 인덱스 테이블 스키마를 동기화합니다."
49
+ Write-Host ""
50
+ Write-Host "사용법: .\sync.ps1 <엔티티명>|-All [-Apply] [-WithData]"
51
+ Write-Host ""
52
+ Write-Host "인자:"
53
+ Write-Host " 엔티티명 동기화할 엔티티 이름 (필수)"
54
+ Write-Host " -All entities/ 내 전체 엔티티 동기화"
55
+ Write-Host ""
56
+ Write-Host "옵션:"
57
+ Write-Host " -Apply 데이터베이스에 변경사항 적용 (기본값: 미리보기)"
58
+ Write-Host " -WithData 스키마 동기화 + 기존 데이터 인덱스 백필"
59
+ Write-Host ""
60
+ Write-Host "예제:"
61
+ Write-Host " .\sync.ps1 user # user 엔티티 변경사항 미리보기"
62
+ Write-Host " .\sync.ps1 user -Apply # user 엔티티 변경사항 적용"
63
+ Write-Host " .\sync.ps1 user -Apply -WithData # 적용 + 기존 데이터 백필"
64
+ Write-Host " .\sync.ps1 -All # 전체 엔티티 미리보기"
65
+ Write-Host " .\sync.ps1 -All -Apply # 전체 엔티티 적용"
66
+ Write-Host " .\sync.ps1 license -Apply # license 엔티티 스키마 동기화"
67
+ }
68
+ exit 0
69
+ }
70
+
71
+ # Validate --with-data requires --apply
72
+ if ($WithData -and -not $Apply) {
73
+ if ($Language -eq "en") {
74
+ Write-Host "❌ -WithData requires -Apply"
75
+ } else {
76
+ Write-Host "❌ -WithData 는 -Apply 와 함께 사용해야 합니다"
77
+ }
78
+ exit 1
79
+ }
80
+
81
+ # Require prebuilt CLI binary
82
+ $CliBin = Join-Path $ProjectRoot "entity-cli.exe"
83
+ if (-not (Test-Path $CliBin)) {
84
+ if ($Language -eq "en") {
85
+ Write-Host "❌ entity-cli.exe not found"
86
+ } else {
87
+ Write-Host "❌ entity-cli.exe 파일이 없습니다"
88
+ }
89
+ exit 1
90
+ }
91
+
92
+ function Invoke-SyncEntity {
93
+ param([string]$EntityName)
94
+ $Args = @("sync-index", "--entity=$EntityName")
95
+ if ($Apply) { $Args += "--apply" }
96
+ if ($WithData) { $Args += "--with-data" }
97
+ Write-Host "[sync] $EntityName"
98
+ & $CliBin @Args
99
+ return $LASTEXITCODE -eq 0
100
+ }
101
+
102
+ if ($Target -eq "-All" -or $Target -eq "--all") {
103
+ $EntityFiles = Get-ChildItem -Path (Join-Path $ProjectRoot "entities") -Filter "*.json" -Recurse |
104
+ Select-Object -ExpandProperty BaseName | Sort-Object -Unique
105
+
106
+ if ($EntityFiles.Count -eq 0) {
107
+ if ($Language -eq "en") {
108
+ Write-Host "❌ No entity config files found in entities/"
109
+ } else {
110
+ Write-Host "❌ entities/ 에 엔티티 설정 파일이 없습니다"
111
+ }
112
+ exit 1
113
+ }
114
+
115
+ $TotalCount = $EntityFiles.Count
116
+ $SuccessCount = 0
117
+ $FailedCount = 0
118
+
119
+ foreach ($Entity in $EntityFiles) {
120
+ if (Invoke-SyncEntity $Entity) {
121
+ $SuccessCount++
122
+ } else {
123
+ $FailedCount++
124
+ }
125
+ }
126
+
127
+ $ApplyLabel = if ($Apply) { "apply" } else { "dry-run" }
128
+ $ModeLabel = if ($WithData) { "with-data" } else { "index-only" }
129
+ Write-Host ""
130
+ Write-Host "[summary] target=all mode=$ModeLabel apply=$ApplyLabel total=$TotalCount success=$SuccessCount failed=$FailedCount"
131
+
132
+ if ($FailedCount -gt 0) { exit 1 }
133
+ } else {
134
+ $ok = Invoke-SyncEntity $Target
135
+ $ApplyLabel = if ($Apply) { "apply" } else { "dry-run" }
136
+ $ModeLabel = if ($WithData) { "with-data" } else { "index-only" }
137
+ if ($ok) {
138
+ Write-Host ""
139
+ Write-Host "[summary] target=$Target mode=$ModeLabel apply=$ApplyLabel total=1 success=1 failed=0"
140
+ } else {
141
+ Write-Host ""
142
+ Write-Host "[summary] target=$Target mode=$ModeLabel apply=$ApplyLabel total=1 success=0 failed=1"
143
+ exit 1
144
+ }
145
+ }