This commit is contained in:
+16
-3
@@ -1,6 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
playwright=false
|
||||
if (($#)); then
|
||||
if [[ "$#" -ne 1 || "$1" != "--playwright" ]]; then
|
||||
printf 'Usage: %s [--playwright]\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
playwright=true
|
||||
fi
|
||||
|
||||
for command in bun curl jq sha256sum tar; do
|
||||
command -v "$command" >/dev/null || { printf 'Required command not found: %s\n' "$command" >&2; exit 1; }
|
||||
done
|
||||
@@ -57,15 +66,19 @@ if [[ ! -e "$config_source" ]]; then
|
||||
config_source="$install/empty-config.json"
|
||||
printf '{}\n' > "$config_source"
|
||||
fi
|
||||
jq -e '
|
||||
jq -e --argjson playwright "$playwright" '
|
||||
if type != "object" then error("opencode.json must contain an object") else . end
|
||||
| if (.plugins // []) | type != "array" then error("opencode.json plugins must be an array") else . end
|
||||
| .["$schema"] = (.["$schema"] // "https://opencode.ai/config.json")
|
||||
| .plugins = (.plugins // [])
|
||||
| if any(.plugins[]?; .package == "./plugins/stanp-opencode") then . else
|
||||
| if any(.plugins[]?; .package == "./plugins/stanp-opencode") then
|
||||
if $playwright then
|
||||
.plugins |= map(if .package == "./plugins/stanp-opencode" then .options = ((.options // {}) + { playwright: true }) else . end)
|
||||
else . end
|
||||
else
|
||||
.plugins += [{
|
||||
package: "./plugins/stanp-opencode",
|
||||
options: { mode: "gpt", provider: "openai", lunaPriority: true }
|
||||
options: ({ mode: "gpt", provider: "openai", lunaPriority: true } + if $playwright then { playwright: true } else {} end)
|
||||
}]
|
||||
end
|
||||
' "$config_source" > "$install/opencode.json"
|
||||
|
||||
Reference in New Issue
Block a user