Skip to content

Commit 9d4d6f7

Browse files
committed
keep postinstall.sh
1 parent e3bdcec commit 9d4d6f7

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ help: ## Show this help message
110110

111111
## Development
112112
ifeq ($(OS),Windows_NT)
113-
dev: node_modules/.installed build-main rebuild-native ## Start development server (Vite + nodemon watcher for Windows compatibility)
113+
dev: node_modules/.installed build-main ## Start development server (Vite + nodemon watcher for Windows compatibility)
114114
@echo "Starting dev mode (2 watchers: nodemon for main process, vite for renderer)..."
115115
# On Windows, use npm run because bunx doesn't correctly pass arguments to concurrently
116116
# https://github.com/oven-sh/bun/issues/18275
117117
@NODE_OPTIONS="--max-old-space-size=4096" npm x concurrently -k --raw \
118118
"bun x nodemon --watch src --watch tsconfig.main.json --watch tsconfig.json --ext ts,tsx,json --ignore dist --ignore node_modules --exec node scripts/build-main-watch.js" \
119119
"vite"
120120
else
121-
dev: node_modules/.installed build-main build-preload rebuild-native ## Start development server (Vite + tsgo watcher for 10x faster type checking)
121+
dev: node_modules/.installed build-main build-preload ## Start development server (Vite + tsgo watcher for 10x faster type checking)
122122
@bun x concurrently -k \
123123
"bun x concurrently \"$(TSGO) -w -p tsconfig.main.json\" \"bun x tsc-alias -w -p tsconfig.main.json\"" \
124124
"vite"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"docs:watch": "make docs-watch",
4242
"storybook": "make storybook",
4343
"storybook:build": "make storybook-build",
44-
"test:storybook": "make test-storybook"
44+
"test:storybook": "make test-storybook",
45+
"postinstall": "sh scripts/postinstall.sh"
4546
},
4647
"dependencies": {
4748
"@ai-sdk/anthropic": "^2.0.44",

scripts/postinstall.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env sh
2+
# Conditional postinstall script for node-pty
3+
#
4+
# Compatible with all environments (no node/bun required).
5+
#
6+
# Desktop mode (Electron present):
7+
# - Rebuilds node-pty for Electron's ABI
8+
#
9+
# Server mode (no Electron):
10+
# - Uses Node.js/Bun prebuilt binaries (no rebuild needed)
11+
12+
set -e
13+
14+
# Get script directory (works in both sh and bash)
15+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
16+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
17+
ELECTRON_PATH="$PROJECT_ROOT/node_modules/electron"
18+
19+
if [ -d "$ELECTRON_PATH" ]; then
20+
echo "🔧 Electron detected - rebuilding node-pty for Electron..."
21+
22+
# Try npx first, fallback to bunx
23+
if command -v npx >/dev/null 2>&1; then
24+
npx @electron/rebuild -f -m node_modules/node-pty || {
25+
echo "⚠️ Failed to rebuild native modules"
26+
echo " Terminal functionality may not work in desktop mode."
27+
echo " Run 'make rebuild-native' manually to fix."
28+
exit 0
29+
}
30+
elif command -v bunx >/dev/null 2>&1; then
31+
bunx @electron/rebuild -f -m node_modules/node-pty || {
32+
echo "⚠️ Failed to rebuild native modules"
33+
echo " Terminal functionality may not work in desktop mode."
34+
echo " Run 'make rebuild-native' manually to fix."
35+
exit 0
36+
}
37+
else
38+
echo "⚠️ Neither npx nor bunx found - cannot rebuild native modules"
39+
echo " Terminal functionality may not work in desktop mode."
40+
echo " Run 'make rebuild-native' manually to fix."
41+
exit 0
42+
fi
43+
44+
echo "✅ Native modules rebuilt successfully"
45+
else
46+
echo "🌐 Server mode detected - using prebuilt binaries"
47+
fi

0 commit comments

Comments
 (0)