Skip to content

backport: feat(scripts): add configure-local.sh for dashmate network setup#640

Merged
lklimek merged 3 commits into
v1.0-devfrom
zk-extract/configure-local-script
Feb 24, 2026
Merged

backport: feat(scripts): add configure-local.sh for dashmate network setup#640
lklimek merged 3 commits into
v1.0-devfrom
zk-extract/configure-local-script

Conversation

@lklimek
Copy link
Copy Markdown
Contributor

@lklimek lklimek commented Feb 24, 2026

Summary

  • New scripts/configure-local.sh that reads dashmate config and populates .env with LOCAL_ network settings
  • Reads RPC password, ports (RPC, ZMQ, DAPI) from dashmate config
  • Supports custom config name (defaults to local_seed)
  • Creates or updates the .env file preserving non-LOCAL settings

Test plan

  • Run with default config: ./scripts/configure-local.sh
  • Run with custom config: ./scripts/configure-local.sh my_config
  • Verify .env file is created with correct LOCAL_ entries
  • Verify existing non-LOCAL entries in .env are preserved

🤖 Co-authored by Claudius the Magnificent AI Agent

Summary by CodeRabbit

  • Chores
    • Added an automated local environment configuration tool that discovers and applies necessary connection settings across macOS and Linux platforms, streamlining the setup process for local development environments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lklimek lklimek self-assigned this Feb 24, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 24, 2026

Warning

Rate limit exceeded

@lklimek has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 86e4d63 and 0bf31a4.

📒 Files selected for processing (1)
  • scripts/configure-local.sh
📝 Walkthrough

Walkthrough

A 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

Cohort / File(s) Summary
Configuration Script
scripts/configure-local.sh
New Bash script that integrates with dashmate CLI, extracts connection details (RPC password, ports, service addresses), and updates or creates a local .env file with LOCAL_ prefixed environment variables while preserving existing non-LOCAL_ configuration.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A script hops softly into place,
Reads dashmate's secrets with grace,
Configures .env with care,
Local connections everywhere! ✨
The Dash Evo Tool takes flight! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a new configure-local.sh script for dashmate network setup, which is the core functionality of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch zk-extract/configure-local-script

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread scripts/configure-local.sh Outdated
Comment thread scripts/configure-local.sh Outdated
- 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>
@lklimek lklimek marked this pull request as ready for review February 24, 2026 11:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
scripts/configure-local.sh (1)

18-22: ⚠️ Potential issue | 🟠 Major

Handle 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" ;;
 esac

Based on learnings: Configuration should be loaded from .env files 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 get fails for RPC/ZMQ/DAPI ports, set -e will 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: Prefer printf over echo when piping file content.

echo can treat leading -n or backslashes specially. printf avoids edge-case mangling of existing .env lines.

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.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b42950 and 86e4d63.

📒 Files selected for processing (1)
  • scripts/configure-local.sh

Comment on lines +42 to +49
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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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>
@lklimek lklimek merged commit a8f4901 into v1.0-dev Feb 24, 2026
2 checks passed
@lklimek lklimek deleted the zk-extract/configure-local-script branch February 24, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant