cloudsync-cli 2026.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +560 -0
- package/bin/cloudsync.js +48 -0
- package/package.json +104 -0
- package/src/cli/commands/clone.js +103 -0
- package/src/cli/commands/commit.js +153 -0
- package/src/cli/commands/config.js +188 -0
- package/src/cli/commands/diff.js +122 -0
- package/src/cli/commands/doctor.js +142 -0
- package/src/cli/commands/download.js +130 -0
- package/src/cli/commands/history.js +92 -0
- package/src/cli/commands/init.js +103 -0
- package/src/cli/commands/log.js +124 -0
- package/src/cli/commands/port.js +76 -0
- package/src/cli/commands/rollback.js +100 -0
- package/src/cli/commands/share.js +305 -0
- package/src/cli/commands/stage.js +155 -0
- package/src/cli/commands/status.js +193 -0
- package/src/cli/commands/sync.js +255 -0
- package/src/cli/commands/unstage.js +92 -0
- package/src/cli/commands/upload.js +287 -0
- package/src/cli/index.js +134 -0
- package/src/core/crypto/index.js +94 -0
- package/src/core/transport/index.js +264 -0
- package/src/core/vcs/index.js +202 -0
- package/src/utils/helpers.js +234 -0
- package/src/utils/logger.js +66 -0
- package/src/version.mjs +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 CloudSync Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
# ๐ CloudSync-CLI
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
[](https://www.npmjs.com/package/cloudsync-cli)
|
|
7
|
+
[](https://github.com/Tech4File/cloudsync-cli/packages)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
[](https://github.com/Tech4File/cloudsync-cli/actions)
|
|
11
|
+
[](https://github.com/Tech4File/cloudsync-cli/releases)
|
|
12
|
+
|
|
13
|
+
**An open-source, Git-like version control CLI for secure cloud-to-local synchronization via encrypted SSH tunnels**
|
|
14
|
+
|
|
15
|
+
*"Your configs, your cloud, your rules - no public repos required."*
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ๐ Why CloudSync-CLI?
|
|
22
|
+
|
|
23
|
+
### The Problem with Traditional Git
|
|
24
|
+
|
|
25
|
+
| Limitation | Git | CloudSync-CLI |
|
|
26
|
+
|------------|-----|---------------|
|
|
27
|
+
| **Sensitive Data** | Requires `.gitignore` hacks & external tools | Built-in encrypted channels for `.env`, keys, configs |
|
|
28
|
+
| **Large Binaries** | Poor handling, bloats repos | Optimized chunking & delta compression |
|
|
29
|
+
| **Binary Diffs** | Not supported | Full delta compression with zstd/lz4 |
|
|
30
|
+
| **Transfer Protocols** | HTTPS only | SSH, SFTP, RSYNC, WebSocket, Direct Pipe |
|
|
31
|
+
|
|
32
|
+
| **Real-time Sync** | Manual push/pull cycles | Optional watch mode with instant sync |
|
|
33
|
+
| **P2P Sharing** | Requires fork/clone | Session links with optional password protection |
|
|
34
|
+
| **Conflict Resolution** | Manual 3-way merge | Visual diff + automated strategies |
|
|
35
|
+
| **Cloud-Native** | Indirect integration | Direct SSH, any cloud platform |
|
|
36
|
+
| **Memory Safety** | Disk-based temp files | Memory-only streams for sensitive data |
|
|
37
|
+
| **Speed** | Compressed HTTPS | Raw SSH piping for maximum throughput |
|
|
38
|
+
|
|
39
|
+
### Our Solution
|
|
40
|
+
|
|
41
|
+
CloudSync-CLI brings **Git-like version control** to sensitive configuration files and environment data, with **enterprise-grade security** and **multiple transport options** that Git simply wasn't designed for.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## โจ Features
|
|
46
|
+
|
|
47
|
+
### ๐ Security First
|
|
48
|
+
- **Pure SSH2 Protocols** - No middleman tracking, all traffic between your authorized keypairs
|
|
49
|
+
- **Memory-Only Streams** - Temporary files bypass disk writes, protecting sensitive keys
|
|
50
|
+
- **SHA-256 Integrity** - Every transfer verified with cryptographic checksums
|
|
51
|
+
- **Password Protection** - Optional password for shareable session links
|
|
52
|
+
|
|
53
|
+
### ๐ Multiple Transport Methods
|
|
54
|
+
| Protocol | Speed | Compression | Resume | Best For |
|
|
55
|
+
|----------|-------|-------------|--------|----------|
|
|
56
|
+
| `SSH-SCP` | โกโกโก | External | โ | Simple transfers |
|
|
57
|
+
| `SSH-SFTP` | โกโกโก | Configurable | โ
| Full features |
|
|
58
|
+
| `RSYNC-DELTA` | โกโกโกโก | Built-in | โ
| Large syncs |
|
|
59
|
+
| `WEBSOCKET` | โกโกโกโก | Stream | โ
| Real-time sync |
|
|
60
|
+
| `DIRECT-PIPE` | โกโกโกโกโก | None | โ | Maximum speed |
|
|
61
|
+
| `HYBRID-ZIP` | โกโกโก | High | โ | Archives |
|
|
62
|
+
|
|
63
|
+
### ๐ฆ Git-Like Version Control
|
|
64
|
+
- **Staging Area** - Stage specific files before committing
|
|
65
|
+
- **Commit History** - Full version history with messages
|
|
66
|
+
- **Diff Comparison** - Compare any two versions
|
|
67
|
+
- **Rollback** - Revert to any previous version instantly
|
|
68
|
+
- **Branching Model** - Profile-based configuration management
|
|
69
|
+
|
|
70
|
+
### ๐ P2P Sharing
|
|
71
|
+
- Generate shareable session links
|
|
72
|
+
- Password-protected sessions
|
|
73
|
+
- Real-time connection monitoring
|
|
74
|
+
- Clipboard-ready URLs
|
|
75
|
+
- Configurable expiration
|
|
76
|
+
|
|
77
|
+
### ๐ฅ๏ธ SSH Tunneling
|
|
78
|
+
- Local and remote port forwarding
|
|
79
|
+
- Background tunnel mode
|
|
80
|
+
- Multi-port configuration
|
|
81
|
+
- Verbose tunnel status
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## ๐ฅ Installation
|
|
86
|
+
|
|
87
|
+
### Via npm (Global)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install -g cloudsync-cli
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Via Windows Installer
|
|
94
|
+
|
|
95
|
+
Download `CloudSync-Setup.exe` from our [releases page](https://github.com/Tech4File/cloudsync-cli/releases) and run the installer.
|
|
96
|
+
|
|
97
|
+
### Verify Installation
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
cloudsync --version
|
|
101
|
+
# cloudsync/1.0.0 linux-x64 node-v18.17.0
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## ๐ Quick Start
|
|
107
|
+
|
|
108
|
+
### 1. Initialize Configuration
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Interactive setup
|
|
112
|
+
cloudsync init
|
|
113
|
+
|
|
114
|
+
# Or with all options
|
|
115
|
+
cloudsync init \
|
|
116
|
+
--host your-server.com \
|
|
117
|
+
--user myusername \
|
|
118
|
+
--port 22 \
|
|
119
|
+
--protocol ssh \
|
|
120
|
+
--verbose
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 2. Stage Files
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Stage specific files
|
|
127
|
+
cloudsync stage .env config.json
|
|
128
|
+
|
|
129
|
+
# Stage all files
|
|
130
|
+
cloudsync stage --all
|
|
131
|
+
|
|
132
|
+
# Stage by pattern
|
|
133
|
+
cloudsync stage --include "*.config.js,*.json"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 3. Commit Changes
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cloudsync commit "Add production environment config"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 4. Upload to Cloud
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Full upload with compression
|
|
146
|
+
cloudsync upload --compress zip --verbose
|
|
147
|
+
|
|
148
|
+
# Upload with custom protocol
|
|
149
|
+
cloudsync upload --protocol rsync --exclude node_modules,.git
|
|
150
|
+
|
|
151
|
+
# Dry run preview
|
|
152
|
+
cloudsync upload --dry-run
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 5. Download from Cloud
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Download latest
|
|
159
|
+
cloudsync download --latest
|
|
160
|
+
|
|
161
|
+
# Download specific version
|
|
162
|
+
cloudsync download --version v1234-abcd
|
|
163
|
+
|
|
164
|
+
# Download specific files
|
|
165
|
+
cloudsync download .env --verbose
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 6. Bidirectional Sync
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# One-time sync
|
|
172
|
+
cloudsync sync
|
|
173
|
+
|
|
174
|
+
# Watch mode (continuous)
|
|
175
|
+
cloudsync sync --watch --interval 30
|
|
176
|
+
|
|
177
|
+
# With conflict strategy
|
|
178
|
+
cloudsync sync --strategy local --verbose
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## ๐ ๏ธ Command Reference
|
|
184
|
+
|
|
185
|
+
### Core Commands
|
|
186
|
+
|
|
187
|
+
| Command | Description |
|
|
188
|
+
|---------|-------------|
|
|
189
|
+
| `cloudsync init` | Initialize configuration profile |
|
|
190
|
+
| `cloudsync upload [files]` | Upload files to remote |
|
|
191
|
+
| `cloudsync download [files]` | Download files from remote |
|
|
192
|
+
| `cloudsync sync` | Bidirectional synchronization |
|
|
193
|
+
| `cloudsync port <local:remote>` | Create SSH tunnel |
|
|
194
|
+
| `cloudsync share [path]` | Generate shareable session link |
|
|
195
|
+
|
|
196
|
+
### Version Control Commands
|
|
197
|
+
|
|
198
|
+
| Command | Description |
|
|
199
|
+
|---------|-------------|
|
|
200
|
+
| `cloudsync stage [files]` | Stage files for commit |
|
|
201
|
+
| `cloudsync unstage [files]` | Remove from staging |
|
|
202
|
+
| `cloudsync commit [msg]` | Commit staged changes |
|
|
203
|
+
| `cloudsync history` | View commit history |
|
|
204
|
+
| `cloudsync diff [versions]` | Compare versions |
|
|
205
|
+
| `cloudsync rollback <version>` | Revert to version |
|
|
206
|
+
| `cloudsync status` | Show repository status |
|
|
207
|
+
| `cloudsync log` | View operation logs |
|
|
208
|
+
|
|
209
|
+
### Utility Commands
|
|
210
|
+
|
|
211
|
+
| Command | Description |
|
|
212
|
+
|---------|-------------|
|
|
213
|
+
| `cloudsync config [key] [value]` | Manage configuration |
|
|
214
|
+
| `cloudsync doctor` | Run diagnostics |
|
|
215
|
+
| `cloudsync clone <remote>` | Clone remote workspace |
|
|
216
|
+
| `cloudsync help [topic]` | Show help |
|
|
217
|
+
|
|
218
|
+
### Global Flags
|
|
219
|
+
|
|
220
|
+
| Flag | Description |
|
|
221
|
+
|------|-------------|
|
|
222
|
+
| `-v, --verbose` | Enable verbose output |
|
|
223
|
+
| `-q, --quiet` | Suppress messages |
|
|
224
|
+
| `-c, --config <path>` | Custom config file |
|
|
225
|
+
| `--no-color` | Disable colors |
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## ๐ Command Options Reference
|
|
230
|
+
|
|
231
|
+
### `upload` Options
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
cloudsync upload [files...]
|
|
235
|
+
--include <patterns> # Files to include (comma-separated)
|
|
236
|
+
--exclude <patterns> # Files to exclude (default: node_modules,.git,dist,build)
|
|
237
|
+
--message <msg> # Commit message
|
|
238
|
+
--all # Upload all changes
|
|
239
|
+
--force # Force overwrite
|
|
240
|
+
--compress <method> # zip|lz4|zstd (default: zip)
|
|
241
|
+
--chunk-size <MB> # Chunk size (default: 10)
|
|
242
|
+
--protocol <proto> # ssh|sftp|rsync|websocket|pipe
|
|
243
|
+
--verbose # Detailed progress
|
|
244
|
+
--dry-run # Preview only
|
|
245
|
+
--profile <name> # Config profile
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### `download` Options
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
cloudsync download [files...]
|
|
252
|
+
--include <patterns> # Specific files to fetch
|
|
253
|
+
--exclude <patterns> # Skip certain files
|
|
254
|
+
--version <id> # Specific version
|
|
255
|
+
--latest # Fetch latest
|
|
256
|
+
--verbose # Detailed progress
|
|
257
|
+
--dry-run # Preview only
|
|
258
|
+
--profile <name> # Config profile
|
|
259
|
+
--output <path> # Output directory
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### `sync` Options
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
cloudsync sync
|
|
266
|
+
--strategy <type> # local|remote|manual
|
|
267
|
+
--watch # Continuous watching
|
|
268
|
+
--interval <seconds> # Sync interval (default: 30)
|
|
269
|
+
--verbose # Detailed logs
|
|
270
|
+
--dry-run # Preview
|
|
271
|
+
--profile <name> # Config profile
|
|
272
|
+
--include <patterns> # Files to sync
|
|
273
|
+
--exclude <patterns> # Files to skip
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### `share` Options
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
cloudsync share [path]
|
|
280
|
+
--type <type> # file|folder|session
|
|
281
|
+
--port <number> # Server port (default: 3000)
|
|
282
|
+
--expires <minutes> # Expiration (default: 60)
|
|
283
|
+
--password <pwd> # Password protection
|
|
284
|
+
--verbose # Show details
|
|
285
|
+
--open # Auto-open URL
|
|
286
|
+
--profile <name> # Config profile
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### `port` Options
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
cloudsync port <local:remote>
|
|
293
|
+
--host <hostname> # Bind host (default: 0.0.0.0)
|
|
294
|
+
--verbose # Show tunnel details
|
|
295
|
+
--background # Run in background
|
|
296
|
+
--profile <name> # Config profile
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## ๐ง Configuration
|
|
302
|
+
|
|
303
|
+
### Profile Structure
|
|
304
|
+
|
|
305
|
+
```json
|
|
306
|
+
{
|
|
307
|
+
"profiles": {
|
|
308
|
+
"default": {
|
|
309
|
+
"host": "your-server.com",
|
|
310
|
+
"user": "myusername",
|
|
311
|
+
"port": 22,
|
|
312
|
+
"key": "~/.ssh/id_rsa",
|
|
313
|
+
"protocol": "ssh",
|
|
314
|
+
"workspace": "/home/myuser/project",
|
|
315
|
+
"createdAt": "2024-01-15T10:30:00Z"
|
|
316
|
+
},
|
|
317
|
+
"production": {
|
|
318
|
+
"host": "prod.example.com",
|
|
319
|
+
"user": "deploy",
|
|
320
|
+
"protocol": "rsync"
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
"settings": {
|
|
324
|
+
"compression": "zip",
|
|
325
|
+
"chunkSize": 10,
|
|
326
|
+
"verbose": false,
|
|
327
|
+
"defaultProfile": "default"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Config Commands
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
# List all config
|
|
336
|
+
cloudsync config --list
|
|
337
|
+
|
|
338
|
+
# Get specific value
|
|
339
|
+
cloudsync config profiles.default.host
|
|
340
|
+
|
|
341
|
+
# Set value
|
|
342
|
+
cloudsync config settings.compression zstd
|
|
343
|
+
|
|
344
|
+
# Use global config
|
|
345
|
+
cloudsync config --global settings.verbose true
|
|
346
|
+
|
|
347
|
+
# Unset value
|
|
348
|
+
cloudsync config --unset profiles.production
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## ๐ Security Architecture
|
|
354
|
+
|
|
355
|
+
### Transport Security
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
359
|
+
โ CloudSync Security โ
|
|
360
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
361
|
+
โ โ
|
|
362
|
+
โ Your Local Machine โ
|
|
363
|
+
โ โโโโโโโโโโโโโโโโโโโ โ
|
|
364
|
+
โ โ Private Key ๐ โโโโโ Encrypted Tunnel โโโโโโโบ โ
|
|
365
|
+
โ โ (never leaves) โ SSH2 โ
|
|
366
|
+
โ โโโโโโโโโโโโโโโโโโโ โ โ
|
|
367
|
+
โ โผ โ
|
|
368
|
+
โ Memory-Only Streams โโโโโโโโโโโโโโโโค โ
|
|
369
|
+
โ (no disk writes) โ โ
|
|
370
|
+
โ โผ โ
|
|
371
|
+
โ Remote Server (SSH or cloud) โ โ
|
|
372
|
+
โ โโโโโโโโโโโโโโโโโโโ Authenticated & Encrypted โ
|
|
373
|
+
โ โ Public Key ๐ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
374
|
+
โ โโโโโโโโโโโโโโโโโโโ โ
|
|
375
|
+
โ โ
|
|
376
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Key Security Features
|
|
380
|
+
|
|
381
|
+
1. **Zero-Trust Architecture** - Keys never leave your machine
|
|
382
|
+
2. **Memory-Only Processing** - Sensitive data never touches disk
|
|
383
|
+
3. **End-to-End Encryption** - SSH2 with strong cipher suites
|
|
384
|
+
4. **Integrity Verification** - SHA-256 checksums on all transfers
|
|
385
|
+
5. **Session Tokens** - Unique, expirable shareable links
|
|
386
|
+
6. **No Third-Party Tracking** - 100% peer-to-peer
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## ๐๏ธ Architecture Overview
|
|
391
|
+
|
|
392
|
+
```
|
|
393
|
+
cloudsync-cli/
|
|
394
|
+
โโโ bin/
|
|
395
|
+
โ โโโ cloudsync.js # Entry point
|
|
396
|
+
โโโ src/
|
|
397
|
+
โ โโโ cli/
|
|
398
|
+
โ โ โโโ index.js # Commander.js setup
|
|
399
|
+
โ โ โโโ commands/ # Command definitions
|
|
400
|
+
โ โ โโโ init.js
|
|
401
|
+
โ โ โโโ upload.js
|
|
402
|
+
โ โ โโโ download.js
|
|
403
|
+
โ โ โโโ sync.js
|
|
404
|
+
โ โ โโโ port.js
|
|
405
|
+
โ โ โโโ share.js
|
|
406
|
+
โ โ โโโ stage.js
|
|
407
|
+
โ โ โโโ commit.js
|
|
408
|
+
โ โ โโโ history.js
|
|
409
|
+
โ โ โโโ diff.js
|
|
410
|
+
โ โ โโโ rollback.js
|
|
411
|
+
โ โ โโโ status.js
|
|
412
|
+
โ โ โโโ config.js
|
|
413
|
+
โ โ โโโ doctor.js
|
|
414
|
+
โ โ โโโ clone.js
|
|
415
|
+
โ โ โโโ log.js
|
|
416
|
+
โ โโโ transport/ # Protocol implementations
|
|
417
|
+
โ โโโ vcs/ # Version control system
|
|
418
|
+
โ โโโ utils/ # Helper functions
|
|
419
|
+
โโโ package.json
|
|
420
|
+
โโโ README.md
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## ๐ Comparison with Git Workflows
|
|
426
|
+
|
|
427
|
+
### Traditional Git Workflow (With Sensitive Files)
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# Problem: Sensitive files need special handling
|
|
431
|
+
git add .env # โ Danger! May commit secrets
|
|
432
|
+
echo ".env" >> .gitignore # โ But now it's untracked
|
|
433
|
+
git add .env.example # โ Manual workaround
|
|
434
|
+
|
|
435
|
+
# Or use git-crypt (complex setup)
|
|
436
|
+
git crypt init # Complex
|
|
437
|
+
git crypt lock # Lock when done
|
|
438
|
+
|
|
439
|
+
# Environment-specific repos (messy)
|
|
440
|
+
git remote add prod git@github.com:myorg/prod-configs.git
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### CloudSync Workflow (Same Project)
|
|
444
|
+
|
|
445
|
+
```bash
|
|
446
|
+
# Simple and secure
|
|
447
|
+
cloudsync init --host your-server.com --user myuser
|
|
448
|
+
cloudsync stage .env config.json
|
|
449
|
+
cloudsync commit "Update environment config"
|
|
450
|
+
cloudsync upload # Encrypted, versioned, done
|
|
451
|
+
|
|
452
|
+
# Files stay private, never in Git
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
|
|
457
|
+
## ๐ Use Cases
|
|
458
|
+
|
|
459
|
+
### 1. Cloud Environment Sync
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
# Sync local .env to your cloud server
|
|
463
|
+
cloudsync upload --include .env,config.json --exclude node_modules
|
|
464
|
+
|
|
465
|
+
# Pull latest from your cloud server
|
|
466
|
+
cloudsync download --latest
|
|
467
|
+
|
|
468
|
+
# Create persistent tunnel for local dev
|
|
469
|
+
cloudsync port 3000:3000 --background
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### 2. Multi-Environment Configs
|
|
473
|
+
|
|
474
|
+
```bash
|
|
475
|
+
# Development profile
|
|
476
|
+
cloudsync init --profile dev --host dev.server.com
|
|
477
|
+
|
|
478
|
+
# Production profile
|
|
479
|
+
cloudsync init --profile prod --host prod.server.com
|
|
480
|
+
|
|
481
|
+
# Switch and sync
|
|
482
|
+
cloudsync upload --profile prod
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### 3. Team Sharing (Without Git Access)
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
# Generate secure share link
|
|
489
|
+
cloudsync share --type folder . --expires 120 --password MyPass123
|
|
490
|
+
|
|
491
|
+
# Share the link with team
|
|
492
|
+
๐ http://localhost:3000/share/abc123
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### 4. CI/CD Integration
|
|
496
|
+
|
|
497
|
+
```bash
|
|
498
|
+
# In CI pipeline
|
|
499
|
+
cloudsync download --version $COMMIT_SHA --dry-run
|
|
500
|
+
cloudsync download --version $COMMIT_SHA
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
---
|
|
504
|
+
|
|
505
|
+
## ๐ Troubleshooting
|
|
506
|
+
|
|
507
|
+
### Doctor Command
|
|
508
|
+
|
|
509
|
+
Run diagnostics to identify issues:
|
|
510
|
+
|
|
511
|
+
```bash
|
|
512
|
+
cloudsync doctor --verbose
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### Common Issues
|
|
516
|
+
|
|
517
|
+
| Issue | Solution |
|
|
518
|
+
|-------|----------|
|
|
519
|
+
| SSH connection fails | Run `cloudsync doctor` to test credentials |
|
|
520
|
+
| Permission denied | Check SSH key permissions: `chmod 600 ~/.ssh/id_rsa` |
|
|
521
|
+
| No files to upload | Ensure `--include` patterns match your files |
|
|
522
|
+
| Config not found | Run `cloudsync init` first |
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## ๐ค Contributing
|
|
527
|
+
|
|
528
|
+
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
|
|
529
|
+
|
|
530
|
+
1. Fork the repository
|
|
531
|
+
2. Create your feature branch (`git checkout -b feature/amazing`)
|
|
532
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
533
|
+
4. Push to the branch (`git push origin feature/amazing`)
|
|
534
|
+
5. Open a Pull Request
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## ๐ License
|
|
539
|
+
|
|
540
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
544
|
+
## ๐ Acknowledgments
|
|
545
|
+
|
|
546
|
+
- [Commander.js](https://www.npmjs.com/package/commander) - CLI framework
|
|
547
|
+
- [ssh2](https://www.npmjs.com/package/ssh2) - SSH client
|
|
548
|
+
- [Archiver](https://www.npmjs.com/package/archiver) - ZIP compression
|
|
549
|
+
- [diff-match-patch](https://www.npmjs.com/package/diff-match-patch) - Text diffing
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
<div align="center">
|
|
554
|
+
|
|
555
|
+
**Made with โค๏ธ for developers who value security and simplicity**
|
|
556
|
+
|
|
557
|
+
[](https://github.com/Tech4File/cloudsync-cli)
|
|
558
|
+
[](https://twitter.com/intent/tweet?text=Check%20out%20CloudSync-CLI%20-%20A%20secure%2C%20Git-like%20tool%20for%20syncing%20configs%20to%20cloud%20environments&url=https%3A%2F%2Fgithub.com%2FTech4File%2Fcloudsync-cli)
|
|
559
|
+
|
|
560
|
+
</div>
|
package/bin/cloudsync.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CloudSync-CLI Entry Point
|
|
5
|
+
*
|
|
6
|
+
* Dynamically loads the CLI module using a resolved absolute file path
|
|
7
|
+
* from import.meta.url so that pkg can locate the bundled files at build time
|
|
8
|
+
* (pkg traces static imports; dynamic paths are resolved via import.meta.url).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { mkdirSync, existsSync } from 'fs';
|
|
12
|
+
import { join, dirname } from 'path';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
|
|
17
|
+
// โโ Ensure .cloudsync directories exist โโโโโโโโโโโโโโโโโโ
|
|
18
|
+
const csyncDir = join(process.cwd(), '.cloudsync');
|
|
19
|
+
[
|
|
20
|
+
csyncDir,
|
|
21
|
+
join(csyncDir, 'staging'),
|
|
22
|
+
join(csyncDir, 'history', 'commits'),
|
|
23
|
+
join(csyncDir, 'history', 'diffs'),
|
|
24
|
+
join(csyncDir, 'cache'),
|
|
25
|
+
join(csyncDir, 'logs'),
|
|
26
|
+
].forEach((dir) => {
|
|
27
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// โโ Global error handlers โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
31
|
+
process.on('uncaughtException', (err) => {
|
|
32
|
+
console.error('\nโ', err.message);
|
|
33
|
+
if (process.argv.includes('--verbose')) console.error(err.stack);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
process.on('unhandledRejection', (reason) => {
|
|
38
|
+
console.error('\nโ Unhandled rejection:', reason);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// โโ Resolve CLI entry via import.meta.url (works with pkg) โโ
|
|
43
|
+
const cliUrl = new URL('../src/cli/index.js', import.meta.url).href;
|
|
44
|
+
|
|
45
|
+
import(cliUrl).catch((err) => {
|
|
46
|
+
console.error('Failed to load CLI:', err.message);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
});
|