Skip to content

Commit f9d6fc9

Browse files
committed
keep postinstall.sh
1 parent e3bdcec commit f9d6fc9

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ dev: node_modules/.installed build-main rebuild-native ## Start development serv
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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env sh
2+
# Postinstall script for developers
3+
#
4+
# Only runs electron-rebuild if Electron is installed (developer mode).
5+
# Server users don't have Electron (devDependency) so this exits immediately.
6+
7+
set -e
8+
9+
# Get script directory (works in both sh and bash)
10+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
11+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
12+
ELECTRON_PATH="$PROJECT_ROOT/node_modules/electron"
13+
14+
# Check if Electron is installed (developer mode)
15+
if [ ! -d "$ELECTRON_PATH" ]; then
16+
echo "🌐 Server mode: Using @lydell/node-pty prebuilt binaries"
17+
exit 0
18+
fi
19+
20+
echo "🔧 Developer mode: 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"

0 commit comments

Comments
 (0)