backport: feat(scripts): add configure-local.sh for dashmate network setup#640
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new Bash script is added that configures a local Dash Evo Tool environment by reading dashmate configuration details and updating a local .env file with connection parameters including RPC credentials, service ports, and API addresses. Changes
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Hide RPC password from console output, show "(found)" instead - Support DASHMATE_CMD env var for custom dashmate command (e.g. DASHMATE_CMD="yarn dashmate" ./configure-local.sh) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
scripts/configure-local.sh (1)
18-22:⚠️ Potential issue | 🟠 MajorHandle Windows config directory to avoid writing .env to the wrong location.
Line 18-22 only covers macOS and XDG-based paths. On Windows, the app expects
%APPDATA%\Dash-Evo-Tool\config\.env, so the script currently targets the wrong location when run under Git Bash/MSYS. Add a Windows branch.Suggested patch
case "$(uname)" in Darwin) ENV_DIR="$HOME/Library/Application Support/Dash-Evo-Tool" ;; - *) ENV_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/dash-evo-tool" ;; + MINGW*|MSYS*|CYGWIN*) + if command -v cygpath >/dev/null 2>&1; then + ENV_DIR="$(cygpath -u "${APPDATA:-$LOCALAPPDATA}")/Dash-Evo-Tool/config" + else + ENV_DIR="${APPDATA:-$LOCALAPPDATA}/Dash-Evo-Tool/config" + fi + ;; + *) ENV_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/dash-evo-tool" ;; esacBased on learnings: Configuration should be loaded from
.envfiles in platform-specific application directories: macOS (~/Library/Application Support/Dash-Evo-Tool/.env), Linux (~/.config/dash-evo-tool/.env), Windows (C:\Users\<User>\AppData\Roaming\Dash-Evo-Tool\config\.env).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/configure-local.sh` around lines 18 - 22, The script's OS branch (case "$(uname)") only handles Darwin and XDG-based Linux paths, so add a Windows branch that detects MSYS/CYGWIN/MINGW unames and sets ENV_DIR to the user's roaming AppData "Dash-Evo-Tool/config" (use the $APPDATA environment variable) before ENV_FILE is computed; update the case arms in the case "$(uname)" block so ENV_DIR is set to "$APPDATA/Dash-Evo-Tool/config" for Windows shells (ensure fallback to existing XDG/default for other unrecognized systems), keeping the existing ENV_FILE="$ENV_DIR/.env" usage.
🧹 Nitpick comments (2)
scripts/configure-local.sh (2)
26-31: Add explicit errors for missing port values.If
dashmate config getfails for RPC/ZMQ/DAPI ports,set -ewill exit without a clear reason. Mirror the RPC password handling for clearer diagnostics.Suggested patch
-RPC_PORT=$($DASHMATE config get core.rpc.port --config="$CONFIG") -ZMQ_PORT=$($DASHMATE config get core.zmq.port --config="$CONFIG") -DAPI_PORT=$($DASHMATE config get platform.gateway.listeners.dapiAndDrive.port --config="$CONFIG") +RPC_PORT=$($DASHMATE config get core.rpc.port --config="$CONFIG" 2>/dev/null) \ + || { echo "Error: Could not read RPC port for '$CONFIG'."; exit 1; } +ZMQ_PORT=$($DASHMATE config get core.zmq.port --config="$CONFIG" 2>/dev/null) \ + || { echo "Error: Could not read ZMQ port for '$CONFIG'."; exit 1; } +DAPI_PORT=$($DASHMATE config get platform.gateway.listeners.dapiAndDrive.port --config="$CONFIG" 2>/dev/null) \ + || { echo "Error: Could not read DAPI port for '$CONFIG'."; exit 1; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/configure-local.sh` around lines 26 - 31, The port variables (RPC_PORT, ZMQ_PORT, DAPI_PORT) lack explicit failure handling like RPC_PASSWORD does, so when `$DASHMATE config get` fails the script may exit with an unclear error; update the assignments for RPC_PORT, ZMQ_PORT, and DAPI_PORT to mirror the RPC_PASSWORD pattern: run `$DASHMATE config get ... --config="$CONFIG"` capturing stderr to /dev/null and add an `|| { echo "Error: Could not read <PORT_NAME>. Is dashmate installed and '$CONFIG' configured?"; exit 1; }` fallback for each, referencing the existing RPC_PASSWORD handling and using the DASHMATE and CONFIG variables to locate the calls.
60-66: Preferprintfoverechowhen piping file content.
echocan treat leading-nor backslashes specially.printfavoids edge-case mangling of existing.envlines.Suggested patch
-CLEANED=$(echo "$CLEANED" | sed -e :a -e '/^\n*$/{$d;N;ba}') +CLEANED=$(printf '%s\n' "$CLEANED" | sed -e :a -e '/^\n*$/{$d;N;ba}')🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/configure-local.sh` around lines 60 - 66, The pipeline that removes trailing blank lines uses echo which can mangle certain lines; replace the echo invocation with printf to preserve content: change the assignment that sets CLEANED with sed from CLEANED=$(echo "$CLEANED" | sed -e :a -e '/^\n*$/{$d;N;ba}') to use printf (e.g., CLEANED=$(printf '%s\n' "$CLEANED" | sed -e :a -e '/^\n*$/{$d;N;ba'})) so the CLEANED variable and subsequent printf '%s\n\n%s\n' "$CLEANED" "$LOCAL_BLOCK" behavior is unchanged but avoids echo edge-cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/configure-local.sh`:
- Around line 42-49: When composing LOCAL_BLOCK in configure-local.sh, the RPC
password (LOCAL_core_rpc_password) must be quoted and have any embedded single
quotes escaped so values with #, spaces, or $ are not truncated or interpolated;
change the code that inserts ${RPC_PASSWORD} into LOCAL_core_rpc_password to
first produce an escaped version (replace each ' with '\'' or equivalent) and
wrap the final value in single quotes, then use that escaped-and-quoted variable
when building LOCAL_BLOCK so the .env line is safe to parse.
---
Duplicate comments:
In `@scripts/configure-local.sh`:
- Around line 18-22: The script's OS branch (case "$(uname)") only handles
Darwin and XDG-based Linux paths, so add a Windows branch that detects
MSYS/CYGWIN/MINGW unames and sets ENV_DIR to the user's roaming AppData
"Dash-Evo-Tool/config" (use the $APPDATA environment variable) before ENV_FILE
is computed; update the case arms in the case "$(uname)" block so ENV_DIR is set
to "$APPDATA/Dash-Evo-Tool/config" for Windows shells (ensure fallback to
existing XDG/default for other unrecognized systems), keeping the existing
ENV_FILE="$ENV_DIR/.env" usage.
---
Nitpick comments:
In `@scripts/configure-local.sh`:
- Around line 26-31: The port variables (RPC_PORT, ZMQ_PORT, DAPI_PORT) lack
explicit failure handling like RPC_PASSWORD does, so when `$DASHMATE config get`
fails the script may exit with an unclear error; update the assignments for
RPC_PORT, ZMQ_PORT, and DAPI_PORT to mirror the RPC_PASSWORD pattern: run
`$DASHMATE config get ... --config="$CONFIG"` capturing stderr to /dev/null and
add an `|| { echo "Error: Could not read <PORT_NAME>. Is dashmate installed and
'$CONFIG' configured?"; exit 1; }` fallback for each, referencing the existing
RPC_PASSWORD handling and using the DASHMATE and CONFIG variables to locate the
calls.
- Around line 60-66: The pipeline that removes trailing blank lines uses echo
which can mangle certain lines; replace the echo invocation with printf to
preserve content: change the assignment that sets CLEANED with sed from
CLEANED=$(echo "$CLEANED" | sed -e :a -e '/^\n*$/{$d;N;ba}') to use printf
(e.g., CLEANED=$(printf '%s\n' "$CLEANED" | sed -e :a -e '/^\n*$/{$d;N;ba'})) so
the CLEANED variable and subsequent printf '%s\n\n%s\n' "$CLEANED"
"$LOCAL_BLOCK" behavior is unchanged but avoids echo edge-cases.
| LOCAL_BLOCK="LOCAL_dapi_addresses=http://${HOST}:${DAPI_PORT} | ||
| LOCAL_core_host=${HOST} | ||
| LOCAL_core_rpc_port=${RPC_PORT} | ||
| LOCAL_core_rpc_user=dashmate | ||
| LOCAL_core_rpc_password=${RPC_PASSWORD} | ||
| LOCAL_insight_api_url=http://localhost:3001/insight-api | ||
| LOCAL_core_zmq_endpoint=tcp://${HOST}:${ZMQ_PORT} | ||
| LOCAL_show_in_ui=true" |
There was a problem hiding this comment.
Quote/escape RPC password before writing .env.
If the RPC password contains #, spaces, or $, the .env line can be truncated or mis-parsed. Escape and quote it when building LOCAL_BLOCK.
Suggested patch
+RPC_PASSWORD_ESCAPED=$(printf '%s' "$RPC_PASSWORD" | sed 's/\\/\\\\/g; s/"/\\"/g')
LOCAL_BLOCK="LOCAL_dapi_addresses=http://${HOST}:${DAPI_PORT}
LOCAL_core_host=${HOST}
LOCAL_core_rpc_port=${RPC_PORT}
LOCAL_core_rpc_user=dashmate
-LOCAL_core_rpc_password=${RPC_PASSWORD}
+LOCAL_core_rpc_password=\"${RPC_PASSWORD_ESCAPED}\"
LOCAL_insight_api_url=http://localhost:3001/insight-api
LOCAL_core_zmq_endpoint=tcp://${HOST}:${ZMQ_PORT}
LOCAL_show_in_ui=true"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| LOCAL_BLOCK="LOCAL_dapi_addresses=http://${HOST}:${DAPI_PORT} | |
| LOCAL_core_host=${HOST} | |
| LOCAL_core_rpc_port=${RPC_PORT} | |
| LOCAL_core_rpc_user=dashmate | |
| LOCAL_core_rpc_password=${RPC_PASSWORD} | |
| LOCAL_insight_api_url=http://localhost:3001/insight-api | |
| LOCAL_core_zmq_endpoint=tcp://${HOST}:${ZMQ_PORT} | |
| LOCAL_show_in_ui=true" | |
| RPC_PASSWORD_ESCAPED=$(printf '%s' "$RPC_PASSWORD" | sed 's/\\/\\\\/g; s/"/\\"/g') | |
| LOCAL_BLOCK="LOCAL_dapi_addresses=http://${HOST}:${DAPI_PORT} | |
| LOCAL_core_host=${HOST} | |
| LOCAL_core_rpc_port=${RPC_PORT} | |
| LOCAL_core_rpc_user=dashmate | |
| LOCAL_core_rpc_password=\"${RPC_PASSWORD_ESCAPED}\" | |
| LOCAL_insight_api_url=http://localhost:3001/insight-api | |
| LOCAL_core_zmq_endpoint=tcp://${HOST}:${ZMQ_PORT} | |
| LOCAL_show_in_ui=true" |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/configure-local.sh` around lines 42 - 49, When composing LOCAL_BLOCK
in configure-local.sh, the RPC password (LOCAL_core_rpc_password) must be quoted
and have any embedded single quotes escaped so values with #, spaces, or $ are
not truncated or interpolated; change the code that inserts ${RPC_PASSWORD} into
LOCAL_core_rpc_password to first produce an escaped version (replace each ' with
'\'' or equivalent) and wrap the final value in single quotes, then use that
escaped-and-quoted variable when building LOCAL_BLOCK so the .env line is safe
to parse.
Wrap the RPC password value in single quotes when writing to .env to prevent mis-parsing if the password contains #, spaces, or $. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
scripts/configure-local.shthat reads dashmate config and populates.envwith LOCAL_ network settingslocal_seed).envfile preserving non-LOCAL settingsTest plan
./scripts/configure-local.sh./scripts/configure-local.sh my_config.envfile is created with correct LOCAL_ entries.envare preserved🤖 Co-authored by Claudius the Magnificent AI Agent
Summary by CodeRabbit