A comprehensive TypeScript library for rsync compatibility checking, automatic installation, and file/folder transfer operations across all major operating systems.
- Cross-platform compatibility checking (Windows, macOS, Linux)
- Enhanced automatic installation with fallback methods
- File and folder transfer operations (local and remote)
- Multiple installation methods per platform
- CLI interface for standalone usage
- Library interface for programmatic usage
- SSH support for remote transfers
- Comprehensive error handling and reporting
The library now includes comprehensive file and folder transfer functionality:
- Basic Transfer: Copy files/folders to local or remote destinations
- Recursive Copy: Copy entire directory structures with progress tracking
- Mirror Operations: Exact synchronization with deletion of extra files
- Incremental Backup: Space-efficient backups using hard links
- Remote Transfers: SSH-based transfers to/from remote servers
- SSH Key Authentication: Support for custom SSH private keys
- Custom Ports: Configure non-standard SSH ports
- SSH Options: Pass additional SSH configuration options
- User@Host Format: Standard SSH destination format support
- Verbose Output: Detailed transfer progress and file listings
- Dry Run: Preview operations without making changes
- Exclude Patterns: Skip files matching specific patterns
- Compression: Enable compression for faster transfers over networks
- Progress Tracking: Real-time transfer progress monitoring
The automatic installation feature now intelligently tries multiple installation methods if the first one fails:
- Platform Detection: Automatically detects your operating system
- Comprehensive Location Scanning: Checks standard PATH and alternative installation locations
- Intelligent Method Filtering: Skips methods where rsync already exists or prerequisites aren't met
- Executable vs Manual: Distinguishes between commands that can be run automatically vs manual steps
- Tool Availability Check: Verifies package managers are installed before attempting
- Fallback Strategy: If one method fails, automatically tries the next available executable option
- Enhanced Error Handling: Intelligently handles common installation scenarios
- Comprehensive Reporting: Provides detailed feedback and next-step guidance
The system now performs comprehensive scanning for existing rsync installations:
Windows Scanning Locations:
- Standard PATH (
rsync --version) - Git Bash:
git_dir\usr\bin\rsync.exe,git_dir\bin\rsync.exe,git_dir\mingw64\bin\rsync.exe - WSL:
wsl rsync --version(all distributions) - Scoop:
%USERPROFILE%\scoop\apps\rsync\current\rsync.exe - Chocolatey:
C:\ProgramData\chocolatey\lib\rsync\tools\rsync.exe
Smart Installation Logic:
- Skip if Found: If rsync exists in Git Bash, skips Git installation
- Skip if No Prerequisites: If WSL isn't available, skips WSL method
- Validate Tools: Checks if Scoop/Chocolatey are installed before attempting
- Existing Installation Handling: Works with already-installed tools
The system now handles common installation issues automatically:
- Permission Errors: Detects Chocolatey permission issues and suggests running as admin
- Existing Installations: When Git is already installed, checks for rsync in Git Bash paths
- WSL Scenarios: Handles existing WSL distributions and installs rsync directly
- Timeout Management: Better handling of long-running installation processes
- Detailed Guidance: Provides specific next steps when all automatic methods fail
// Enhanced auto-installation with comprehensive location checking
const result = await RsyncCompatibilityChecker.checkCompatibility();
// Now scans: PATH → Git Bash → WSL → Scoop → Chocolatey
const installResult = await RsyncCompatibilityChecker.attemptAutoInstall();
// Intelligently skips methods where rsync already exists
// Only attempts installation where prerequisites are met- Automatic (auto): Can be executed automatically via command line
- Manual (manual): Requires manual download/setup (shown for reference but skipped in auto-install)
import { RsyncCompatibilityChecker, RsyncManager } from 'fast-transferlib';
// Check if rsync is available
const result = await RsyncCompatibilityChecker.checkCompatibility();
if (result.isAvailable) {
console.log(`Rsync ${result.version} ready!`);
// Use RsyncManager for transfers
const rsync = new RsyncManager();
// Local file transfer
const localResult = await rsync.transfer('file.txt', '/backup/', {
verbose: true
});
// Remote transfer to server
const remoteResult = await rsync.transferToRemote('src/', {
user: 'username',
host: 'server.com',
path: '/home/user/backup/'
}, {
recursive: true,
sshKey: '~/.ssh/id_rsa'
});
// Mirror directory (exact copy with deletion)
const mirrorResult = await rsync.mirrorDirectory('src/', '/mirror/', {
verbose: true,
dryRun: true // Preview changes first
});
// Incremental backup
const backupResult = await rsync.backup('data/', '/backups/', {
exclude: ['*.log', 'node_modules/']
});
} else {
console.log(`Rsync not available: ${result.errorMessage}`);
console.log('Installation instructions:', result.installInstructions);
}# Check rsync availability
npx ts-node src/cli/rsyncCli.ts check
# File transfer operations
npx ts-node src/rsync/cli/rsyncCli.ts transfer file.txt /backup/
npx ts-node src/rsync/cli/rsyncCli.ts transfer --recursive src/ user@host:/backup/
npx ts-node src/rsync/cli/rsyncCli.ts transfer --ssh-key ~/.ssh/id_rsa src/ user@host:/data/
# Copy operations
npx ts-node src/rsync/cli/rsyncCli.ts copy src/ /backup/
npx ts-node src/rsync/cli/rsyncCli.ts copy --verbose --exclude "*.log" src/ /backup/
# Mirror operations
npx ts-node src/rsync/cli/rsyncCli.ts mirror src/ /mirror/
npx ts-node src/rsync/cli/rsyncCli.ts mirror --dry-run src/ /mirror/
# Backup operations
npx ts-node src/rsync/cli/rsyncCli.ts backup src/ /backups/
npx ts-node src/rsync/cli/rsyncCli.ts backup --exclude "node_modules" src/ /backups/
# Installation commands
npx ts-node src/rsync/cli/rsyncCli.ts install
npx ts-node src/rsync/cli/rsyncCli.ts install --interactive
npx ts-node src/rsync/cli/rsyncCli.ts install --auto
# Generate compatibility report
npx ts-node src/rsync/cli/rsyncCli.ts report- Chocolatey:
choco install rsync - Scoop:
scoop install rsync - WSL2:
wsl --install -d Ubuntu && wsl sudo apt install rsync - Git Bash: Included with Git for Windows
- Cygwin: Available through Cygwin installer
- Homebrew:
brew install rsync - MacPorts:
sudo port install rsync - Xcode Command Line Tools:
xcode-select --install
- Debian/Ubuntu:
sudo apt update && sudo apt install rsync - Fedora:
sudo dnf install rsync - CentOS/RHEL:
sudo yum install rsync - Arch:
sudo pacman -S rsync - openSUSE:
sudo zypper install rsync - Alpine:
apk add rsync
Checks if rsync is available on the current system.
Returns installation methods for the specified or current platform.
Attempts automatic installation using available package managers.
Generates a comprehensive compatibility and installation report.
Basic file/folder transfer to local or remote destination.
transferToRemote(source: string, target: TransferTarget, options?: RsyncOptions): Promise<RsyncResult>
Transfer files to a remote server via SSH.
transferFromRemote(source: TransferTarget, destination: string, options?: RsyncOptions): Promise<RsyncResult>
Download files from a remote server via SSH.
Copy folders recursively with progress tracking.
Create exact mirror of source (deletes extra files in destination).
Create incremental backup using hard links for space efficiency.
interface RsyncOptions {
verbose?: boolean; // Enable verbose output
recursive?: boolean; // Recursive directory transfer
delete?: boolean; // Delete files not in source
dryRun?: boolean; // Preview without making changes
compress?: boolean; // Enable compression
exclude?: string[]; // Exclude patterns
sshKey?: string; // SSH private key path
port?: number; // SSH port number
sshOptions?: string; // Additional SSH options
}interface TransferTarget {
user: string; // SSH username
host: string; // Remote hostname/IP
path: string; // Remote path
}interface RsyncResult {
success: boolean; // Operation success status
exitCode?: number; // Command exit code
output?: string; // Command output
error?: string; // Error message
}Attempts automatic installation using the best available method.
Generates a formatted compatibility and installation report.
Initialize the manager and check rsync availability.
Synchronize files from source to destination.
Perform a dry run to see what would be transferred.
See examples.js for comprehensive usage examples including:
- Basic compatibility checking
- Error handling and fallbacks
- Real-world integration scenarios
- CLI automation scripts
- Node.js 16.0.0 or higher
- TypeScript 5.2.2 or higher
GPL-3.0-only