create-entity-server 0.7.3 → 0.7.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-entity-server",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Create a new entity-server project in one command — like create-react-app or create-vite.",
5
5
  "keywords": [
6
6
  "entity-server",
@@ -74,6 +74,43 @@ get_env_value() {
74
74
  fi
75
75
  }
76
76
 
77
+ set_env_key() {
78
+ local env_file="$1"
79
+ local key="$2"
80
+ local value="$3"
81
+
82
+ if grep -q -E "^${key}=" "$env_file"; then
83
+ sed -i "s|^${key}=.*|${key}=${value}|" "$env_file"
84
+ return
85
+ fi
86
+
87
+ printf '\n%s=%s\n' "$key" "$value" >> "$env_file"
88
+ }
89
+
90
+ update_adjacent_as_env() {
91
+ local api_key="$1"
92
+ local hmac_secret="$2"
93
+ local sibling_root
94
+ local candidate_dir
95
+ local candidate_env
96
+ local updated_envs=()
97
+
98
+ sibling_root="$(dirname "$PROJECT_ROOT")"
99
+
100
+ for candidate_dir in "$sibling_root/as" "$sibling_root/entity-app-server"; do
101
+ candidate_env="$candidate_dir/.env"
102
+ if [ ! -d "$candidate_dir" ] || [ ! -f "$candidate_env" ]; then
103
+ continue
104
+ fi
105
+
106
+ set_env_key "$candidate_env" "ENTITY_API_KEY" "$api_key"
107
+ set_env_key "$candidate_env" "ENTITY_HMAC_SECRET" "$hmac_secret"
108
+ updated_envs+=("$candidate_env")
109
+ done
110
+
111
+ printf '%s\n' "${updated_envs[@]}"
112
+ }
113
+
77
114
  get_database_default_group() {
78
115
  grep -E '"default"[[:space:]]*:' "$PROJECT_ROOT/configs/database.json" \
79
116
  | head -n 1 \
@@ -227,15 +264,7 @@ case "$1" in
227
264
  if [ -n "$NEW_API_KEY" ] && [ -n "$NEW_HMAC" ]; then
228
265
  warn_running_server_reload_needed
229
266
 
230
- # 게이트웨이 .env 자동 업데이트 (개발 환경: entity-app-server/ 폴더가 같은 레벨에 있을 때만)
231
- GW_DIR="$(dirname "$PROJECT_ROOT")/entity-app-server"
232
- GW_ENV="$GW_DIR/.env"
233
- GW_UPDATED=0
234
- if [ -d "$GW_DIR" ] && [ -f "$GW_ENV" ]; then
235
- sed -i "s|^ENTITY_API_KEY=.*|ENTITY_API_KEY=$NEW_API_KEY|" "$GW_ENV"
236
- sed -i "s|^ENTITY_HMAC_SECRET=.*|ENTITY_HMAC_SECRET=$NEW_HMAC|" "$GW_ENV"
237
- GW_UPDATED=1
238
- fi
267
+ mapfile -t UPDATED_AS_ENVS < <(update_adjacent_as_env "$NEW_API_KEY" "$NEW_HMAC")
239
268
 
240
269
  echo ""
241
270
  echo "=================================================="
@@ -248,11 +277,21 @@ case "$1" in
248
277
  echo " ENTITY_API_KEY = $NEW_API_KEY"
249
278
  echo " ENTITY_HMAC_SECRET = $NEW_HMAC"
250
279
  echo ""
251
- if [ "$GW_UPDATED" = "1" ]; then
280
+ if [ "${#UPDATED_AS_ENVS[@]}" -gt 0 ]; then
281
+ if [ "$LANGUAGE" = "en" ]; then
282
+ echo " ✓ Updated adjacent AS .env files:"
283
+ else
284
+ echo " ✓ 같은 레벨 AS .env 업데이트 완료:"
285
+ fi
286
+ for updated_env in "${UPDATED_AS_ENVS[@]}"; do
287
+ echo " - $updated_env"
288
+ done
289
+ echo ""
290
+ else
252
291
  if [ "$LANGUAGE" = "en" ]; then
253
- echo " Updated: entity-app-server/.env"
292
+ echo " ℹ️ No adjacent as/.env file was found to update automatically."
254
293
  else
255
- echo " 업데이트 완료: entity-app-server/.env"
294
+ echo " ℹ️ 자동 업데이트할 같은 레벨 as/.env 파일을 찾지 못했습니다."
256
295
  fi
257
296
  echo ""
258
297
  fi