forked from
j4ck.xyz/tweets2bsky
A simple tool which lets you scrape twitter accounts and crosspost them to bluesky accounts! Comes with a CLI and a webapp for managing profiles! Works with images/videos/link embeds/threads.
1#!/bin/bash
2
3echo "🔄 Tweets-2-Bsky Updater"
4echo "========================="
5
6# Check if git is available
7if ! command -v git &> /dev/null; then
8 echo "❌ Git is not installed. Please install git to update."
9 exit 1
10fi
11
12echo "⬇️ Pulling latest changes..."
13# Attempt to pull with autostash to handle local changes gracefully
14if ! git pull --autostash; then
15 echo "⚠️ Standard pull failed. Attempting to stash local changes and retry..."
16 git stash
17 if ! git pull; then
18 echo "❌ Git pull failed even after stashing. You might have complex local changes."
19 echo " Please check 'git status' and resolve conflicts manually."
20 exit 1
21 fi
22fi
23
24echo "📦 Installing dependencies..."
25npm install
26
27if [ $? -ne 0 ]; then
28 echo "❌ npm install failed."
29 exit 1
30fi
31
32echo "🏗️ Building project..."
33npm run build
34
35if [ $? -ne 0 ]; then
36 echo "❌ Build failed."
37 exit 1
38fi
39
40echo "✅ Update complete!"
41
42# Determine PM2 process name (default to 'tweets-2-bsky' if not found)
43PROCESS_NAME="tweets-2-bsky"
44if pm2 describe twitter-mirror &> /dev/null; then
45 PROCESS_NAME="twitter-mirror"
46fi
47
48if command -v pm2 &> /dev/null; then
49 echo "🔄 Hard restarting PM2 process '$PROCESS_NAME' to fix environment paths..."
50 pm2 delete $PROCESS_NAME
51 pm2 start dist/index.js --name $PROCESS_NAME
52 pm2 save
53 echo "✅ PM2 process restarted and saved."
54else
55 echo "⚠️ PM2 not found. Please restart your application manually."
56fi