High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: add npm CLI macOS e2e and default macOS config to ~/.pinchtab
Luigi Agosti96a60c29fc3d
diff --git a/.github/workflows/ci-e2e.yml b/.github/workflows/ci-e2e.ymlindex 7373ae45..2a6c6161 100644--- a/.github/workflows/ci-e2e.yml+++ b/.github/workflows/ci-e2e.yml@@ -35,6 +35,7 @@ jobs:api_extended_touched: ${{ steps.changes.outputs.api_extended_touched }}cli_extended_touched: ${{ steps.changes.outputs.cli_extended_touched }}infra_extended_touched: ${{ steps.changes.outputs.infra_extended_touched }}+ npm_cli_touched: ${{ steps.changes.outputs.npm_cli_touched }}steps:- uses: actions/checkout@v6with:@@ -65,6 +66,12 @@ jobs:echo "infra_extended_touched=false" >> "$GITHUB_OUTPUT"fi+ if echo "$CHANGED" | grep -E '^npm/|^cmd/pinchtab/|^internal/config/|^\.github/workflows/(ci-e2e|reusable-npm-e2e|reusable-npm|reusable-release-publish)\.yml$' >/dev/null; then+ echo "npm_cli_touched=true" >> "$GITHUB_OUTPUT"+ else+ echo "npm_cli_touched=false" >> "$GITHUB_OUTPUT"+ fi+api:needs: [detect-changes]if: always() && (needs.detect-changes.result == 'success' || needs.detect-changes.result == 'skipped')@@ -161,3 +168,18 @@ jobs:summary_title: E2E Infra Extended Teststimeout_minutes: 25compose_file: tests/e2e/docker-compose-multi.yml++ npm-cli-macos-pr:+ needs: [detect-changes]+ if: github.event_name == 'pull_request' && needs.detect-changes.outputs.npm_cli_touched == 'true'+ uses: ./.github/workflows/reusable-npm-e2e.yml+ with:+ ref: ${{ github.sha }}+ summary_title: E2E npm CLI Tests (macOS)++ npm-cli-macos:+ if: github.event_name == 'workflow_dispatch' && inputs.suite == 'all'+ uses: ./.github/workflows/reusable-npm-e2e.yml+ with:+ ref: ${{ github.sha }}+ summary_title: E2E npm CLI Tests (macOS)diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex ab16b6cf..43f1f8fa 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -63,6 +63,14 @@ jobs:ref: ${{ needs.validate.outputs.sha }}version: ${{ needs.validate.outputs.version }}+ e2e-npm-cli-macos:+ needs: validate+ uses: ./.github/workflows/reusable-npm-e2e.yml+ with:+ ref: ${{ needs.validate.outputs.sha }}+ version: ${{ needs.validate.outputs.version }}+ summary_title: Release E2E npm CLI (macOS)+e2e-api-extended:needs: validateuses: ./.github/workflows/reusable-e2e.yml@@ -157,6 +165,7 @@ jobs:- dashboard-checks- docs-checks- npm-checks+ - e2e-npm-cli-macos- e2e-api-extended- e2e-cli-extended- e2e-infra-extended@@ -186,6 +195,7 @@ jobs:echo "| Dashboard | ✅ |" >> "$GITHUB_STEP_SUMMARY"echo "| Docs | ✅ |" >> "$GITHUB_STEP_SUMMARY"echo "| npm | ✅ |" >> "$GITHUB_STEP_SUMMARY"+ echo "| E2E npm CLI (macOS) | ${{ needs.e2e-npm-cli-macos.result == 'success' && '✅' || '⚠️ ' }}${{ needs.e2e-npm-cli-macos.result }} |" >> "$GITHUB_STEP_SUMMARY"echo "| Publish dry run | ✅ |" >> "$GITHUB_STEP_SUMMARY"echo "| Docker smoke | ${{ needs.docker-smoke.result == 'success' && '✅' || '⚠️ ' }}${{ needs.docker-smoke.result }} |" >> "$GITHUB_STEP_SUMMARY"echo "| E2E API | ${{ needs.e2e-api-extended.result == 'success' && '✅' || '⚠️ ' }}${{ needs.e2e-api-extended.result }} |" >> "$GITHUB_STEP_SUMMARY"@@ -193,7 +203,7 @@ jobs:echo "| E2E Infra | ${{ needs.e2e-infra-extended.result == 'success' && '✅' || '⚠️ ' }}${{ needs.e2e-infra-extended.result }} |" >> "$GITHUB_STEP_SUMMARY"echo "" >> "$GITHUB_STEP_SUMMARY"- if [ "${{ needs.e2e-api-extended.result }}" != "success" ] || [ "${{ needs.e2e-cli-extended.result }}" != "success" ] || [ "${{ needs.e2e-infra-extended.result }}" != "success" ] || [ "${{ needs.docker-smoke.result }}" != "success" ]; then+ if [ "${{ needs.e2e-npm-cli-macos.result }}" != "success" ] || [ "${{ needs.e2e-api-extended.result }}" != "success" ] || [ "${{ needs.e2e-cli-extended.result }}" != "success" ] || [ "${{ needs.e2e-infra-extended.result }}" != "success" ] || [ "${{ needs.docker-smoke.result }}" != "success" ]; thenecho "⚠️ **Some checks failed — review artifacts before approving.**" >> "$GITHUB_STEP_SUMMARY"fidiff --git a/.github/workflows/reusable-npm-e2e.yml b/.github/workflows/reusable-npm-e2e.ymlnew file mode 100644index 00000000..c1fdfec1--- /dev/null+++ b/.github/workflows/reusable-npm-e2e.yml@@ -0,0 +1,63 @@+name: Reusable / npm E2E++on:+ workflow_call:+ inputs:+ ref:+ required: true+ type: string+ version:+ required: false+ type: string+ summary_title:+ required: true+ type: string+++permissions:+ contents: read++jobs:+ npm-cli-macos-amd64:+ name: ${{ inputs.summary_title }}+ runs-on: macos-13+ timeout-minutes: 20+ steps:+ - uses: actions/checkout@v6+ with:+ ref: ${{ inputs.ref }}++ - uses: actions/setup-node@v6+ with:+ node-version: '22'++ - name: Update npm package version+ if: ${{ inputs.version != '' }}+ working-directory: npm+ run: |+ CURRENT=$(node -pe "require('./package.json').version")+ DESIRED="${{ inputs.version }}"+ if [ "$CURRENT" != "$DESIRED" ]; then+ npm version "$DESIRED" --no-git-tag-version+ else+ echo "Version already correct: $CURRENT"+ fi++ - name: Install dependencies+ working-directory: npm+ run: npm ci --ignore-scripts++ - name: Build TypeScript+ working-directory: npm+ run: npm run build++ - name: Pack npm tarball+ working-directory: npm+ run: npm pack++ - name: Run npm CLI E2E on macOS amd64+ working-directory: npm+ run: |+ chmod +x scripts/npm-cli-e2e.sh+ TARBALL="$(ls -t pinchtab-*.tgz | head -1)"+ ./scripts/npm-cli-e2e.sh "$TARBALL"diff --git a/.github/workflows/reusable-release-publish.yml b/.github/workflows/reusable-release-publish.ymlindex 0d043e4d..ca0ee094 100644--- a/.github/workflows/reusable-release-publish.yml+++ b/.github/workflows/reusable-release-publish.yml@@ -80,7 +80,7 @@ jobs:- name: Update npm package versionworking-directory: npmrun: |- CURRENT=$(jq -r .version package.json)+ CURRENT=$(node -pe "require('./package.json').version")DESIRED=${{ steps.version.outputs.version }}if [ "$CURRENT" != "$DESIRED" ]; thennpm version "$DESIRED" --no-git-tag-versiondiff --git a/docs/guides/data-storage.md b/docs/guides/data-storage.mdindex c77e4251..e342186f 100644--- a/docs/guides/data-storage.md+++ b/docs/guides/data-storage.md@@ -20,7 +20,7 @@ PinchTab uses the OS config directory:| OS | Default Base Directory || --- | --- || Linux | `~/.config/pinchtab/` or `$XDG_CONFIG_HOME/pinchtab/` |-| macOS | `~/Library/Application Support/pinchtab/` |+| macOS | `~/.pinchtab/` || Windows | `%APPDATA%\\pinchtab\\` |Typical layout:@@ -37,12 +37,9 @@ pinchtab/## Legacy Fallback-For backward compatibility, PinchTab still uses `~/.pinchtab/` if:+On macOS, `~/.pinchtab/` is the default base directory.-- that legacy directory already exists-- and the newer OS-native location does not exist yet--That fallback applies to both config lookup and the default base storage directory.+On Linux and Windows, PinchTab still falls back to `~/.pinchtab/` when that legacy directory already exists and the newer OS-native location does not.## Profilesdiff --git a/docs/reference/config.md b/docs/reference/config.mdindex e979be7b..ec0f5a24 100644--- a/docs/reference/config.md+++ b/docs/reference/config.md@@ -125,13 +125,11 @@ For remote CLI targeting, use the root `--server` flag instead of config.Default location by OS:-- macOS: `~/Library/Application Support/pinchtab/config.json`+- macOS: `~/.pinchtab/config.json`- Linux: `~/.config/pinchtab/config.json` or `$XDG_CONFIG_HOME/pinchtab/config.json`- Windows: `%APPDATA%\pinchtab\config.json`-Legacy fallback:--- if `~/.pinchtab/config.json` exists and the newer location does not, PinchTab still uses the legacy location+On macOS, PinchTab defaults to `~/.pinchtab` so the CLI, npm-managed binary, and config file all use the same base directory.Override the config path with:@@ -301,7 +299,7 @@ For Linux container compatibility, use the runtime-managed path instead of `browBy default, PinchTab looks for unpacked Chrome extensions in `<server.stateDir>/extensions`. On a normal local install that means the OS-specific PinchTab config directory plus `extensions/`, for example:-- macOS: `~/Library/Application Support/pinchtab/extensions`+- macOS: `~/.pinchtab/extensions`- Linux: `~/.config/pinchtab/extensions`- Windows: `%APPDATA%\\pinchtab\\extensions`diff --git a/internal/config/config_utils.go b/internal/config/config_utils.goindex ed8cc3d6..8d81dea4 100644--- a/internal/config/config_utils.go+++ b/internal/config/config_utils.go@@ -6,6 +6,7 @@ import ("fmt""os""path/filepath"+ "runtime""strings")@@ -23,6 +24,12 @@ func userConfigDir() string {home := homeDir()legacyPath := filepath.Join(home, ".pinchtab")+ // On macOS, keep config and state rooted in ~/.pinchtab so the CLI,+ // npm-managed binary, and config path all resolve to the same location.+ if runtime.GOOS == "darwin" {+ return legacyPath+ }+configDir, err := os.UserConfigDir()if err != nil {return legacyPathdiff --git a/internal/config/config_utils_test.go b/internal/config/config_utils_test.goindex 4eba4727..c90e2a74 100644--- a/internal/config/config_utils_test.go+++ b/internal/config/config_utils_test.go@@ -134,3 +134,23 @@ func TestUserConfigDirPrefersNewConfigFileWhenPresent(t *testing.T) {t.Fatalf("userConfigDir() = %q, want new XDG path %q", got, newDir)}}++func TestUserConfigDirDarwinAlwaysUsesLegacyPath(t *testing.T) {+ if runtime.GOOS != "darwin" {+ t.Skip("macOS-specific path test")+ }++ tmpHome, err := os.MkdirTemp("", "pinchtab-home-*")+ if err != nil {+ t.Fatalf("Failed to create temp home: %v", err)+ }+ defer func() { _ = os.RemoveAll(tmpHome) }()++ t.Setenv("HOME", tmpHome)++ got := userConfigDir()+ want := filepath.Join(tmpHome, ".pinchtab")+ if got != want {+ t.Fatalf("userConfigDir() = %q, want macOS default path %q", got, want)+ }+}diff --git a/npm/scripts/npm-cli-e2e.sh b/npm/scripts/npm-cli-e2e.shnew file mode 100755index 00000000..5c9f288f--- /dev/null+++ b/npm/scripts/npm-cli-e2e.sh@@ -0,0 +1,62 @@+#!/usr/bin/env bash+set -euo pipefail++if [ "$#" -ne 1 ]; then+ echo "usage: $0 <npm-tarball>" >&2+ exit 1+fi++TARBALL="$1"+TMP_ROOT="$(mktemp -d)"+HOME_DIR="$TMP_ROOT/home"+PREFIX_DIR="$TMP_ROOT/prefix"+BIN_DIR="$PREFIX_DIR/bin"+SERVER_LOG="$TMP_ROOT/server.log"+PORT="${PINCHTAB_SMOKE_PORT:-19867}"+SERVER_PID=""++cleanup() {+ if [ -n "$SERVER_PID" ] && kill -0 "$SERVER_PID" 2>/dev/null; then+ kill "$SERVER_PID" >/dev/null 2>&1 || true+ wait "$SERVER_PID" >/dev/null 2>&1 || true+ fi+ rm -rf "$TMP_ROOT"+}+trap cleanup EXIT++mkdir -p "$HOME_DIR" "$PREFIX_DIR"++export HOME="$HOME_DIR"+export PATH="$BIN_DIR:$PATH"++echo "Installing npm package from $TARBALL"+npm install -g --prefix "$PREFIX_DIR" "$TARBALL"++echo "Initializing CLI config"+pinchtab config init+pinchtab config set server.port "$PORT"++CONFIG_PATH="$(pinchtab config path)"+TOKEN="$(node -pe "require(process.argv[1]).server.token" "$CONFIG_PATH")"++if [ -z "$TOKEN" ]; then+ echo "smoke failed: expected non-empty server token in $CONFIG_PATH" >&2+ exit 1+fi++echo "Starting PinchTab server on port $PORT"+pinchtab server >"$SERVER_LOG" 2>&1 &+SERVER_PID="$!"++for _ in $(seq 1 60); do+ if curl -fsS -H "Authorization: Bearer $TOKEN" "http://127.0.0.1:$PORT/health" >/dev/null; then+ echo "CLI auth smoke passed"+ exit 0+ fi+ sleep 1+done++echo "smoke failed: server never accepted the configured token" >&2+echo "server log:" >&2+cat "$SERVER_LOG" >&2+exit 1