diff --git a/scripts/test-package.sh b/scripts/test-package.sh new file mode 100755 index 0000000..998ba99 --- /dev/null +++ b/scripts/test-package.sh @@ -0,0 +1,140 @@ +#!/bin/bash + +# Simple package test script for Peekaboo MCP +# Tests the package locally without publishing + +set -e + +echo "๐Ÿงช Testing npm package locally..." +echo "" + +# Build everything +echo "๐Ÿ”จ Building package..." +npm run build:all + +# Create package +echo "๐Ÿ“ฆ Creating package tarball..." +PACKAGE_FILE=$(npm pack 2>&1 | tail -1) +PACKAGE_PATH=$(pwd)/$PACKAGE_FILE +echo "Created: $PACKAGE_FILE" + +# Get package info +PACKAGE_SIZE=$(du -h "$PACKAGE_FILE" | cut -f1) +echo "Package size: $PACKAGE_SIZE" + +# Test installation in a temporary directory +TEMP_DIR=$(mktemp -d) +echo "" +echo "๐Ÿ“ฅ Testing installation in: $TEMP_DIR" +cd "$TEMP_DIR" + +# Initialize a test project +npm init -y > /dev/null 2>&1 + +# Install the package from tarball +echo "๐Ÿ“ฆ Installing from tarball..." +npm install "$PACKAGE_PATH" + +# Check installation +echo "" +echo "๐Ÿ” Checking installation..." + +# Check if binary exists and is executable +if [ -f "node_modules/@steipete/peekaboo-mcp/peekaboo" ]; then + echo "โœ… Binary found" + + # Check if executable + if [ -x "node_modules/@steipete/peekaboo-mcp/peekaboo" ]; then + echo "โœ… Binary is executable" + + # Test the binary + echo "" + echo "๐Ÿงช Testing Swift CLI..." + if node_modules/@steipete/peekaboo-mcp/peekaboo --version; then + echo "โœ… Swift CLI works!" + else + echo "โŒ Swift CLI failed" + fi + else + echo "โŒ Binary is not executable" + fi +else + echo "โŒ Binary not found!" +fi + +# Check main entry point +if [ -f "node_modules/@steipete/peekaboo-mcp/dist/index.js" ]; then + echo "โœ… Main entry point found" +else + echo "โŒ Main entry point missing!" +fi + +# List all files in package +echo "" +echo "๐Ÿ“‹ Package contents:" +find node_modules/@steipete/peekaboo-mcp -type f -name "*.js" -o -name "*.d.ts" -o -name "peekaboo" | head -20 + +# Test the MCP server +echo "" +echo "๐Ÿงช Testing MCP server startup..." +cat > test-mcp.js << 'EOF' +const { spawn } = require('child_process'); +const path = require('path'); + +const mcpPath = path.join('node_modules', '@steipete', 'peekaboo-mcp', 'dist', 'index.js'); +const server = spawn('node', [mcpPath], { + stdio: ['pipe', 'pipe', 'pipe'] +}); + +const request = JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "tools/list" +}) + '\n'; + +setTimeout(() => { + server.stdin.write(request); +}, 100); + +let responded = false; +server.stdout.on('data', (data) => { + const lines = data.toString().split('\n').filter(l => l.trim()); + for (const line of lines) { + try { + const response = JSON.parse(line); + if (response.result && response.result.tools) { + console.log('โœ… MCP server works! Available tools:', response.result.tools.map(t => t.name).join(', ')); + responded = true; + server.kill(); + process.exit(0); + } + } catch (e) { + // Ignore non-JSON lines + } + } +}); + +server.stderr.on('data', (data) => { + console.error('Server error:', data.toString()); +}); + +setTimeout(() => { + if (!responded) { + console.error('โŒ Timeout waiting for MCP server response'); + server.kill(); + process.exit(1); + } +}, 5000); +EOF + +node test-mcp.js + +# Cleanup +cd - > /dev/null +rm -rf "$TEMP_DIR" +rm -f "$PACKAGE_PATH" + +echo "" +echo "โœจ Package test complete!" +echo "" +echo "If all tests passed, the package is ready for publishing!" \ No newline at end of file diff --git a/scripts/test-publish.sh b/scripts/test-publish.sh new file mode 100755 index 0000000..7229509 --- /dev/null +++ b/scripts/test-publish.sh @@ -0,0 +1,148 @@ +#!/bin/bash + +# Test publishing script for Peekaboo MCP +# This script tests the npm package in a local registry before public release + +set -e + +echo "๐Ÿงช Testing npm package publishing..." +echo "" + +# Save current registry +ORIGINAL_REGISTRY=$(npm config get registry) +echo "๐Ÿ“ฆ Original registry: $ORIGINAL_REGISTRY" + +# Check if Verdaccio is installed +if ! command -v verdaccio &> /dev/null; then + echo "โŒ Verdaccio not found. Install it with: npm install -g verdaccio" + exit 1 +fi + +# Start Verdaccio in background if not already running +if ! curl -s http://localhost:4873/ > /dev/null; then + echo "๐Ÿš€ Starting Verdaccio local registry..." + verdaccio > /tmp/verdaccio.log 2>&1 & + VERDACCIO_PID=$! + sleep 3 +else + echo "โœ… Verdaccio already running" +fi + +# Set to local registry +echo "๐Ÿ”„ Switching to local registry..." +npm set registry http://localhost:4873/ + +# Create test auth token (Verdaccio accepts any auth on first use) +echo "๐Ÿ”‘ Setting up authentication..." +TOKEN=$(echo -n "testuser:testpass" | base64) +npm set //localhost:4873/:_authToken "$TOKEN" + +# Build the package +echo "๐Ÿ”จ Building package..." +npm run build:all + +# Publish to local registry +echo "๐Ÿ“ค Publishing to local registry..." +npm publish --registry http://localhost:4873/ + +echo "" +echo "โœ… Package published to local registry!" +echo "" + +# Test installation in a temporary directory +TEMP_DIR=$(mktemp -d) +echo "๐Ÿ“ฅ Testing installation in: $TEMP_DIR" +cd "$TEMP_DIR" + +# Initialize a test project +npm init -y > /dev/null 2>&1 + +# Install the package +echo "๐Ÿ“ฆ Installing @steipete/peekaboo-mcp from local registry..." +npm install @steipete/peekaboo-mcp --registry http://localhost:4873/ + +# Check if binary exists +if [ -f "node_modules/@steipete/peekaboo-mcp/peekaboo" ]; then + echo "โœ… Binary found in package" + + # Test the binary + echo "๐Ÿงช Testing binary..." + if node_modules/@steipete/peekaboo-mcp/peekaboo --version; then + echo "โœ… Binary works!" + else + echo "โŒ Binary failed to execute" + fi +else + echo "โŒ Binary not found in package!" +fi + +# Test the MCP server +echo "" +echo "๐Ÿงช Testing MCP server..." +cat > test-mcp.js << 'EOF' +const { spawn } = require('child_process'); + +const server = spawn('npx', ['@steipete/peekaboo-mcp'], { + stdio: ['pipe', 'pipe', 'pipe'] +}); + +const request = JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "tools/list" +}) + '\n'; + +server.stdin.write(request); + +server.stdout.on('data', (data) => { + const lines = data.toString().split('\n').filter(l => l.trim()); + for (const line of lines) { + try { + const response = JSON.parse(line); + if (response.result && response.result.tools) { + console.log('โœ… MCP server responded with tools:', response.result.tools.map(t => t.name).join(', ')); + server.kill(); + process.exit(0); + } + } catch (e) { + // Ignore non-JSON lines + } + } +}); + +setTimeout(() => { + console.error('โŒ Timeout waiting for MCP server response'); + server.kill(); + process.exit(1); +}, 5000); +EOF + +if node test-mcp.js; then + echo "โœ… MCP server test passed!" +else + echo "โŒ MCP server test failed" +fi + +# Cleanup +cd - > /dev/null +rm -rf "$TEMP_DIR" + +# Restore original registry +echo "" +echo "๐Ÿ”„ Restoring original registry..." +npm set registry "$ORIGINAL_REGISTRY" +npm config delete //localhost:4873/:_authToken + +# Kill Verdaccio if we started it +if [ ! -z "$VERDACCIO_PID" ]; then + echo "๐Ÿ›‘ Stopping Verdaccio..." + kill $VERDACCIO_PID 2>/dev/null || true +fi + +echo "" +echo "โœจ Test publish complete!" +echo "" +echo "๐Ÿ“‹ Next steps:" +echo "1. If all tests passed, you can publish to npm with: npm publish" +echo "2. Remember to tag appropriately if beta: npm publish --tag beta" +echo "3. Create a GitHub release after publishing" \ No newline at end of file