feat(new-setup-2): add per-channel bundled install scripts
Twelve idempotent install scripts matching install-telegram.sh's shape,
one per channel in /new-setup-2's pick list (except Emacs, which uses
a git-merge install flow). Each bundles preflight + fetch + copy +
register + pnpm install + build so a single allowlisted bash call can
replace a chain of permission prompts. Linear's also patches
chat-sdk-bridge.ts for catchAll forwarding; Matrix's runs the
post-install ESM-extension dist patch; WhatsApp-native's covers the
deterministic install portion only — QR/pairing auth still lives in
/add-whatsapp.
Scripts only; new-setup-2/SKILL.md integration deferred pending a
decision on whether to generalize the set-env pattern from 712a0e1
across the Chat SDK channels (each /add-<channel>/SKILL.md's
Credentials section has a similar unapprovable shell chain).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
75
setup/install-whatsapp.sh
Executable file
75
setup/install-whatsapp.sh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
# Setup helper: install-whatsapp — bundles the preflight + install commands
|
||||
# from the /add-whatsapp skill into one idempotent script so /new-setup-2 can
|
||||
# run them programmatically before continuing to QR/pairing-code auth.
|
||||
#
|
||||
# Copies the native Baileys WhatsApp adapter, its whatsapp-auth and groups
|
||||
# setup steps in from the `channels` branch; appends the self-registration
|
||||
# import; registers `groups` and `whatsapp-auth` entries in the setup STEPS
|
||||
# map; installs the pinned @whiskeysockets/baileys + qrcode + pino packages;
|
||||
# builds. All steps are safe to re-run. QR/pairing-code authentication
|
||||
# stays in the skill — this script only handles the deterministic install.
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
echo "=== NANOCLAW SETUP: INSTALL_WHATSAPP ==="
|
||||
|
||||
CHANNEL_FILES=(
|
||||
src/channels/whatsapp.ts
|
||||
setup/whatsapp-auth.ts
|
||||
setup/groups.ts
|
||||
)
|
||||
|
||||
needs_install=false
|
||||
for f in "${CHANNEL_FILES[@]}"; do
|
||||
[[ -f "$f" ]] || needs_install=true
|
||||
done
|
||||
grep -q "import './whatsapp.js';" src/channels/index.ts || needs_install=true
|
||||
grep -q "groups: " setup/index.ts || needs_install=true
|
||||
grep -q "'whatsapp-auth':" setup/index.ts || needs_install=true
|
||||
grep -q '"@whiskeysockets/baileys"' package.json || needs_install=true
|
||||
grep -q '"qrcode"' package.json || needs_install=true
|
||||
grep -q '"pino"' package.json || needs_install=true
|
||||
[[ -d node_modules/@whiskeysockets/baileys ]] || needs_install=true
|
||||
|
||||
if ! $needs_install; then
|
||||
echo "STATUS: already-installed"
|
||||
echo "=== END ==="
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "STEP: fetch-channels-branch"
|
||||
git fetch origin channels
|
||||
|
||||
echo "STEP: copy-files"
|
||||
for f in "${CHANNEL_FILES[@]}"; do
|
||||
git show "origin/channels:$f" > "$f"
|
||||
done
|
||||
|
||||
echo "STEP: register-import"
|
||||
if ! grep -q "import './whatsapp.js';" src/channels/index.ts; then
|
||||
printf "import './whatsapp.js';\n" >> src/channels/index.ts
|
||||
fi
|
||||
|
||||
echo "STEP: register-setup-steps"
|
||||
if ! grep -q "'whatsapp-auth':" setup/index.ts; then
|
||||
awk '
|
||||
{ print }
|
||||
/register: \(\) => import/ && !inserted {
|
||||
print " groups: () => import('\''./groups.js'\''),"
|
||||
print " '\''whatsapp-auth'\'': () => import('\''./whatsapp-auth.js'\''),"
|
||||
inserted = 1
|
||||
}
|
||||
' setup/index.ts > setup/index.ts.tmp && mv setup/index.ts.tmp setup/index.ts
|
||||
fi
|
||||
|
||||
echo "STEP: pnpm-install"
|
||||
pnpm install @whiskeysockets/baileys@6.17.16 qrcode@1.5.4 @types/qrcode@1.5.6 pino@9.6.0
|
||||
|
||||
echo "STEP: pnpm-build"
|
||||
pnpm run build
|
||||
|
||||
echo "STATUS: installed"
|
||||
echo "=== END ==="
|
||||
Reference in New Issue
Block a user