add ios social-app
This commit is contained in:
94
ios/setup.zsh
Executable file
94
ios/setup.zsh
Executable file
@@ -0,0 +1,94 @@
|
||||
#!/bin/zsh
|
||||
|
||||
set -e
|
||||
d=${0:a:h}
|
||||
source $d/config.zsh
|
||||
|
||||
# Sed compatibility wrapper
|
||||
function sediment() {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "$@"
|
||||
else
|
||||
sed -i "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Configuring $APP_NAME..."
|
||||
|
||||
# Check if repo exists
|
||||
if [ ! -d "$REPO_DIR" ]; then
|
||||
echo "Cloning social-app..."
|
||||
git clone https://github.com/bluesky-social/social-app "$REPO_DIR"
|
||||
else
|
||||
echo "Updating social-app..."
|
||||
pushd "$REPO_DIR"
|
||||
git stash -u
|
||||
if ! git pull; then
|
||||
echo "Git pull failed. Resetting..."
|
||||
git reset --hard HEAD
|
||||
git pull
|
||||
fi
|
||||
popd
|
||||
fi
|
||||
|
||||
# Backup config if not exists
|
||||
if [ ! -f "$CONFIG_FILE.bak" ]; then
|
||||
cp "$CONFIG_FILE" "$CONFIG_FILE.bak"
|
||||
fi
|
||||
|
||||
# 1. app.config.js modifications
|
||||
echo "Updating app.config.js..."
|
||||
|
||||
# Replace name
|
||||
sediment "s/name: 'Bluesky'/name: '$APP_NAME'/g" "$CONFIG_FILE"
|
||||
sediment "s/name: 'Aiat'/name: '$APP_NAME'/g" "$CONFIG_FILE" # Handle re-run
|
||||
sediment "s/slug: 'bluesky'/slug: '$APP_SLUG'/g" "$CONFIG_FILE"
|
||||
sediment "s/slug: 'aiat'/slug: '$APP_SLUG'/g" "$CONFIG_FILE" # Handle re-run
|
||||
sediment "s/scheme: 'bsky'/scheme: '$APP_SCHEME'/g" "$CONFIG_FILE"
|
||||
|
||||
# Replace Bundle ID and App Group
|
||||
sediment "s/xyz.blueskyweb.app/$BUNDLE_ID/g" "$CONFIG_FILE"
|
||||
sediment "s/group.app.bsky/$APP_GROUP/g" "$CONFIG_FILE"
|
||||
|
||||
# Inject NSAppTransportSecurity for development/preview (Allow Arbitrary Loads)
|
||||
if ! grep -q "NSAppTransportSecurity" "$CONFIG_FILE"; then
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "/ios: {/a\\
|
||||
infoPlist: {\\
|
||||
NSAppTransportSecurity: {\\
|
||||
NSAllowsArbitraryLoads: true,\\
|
||||
},\\
|
||||
}," "$CONFIG_FILE"
|
||||
else
|
||||
sed -i "/ios: {/a\\
|
||||
infoPlist: {\\
|
||||
NSAppTransportSecurity: {\\
|
||||
NSAllowsArbitraryLoads: true,\\
|
||||
},\\
|
||||
}," "$CONFIG_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. constants.ts modifications
|
||||
echo "Updating constants.ts..."
|
||||
sediment "s|export const BSKY_SERVICE = 'https://bsky.social'|export const BSKY_SERVICE = '$SERVICE_URL'|g" "$CONSTANTS_FILE"
|
||||
sediment "s|export const BSKY_SERVICE_DID = 'did:web:bsky.social'|export const BSKY_SERVICE_DID = 'did:web:syu.is'|g" "$CONSTANTS_FILE"
|
||||
sediment "s|export const PUBLIC_BSKY_SERVICE = 'https://public.api.bsky.app'|export const PUBLIC_BSKY_SERVICE = 'https://bsky.syu.is'|g" "$CONSTANTS_FILE"
|
||||
sediment "s|const HELP_DESK_LANG = 'en-us'|const HELP_DESK_LANG = 'ja-jp'|g" "$CONSTANTS_FILE"
|
||||
sediment "s|export const HELP_DESK_URL = \`https://blueskyweb.zendesk.com/hc/\${HELP_DESK_LANG}\`|export const HELP_DESK_URL = '$HELP_URL'|g" "$CONSTANTS_FILE"
|
||||
|
||||
# 3. Footer/Link replacements (Global text replacement for specific URLs)
|
||||
echo "Replacing links..."
|
||||
grep -r "https://bsky.social/about/blog" "$REPO_DIR/src" -l | xargs -I {} zsh -c "if [[ \"\$OSTYPE\" == \"darwin\"* ]]; then sed -i '' \"s|https://bsky.social/about/blog|$HELP_URL|g\" {}; else sed -i \"s|https://bsky.social/about/blog|$HELP_URL|g\" {}; fi"
|
||||
grep -r "https://bsky.social/about/blog/jobs" "$REPO_DIR/src" -l | xargs -I {} zsh -c "if [[ \"\$OSTYPE\" == \"darwin\"* ]]; then sed -i '' \"s|https://bsky.social/about/blog/jobs|$HELP_URL|g\" {}; else sed -i \"s|https://bsky.social/about/blog/jobs|$HELP_URL|g\" {}; fi"
|
||||
grep -r "/support/privacy" "$REPO_DIR/src" -l | xargs -I {} zsh -c "if [[ \"\$OSTYPE\" == \"darwin\"* ]]; then sed -i '' \"s|/support/privacy|$PRIVACY_URL|g\" {}; else sed -i \"s|/support/privacy|$PRIVACY_URL|g\" {}; fi"
|
||||
grep -r "/support/tos" "$REPO_DIR/src" -l | xargs -I {} zsh -c "if [[ \"\$OSTYPE\" == \"darwin\"* ]]; then sed -i '' \"s|/support/tos|$TERMS_URL|g\" {}; else sed -i \"s|/support/tos|$TERMS_URL|g\" {}; fi"
|
||||
|
||||
# 4. Icon replacement (Stub)
|
||||
if [ -f "icon.png" ]; then
|
||||
echo "Updating icon..."
|
||||
cp "icon.png" "$REPO_DIR/assets/icon.png"
|
||||
cp "icon.png" "$REPO_DIR/assets/icon-android-notification.png"
|
||||
fi
|
||||
|
||||
echo "Setup complete."
|
||||
Reference in New Issue
Block a user