Skip to content

Commit 2e8cc70

Browse files
committed
chore: include vendored node executable (#5160)
1 parent 7b4ce18 commit 2e8cc70

File tree

3 files changed

+122
-94
lines changed

3 files changed

+122
-94
lines changed

ui/desktop/src/bin/node

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Enable strict mode to exit on errors and unset variables
4+
set -euo pipefail
5+
6+
# Get the directory where this script is located
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
9+
# Source the common setup script
10+
source "$SCRIPT_DIR/node-setup-common.sh"
11+
12+
# Final step: Execute node with passed arguments
13+
log "Executing 'node' command with arguments: $*"
14+
node "$@" || log "Failed to execute 'node' with arguments: $*"
15+
16+
log "node script completed successfully."
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
3+
# Common setup script for node and npx
4+
# This script sets up hermit and node.js environment
5+
6+
# Enable strict mode to exit on errors and unset variables
7+
set -euo pipefail
8+
9+
# Set log file
10+
LOG_FILE="/tmp/mcp.log"
11+
12+
# Clear the log file at the start
13+
> "$LOG_FILE"
14+
15+
# Function for logging
16+
log() {
17+
local MESSAGE="$1"
18+
echo "$(date +'%Y-%m-%d %H:%M:%S') - $MESSAGE" | tee -a "$LOG_FILE" >&2
19+
}
20+
21+
# Trap errors and log them before exiting
22+
trap 'log "An error occurred. Exiting with status $?."' ERR
23+
24+
log "Starting node setup (common)."
25+
26+
# Ensure ~/.config/goose/mcp-hermit/bin exists
27+
log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist."
28+
mkdir -p ~/.config/goose/mcp-hermit/bin
29+
30+
# Change to the ~/.config/goose/mcp-hermit directory
31+
log "Changing to directory ~/.config/goose/mcp-hermit."
32+
cd ~/.config/goose/mcp-hermit
33+
34+
35+
# Check if hermit binary exists and download if not
36+
if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then
37+
log "Hermit binary not found. Downloading hermit binary."
38+
curl -fsSL "https://github.com/cashapp/hermit/releases/download/stable/hermit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').gz" \
39+
| gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit
40+
log "Hermit binary downloaded and made executable."
41+
else
42+
log "Hermit binary already exists. Skipping download."
43+
fi
44+
45+
46+
log "setting hermit cache to be local for MCP servers"
47+
mkdir -p ~/.config/goose/mcp-hermit/cache
48+
export HERMIT_STATE_DIR=~/.config/goose/mcp-hermit/cache
49+
50+
51+
# Update PATH
52+
export PATH=~/.config/goose/mcp-hermit/bin:$PATH
53+
log "Updated PATH to include ~/.config/goose/mcp-hermit/bin."
54+
55+
56+
# Verify hermit installation
57+
log "Checking for hermit in PATH."
58+
which hermit >> "$LOG_FILE"
59+
60+
# Initialize hermit
61+
log "Initializing hermit."
62+
hermit init >> "$LOG_FILE"
63+
64+
# Install Node.js using hermit
65+
log "Installing Node.js with hermit."
66+
hermit install node >> "$LOG_FILE"
67+
68+
# Verify installations
69+
log "Verifying installation locations:"
70+
log "hermit: $(which hermit)"
71+
log "node: $(which node)"
72+
log "npx: $(which npx)"
73+
74+
75+
log "Checking for GOOSE_NPM_REGISTRY and GOOSE_NPM_CERT environment variables for custom npm registry setup..."
76+
# Check if GOOSE_NPM_REGISTRY is set and accessible
77+
if [ -n "${GOOSE_NPM_REGISTRY:-}" ] && curl -s --head --fail "$GOOSE_NPM_REGISTRY" > /dev/null; then
78+
log "Checking custom goose registry availability: $GOOSE_NPM_REGISTRY"
79+
log "$GOOSE_NPM_REGISTRY is accessible. Using it for npm registry."
80+
export NPM_CONFIG_REGISTRY="$GOOSE_NPM_REGISTRY"
81+
82+
# Check if GOOSE_NPM_CERT is set and accessible
83+
if [ -n "${GOOSE_NPM_CERT:-}" ] && curl -s --head --fail "$GOOSE_NPM_CERT" > /dev/null; then
84+
log "Downloading certificate from: $GOOSE_NPM_CERT"
85+
curl -sSL -o ~/.config/goose/mcp-hermit/cert.pem "$GOOSE_NPM_CERT"
86+
if [ $? -eq 0 ]; then
87+
log "Certificate downloaded successfully."
88+
export NODE_EXTRA_CA_CERTS=~/.config/goose/mcp-hermit/cert.pem
89+
else
90+
log "Unable to download the certificate. Skipping certificate setup."
91+
fi
92+
else
93+
log "GOOSE_NPM_CERT is either not set or not accessible. Skipping certificate setup."
94+
fi
95+
96+
else
97+
log "GOOSE_NPM_REGISTRY is either not set or not accessible. Falling back to default npm registry."
98+
export NPM_CONFIG_REGISTRY="https://registry.npmjs.org/"
99+
fi
100+
101+
log "Node setup (common) completed successfully."

ui/desktop/src/bin/npx

Lines changed: 5 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -3,103 +3,14 @@
33
# Enable strict mode to exit on errors and unset variables
44
set -euo pipefail
55

6-
# Set log file
7-
LOG_FILE="/tmp/mcp.log"
8-
9-
# Clear the log file at the start
10-
> "$LOG_FILE"
11-
12-
# Function for logging
13-
log() {
14-
local MESSAGE="$1"
15-
echo "$(date +'%Y-%m-%d %H:%M:%S') - $MESSAGE" | tee -a "$LOG_FILE" >&2
16-
}
17-
18-
# Trap errors and log them before exiting
19-
trap 'log "An error occurred. Exiting with status $?."' ERR
20-
21-
log "Starting npx setup script."
22-
23-
# Ensure ~/.config/goose/mcp-hermit/bin exists
24-
log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist."
25-
mkdir -p ~/.config/goose/mcp-hermit/bin
26-
27-
# Change to the ~/.config/goose/mcp-hermit directory
28-
log "Changing to directory ~/.config/goose/mcp-hermit."
29-
cd ~/.config/goose/mcp-hermit
30-
31-
32-
# Check if hermit binary exists and download if not
33-
if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then
34-
log "Hermit binary not found. Downloading hermit binary."
35-
curl -fsSL "https://github.com/cashapp/hermit/releases/download/stable/hermit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').gz" \
36-
| gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit
37-
log "Hermit binary downloaded and made executable."
38-
else
39-
log "Hermit binary already exists. Skipping download."
40-
fi
41-
42-
43-
log "setting hermit cache to be local for MCP servers"
44-
mkdir -p ~/.config/goose/mcp-hermit/cache
45-
export HERMIT_STATE_DIR=~/.config/goose/mcp-hermit/cache
46-
47-
48-
# Update PATH
49-
export PATH=~/.config/goose/mcp-hermit/bin:$PATH
50-
log "Updated PATH to include ~/.config/goose/mcp-hermit/bin."
51-
52-
53-
# Verify hermit installation
54-
log "Checking for hermit in PATH."
55-
which hermit >> "$LOG_FILE"
56-
57-
# Initialize hermit
58-
log "Initializing hermit."
59-
hermit init >> "$LOG_FILE"
60-
61-
# Install Node.js using hermit
62-
log "Installing Node.js with hermit."
63-
hermit install node >> "$LOG_FILE"
64-
65-
# Verify installations
66-
log "Verifying installation locations:"
67-
log "hermit: $(which hermit)"
68-
log "node: $(which node)"
69-
log "npx: $(which npx)"
70-
71-
72-
log "Checking for GOOSE_NPM_REGISTRY and GOOSE_NPM_CERT environment variables for custom npm registry setup..."
73-
# Check if GOOSE_NPM_REGISTRY is set and accessible
74-
if [ -n "${GOOSE_NPM_REGISTRY:-}" ] && curl -s --head --fail "$GOOSE_NPM_REGISTRY" > /dev/null; then
75-
log "Checking custom goose registry availability: $GOOSE_NPM_REGISTRY"
76-
log "$GOOSE_NPM_REGISTRY is accessible. Using it for npm registry."
77-
export NPM_CONFIG_REGISTRY="$GOOSE_NPM_REGISTRY"
78-
79-
# Check if GOOSE_NPM_CERT is set and accessible
80-
if [ -n "${GOOSE_NPM_CERT:-}" ] && curl -s --head --fail "$GOOSE_NPM_CERT" > /dev/null; then
81-
log "Downloading certificate from: $GOOSE_NPM_CERT"
82-
curl -sSL -o ~/.config/goose/mcp-hermit/cert.pem "$GOOSE_NPM_CERT"
83-
if [ $? -eq 0 ]; then
84-
log "Certificate downloaded successfully."
85-
export NODE_EXTRA_CA_CERTS=~/.config/goose/mcp-hermit/cert.pem
86-
else
87-
log "Unable to download the certificate. Skipping certificate setup."
88-
fi
89-
else
90-
log "GOOSE_NPM_CERT is either not set or not accessible. Skipping certificate setup."
91-
fi
92-
93-
else
94-
log "GOOSE_NPM_REGISTRY is either not set or not accessible. Falling back to default npm registry."
95-
export NPM_CONFIG_REGISTRY="https://registry.npmjs.org/"
96-
fi
97-
98-
6+
# Get the directory where this script is located
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
998

9+
# Source the common setup script
10+
source "$SCRIPT_DIR/node-setup-common.sh"
10011

10112
# Final step: Execute npx with passed arguments
10213
log "Executing 'npx' command with arguments: $*"
10314
npx "$@" || log "Failed to execute 'npx' with arguments: $*"
10415

105-
log "npx setup script completed successfully."
16+
log "npx script completed successfully."

0 commit comments

Comments
 (0)