diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ab4819..e1375b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -60,3 +60,18 @@ jobs: done echo "All lint checks passed!" + + - name: Check VERSION consistency + run: | + FILE_VERSION=$(cat VERSION) + SCRIPT_VERSION=$(grep 'x-release-please-version' install.sh | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') + UNINSTALL_VERSION=$(grep 'x-release-please-version' uninstall.sh | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') + if [ "$FILE_VERSION" != "$SCRIPT_VERSION" ]; then + echo "ERROR: VERSION ($FILE_VERSION) != install.sh ($SCRIPT_VERSION)" + exit 1 + fi + if [ "$FILE_VERSION" != "$UNINSTALL_VERSION" ]; then + echo "ERROR: VERSION ($FILE_VERSION) != uninstall.sh ($UNINSTALL_VERSION)" + exit 1 + fi + echo "VERSION consistency check passed: $FILE_VERSION" diff --git a/README.md b/README.md index 94b5efa..f1b8daf 100644 --- a/README.md +++ b/README.md @@ -97,10 +97,29 @@ mv ~/Documents/WaveNotes ~/Library/Mobile\ Documents/com~apple~CloudDocs/WaveNot ln -s ~/Library/Mobile\ Documents/com~apple~CloudDocs/WaveNotes ~/Documents/WaveNotes ``` +## Troubleshooting + +### Widget fails after upgrading Wave Terminal to v0.14.0+ + +Wave Terminal v0.14.0 changed how authentication works for widget commands. If your note widget stopped working after upgrading Wave Terminal (you may see an authentication error or the editor fails to open), re-run the installer to regenerate the script: + +```bash +wave-notes-setup +``` + +This updates `~/bin/wave-scratch.sh` with the new token exchange mechanism. No data is lost — your existing notes and configuration are preserved. + +If you installed via Homebrew, update first: + +```bash +brew upgrade wave-notes-setup +wave-notes-setup +``` + ## Requirements - macOS -- [Wave Terminal](https://www.waveterm.dev/) +- [Wave Terminal](https://www.waveterm.dev/) (v0.14.0+ supported with automatic swap token exchange) - `jq` (optional, falls back to Python if missing) ## Security @@ -133,7 +152,7 @@ The project includes a comprehensive test suite using [bats](https://github.com/ # Install bats brew install bats-core -# Run all tests (77 tests) +# Run all tests (85 tests) ./test/run_tests.sh # Or run bats directly diff --git a/VERSION b/VERSION index 3eefcb9..38f77a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +2.0.1 diff --git a/install.sh b/install.sh index 16012d5..0735d76 100755 --- a/install.sh +++ b/install.sh @@ -1,11 +1,11 @@ #!/bin/bash -# wave-notes-setup v1.0.0 +# wave-notes-setup v2.0.1 # Configure Wave Terminal with a Warp-like notes system # https://github.com/qbandev/wave-notes-setup set -euo pipefail -VERSION="1.0.0" +VERSION="2.0.1" # x-release-please-version SCRIPT_NAME="wave-notes-setup" # Colors @@ -316,7 +316,7 @@ install_scratchpad_script() { # Generate the script with injected paths cat > "$script_path" << 'SCRIPT_EOF' #!/bin/bash -# Generated by wave-notes-setup v1.0.0 +# Generated by wave-notes-setup v2.0.1 # Re-run wave-notes-setup to update paths set -euo pipefail @@ -338,6 +338,8 @@ find_wsh() { return fi local paths=( + "$HOME/.config/waveterm/bin/wsh" + "$HOME/.waveterm/bin/wsh" "$HOME/Library/Application Support/waveterm/bin/wsh" "/usr/local/bin/wsh" "/opt/homebrew/bin/wsh" @@ -353,13 +355,34 @@ find_wsh() { WSH_CMD=$(find_wsh) -if [[ -n "$WSH_CMD" ]]; then - "$WSH_CMD" edit "$FILEPATH" -else +if [[ -z "$WSH_CMD" ]]; then echo "Error: 'wsh' command not found. Is Wave Terminal installed and running?" >&2 echo "File created at: $FILEPATH" >&2 exit 1 fi + +# Wave Terminal v0.14.0+ token exchange for cmd controller blocks. +# wsh token outputs shell code setting multiple env vars needed by wsh +# commands (not just WAVETERM_JWT), so eval is required here — matching +# Wave's own integration at ~/Library/Application Support/waveterm/shell/bash/.bashrc +if [[ -z "${WAVETERM_JWT:-}" && -n "${WAVETERM_SWAPTOKEN:-}" ]]; then + eval "$("$WSH_CMD" token "$WAVETERM_SWAPTOKEN" bash 2>/dev/null)" || true +fi + +ERR_FILE=$(mktemp) +if ! "$WSH_CMD" edit "$FILEPATH" 2>"$ERR_FILE"; then + wsh_err=$(cat "$ERR_FILE" 2>/dev/null) + rm -f "$ERR_FILE" + if printf '%s\n' "$wsh_err" | grep -q "WAVETERM"; then + echo "Error: Wave Terminal authentication failed." >&2 + echo "Try: Re-run 'wave-notes-setup' to update configuration." >&2 + else + echo "Error: Failed to open editor: $wsh_err" >&2 + fi + echo "Note created at: $FILEPATH" >&2 + exit 1 +fi +rm -f "$ERR_FILE" SCRIPT_EOF # Replace placeholder with actual path diff --git a/release-please-config.json b/release-please-config.json index b7f6bd0..85af6c4 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -6,10 +6,16 @@ "package-name": "wave-notes-setup", "changelog-path": "CHANGELOG.md", "extra-files": [ + "VERSION", { "type": "generic", "path": "install.sh", "glob": false + }, + { + "type": "generic", + "path": "uninstall.sh", + "glob": false } ] } diff --git a/test/install.bats b/test/install.bats index 2e820e6..a1cf2da 100644 --- a/test/install.bats +++ b/test/install.bats @@ -293,6 +293,92 @@ EOF assert_file_contains "$BIN_DIR/wave-scratch.sh" "find_wsh()" } +@test "install_scratchpad_script: find_wsh includes .config/waveterm/bin/wsh path" { + NOTES_DIR="$TEST_HOME/TestNotes" + BIN_DIR="$TEST_HOME/TestBin" + mkdir -p "$BIN_DIR" + + install_scratchpad_script + + assert_file_contains "$BIN_DIR/wave-scratch.sh" '.config/waveterm/bin/wsh' +} + +@test "install_scratchpad_script: find_wsh includes .waveterm/bin/wsh path" { + NOTES_DIR="$TEST_HOME/TestNotes" + BIN_DIR="$TEST_HOME/TestBin" + mkdir -p "$BIN_DIR" + + install_scratchpad_script + + assert_file_contains "$BIN_DIR/wave-scratch.sh" '.waveterm/bin/wsh' +} + +@test "install_scratchpad_script: find_wsh lists new paths before old paths" { + NOTES_DIR="$TEST_HOME/TestNotes" + BIN_DIR="$TEST_HOME/TestBin" + mkdir -p "$BIN_DIR" + + install_scratchpad_script + + # .config/waveterm/bin/wsh should appear before /usr/local/bin/wsh + local config_line old_line + config_line=$(grep -n '.config/waveterm/bin/wsh' "$BIN_DIR/wave-scratch.sh" | head -1 | cut -d: -f1) + old_line=$(grep -n '/usr/local/bin/wsh' "$BIN_DIR/wave-scratch.sh" | head -1 | cut -d: -f1) + [ "$config_line" -lt "$old_line" ] +} + +@test "install_scratchpad_script: contains swap token exchange logic" { + NOTES_DIR="$TEST_HOME/TestNotes" + BIN_DIR="$TEST_HOME/TestBin" + mkdir -p "$BIN_DIR" + + install_scratchpad_script + + assert_file_contains "$BIN_DIR/wave-scratch.sh" "WAVETERM_SWAPTOKEN" + assert_file_contains "$BIN_DIR/wave-scratch.sh" 'WSH_CMD.*token' +} + +@test "install_scratchpad_script: uses mktemp for error handling" { + NOTES_DIR="$TEST_HOME/TestNotes" + BIN_DIR="$TEST_HOME/TestBin" + mkdir -p "$BIN_DIR" + + install_scratchpad_script + + assert_file_contains "$BIN_DIR/wave-scratch.sh" "mktemp" + assert_file_contains "$BIN_DIR/wave-scratch.sh" "ERR_FILE" +} + +@test "install_scratchpad_script: swap token is backward compatible (no-op if JWT present)" { + NOTES_DIR="$TEST_HOME/TestNotes" + BIN_DIR="$TEST_HOME/TestBin" + mkdir -p "$BIN_DIR" + + install_scratchpad_script + + # The condition checks for empty WAVETERM_JWT, so it's a no-op if JWT is already set + # grep -F for fixed string since -z looks like a grep flag + grep -F 'WAVETERM_JWT' "$BIN_DIR/wave-scratch.sh" | grep -qF 'z "' +} + +@test "VERSION consistency: VERSION file matches install.sh" { + local file_version + file_version=$(cat "$BATS_TEST_DIRNAME/../VERSION") + local script_version + script_version=$(grep 'x-release-please-version' "$BATS_TEST_DIRNAME/../install.sh" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') + + [ "$file_version" = "$script_version" ] +} + +@test "VERSION consistency: VERSION file matches uninstall.sh" { + local file_version + file_version=$(cat "$BATS_TEST_DIRNAME/../VERSION") + local script_version + script_version=$(grep 'x-release-please-version' "$BATS_TEST_DIRNAME/../uninstall.sh" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') + + [ "$file_version" = "$script_version" ] +} + # ============================================================================= # install_widgets() tests # ============================================================================= diff --git a/uninstall.sh b/uninstall.sh index 26a1eef..009ef6f 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,10 +1,10 @@ #!/bin/bash -# wave-notes-setup uninstaller v1.0.0 +# wave-notes-setup uninstaller v2.0.1 # https://github.com/qbandev/wave-notes-setup set -euo pipefail -VERSION="1.0.0" +VERSION="2.0.1" # x-release-please-version # Colors RED='\033[0;31m'