Skip to content

Commit d7c1442

Browse files
authored
chore: add bin/setup to setup package linking (#149)
1 parent 4722ed4 commit d7c1442

File tree

7 files changed

+67
-1
lines changed

7 files changed

+67
-1
lines changed

β€Ž.env.exampleβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ APPLE_TEAM_ID=
1616
APPLE_CODESIGN_CERT_BASE64=
1717
APPLE_CODESIGN_CERT_PASSWORD=
1818
APPLE_CODESIGN_KEYCHAIN_PASSWORD=
19+
20+
# Uncomment to use local @posthog/agent package
21+
# AGENT_PACKAGE_LOCATION=file:../agent

β€Ž.github/workflows/release.ymlβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ jobs:
9393
with:
9494
node-version: 22
9595
cache: "pnpm"
96+
- name: Setup workspace
97+
run: bin/setup
9698
- name: Install dependencies
9799
run: pnpm install --frozen-lockfile
98100
- name: Import code signing certificate

β€Ž.github/workflows/typecheck.ymlβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
uses: actions/setup-node@v4
2020
with:
2121
cache: 'pnpm'
22+
- name: Setup workspace
23+
run: bin/setup
2224
- name: Install dependencies
2325
run: pnpm install --frozen-lockfile
2426
- name: Run type check

β€Ž.husky/pre-commitβ€Ž

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1+
#!/bin/bash
2+
3+
# Load .env file if it exists
4+
if [ -f .env ]; then
5+
export $(grep -v '^#' .env | grep -v '^[[:space:]]*$' | xargs 2>/dev/null)
6+
fi
7+
8+
# Check if AGENT_PACKAGE_LOCATION is set and lockfile is being committed
9+
if [ -n "$AGENT_PACKAGE_LOCATION" ]; then
10+
if git diff --cached --name-only | grep -q "pnpm-lock.yaml"; then
11+
echo "❌ Error: Cannot commit pnpm-lock.yaml when AGENT_PACKAGE_LOCATION is set"
12+
echo " You have a local agent override active in .env"
13+
echo " Either:"
14+
echo " - Comment out AGENT_PACKAGE_LOCATION in .env and run bin/setup"
15+
echo " - Unstage pnpm-lock.yaml: git reset pnpm-lock.yaml"
16+
exit 1
17+
fi
18+
fi
19+
120
pnpm lint-staged

β€Žbin/setupβ€Ž

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Setup script for Array development environment
4+
# Run this after cloning or when changing AGENT_PACKAGE_LOCATION in .env
5+
6+
echo "πŸ”§ Setting up Array development environment..."
7+
8+
# Load .env file if it exists
9+
if [ -f .env ]; then
10+
export $(grep -v '^#' .env | grep -v '^[[:space:]]*$' | xargs)
11+
fi
12+
13+
# Start with base workspace config
14+
cp pnpm-workspace.base.yaml pnpm-workspace.yaml
15+
16+
# If AGENT_PACKAGE_LOCATION is set, add the override and build the agent
17+
if [ -n "$AGENT_PACKAGE_LOCATION" ]; then
18+
echo "βœ“ Using local @posthog/agent from: $AGENT_PACKAGE_LOCATION"
19+
cat >> pnpm-workspace.yaml <<EOF
20+
21+
overrides:
22+
"@posthog/agent": $AGENT_PACKAGE_LOCATION
23+
EOF
24+
25+
# Extract the path from file:../agent format
26+
AGENT_PATH="${AGENT_PACKAGE_LOCATION#file:}"
27+
28+
if [ -d "$AGENT_PATH" ]; then
29+
echo "πŸ“¦ Building @posthog/agent..."
30+
(cd "$AGENT_PATH" && pnpm install && pnpm build)
31+
echo "βœ“ @posthog/agent built successfully"
32+
else
33+
echo "⚠️ Warning: Agent path $AGENT_PATH does not exist"
34+
fi
35+
else
36+
echo "βœ“ Using production @posthog/agent package"
37+
fi
38+
39+
echo "βœ“ Workspace configured"

β€Žpackage.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"packageManager": "[email protected]",
1212
"scripts": {
13+
"setup": "bash bin/setup",
1314
"start": "electron-forge start",
1415
"package": "electron-forge package",
1516
"make": "electron-forge make",

β€Žpnpm-workspace.yamlβ€Ž renamed to β€Žpnpm-workspace.base.yamlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ packages:
33

44
onlyBuiltDependencies:
55
- electron
6-
- esbuild
6+
- esbuild

0 commit comments

Comments
Β (0)