From 450e62dd259c02e6a902a940e71781689434a903 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Tue, 21 Oct 2025 21:45:17 +0100 Subject: [PATCH] Improve --- frontend/local-client-cli/Dockerfile | 4 +- frontend/local-client-cli/README.md | 320 ++++++++------------ frontend/local-client-cli/webpack.config.js | 48 +-- 3 files changed, 144 insertions(+), 228 deletions(-) diff --git a/frontend/local-client-cli/Dockerfile b/frontend/local-client-cli/Dockerfile index 36a314d0..6b8e1d6c 100644 --- a/frontend/local-client-cli/Dockerfile +++ b/frontend/local-client-cli/Dockerfile @@ -15,9 +15,7 @@ LABEL org.opencontainers.image.source="https://github.com/schmelczer/vault-link" LABEL org.opencontainers.image.licenses="MIT" LABEL org.opencontainers.image.authors="andras@schmelczer.dev" - - -COPY --from=builder --chown=vaultlink:vaultlink /build/local-client-cli/dist/cli.js /app/cli.js +COPY --from=builder /build/local-client-cli/dist/cli.js /app/cli.js WORKDIR /vault diff --git a/frontend/local-client-cli/README.md b/frontend/local-client-cli/README.md index 42a036b2..0585bacc 100644 --- a/frontend/local-client-cli/README.md +++ b/frontend/local-client-cli/README.md @@ -1,57 +1,23 @@ # VaultLink Local CLI -A standalone command-line interface for syncing VaultLink vaults to your local filesystem. This CLI wraps the VaultLink sync client and provides file watching capabilities for real-time synchronization. - -## Features - -- Real-time bidirectional sync between local filesystem and VaultLink server -- File watching with automatic change detection -- Cross-platform support (Linux, macOS, Windows) -- Configuration via command-line arguments or JSON file -- Comprehensive error handling and logging -- Graceful shutdown on SIGINT/SIGTERM +Standalone CLI for syncing VaultLink vaults to local filesystem with real-time bidirectional sync and file watching. ## Installation -### Using Docker (Recommended) - -The easiest way to run VaultLink CLI is using Docker: +### Docker (Recommended) ```bash docker pull ghcr.io/schmelczer/vault-link-cli:latest -# Run with all options via command line docker run -v /path/to/vault:/vault \ ghcr.io/schmelczer/vault-link-cli:latest \ -l /vault \ - -r https://sync.example.com \ + -r wss://sync.example.com \ -t your-auth-token \ -v default - -# Or use a config file -docker run -v /path/to/vault:/vault \ - -v /path/to/config.json:/config.json \ - ghcr.io/schmelczer/vault-link-cli:latest \ - -l /vault \ - -c /config.json ``` -### Using Docker Compose - -```yaml -version: '3.8' - -services: - vaultlink-cli: - image: ghcr.io/schmelczer/vault-link-cli:latest - volumes: - - ./vault:/vault - - ./config.json:/config.json - command: -l /vault -c /config.json - restart: unless-stopped -``` - -### From npm Package +### npm ```bash npm install -g @schmelczer/local-client-cli @@ -69,220 +35,172 @@ node dist/cli.js --help ## Usage -### Basic Usage - ```bash vaultlink \ - --local-path ./my-vault \ - --remote-uri https://sync.example.com \ + --local-path ./vault \ + --remote-uri wss://sync.example.com \ --token your-auth-token \ --vault-name default ``` -### Using a Configuration File +## Options -Create a `config.json` file: +### Required -```json -{ - "remoteUri": "https://sync.example.com", - "token": "your-auth-token", - "vaultName": "default", - "syncConcurrency": 1, - "maxFileSizeMB": 10, - "ignorePatterns": [".git/**", "*.tmp"], - "webSocketRetryIntervalMs": 3500 -} -``` +| Option | Description | +|--------|-------------| +| `-l, --local-path ` | Local directory to sync | +| `-r, --remote-uri ` | Remote server WebSocket URI (ws:// or wss://) | +| `-t, --token ` | Authentication token | +| `-v, --vault-name ` | Vault name on server | -Then run: +### Optional -```bash -vaultlink --local-path ./my-vault --config config.json -``` +| Option | Default | Description | +|--------|---------|-------------| +| `--sync-concurrency ` | `1` | Concurrent sync operations | +| `--max-file-size-mb ` | `10` | Maximum file size in MB | +| `--ignore-pattern ` | - | Glob pattern to ignore (repeatable) | +| `--websocket-retry-interval-ms ` | `3500` | WebSocket reconnection interval | +| `--log-level ` | `INFO` | Log level: DEBUG, INFO, WARNING, ERROR | +| `-h, --help` | - | Show help | +| `-V, --version` | - | Show version | -### Command-Line Options +### Auto-Ignored Patterns -#### Required Arguments - -- `-l, --local-path ` - Local directory path to sync -- `-r, --remote-uri ` - Remote server URI (unless using --config) -- `-t, --token ` - Authentication token (unless using --config) -- `-v, --vault-name ` - Vault name (unless using --config) - -#### Optional Arguments - -- `-c, --config ` - Load configuration from JSON file -- `--sync-concurrency ` - Number of concurrent sync operations (default: 1) -- `--max-file-size-mb ` - Maximum file size in MB (default: 10) -- `--ignore-pattern ` - Pattern to ignore (can be used multiple times) -- `--websocket-retry-interval-ms ` - WebSocket retry interval in ms (default: 3500) -- `-h, --help` - Print help message -- `-V, --version` - Print version - -### Ignore Patterns - -Ignore patterns support glob syntax. The CLI automatically ignores: - -- `.vaultlink/**` - Internal sync data directory +- `.vaultlink/**` - Internal sync metadata - `.git/**` - Git repository files -You can add additional patterns: +### Examples +Basic usage: ```bash -vaultlink \ - --local-path ./my-vault \ - --remote-uri https://sync.example.com \ - --token mytoken \ - --vault-name default \ +vaultlink -l ./vault -r wss://sync.example.com -t token123 -v default +``` + +With ignore patterns: +```bash +vaultlink -l ./vault -r wss://sync.example.com -t token123 -v default \ --ignore-pattern "*.tmp" \ --ignore-pattern ".DS_Store" \ --ignore-pattern "node_modules/**" ``` +With debug logging: +```bash +vaultlink -l ./vault -r wss://sync.example.com -t token123 -v default \ + --log-level DEBUG +``` + ## Docker Deployment -### Self-Hosting with Docker - -The CLI is designed to run as a long-lived container: +### Docker Run ```bash -# Create a vault directory -mkdir -p ./vault - -# Create config.json -cat > config.json <