ework-aio 0.1.16 → 0.1.17

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.
Files changed (2) hide show
  1. package/bin/install.sh +54 -0
  2. package/package.json +1 -1
package/bin/install.sh CHANGED
@@ -395,6 +395,11 @@ write_web_env() {
395
395
  mkdir -p "$(dirname "$WEB_ENV")"
396
396
  if [[ -f "$WEB_ENV" ]]; then
397
397
  log "Preserving existing $WEB_ENV"
398
+ # Older installs (pre-0.1.16) may have a .env that predates some keys
399
+ # ework-web's Zod schema now requires (WORK_COOKIE_SECRET in particular).
400
+ # Fill any missing required keys with fresh defaults so the preserved
401
+ # .env doesn't crash the next start. User-set keys are never overwritten.
402
+ ensure_web_env_keys
398
403
  return
399
404
  fi
400
405
  local tok secret webhook
@@ -420,6 +425,39 @@ EOF
420
425
  ok "Wrote $WEB_ENV"
421
426
  }
422
427
 
428
+ # ensure_env_key: append KEY=value to $file iff KEY is not already present.
429
+ # Used to forward-fill schema-required keys on preserved .env files without
430
+ # clobbering any user-set values.
431
+ ensure_env_key() {
432
+ local file="$1" key="$2" val="$3"
433
+ if ! grep -qE "^${key}=" "$file" 2>/dev/null; then
434
+ printf '%s=%s\n' "$key" "$val" >> "$file"
435
+ log " + added missing key: $key"
436
+ fi
437
+ }
438
+
439
+ ensure_web_env_keys() {
440
+ # Only fills keys that are missing; never overwrites existing values.
441
+ # Tokens / secrets get fresh random values (safe because if they were
442
+ # missing, web couldn't have started, so nothing depends on them yet).
443
+ local tok secret webhook
444
+ tok=$(gen_token 20)
445
+ secret=$(gen_token 24)
446
+ webhook=$(gen_token 20)
447
+ ensure_env_key "$WEB_ENV" WORK_PORT "$WORK_PORT"
448
+ ensure_env_key "$WEB_ENV" WORK_HOST "127.0.0.1"
449
+ ensure_env_key "$WEB_ENV" WORK_TOKEN "$tok"
450
+ ensure_env_key "$WEB_ENV" WORK_COOKIE_SECRET "$secret"
451
+ ensure_env_key "$WEB_ENV" WORK_OPERATOR_LOGIN "$USER"
452
+ ensure_env_key "$WEB_ENV" WORK_WRITES_ENABLED "true"
453
+ ensure_env_key "$WEB_ENV" WORK_DB_PATH "$WEB_DATA_DIR/ework.db"
454
+ ensure_env_key "$WEB_ENV" WORK_ATTACHMENT_ROOT "$WEB_DATA_DIR/attachments"
455
+ ensure_env_key "$WEB_ENV" WORK_FILE_ROOTS "/tmp,$DATA_DIR"
456
+ ensure_env_key "$WEB_ENV" WORK_DAEMON_BOT_LOGIN "$BOT_NAME"
457
+ ensure_env_key "$WEB_ENV" WORK_DAEMON_WEBHOOK_URL "http://127.0.0.1:$DAEMON_PORT"
458
+ ensure_env_key "$WEB_ENV" WORK_DAEMON_WEBHOOK_SECRET "$webhook"
459
+ }
460
+
423
461
  write_daemon_env() {
424
462
  mkdir -p "$(dirname "$DAEMON_ENV")"
425
463
  local bot_token="$1"
@@ -427,6 +465,22 @@ write_daemon_env() {
427
465
  # Reuse webhook secret from web env so daemon's signature matches web's verify
428
466
  webhook=$(awk -F= '/^WORK_DAEMON_WEBHOOK_SECRET=/{print $2}' "$WEB_ENV" 2>/dev/null || true)
429
467
  [[ -n "$webhook" ]] || webhook=$(gen_token 20)
468
+ if [[ -f "$DAEMON_ENV" ]]; then
469
+ log "Preserving existing $DAEMON_ENV"
470
+ # Same forward-fill pattern as web: required keys get filled if missing.
471
+ ensure_env_key "$DAEMON_ENV" DAEMON_ENV "production"
472
+ ensure_env_key "$DAEMON_ENV" DAEMON_PORT "$DAEMON_PORT"
473
+ ensure_env_key "$DAEMON_ENV" DAEMON_HOST "127.0.0.1"
474
+ ensure_env_key "$DAEMON_ENV" DAEMON_DB_PATH "$DAEMON_DATA_DIR/ework-daemon.db"
475
+ ensure_env_key "$DAEMON_ENV" GITEA_URL "http://127.0.0.1:$WORK_PORT"
476
+ ensure_env_key "$DAEMON_ENV" GITEA_TOKEN "$bot_token"
477
+ ensure_env_key "$DAEMON_ENV" GITEA_WEBHOOK_SECRET "$webhook"
478
+ ensure_env_key "$DAEMON_ENV" BOT_USERNAME "$BOT_NAME"
479
+ ensure_env_key "$DAEMON_ENV" BOT_TOKEN "$bot_token"
480
+ ensure_env_key "$DAEMON_ENV" OPENCODE_BINARY "$(command -v opencode)"
481
+ ensure_env_key "$DAEMON_ENV" OPENCODE_BASE_WORKDIR "$DATA_DIR/opencode-workdir"
482
+ return
483
+ fi
430
484
  cat > "$DAEMON_ENV" <<EOF
431
485
  # Generated by ework-aio at $(date -u +%Y-%m-%dT%H:%M:%SZ)
432
486
  DAEMON_ENV=production
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-aio",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "All-in-one installer for ework (issue tracker) + ework-daemon (AI bridge) + opencode-ework (plugin). One command: npm i -g ework-aio && ework-aio install.",
5
5
  "type": "module",
6
6
  "license": "MIT",