ework-aio 0.1.1 → 0.1.2
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/bin/install.sh +40 -15
- package/package.json +1 -1
package/bin/install.sh
CHANGED
|
@@ -409,7 +409,32 @@ else
|
|
|
409
409
|
fi
|
|
410
410
|
|
|
411
411
|
# ─── Register opencode-ework plugin ────────────────────────────────────────
|
|
412
|
+
# Safety: every edit writes to a temp file, validates with `jq -e .`, only
|
|
413
|
+
# then atomically replaces the original. A timestamped .bak is always kept.
|
|
412
414
|
mkdir -p "$(dirname "$OPENCODE_CFG")"
|
|
415
|
+
|
|
416
|
+
json_edit() {
|
|
417
|
+
# $1 = file, $2 = jq program, $3 = expected JSON type (optional, e.g. "object").
|
|
418
|
+
# Writes to temp, validates (parses + optional type check), only then swaps.
|
|
419
|
+
# Backup at $file.bak.<epoch>.
|
|
420
|
+
local file="$1" prog="$2" expected="${3:-}" tmp
|
|
421
|
+
tmp=$(mktemp)
|
|
422
|
+
if ! jq "$prog" "$file" > "$tmp" 2>/dev/null; then
|
|
423
|
+
rm -f "$tmp"
|
|
424
|
+
die "jq edit failed on $file (program: $prog)"
|
|
425
|
+
fi
|
|
426
|
+
if ! jq -e . "$tmp" >/dev/null 2>&1; then
|
|
427
|
+
rm -f "$tmp"
|
|
428
|
+
die "jq edit produced invalid JSON on $file — aborted, original untouched"
|
|
429
|
+
fi
|
|
430
|
+
if [[ -n "$expected" ]] && ! jq -e "type == \"$expected\"" "$tmp" >/dev/null 2>&1; then
|
|
431
|
+
rm -f "$tmp"
|
|
432
|
+
die "jq edit produced wrong type on $file (expected $expected) — aborted, original untouched"
|
|
433
|
+
fi
|
|
434
|
+
cp "$file" "$file.bak.$(date +%s)"
|
|
435
|
+
mv "$tmp" "$file"
|
|
436
|
+
}
|
|
437
|
+
|
|
413
438
|
if [[ ! -f "$OPENCODE_CFG" ]]; then
|
|
414
439
|
log "Writing $OPENCODE_CFG (registering opencode-ework plugin)"
|
|
415
440
|
cat > "$OPENCODE_CFG" <<'EOF'
|
|
@@ -418,26 +443,26 @@ if [[ ! -f "$OPENCODE_CFG" ]]; then
|
|
|
418
443
|
"plugin": ["opencode-ework@latest"]
|
|
419
444
|
}
|
|
420
445
|
EOF
|
|
421
|
-
elif grep -
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
"$OPENCODE_CFG" > "$tmp" && mv "$tmp" "$OPENCODE_CFG"
|
|
430
|
-
ok "Plugin upgraded (backup at $OPENCODE_CFG.bak.*)"
|
|
431
|
-
fi
|
|
446
|
+
elif grep -q '"opencode-ework@latest"' "$OPENCODE_CFG"; then
|
|
447
|
+
ok "opencode-ework@latest already in $OPENCODE_CFG"
|
|
448
|
+
elif grep -q '"opencode-ework"' "$OPENCODE_CFG"; then
|
|
449
|
+
log "Upgrading opencode-ework → opencode-ework@latest in $OPENCODE_CFG"
|
|
450
|
+
json_edit "$OPENCODE_CFG" \
|
|
451
|
+
'.plugin = ((.plugin // []) | map(if . == "opencode-ework" then "opencode-ework@latest" else . end))' \
|
|
452
|
+
object
|
|
453
|
+
ok "Plugin upgraded (backup at $OPENCODE_CFG.bak.*)"
|
|
432
454
|
else
|
|
433
455
|
log "Merging opencode-ework@latest into existing $OPENCODE_CFG"
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
"$OPENCODE_CFG" > "$tmp" && mv "$tmp" "$OPENCODE_CFG"
|
|
456
|
+
json_edit "$OPENCODE_CFG" \
|
|
457
|
+
'if .plugin then .plugin += ["opencode-ework@latest"] else . + {plugin:["opencode-ework@latest"]} end' \
|
|
458
|
+
object
|
|
438
459
|
ok "Plugin registered (backup at $OPENCODE_CFG.bak.*)"
|
|
439
460
|
fi
|
|
440
461
|
|
|
462
|
+
if ! jq -e 'type == "object"' "$OPENCODE_CFG" >/dev/null 2>&1; then
|
|
463
|
+
warn "$OPENCODE_CFG is not a JSON object — check $OPENCODE_CFG.bak.* for restore"
|
|
464
|
+
fi
|
|
465
|
+
|
|
441
466
|
# ─── Done ──────────────────────────────────────────────────────────────────
|
|
442
467
|
hr
|
|
443
468
|
ok "Install complete."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ework-aio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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",
|