Add Twitter and LinkedIn publishers with Playwright sidecars
- Create twitter-post sidecar with Playwright for browser automation - Create linkedin-post sidecar with Playwright for browser automation - Add TwitterPublisher class that calls twitter-post sidecar - Add LinkedInPublisher class that calls linkedin-post sidecar - Register both publishers in PublisherManager via AppServiceProvider - Update Posts index view to show Publish button for twitter/linkedin types Both publishers use the same pattern as RedditPublisher: - No API keys required (uses stored credentials from Social Accounts) - Browser automation via Playwright - Returns JSON result with success/failure and URL Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
USERNAME=""
|
||||
PASSWORD=""
|
||||
TWEET=""
|
||||
HEADLESS_FLAG="true"
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--username=*) USERNAME="${arg#*=}" ;;
|
||||
--password=*) PASSWORD="${arg#*=}" ;;
|
||||
--tweet=*) TWEET="${arg#*=}" ;;
|
||||
--headed) HEADLESS_FLAG="false" ;;
|
||||
*)
|
||||
UNKNOWN_FLAG="${arg%%=*}"
|
||||
echo "{\"success\": false, \"error\": \"Unknown argument: $UNKNOWN_FLAG\"}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
MISSING=""
|
||||
[ -z "$USERNAME" ] && MISSING="$MISSING --username"
|
||||
[ -z "$PASSWORD" ] && MISSING="$MISSING --password"
|
||||
[ -z "$TWEET" ] && MISSING="$MISSING --tweet"
|
||||
|
||||
if [ -n "$MISSING" ]; then
|
||||
echo "{\"success\": false, \"error\": \"Missing required argument(s):$MISSING\"}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export TWITTER_USERNAME="$USERNAME"
|
||||
export TWITTER_PASSWORD="$PASSWORD"
|
||||
export TWEET_TEXT="$TWEET"
|
||||
export HEADLESS="$HEADLESS_FLAG"
|
||||
|
||||
set +e
|
||||
npx playwright test tests/twitter-post.spec.js
|
||||
PLAYWRIGHT_EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
RESULT_FILE="test-results/result.json"
|
||||
|
||||
if [ -f "$RESULT_FILE" ]; then
|
||||
cat "$RESULT_FILE"
|
||||
echo
|
||||
else
|
||||
echo "{\"success\": false, \"error\": \"Test did not produce a result file\"}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit "$PLAYWRIGHT_EXIT_CODE"
|
||||
Reference in New Issue
Block a user