--files-only mode, -h --help flags

This commit is contained in:
2026-01-17 16:17:24 +02:00
parent bca9dbe2c2
commit 744b7a3221
2 changed files with 96 additions and 5 deletions

70
MANUAL Normal file
View File

@@ -0,0 +1,70 @@
SYNC-PROJECT(1) Project Sync Toolkit SYNC-PROJECT(1)
NAME
sync-project.sh - Sync projects between remote servers and local machine
SYNOPSIS
sync-project.sh [OPTIONS]
DESCRIPTION
Downloads a project from a remote server and optionally generates helper
scripts for ongoing synchronization. Uses tar for initial sync and rsync
for subsequent syncs.
OPTIONS
-h, --help
Display this help and exit.
--files-only
Quick sync mode. Downloads files only, excluding node_modules and
vendor directories. Does not create helper scripts, sftp.json, or
upload lazygit.
--sftp-only
Setup mode for SFTP workflow. Creates helper scripts but skips
lazygit upload and .gitignore modifications.
MODES
Default mode:
- Downloads all project files
- Creates .vscode/sftp.json
- Generates all helper scripts
- Uploads lazygit to server
- Updates .gitignore
--sftp-only mode:
- Downloads all project files
- Creates .vscode/sftp.json
- Generates: local-remote.sh, remote-local.sh, sftp-watch.sh, ssh.sh
- No lazygit, no .gitignore updates
--files-only mode:
- Downloads project files (excludes node_modules, vendor)
- No helper scripts
- No configuration files
EXAMPLES
Full setup with all scripts:
./sync-project.sh
Quick file sync only:
./sync-project.sh --files-only
SFTP workflow without git tools:
./sync-project.sh --sftp-only
GENERATED SCRIPTS
remote-local.sh Pull files from server
local-remote.sh Push files to server
ssh.sh SSH with --db, --git, --todo flags
sftp-watch.sh Continuous sync with watchexec
watch-build.sh Build and deploy automation
split-conflicts.sh Git conflict resolver
REQUIREMENTS
sshpass, rsync, tar, ssh/scp
Optional: watchexec (for watch scripts)
FILES
.sync-credentials Pre-defined config (optional)
.vscode/sftp.json VS Code SFTP config (generated)

View File

@@ -17,11 +17,23 @@ ARCHIVE_NAME="sync.tar.gz"
# Parse command line arguments # Parse command line arguments
SFTP_ONLY=false SFTP_ONLY=false
FILES_ONLY=false
for arg in "$@"; do for arg in "$@"; do
if [ "$arg" = "--sftp-only" ]; then case "$arg" in
SFTP_ONLY=true -h|--help)
echo -e "${YELLOW}Sftp only mode enabled${NC}" cat "$SCRIPT_DIR/MANUAL"
fi exit 0
;;
--sftp-only)
SFTP_ONLY=true
echo -e "${YELLOW}SFTP only mode enabled${NC}"
;;
--files-only)
FILES_ONLY=true
echo -e "${YELLOW}Files only mode enabled${NC}"
;;
esac
done done
# Function to add entry to .gitignore if not already present # Function to add entry to .gitignore if not already present
@@ -73,7 +85,11 @@ echo "Starting project sync..."
# Step 1: SSH into server and create tar archive # Step 1: SSH into server and create tar archive
echo "Creating archive on server..." echo "Creating archive on server..."
sshpass -p "${SSH_PASSWORD}" ssh ${SERVER_HOST} "cd ${SERVER_PROJECT_PATH} && tar -czf ../${ARCHIVE_NAME} ." if [ "$FILES_ONLY" = true ]; then
sshpass -p "${SSH_PASSWORD}" ssh ${SERVER_HOST} "cd ${SERVER_PROJECT_PATH} && tar -czf ../${ARCHIVE_NAME} --exclude='node_modules' --exclude='vendor' ."
else
sshpass -p "${SSH_PASSWORD}" ssh ${SERVER_HOST} "cd ${SERVER_PROJECT_PATH} && tar -czf ../${ARCHIVE_NAME} ."
fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "${RED}Failed to create archive on server${NC}" echo -e "${RED}Failed to create archive on server${NC}"
@@ -118,6 +134,11 @@ sshpass -p "${SSH_PASSWORD}" ssh ${SERVER_HOST} "rm ~/${ARCHIVE_NAME}"
echo -e "${GREEN}File sync complete!${NC}" echo -e "${GREEN}File sync complete!${NC}"
# Skip helper scripts and config generation in files-only mode
if [ "$FILES_ONLY" = true ]; then
exit 0
fi
# Create .vscode sftp.json file # Create .vscode sftp.json file
mkdir -p .vscode mkdir -p .vscode