From 744b7a32214becd735bee3107b5df8be6507c8f8 Mon Sep 17 00:00:00 2001 From: Leons Aleksandrovs Date: Sat, 17 Jan 2026 16:17:24 +0200 Subject: [PATCH] --files-only mode, -h --help flags --- MANUAL | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ sync-project.sh | 31 ++++++++++++++++++---- 2 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 MANUAL diff --git a/MANUAL b/MANUAL new file mode 100644 index 0000000..d2f3c58 --- /dev/null +++ b/MANUAL @@ -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) diff --git a/sync-project.sh b/sync-project.sh index bc673f1..68aeabe 100755 --- a/sync-project.sh +++ b/sync-project.sh @@ -17,11 +17,23 @@ ARCHIVE_NAME="sync.tar.gz" # Parse command line arguments SFTP_ONLY=false +FILES_ONLY=false + for arg in "$@"; do - if [ "$arg" = "--sftp-only" ]; then - SFTP_ONLY=true - echo -e "${YELLOW}Sftp only mode enabled${NC}" - fi + case "$arg" in + -h|--help) + cat "$SCRIPT_DIR/MANUAL" + 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 # 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 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 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}" +# Skip helper scripts and config generation in files-only mode +if [ "$FILES_ONLY" = true ]; then + exit 0 +fi + # Create .vscode sftp.json file mkdir -p .vscode