-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdev-web.sh
More file actions
executable file
·142 lines (119 loc) · 4.93 KB
/
dev-web.sh
File metadata and controls
executable file
·142 lines (119 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# PREREQ:
# Run ./setup-web.sh at least once before running this script.
#
# This script will be run many times as you develop web packages locally.
# Each run:
# 1. Increments the build number (stored in web-build-number.txt)
# 2. Builds and publishes @beamable/sdk and @beamable/portal-toolkit
# as version 0.0.123-local<build_number> to the local Verdaccio
# registry (http://localhost:4873)
# 3. Restarts local-unpkg to bust its in-memory file cache
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WEB_SDK_DIR="$SCRIPT_DIR/web"
TOOLKIT_DIR="$SCRIPT_DIR/beam-portal-toolkit"
LOCALDEV_DIR="$SCRIPT_DIR/portal-localdev"
WEB_BUILD_NUMBER_FILE="$SCRIPT_DIR/web-build-number.txt"
REGISTRY="http://localhost:4873"
# ---------------------------------------------------------------------------
# Cleanup trap — restores package.json files even if the script exits early
# ---------------------------------------------------------------------------
SDK_BACKUP=false
TOOLKIT_BACKUP=false
cleanup() {
local exit_code=$?
if [ "$SDK_BACKUP" = true ]; then
echo " Restoring web/package.json..."
cp "$WEB_SDK_DIR/package.json.devbak" "$WEB_SDK_DIR/package.json" 2>/dev/null || true
rm -f "$WEB_SDK_DIR/package.json.devbak"
fi
if [ "$TOOLKIT_BACKUP" = true ]; then
echo " Restoring beam-portal-toolkit/package.json..."
cp "$TOOLKIT_DIR/package.json.devbak" "$TOOLKIT_DIR/package.json" 2>/dev/null || true
rm -f "$TOOLKIT_DIR/package.json.devbak"
fi
exit $exit_code
}
trap cleanup EXIT
# ---------------------------------------------------------------------------
# Build number
# ---------------------------------------------------------------------------
if [ ! -f "$WEB_BUILD_NUMBER_FILE" ]; then
echo "web-build-number.txt not found. Run ./setup-web.sh first."
exit 1
fi
NEXT_BUILD_NUMBER=$(cat "$WEB_BUILD_NUMBER_FILE")
((NEXT_BUILD_NUMBER += 1))
echo $NEXT_BUILD_NUMBER > "$WEB_BUILD_NUMBER_FILE"
VERSION="0.0.123-local$NEXT_BUILD_NUMBER"
echo ""
echo "=== Beamable Web Local Dev ==="
echo "Publishing version: $VERSION"
echo "Registry: $REGISTRY"
echo ""
# ---------------------------------------------------------------------------
# Publish webSDK
# ---------------------------------------------------------------------------
echo "--- Building @beamable/sdk ---"
cd "$WEB_SDK_DIR"
cp package.json package.json.devbak
SDK_BACKUP=true
echo " [cmd] pnpm install"
pnpm install
echo " [cmd] pnpm version $VERSION --no-git-tag-version"
pnpm version "$VERSION" --no-git-tag-version
echo " [cmd] pnpm build"
pnpm build
echo " [cmd] pnpm publish --registry $REGISTRY --no-git-checks --tag local"
pnpm publish --registry "$REGISTRY" --no-git-checks --tag local
cp package.json.devbak package.json && rm package.json.devbak
SDK_BACKUP=false
echo "Published @beamable/sdk@$VERSION"
cd "$SCRIPT_DIR"
# ---------------------------------------------------------------------------
# Publish toolkit
# ---------------------------------------------------------------------------
echo ""
echo "--- Building @beamable/portal-toolkit ---"
cd "$TOOLKIT_DIR"
cp package.json package.json.devbak
TOOLKIT_BACKUP=true
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.peerDependencies['@beamable/sdk'] = '$VERSION';
pkg.devDependencies['@beamable/sdk'] = '$VERSION';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
echo " Updated @beamable/sdk → $VERSION"
# Evict any cached @beamable/sdk tarball from the pnpm content-addressable store
# AND the pnpm metadata cache. After a Verdaccio wipe the same version is
# republished with a different hash, so stale cached integrity hashes cause
# ERR_PNPM_TARBALL_INTEGRITY on the next install.
rm -f pnpm-lock.yaml
pnpm store delete @beamable/sdk 2>/dev/null || true
pnpm cache delete @beamable/sdk 2>/dev/null || true
echo " [cmd] pnpm install"
pnpm install
echo " [cmd] pnpm version $VERSION --no-git-tag-version"
pnpm version "$VERSION" --no-git-tag-version
echo " [cmd] pnpm build"
pnpm build
echo " [cmd] pnpm publish --registry $REGISTRY --no-git-checks --tag local"
pnpm publish --registry "$REGISTRY" --no-git-checks --tag local
cp package.json.devbak package.json && rm package.json.devbak
TOOLKIT_BACKUP=false
echo "Published @beamable/portal-toolkit@$VERSION"
cd "$SCRIPT_DIR"
# ---------------------------------------------------------------------------
# Restart local-unpkg to clear the in-memory file cache
# ---------------------------------------------------------------------------
echo ""
echo "--- Restarting local-unpkg (clearing file cache) ---"
docker compose -f "$LOCALDEV_DIR/docker-compose.yml" restart local-unpkg
# ---------------------------------------------------------------------------
# Done
# ---------------------------------------------------------------------------
echo ""
echo "Done. Set ToolkitVersion: \"$VERSION\" in your extension manifest and run the Portal."