diff --git a/package.json b/package.json index 9eeb531..9d88cb9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,13 @@ "name": "marketplace-scrapers-monorepo", "version": "1.0.0", "scripts": { - "ci": "biome ci" + "ci": "biome ci", + "clean": "rm -rf dist", + "build:api": "bun build ./packages/api-server/src/index.ts --target=bun --outdir=./dist/api --minify", + "build:mcp": "bun build ./packages/mcp-server/src/index.ts --target=bun --outdir=./dist/mcp --minify", + "build:all": "bun run build:api && bun run build:mcp", + "build": "bun run clean && bun run build:all", + "start": "./start.sh" }, "private": true, "type": "module", diff --git a/scripts/biome-symlink.sh b/scripts/biome-symlink.sh new file mode 100755 index 0000000..90b0bd6 --- /dev/null +++ b/scripts/biome-symlink.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# Get the path to the system biome executable +BIOME_PATH=$(which biome) + +if [ -z "$BIOME_PATH" ]; then + echo "Error: biome executable not found in PATH" + exit 1 +fi + +# Find all biome executables in node_modules +files=$(fd biome node_modules --type executable --no-ignore --follow) + +if [ -z "$files" ]; then + echo "No biome executables found in node_modules" + exit 0 +fi + +# Replace each with a symlink to the system biome +for file in $files; do + echo "Replacing $file with symlink to $BIOME_PATH" + rm "$file" + ln -s "$BIOME_PATH" "$file" +done + +echo "Done." diff --git a/scripts/remove-eslint.sh b/scripts/remove-eslint.sh new file mode 100755 index 0000000..41244d3 --- /dev/null +++ b/scripts/remove-eslint.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +PATTERN="eslint" +FILES="$(fd .)" # Or use 'find .' to search recursively + +for file in $FILES; do + if [[ -f "$file" ]]; then + # 1. Use rg with line numbers (-n) and only the matched line (-o) + # 2. Use awk to print ONLY the line number (field 1) + # 3. Use xargs to pass multiple line numbers to a single sed command + + LINE_NUMBERS=$(rg --line-number --no-filename "$PATTERN" "$file" | awk -F':' '{print $1}' | tr '\n' ',') + + # Remove trailing comma if any + LINE_NUMBERS=${LINE_NUMBERS%,} + + if [[ -n "$LINE_NUMBERS" ]]; then + echo "Deleting lines $LINE_NUMBERS from $file..." + + # Use sed to delete the specified comma-separated line numbers in-place (-i) + # NOTE: The syntax for -i might vary slightly between GNU sed (Linux) and BSD sed (macOS). + sed -i.bak "${LINE_NUMBERS}d" "$file" + + # Optional: Remove the backup file created by sed -i.bak + # rm "${file}.bak" + else + echo "$file: No lines matching pattern found." + fi + fi +done diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..cdb40e2 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -e + +# Trap SIGTERM and SIGINT for graceful shutdown +trap 'echo "Received shutdown signal, stopping services..."; kill -TERM $API_PID $MCP_PID 2>/dev/null; wait' TERM INT + +# Start API Server in background +echo "Starting API Server on port ${API_PORT:-4005}..." +bun ../dist/api/index.js & +API_PID=$! + +# Give API server a moment to initialize +sleep 1 + +# Start MCP Server in background +echo "Starting MCP Server on port ${API_PORT:-4006}..." +bun ../dist/mcp/index.js & +MCP_PID=$! + +echo "Both services started successfully" +echo "API Server PID: $API_PID" +echo "MCP Server PID: $MCP_PID" + +# Wait for both processes +wait $API_PID $MCP_PID