Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: correct npm wrapper binary naming (x64 -> amd64, handle aarch64) (#79)

luigiagent277f20f682ac
diff --git a/cmd/pinchtab/build_test.go b/cmd/pinchtab/build_test.go
new file mode 100644
index 00000000..bcb5e70e
--- /dev/null
+++ b/cmd/pinchtab/build_test.go
@@ -0,0 +1,111 @@
+package main
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+
+ "gopkg.in/yaml.v3"
+)
+
+// GoReleaserConfig represents the minimal goreleaser config we care about
+type GoReleaserConfig struct {
+ Builds []struct {
+ GOOS []string `yaml:"goos"`
+ GOARCH []string `yaml:"goarch"`
+ } `yaml:"builds"`
+}
+
+// TestBinaryPermutations verifies all expected binary permutations are configured in goreleaser
+func TestBinaryPermutations(t *testing.T) {
+ // Find .goreleaser.yml in repo root (2 levels up from cmd/pinchtab/)
+ repoRoot := filepath.Join("..", "..", ".goreleaser.yml")
+ data, err := os.ReadFile(repoRoot)
+ if err != nil {
+ t.Fatalf("failed to read .goreleaser.yml at %s: %v", repoRoot, err)
+ }
+
+ var cfg GoReleaserConfig
+ if err := yaml.Unmarshal(data, &cfg); err != nil {
+ t.Fatalf("failed to parse .goreleaser.yml: %v", err)
+ }
+
+ if len(cfg.Builds) == 0 {
+ t.Fatal("no builds configured in .goreleaser.yml")
+ }
+
+ build := cfg.Builds[0]
+
+ // Expected OS/arch combinations
+ expectedOS := map[string]bool{
+ "linux": true,
+ "darwin": true,
+ "windows": true,
+ }
+
+ expectedArch := map[string]bool{
+ "amd64": true,
+ "arm64": true,
+ }
+
+ // Verify all expected OS are configured
+ for os := range expectedOS {
+ found := false
+ for _, configOS := range build.GOOS {
+ if configOS == os {
+ found = true
+ break
+ }
+ }
+ if !found {
+ t.Errorf("OS %q not found in goreleaser config", os)
+ }
+ }
+
+ // Verify all expected architectures are configured
+ for arch := range expectedArch {
+ found := false
+ for _, configArch := range build.GOARCH {
+ if configArch == arch {
+ found = true
+ break
+ }
+ }
+ if !found {
+ t.Errorf("Architecture %q not found in goreleaser config", arch)
+ }
+ }
+
+ // Calculate expected binary count
+ totalExpected := len(expectedOS) * len(expectedArch)
+ totalConfigured := len(build.GOOS) * len(build.GOARCH)
+
+ if totalConfigured != totalExpected {
+ t.Errorf("expected %d binaries (3 OS × 2 arch), but config produces %d",
+ totalExpected, totalConfigured)
+ }
+
+ t.Logf("✓ Binary matrix verified: %d OS × %d arch = %d total binaries",
+ len(build.GOOS), len(build.GOARCH), totalConfigured)
+}
+
+// TestExpectedBinaryNames verifies correct naming for all permutations
+func TestExpectedBinaryNames(t *testing.T) {
+ expectedBinaries := []string{
+ "pinchtab-linux-amd64",
+ "pinchtab-linux-arm64",
+ "pinchtab-darwin-amd64",
+ "pinchtab-darwin-arm64",
+ "pinchtab-windows-amd64.exe",
+ "pinchtab-windows-arm64.exe",
+ }
+
+ if len(expectedBinaries) != 6 {
+ t.Errorf("expected 6 binaries, got %d", len(expectedBinaries))
+ }
+
+ t.Logf("Expected binary names (%d total):", len(expectedBinaries))
+ for _, bin := range expectedBinaries {
+ t.Logf(" ✓ %s", bin)
+ }
+}
diff --git a/npm/bin/pinchtab b/npm/bin/pinchtab
index 9db911eb..a4bf237b 100755
--- a/npm/bin/pinchtab
+++ b/npm/bin/pinchtab
@@ -7,7 +7,7 @@ const fs = require('fs');
function getBinaryName() {
const platform = process.platform;
- const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
+ const arch = (process.arch === 'arm64' || process.arch === 'aarch64') ? 'arm64' : 'amd64';
if (platform === 'darwin') {
return `pinchtab-darwin-${arch}`;
diff --git a/npm/package.json b/npm/package.json
index 5a7c2dac..895978cb 100644
--- a/npm/package.json
+++ b/npm/package.json
@@ -15,7 +15,7 @@
"format": "prettier --write src tests scripts",
"format:check": "prettier --check src tests scripts",
"build": "npm run lint && npm run format:check && tsc",
- "test": "node --test dist/tests/integration.test.js",
+ "test": "node --test 'dist/tests/**/*.test.js'",
"postinstall": "node scripts/postinstall.js",
"prepare": "npm run build"
},
diff --git a/npm/tests/platform-detection.test.ts b/npm/tests/platform-detection.test.ts
new file mode 100644
index 00000000..d2e381ad
--- /dev/null
+++ b/npm/tests/platform-detection.test.ts
@@ -0,0 +1,182 @@
+/**
+ * Platform Detection Tests
+ *
+ * Verifies that the platform detection logic correctly maps Node.js process.platform/process.arch
+ * to the goreleaser binary filenames.
+ *
+ * Matrix:
+ * process.platform | process.arch | Expected Binary
+ * ───────────────────────────────────────────────────────
+ * darwin | x64 | pinchtab-darwin-amd64
+ * darwin | arm64 | pinchtab-darwin-arm64
+ * linux | x64 | pinchtab-linux-amd64
+ * linux | arm64 | pinchtab-linux-arm64
+ * win32 | x64 | pinchtab-windows-amd64.exe
+ * win32 | arm64 | pinchtab-windows-arm64.exe
+ */
+
+import { test, describe } from 'node:test';
+import * as assert from 'node:assert';
+
+/**
+ * Extracted detectPlatform logic from postinstall.js
+ * (duplicated here for isolated testing)
+ */
+function detectPlatform(platform: string, arch: string) {
+ // Only support x64 and arm64
+ let mappedArch: string;
+ if (arch === 'x64') {
+ mappedArch = 'amd64';
+ } else if (arch === 'arm64') {
+ mappedArch = 'arm64';
+ } else {
+ throw new Error(`Unsupported architecture: ${arch}. Only x64 (amd64) and arm64 are supported.`);
+ }
+
+ const osMap: Record<string, string> = {
+ darwin: 'darwin',
+ linux: 'linux',
+ win32: 'windows',
+ };
+
+ const detectedOS = osMap[platform];
+ if (!detectedOS) {
+ throw new Error(`Unsupported platform: ${platform}`);
+ }
+
+ return { os: detectedOS, arch: mappedArch };
+}
+
+interface PlatformResult {
+ os: string;
+ arch: string;
+}
+
+function getBinaryName(platform: PlatformResult): string {
+ const { os, arch } = platform;
+ const archName = arch === 'arm64' ? 'arm64' : 'amd64';
+
+ if (os === 'windows') {
+ return `pinchtab-${os}-${archName}.exe`;
+ }
+ return `pinchtab-${os}-${archName}`;
+}
+
+describe('Platform Detection', () => {
+ describe('detectPlatform', () => {
+ test('darwin + x64 → darwin-amd64', () => {
+ const platform = detectPlatform('darwin', 'x64');
+ assert.strictEqual(platform.os, 'darwin');
+ assert.strictEqual(platform.arch, 'amd64');
+ });
+
+ test('darwin + arm64 → darwin-arm64', () => {
+ const platform = detectPlatform('darwin', 'arm64');
+ assert.strictEqual(platform.os, 'darwin');
+ assert.strictEqual(platform.arch, 'arm64');
+ });
+
+ test('linux + x64 → linux-amd64', () => {
+ const platform = detectPlatform('linux', 'x64');
+ assert.strictEqual(platform.os, 'linux');
+ assert.strictEqual(platform.arch, 'amd64');
+ });
+
+ test('linux + arm64 → linux-arm64', () => {
+ const platform = detectPlatform('linux', 'arm64');
+ assert.strictEqual(platform.os, 'linux');
+ assert.strictEqual(platform.arch, 'arm64');
+ });
+
+ test('win32 + x64 → windows-amd64', () => {
+ const platform = detectPlatform('win32', 'x64');
+ assert.strictEqual(platform.os, 'windows');
+ assert.strictEqual(platform.arch, 'amd64');
+ });
+
+ test('win32 + arm64 → windows-arm64', () => {
+ const platform = detectPlatform('win32', 'arm64');
+ assert.strictEqual(platform.os, 'windows');
+ assert.strictEqual(platform.arch, 'arm64');
+ });
+
+ test('unsupported platform → error', () => {
+ assert.throws(() => detectPlatform('freebsd', 'x64'), /Unsupported platform: freebsd/);
+ });
+
+ test('unsupported arch → error', () => {
+ assert.throws(() => detectPlatform('linux', 'ia32'), /Unsupported architecture: ia32/);
+ });
+ });
+
+ describe('getBinaryName', () => {
+ test('darwin-amd64 → pinchtab-darwin-amd64', () => {
+ const platform = { os: 'darwin', arch: 'amd64' };
+ const name = getBinaryName(platform);
+ assert.strictEqual(name, 'pinchtab-darwin-amd64');
+ });
+
+ test('darwin-arm64 → pinchtab-darwin-arm64', () => {
+ const platform = { os: 'darwin', arch: 'arm64' };
+ const name = getBinaryName(platform);
+ assert.strictEqual(name, 'pinchtab-darwin-arm64');
+ });
+
+ test('linux-amd64 → pinchtab-linux-amd64', () => {
+ const platform = { os: 'linux', arch: 'amd64' };
+ const name = getBinaryName(platform);
+ assert.strictEqual(name, 'pinchtab-linux-amd64');
+ });
+
+ test('linux-arm64 → pinchtab-linux-arm64', () => {
+ const platform = { os: 'linux', arch: 'arm64' };
+ const name = getBinaryName(platform);
+ assert.strictEqual(name, 'pinchtab-linux-arm64');
+ });
+
+ test('windows-amd64 → pinchtab-windows-amd64.exe', () => {
+ const platform = { os: 'windows', arch: 'amd64' };
+ const name = getBinaryName(platform);
+ assert.strictEqual(name, 'pinchtab-windows-amd64.exe');
+ });
+
+ test('windows-arm64 → pinchtab-windows-arm64.exe', () => {
+ const platform = { os: 'windows', arch: 'arm64' };
+ const name = getBinaryName(platform);
+ assert.strictEqual(name, 'pinchtab-windows-arm64.exe');
+ });
+ });
+
+ describe('Full Matrix (detectPlatform + getBinaryName)', () => {
+ interface MatrixEntry {
+ nodejs_platform: string;
+ nodejs_arch: string;
+ expected_binary: string;
+ }
+
+ const matrix: MatrixEntry[] = [
+ { nodejs_platform: 'darwin', nodejs_arch: 'x64', expected_binary: 'pinchtab-darwin-amd64' },
+ { nodejs_platform: 'darwin', nodejs_arch: 'arm64', expected_binary: 'pinchtab-darwin-arm64' },
+ { nodejs_platform: 'linux', nodejs_arch: 'x64', expected_binary: 'pinchtab-linux-amd64' },
+ { nodejs_platform: 'linux', nodejs_arch: 'arm64', expected_binary: 'pinchtab-linux-arm64' },
+ {
+ nodejs_platform: 'win32',
+ nodejs_arch: 'x64',
+ expected_binary: 'pinchtab-windows-amd64.exe',
+ },
+ {
+ nodejs_platform: 'win32',
+ nodejs_arch: 'arm64',
+ expected_binary: 'pinchtab-windows-arm64.exe',
+ },
+ ];
+
+ matrix.forEach(({ nodejs_platform, nodejs_arch, expected_binary }) => {
+ test(`${nodejs_platform}/${nodejs_arch} → ${expected_binary}`, () => {
+ const platform = detectPlatform(nodejs_platform, nodejs_arch);
+ const binary = getBinaryName(platform);
+ assert.strictEqual(binary, expected_binary);
+ });
+ });
+ });
+});
diff --git a/scripts/verify-release.sh b/scripts/verify-release.sh
new file mode 100755
index 00000000..6df1d7bd
--- /dev/null
+++ b/scripts/verify-release.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+# verify-release.sh - Validate that a release has all expected binary permutations
+#
+# Usage:
+# ./scripts/verify-release.sh [TAG] # Verify specific tag (default: latest)
+# ./scripts/verify-release.sh v0.7.6
+#
+# This script ensures:
+# 1. All 6 binary permutations are present
+# 2. checksums.txt exists
+# 3. Checksums are valid (optional, requires local binaries)
+
+set -e
+
+REPO="${REPO:-pinchtab/pinchtab}"
+TAG="${1:-}" # Empty = latest
+
+# Expected binary names (must match .goreleaser.yml)
+EXPECTED_BINARIES=(
+ "pinchtab-linux-amd64"
+ "pinchtab-linux-arm64"
+ "pinchtab-darwin-amd64"
+ "pinchtab-darwin-arm64"
+ "pinchtab-windows-amd64.exe"
+ "pinchtab-windows-arm64.exe"
+)
+
+echo "=== Release Binary Verification ==="
+echo ""
+
+# Get release info
+if [ -z "$TAG" ]; then
+ echo "📦 Fetching latest release..."
+ RELEASE=$(gh release view --repo "$REPO" --json assets,tagName)
+else
+ echo "📦 Fetching release: $TAG"
+ RELEASE=$(gh release view "$TAG" --repo "$REPO" --json assets,tagName 2>/dev/null) || {
+ echo "❌ Release not found: $TAG"
+ exit 1
+ }
+fi
+
+TAG_NAME=$(echo "$RELEASE" | jq -r '.tagName')
+echo " Tag: $TAG_NAME"
+echo ""
+
+# Extract asset names
+ASSETS=$(echo "$RELEASE" | jq -r '.assets[].name')
+
+# Check for each expected binary
+FOUND=0
+MISSING=()
+
+echo "Checking binaries:"
+for BINARY in "${EXPECTED_BINARIES[@]}"; do
+ if echo "$ASSETS" | grep -q "^${BINARY}$"; then
+ echo " ✓ $BINARY"
+ ((FOUND++))
+ else
+ echo " ✗ $BINARY (MISSING)"
+ MISSING+=("$BINARY")
+ fi
+done
+
+EXPECTED_COUNT=${#EXPECTED_BINARIES[@]}
+
+echo ""
+echo "Summary:"
+echo " Expected: $EXPECTED_COUNT"
+echo " Found: $FOUND"
+
+# Check for checksums
+if echo "$ASSETS" | grep -q "^checksums.txt$"; then
+ echo " ✓ checksums.txt present"
+else
+ echo " ✗ checksums.txt missing"
+fi
+
+echo ""
+
+# Status
+if [ $FOUND -eq $EXPECTED_COUNT ] && echo "$ASSETS" | grep -q "^checksums.txt$"; then
+ echo "✅ All binaries present ($FOUND/$EXPECTED_COUNT)"
+ exit 0
+else
+ if [ ${#MISSING[@]} -gt 0 ]; then
+ echo "❌ Missing binaries:"
+ for BIN in "${MISSING[@]}"; do
+ echo " - $BIN"
+ done
+ fi
+ exit 1
+fi