pushwork 2.0.0-a.sub.1 → 2.0.0-preview.2
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/dist/branches.d.ts +20 -0
- package/dist/branches.d.ts.map +1 -0
- package/dist/branches.js +111 -0
- package/dist/branches.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +245 -270
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +84 -0
- package/dist/config.js.map +1 -0
- package/dist/fs-tree.d.ts +6 -0
- package/dist/fs-tree.d.ts.map +1 -0
- package/dist/fs-tree.js +99 -0
- package/dist/fs-tree.js.map +1 -0
- package/dist/ignore.d.ts +6 -0
- package/dist/ignore.d.ts.map +1 -0
- package/dist/ignore.js +74 -0
- package/dist/ignore.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -4
- package/dist/index.js.map +1 -1
- package/dist/log.d.ts +3 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +14 -0
- package/dist/log.js.map +1 -0
- package/dist/pushwork.d.ts +129 -0
- package/dist/pushwork.d.ts.map +1 -0
- package/dist/pushwork.js +1062 -0
- package/dist/pushwork.js.map +1 -0
- package/dist/repo.d.ts +14 -0
- package/dist/repo.d.ts.map +1 -0
- package/dist/repo.js +60 -0
- package/dist/repo.js.map +1 -0
- package/dist/shapes/custom.d.ts +3 -0
- package/dist/shapes/custom.d.ts.map +1 -0
- package/dist/shapes/custom.js +57 -0
- package/dist/shapes/custom.js.map +1 -0
- package/dist/shapes/file.d.ts +20 -0
- package/dist/shapes/file.d.ts.map +1 -0
- package/dist/shapes/file.js +140 -0
- package/dist/shapes/file.js.map +1 -0
- package/dist/shapes/index.d.ts +10 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +35 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/patchwork-folder.d.ts +3 -0
- package/dist/shapes/patchwork-folder.d.ts.map +1 -0
- package/dist/shapes/patchwork-folder.js +160 -0
- package/dist/shapes/patchwork-folder.js.map +1 -0
- package/dist/shapes/types.d.ts +38 -0
- package/dist/shapes/types.d.ts.map +1 -0
- package/dist/shapes/types.js +52 -0
- package/dist/shapes/types.js.map +1 -0
- package/dist/shapes/vfs.d.ts +3 -0
- package/dist/shapes/vfs.d.ts.map +1 -0
- package/dist/shapes/vfs.js +92 -0
- package/dist/shapes/vfs.js.map +1 -0
- package/dist/stash.d.ts +23 -0
- package/dist/stash.d.ts.map +1 -0
- package/dist/stash.js +118 -0
- package/dist/stash.js.map +1 -0
- package/dist/version.d.ts +11 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +93 -0
- package/dist/version.js.map +1 -0
- package/package.json +19 -48
- package/patches/@automerge__automerge-repo@2.6.0-subduction.15.patch +26 -0
- package/.prettierrc +0 -9
- package/ARCHITECTURE-ACCORDING-TO-CLAUDE.md +0 -248
- package/CLAUDE.md +0 -141
- package/README.md +0 -221
- package/babel.config.js +0 -5
- package/dist/cli/commands.d.ts +0 -71
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -794
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -19
- package/dist/cli/index.js.map +0 -1
- package/dist/commands.d.ts +0 -61
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -861
- package/dist/commands.js.map +0 -1
- package/dist/config/index.d.ts +0 -71
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -314
- package/dist/config/index.js.map +0 -1
- package/dist/core/change-detection.d.ts +0 -80
- package/dist/core/change-detection.d.ts.map +0 -1
- package/dist/core/change-detection.js +0 -523
- package/dist/core/change-detection.js.map +0 -1
- package/dist/core/config.d.ts +0 -81
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -258
- package/dist/core/config.js.map +0 -1
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -6
- package/dist/core/index.js.map +0 -1
- package/dist/core/move-detection.d.ts +0 -34
- package/dist/core/move-detection.d.ts.map +0 -1
- package/dist/core/move-detection.js +0 -121
- package/dist/core/move-detection.js.map +0 -1
- package/dist/core/snapshot.d.ts +0 -105
- package/dist/core/snapshot.d.ts.map +0 -1
- package/dist/core/snapshot.js +0 -217
- package/dist/core/snapshot.js.map +0 -1
- package/dist/core/sync-engine.d.ts +0 -157
- package/dist/core/sync-engine.d.ts.map +0 -1
- package/dist/core/sync-engine.js +0 -1379
- package/dist/core/sync-engine.js.map +0 -1
- package/dist/types/config.d.ts +0 -99
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -5
- package/dist/types/config.js.map +0 -1
- package/dist/types/documents.d.ts +0 -88
- package/dist/types/documents.d.ts.map +0 -1
- package/dist/types/documents.js +0 -20
- package/dist/types/documents.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/snapshot.d.ts +0 -64
- package/dist/types/snapshot.d.ts.map +0 -1
- package/dist/types/snapshot.js +0 -2
- package/dist/types/snapshot.js.map +0 -1
- package/dist/utils/content-similarity.d.ts +0 -53
- package/dist/utils/content-similarity.d.ts.map +0 -1
- package/dist/utils/content-similarity.js +0 -155
- package/dist/utils/content-similarity.js.map +0 -1
- package/dist/utils/content.d.ts +0 -10
- package/dist/utils/content.d.ts.map +0 -1
- package/dist/utils/content.js +0 -31
- package/dist/utils/content.js.map +0 -1
- package/dist/utils/directory.d.ts +0 -24
- package/dist/utils/directory.d.ts.map +0 -1
- package/dist/utils/directory.js +0 -52
- package/dist/utils/directory.js.map +0 -1
- package/dist/utils/fs.d.ts +0 -74
- package/dist/utils/fs.d.ts.map +0 -1
- package/dist/utils/fs.js +0 -248
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -5
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/mime-types.d.ts +0 -13
- package/dist/utils/mime-types.d.ts.map +0 -1
- package/dist/utils/mime-types.js +0 -209
- package/dist/utils/mime-types.js.map +0 -1
- package/dist/utils/network-sync.d.ts +0 -36
- package/dist/utils/network-sync.d.ts.map +0 -1
- package/dist/utils/network-sync.js +0 -250
- package/dist/utils/network-sync.js.map +0 -1
- package/dist/utils/node-polyfills.d.ts +0 -9
- package/dist/utils/node-polyfills.d.ts.map +0 -1
- package/dist/utils/node-polyfills.js +0 -9
- package/dist/utils/node-polyfills.js.map +0 -1
- package/dist/utils/output.d.ts +0 -129
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/output.js +0 -368
- package/dist/utils/output.js.map +0 -1
- package/dist/utils/repo-factory.d.ts +0 -13
- package/dist/utils/repo-factory.d.ts.map +0 -1
- package/dist/utils/repo-factory.js +0 -46
- package/dist/utils/repo-factory.js.map +0 -1
- package/dist/utils/string-similarity.d.ts +0 -14
- package/dist/utils/string-similarity.d.ts.map +0 -1
- package/dist/utils/string-similarity.js +0 -39
- package/dist/utils/string-similarity.js.map +0 -1
- package/dist/utils/text-diff.d.ts +0 -37
- package/dist/utils/text-diff.d.ts.map +0 -1
- package/dist/utils/text-diff.js +0 -93
- package/dist/utils/text-diff.js.map +0 -1
- package/dist/utils/trace.d.ts +0 -19
- package/dist/utils/trace.d.ts.map +0 -1
- package/dist/utils/trace.js +0 -63
- package/dist/utils/trace.js.map +0 -1
- package/src/cli.ts +0 -442
- package/src/commands.ts +0 -1134
- package/src/core/change-detection.ts +0 -712
- package/src/core/config.ts +0 -313
- package/src/core/index.ts +0 -5
- package/src/core/move-detection.ts +0 -169
- package/src/core/snapshot.ts +0 -275
- package/src/core/sync-engine.ts +0 -1795
- package/src/index.ts +0 -4
- package/src/types/config.ts +0 -111
- package/src/types/documents.ts +0 -91
- package/src/types/index.ts +0 -3
- package/src/types/snapshot.ts +0 -67
- package/src/utils/content.ts +0 -34
- package/src/utils/directory.ts +0 -73
- package/src/utils/fs.ts +0 -297
- package/src/utils/index.ts +0 -4
- package/src/utils/mime-types.ts +0 -244
- package/src/utils/network-sync.ts +0 -319
- package/src/utils/node-polyfills.ts +0 -8
- package/src/utils/output.ts +0 -450
- package/src/utils/repo-factory.ts +0 -73
- package/src/utils/string-similarity.ts +0 -54
- package/src/utils/text-diff.ts +0 -101
- package/src/utils/trace.ts +0 -70
- package/test/integration/README.md +0 -328
- package/test/integration/clone-test.sh +0 -310
- package/test/integration/conflict-resolution-test.sh +0 -309
- package/test/integration/debug-both-nested.sh +0 -74
- package/test/integration/debug-concurrent-nested.sh +0 -87
- package/test/integration/debug-nested.sh +0 -73
- package/test/integration/deletion-behavior-test.sh +0 -487
- package/test/integration/deletion-sync-test-simple.sh +0 -193
- package/test/integration/deletion-sync-test.sh +0 -297
- package/test/integration/exclude-patterns.test.ts +0 -144
- package/test/integration/full-integration-test.sh +0 -363
- package/test/integration/fuzzer.test.ts +0 -818
- package/test/integration/in-memory-sync.test.ts +0 -830
- package/test/integration/init-sync.test.ts +0 -89
- package/test/integration/manual-sync-test.sh +0 -84
- package/test/integration/sync-deletion.test.ts +0 -280
- package/test/integration/sync-flow.test.ts +0 -291
- package/test/jest.setup.ts +0 -34
- package/test/run-tests.sh +0 -225
- package/test/unit/deletion-behavior.test.ts +0 -249
- package/test/unit/enhanced-mime-detection.test.ts +0 -244
- package/test/unit/snapshot.test.ts +0 -404
- package/test/unit/sync-convergence.test.ts +0 -298
- package/test/unit/sync-timing.test.ts +0 -134
- package/test/unit/utils.test.ts +0 -366
- package/tsconfig.json +0 -23
package/src/utils/trace.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { out } from "./output.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Global tracing state
|
|
5
|
-
*/
|
|
6
|
-
let tracingEnabled = false;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Enable or disable tracing
|
|
10
|
-
*/
|
|
11
|
-
export function setTracingEnabled(enabled: boolean): void {
|
|
12
|
-
tracingEnabled = enabled;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Check if tracing is enabled
|
|
17
|
-
*/
|
|
18
|
-
export function isTracingEnabled(): boolean {
|
|
19
|
-
return tracingEnabled;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Trace a span of work by outputting to console
|
|
24
|
-
* Works for both sync and async functions
|
|
25
|
-
* Only outputs if tracing is enabled
|
|
26
|
-
*
|
|
27
|
-
* Usage:
|
|
28
|
-
* await span("operation", async () => { ... })
|
|
29
|
-
* span("operation", () => { ... })
|
|
30
|
-
*/
|
|
31
|
-
export function span<T>(
|
|
32
|
-
name: string,
|
|
33
|
-
fn: () => T | Promise<T>
|
|
34
|
-
): T | Promise<T> {
|
|
35
|
-
if (!tracingEnabled) {
|
|
36
|
-
return fn();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const start = performance.now();
|
|
40
|
-
const result = fn();
|
|
41
|
-
|
|
42
|
-
// Check if it's a promise (async)
|
|
43
|
-
if (result instanceof Promise) {
|
|
44
|
-
return result.then((value) => {
|
|
45
|
-
const duration = performance.now() - start;
|
|
46
|
-
out.taskLine(`${name} (${formatDuration(duration)})`, true);
|
|
47
|
-
return value;
|
|
48
|
-
}) as T;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Sync case
|
|
52
|
-
const duration = performance.now() - start;
|
|
53
|
-
out.taskLine(`${name} (${formatDuration(duration)})`, true);
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Format duration for display
|
|
59
|
-
*/
|
|
60
|
-
function formatDuration(ms: number): string {
|
|
61
|
-
if (ms < 1) {
|
|
62
|
-
return `${ms.toFixed(2)}ms`;
|
|
63
|
-
} else if (ms < 1000) {
|
|
64
|
-
return `${Math.round(ms)}ms`;
|
|
65
|
-
} else if (ms < 2000) {
|
|
66
|
-
return `${(ms / 1000).toFixed(2)}s`;
|
|
67
|
-
} else {
|
|
68
|
-
return `${(ms / 1000).toFixed(1)}s`;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
# Integration Tests
|
|
2
|
-
|
|
3
|
-
This directory contains comprehensive integration tests for the pushwork sync tool.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
From the project root directory:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# Run all tests with the test runner
|
|
11
|
-
./test/run-tests.sh
|
|
12
|
-
|
|
13
|
-
# Run specific test suites
|
|
14
|
-
./test/run-tests.sh clone # Clone functionality tests
|
|
15
|
-
./test/run-tests.sh conflict # CRDT conflict resolution tests
|
|
16
|
-
./test/run-tests.sh full # Full integration tests
|
|
17
|
-
./test/run-tests.sh unit # Unit tests
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Test Scripts
|
|
21
|
-
|
|
22
|
-
### 1. Test Runner (`../run-tests.sh`)
|
|
23
|
-
|
|
24
|
-
Main entry point for running all tests. Provides:
|
|
25
|
-
|
|
26
|
-
- Dependency checking
|
|
27
|
-
- Multiple test suite options
|
|
28
|
-
- Consistent output formatting
|
|
29
|
-
- Error handling
|
|
30
|
-
|
|
31
|
-
### 2. Full Integration Test (`full-integration-test.sh`)
|
|
32
|
-
|
|
33
|
-
Comprehensive test suite covering all major functionality:
|
|
34
|
-
|
|
35
|
-
**Features Tested:**
|
|
36
|
-
|
|
37
|
-
- ✅ Help commands for all CLI commands
|
|
38
|
-
- ✅ Init with default and custom sync servers
|
|
39
|
-
- ✅ Clone with default and custom sync servers
|
|
40
|
-
- ✅ Status, diff, commit, and sync operations
|
|
41
|
-
- ✅ Error handling and parameter validation
|
|
42
|
-
- ✅ File operations (create, modify, delete)
|
|
43
|
-
- ✅ Bidirectional sync scenarios
|
|
44
|
-
|
|
45
|
-
**Test Sections:**
|
|
46
|
-
|
|
47
|
-
1. Help Commands - Verify all --help options work
|
|
48
|
-
2. Init Functionality - Test directory initialization
|
|
49
|
-
3. Status Functionality - Test status reporting
|
|
50
|
-
4. Commit Functionality - Test local commits
|
|
51
|
-
5. Sync Functionality - Test sync operations
|
|
52
|
-
6. Diff Functionality - Test change detection
|
|
53
|
-
7. Clone Functionality - Test cloning repositories
|
|
54
|
-
8. Bidirectional Sync - Test multi-directory sync
|
|
55
|
-
9. File Operations - Test various file types and operations
|
|
56
|
-
|
|
57
|
-
### 3. Clone Test (`clone-test.sh`)
|
|
58
|
-
|
|
59
|
-
Focused test suite specifically for clone functionality:
|
|
60
|
-
|
|
61
|
-
**Features Tested:**
|
|
62
|
-
|
|
63
|
-
- ✅ Clone with default sync server settings
|
|
64
|
-
- ✅ Clone with custom sync server and storage ID
|
|
65
|
-
- ✅ Parameter validation (sync server options must be used together)
|
|
66
|
-
- ✅ Force overwrite functionality
|
|
67
|
-
- ✅ Configuration verification in cloned repositories
|
|
68
|
-
- ✅ Error handling for invalid scenarios
|
|
69
|
-
- ✅ Status and diff operations in cloned directories
|
|
70
|
-
|
|
71
|
-
**Test Sections:**
|
|
72
|
-
|
|
73
|
-
1. Clone Functionality - All clone scenarios
|
|
74
|
-
2. Cloned Directory Status - Operations in cloned repos
|
|
75
|
-
3. Configuration Comparison - Verify settings propagation
|
|
76
|
-
|
|
77
|
-
### 4. CRDT Conflict Resolution Test (`conflict-resolution-test.sh`)
|
|
78
|
-
|
|
79
|
-
Specialized test demonstrating pushwork's excellent CRDT-based conflict resolution capabilities:
|
|
80
|
-
|
|
81
|
-
**Features Tested:**
|
|
82
|
-
|
|
83
|
-
- ✅ Create repository with initial document
|
|
84
|
-
- ✅ Clone repository to second location
|
|
85
|
-
- ✅ Make simultaneous conflicting edits on both sides
|
|
86
|
-
- ✅ Verify CRDT text merging preserves ALL changes
|
|
87
|
-
- ✅ Validate that no data is lost during conflicts
|
|
88
|
-
- ✅ Confirm true collaborative editing capabilities
|
|
89
|
-
|
|
90
|
-
**Test Scenario:**
|
|
91
|
-
|
|
92
|
-
1. Alice creates a document with baseline content
|
|
93
|
-
2. Bob clones Alice's repository
|
|
94
|
-
3. Both users make different additions to the same file simultaneously
|
|
95
|
-
4. Alice syncs her changes first
|
|
96
|
-
5. Bob syncs his changes (CRDT merging occurs)
|
|
97
|
-
6. Final sync rounds ensure eventual consistency
|
|
98
|
-
7. **Result**: Bob's repository contains BOTH Alice's AND Bob's changes
|
|
99
|
-
8. **Demonstrates**: True CRDT collaborative editing without data loss
|
|
100
|
-
|
|
101
|
-
**Key Findings:**
|
|
102
|
-
|
|
103
|
-
- ✅ Pushwork uses character-level CRDT text merging
|
|
104
|
-
- ✅ Both users' contributions are preserved automatically
|
|
105
|
-
- ✅ No manual conflict resolution required
|
|
106
|
-
- ✅ Immediate convergence to consistent state
|
|
107
|
-
- ✅ Sync timing issue has been resolved
|
|
108
|
-
- Repositories eventually converge to consistent state
|
|
109
|
-
|
|
110
|
-
## Test Configuration
|
|
111
|
-
|
|
112
|
-
### Required Dependencies
|
|
113
|
-
|
|
114
|
-
- **Node.js** - For running pushwork CLI
|
|
115
|
-
- **npm** - For building the project
|
|
116
|
-
|
|
117
|
-
### Optional Dependencies
|
|
118
|
-
|
|
119
|
-
- **jq** - For advanced JSON parsing in configuration tests (tests will be skipped if not available)
|
|
120
|
-
|
|
121
|
-
Install jq (optional):
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
# macOS
|
|
125
|
-
brew install jq
|
|
126
|
-
|
|
127
|
-
# Ubuntu/Debian
|
|
128
|
-
sudo apt-get install jq
|
|
129
|
-
|
|
130
|
-
# Other platforms
|
|
131
|
-
# See: https://stedolan.github.io/jq/download/
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Test Environment
|
|
135
|
-
|
|
136
|
-
- Tests run in isolated temporary directories
|
|
137
|
-
- Automatic cleanup on completion
|
|
138
|
-
- No modification of project files
|
|
139
|
-
- Safe to run multiple times
|
|
140
|
-
|
|
141
|
-
### Test Parameters
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
# Default test configuration
|
|
145
|
-
TEST_DIR="/tmp/pushwork-*-test"
|
|
146
|
-
CUSTOM_SYNC_SERVER="ws://localhost:3030"
|
|
147
|
-
CUSTOM_STORAGE_ID="1d89eba7-f7a4-4e8e-80f2-5f4e2406f507"
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Understanding Test Output
|
|
151
|
-
|
|
152
|
-
### Log Levels
|
|
153
|
-
|
|
154
|
-
- 🔵 **[INFO]** - General information
|
|
155
|
-
- 🟡 **[TEST]** - Test being executed
|
|
156
|
-
- 🟢 **[PASS]** - Test passed
|
|
157
|
-
- 🔴 **[FAIL]** - Test failed
|
|
158
|
-
- 🟡 **[WARN]** - Warning (non-critical)
|
|
159
|
-
|
|
160
|
-
### Test Results
|
|
161
|
-
|
|
162
|
-
Each test script provides a summary:
|
|
163
|
-
|
|
164
|
-
```
|
|
165
|
-
======================================
|
|
166
|
-
Test Results Summary
|
|
167
|
-
======================================
|
|
168
|
-
Tests Run: 45
|
|
169
|
-
Tests Passed: 43
|
|
170
|
-
Tests Failed: 2
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
## Running Individual Tests
|
|
174
|
-
|
|
175
|
-
### Full Integration Test
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
./test/integration/full-integration-test.sh
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Clone Test
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
./test/integration/clone-test.sh
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### With Verbose Output
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
# Remove `> /dev/null 2>&1` redirections in scripts for verbose output
|
|
191
|
-
# Or modify the log functions to always show output
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Test Coverage
|
|
195
|
-
|
|
196
|
-
### ✅ Covered Functionality
|
|
197
|
-
|
|
198
|
-
- All CLI commands and help output
|
|
199
|
-
- Directory initialization (init)
|
|
200
|
-
- Repository cloning (clone) - **NEW**
|
|
201
|
-
- Sync operations (sync, status, diff, commit)
|
|
202
|
-
- Parameter validation
|
|
203
|
-
- Error handling for common scenarios
|
|
204
|
-
- File operations and change detection
|
|
205
|
-
- Configuration management
|
|
206
|
-
- Custom sync server support - **NEW**
|
|
207
|
-
|
|
208
|
-
### ⚠️ Known Limitations
|
|
209
|
-
|
|
210
|
-
- Network sync requires actual connectivity
|
|
211
|
-
- Some tests skip when dependencies missing (jq)
|
|
212
|
-
- Limited testing of concurrent operations
|
|
213
|
-
- Performance testing not included
|
|
214
|
-
|
|
215
|
-
## Troubleshooting
|
|
216
|
-
|
|
217
|
-
### Common Issues
|
|
218
|
-
|
|
219
|
-
**"jq: command not found"**
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
# Install jq (see dependencies section above)
|
|
223
|
-
brew install jq # macOS
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
**"Permission denied"**
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
# Make scripts executable
|
|
230
|
-
chmod +x test/integration/*.sh
|
|
231
|
-
chmod +x test/run-tests.sh
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
**"Not in project directory"**
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
# Run from project root where package.json exists
|
|
238
|
-
cd /path/to/pushwork
|
|
239
|
-
./test/run-tests.sh
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
**Tests failing unexpectedly**
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
# Check if project builds
|
|
246
|
-
npm run build
|
|
247
|
-
|
|
248
|
-
# Check if CLI works
|
|
249
|
-
node dist/cli.js --help
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### Debug Mode
|
|
253
|
-
|
|
254
|
-
To see more detailed output, modify the test scripts to remove output redirection:
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
# Change this:
|
|
258
|
-
if $PUSHWORK_CMD init . > /dev/null 2>&1; then
|
|
259
|
-
|
|
260
|
-
# To this:
|
|
261
|
-
if $PUSHWORK_CMD init .; then
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
## Adding New Tests
|
|
265
|
-
|
|
266
|
-
### Test Script Template
|
|
267
|
-
|
|
268
|
-
```bash
|
|
269
|
-
#!/bin/bash
|
|
270
|
-
set -e
|
|
271
|
-
|
|
272
|
-
# Test configuration
|
|
273
|
-
TEST_DIR="/tmp/my-test"
|
|
274
|
-
PUSHWORK_CMD="node $(pwd)/dist/cli.js"
|
|
275
|
-
|
|
276
|
-
# Colors and logging functions
|
|
277
|
-
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
|
|
278
|
-
BLUE='\033[0;34m'; NC='\033[0m'
|
|
279
|
-
|
|
280
|
-
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
281
|
-
log_success() { echo -e "${GREEN}[PASS]${NC} $1"; }
|
|
282
|
-
log_error() { echo -e "${RED}[FAIL]${NC} $1"; }
|
|
283
|
-
log_test() { echo -e "${YELLOW}[TEST]${NC} $1"; }
|
|
284
|
-
|
|
285
|
-
# Cleanup
|
|
286
|
-
cleanup() { rm -rf "$TEST_DIR"; }
|
|
287
|
-
trap cleanup EXIT
|
|
288
|
-
|
|
289
|
-
# Test logic here
|
|
290
|
-
setup_test_environment
|
|
291
|
-
run_tests
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
### Guidelines
|
|
295
|
-
|
|
296
|
-
1. Use consistent naming patterns
|
|
297
|
-
2. Include both positive and negative test cases
|
|
298
|
-
3. Test error conditions thoroughly
|
|
299
|
-
4. Provide clear test descriptions
|
|
300
|
-
5. Clean up resources properly
|
|
301
|
-
6. Use the established logging format
|
|
302
|
-
|
|
303
|
-
## Integration with CI/CD
|
|
304
|
-
|
|
305
|
-
These tests are designed to be run in automated environments:
|
|
306
|
-
|
|
307
|
-
```bash
|
|
308
|
-
# In your CI pipeline
|
|
309
|
-
./test/run-tests.sh full
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
Exit codes:
|
|
313
|
-
|
|
314
|
-
- `0` - All tests passed
|
|
315
|
-
- `1` - Some tests failed
|
|
316
|
-
- Non-zero - Setup or dependency errors
|
|
317
|
-
|
|
318
|
-
## Contributing
|
|
319
|
-
|
|
320
|
-
When adding new features to pushwork:
|
|
321
|
-
|
|
322
|
-
1. **Add integration tests** for new CLI commands
|
|
323
|
-
2. **Update existing tests** if command behavior changes
|
|
324
|
-
3. **Test error scenarios** - not just happy paths
|
|
325
|
-
4. **Document test coverage** in this README
|
|
326
|
-
5. **Verify tests pass** before submitting PRs
|
|
327
|
-
|
|
328
|
-
The integration tests serve as both testing and documentation for how the CLI should behave.
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Focused Clone Functionality Test for Pushwork
|
|
4
|
-
# Tests the clone command with various sync server configurations
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
# Colors for output
|
|
9
|
-
RED='\033[0;31m'
|
|
10
|
-
GREEN='\033[0;32m'
|
|
11
|
-
YELLOW='\033[1;33m'
|
|
12
|
-
BLUE='\033[0;34m'
|
|
13
|
-
NC='\033[0m'
|
|
14
|
-
|
|
15
|
-
# Test configuration
|
|
16
|
-
TEST_DIR="/tmp/pushwork-clone-test"
|
|
17
|
-
PUSHWORK_CMD="node $(pwd)/dist/cli.js"
|
|
18
|
-
CUSTOM_SYNC_SERVER="ws://localhost:3030"
|
|
19
|
-
CUSTOM_STORAGE_ID="1d89eba7-f7a4-4e8e-80f2-5f4e2406f507"
|
|
20
|
-
|
|
21
|
-
# Helper functions
|
|
22
|
-
log_info() {
|
|
23
|
-
echo -e "${BLUE}[INFO]${NC} $1"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
log_success() {
|
|
27
|
-
echo -e "${GREEN}[PASS]${NC} $1"
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
log_error() {
|
|
31
|
-
echo -e "${RED}[FAIL]${NC} $1"
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
log_test() {
|
|
35
|
-
echo -e "${YELLOW}[TEST]${NC} $1"
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
# Cleanup function
|
|
39
|
-
cleanup() {
|
|
40
|
-
log_info "Cleaning up test directory..."
|
|
41
|
-
rm -rf "$TEST_DIR"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
# Setup function
|
|
45
|
-
setup() {
|
|
46
|
-
log_info "Setting up clone test environment..."
|
|
47
|
-
|
|
48
|
-
# Build the project
|
|
49
|
-
log_info "Building pushwork..."
|
|
50
|
-
npm run build
|
|
51
|
-
|
|
52
|
-
# Clean up and create test directory
|
|
53
|
-
rm -rf "$TEST_DIR"
|
|
54
|
-
mkdir -p "$TEST_DIR"
|
|
55
|
-
cd "$TEST_DIR"
|
|
56
|
-
|
|
57
|
-
log_info "Test directory: $TEST_DIR"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
# Create a test repository to clone from
|
|
61
|
-
create_test_repo() {
|
|
62
|
-
log_info "Creating test repository..."
|
|
63
|
-
|
|
64
|
-
mkdir source-repo
|
|
65
|
-
cd source-repo
|
|
66
|
-
|
|
67
|
-
# Add some test files
|
|
68
|
-
echo "Hello from source repo" > hello.txt
|
|
69
|
-
echo "# Test Repository" > README.md
|
|
70
|
-
mkdir -p docs
|
|
71
|
-
echo "Documentation content" > docs/guide.md
|
|
72
|
-
|
|
73
|
-
# Initialize with default settings
|
|
74
|
-
$PUSHWORK_CMD init .
|
|
75
|
-
|
|
76
|
-
cd ..
|
|
77
|
-
|
|
78
|
-
log_success "Test repository created"
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
# Test clone functionality
|
|
82
|
-
test_clone_functionality() {
|
|
83
|
-
log_info "=== Testing Clone Functionality ==="
|
|
84
|
-
|
|
85
|
-
cd source-repo
|
|
86
|
-
|
|
87
|
-
# Get the root URL from the repository
|
|
88
|
-
if [ -f .pushwork/snapshot.json ]; then
|
|
89
|
-
ROOT_URL=$($PUSHWORK_CMD url .)
|
|
90
|
-
|
|
91
|
-
if [ -n "$ROOT_URL" ]; then
|
|
92
|
-
cd ..
|
|
93
|
-
|
|
94
|
-
log_test "Clone with default settings"
|
|
95
|
-
if $PUSHWORK_CMD clone "$ROOT_URL" clone-default; then
|
|
96
|
-
log_success "Clone with default settings"
|
|
97
|
-
|
|
98
|
-
# Verify cloned content
|
|
99
|
-
if [ -f clone-default/hello.txt ] && [ -f clone-default/README.md ]; then
|
|
100
|
-
log_success "Cloned files are present"
|
|
101
|
-
else
|
|
102
|
-
log_error "Cloned files are missing"
|
|
103
|
-
fi
|
|
104
|
-
|
|
105
|
-
# Check configuration
|
|
106
|
-
if [ -f clone-default/.pushwork/config.json ]; then
|
|
107
|
-
if grep -q "wss://sync3.automerge.org" clone-default/.pushwork/config.json; then
|
|
108
|
-
log_success "Default sync server in config"
|
|
109
|
-
else
|
|
110
|
-
log_error "Default sync server not found in config"
|
|
111
|
-
fi
|
|
112
|
-
fi
|
|
113
|
-
else
|
|
114
|
-
log_error "Clone with default settings failed"
|
|
115
|
-
fi
|
|
116
|
-
|
|
117
|
-
log_test "Clone with custom sync server"
|
|
118
|
-
if $PUSHWORK_CMD clone "$ROOT_URL" clone-custom --sync-server "$CUSTOM_SYNC_SERVER" --sync-server-storage-id "$CUSTOM_STORAGE_ID"; then
|
|
119
|
-
log_success "Clone with custom sync server"
|
|
120
|
-
|
|
121
|
-
# Verify custom configuration
|
|
122
|
-
if [ -f clone-custom/.pushwork/config.json ]; then
|
|
123
|
-
if grep -q "$CUSTOM_SYNC_SERVER" clone-custom/.pushwork/config.json; then
|
|
124
|
-
log_success "Custom sync server in config"
|
|
125
|
-
else
|
|
126
|
-
log_error "Custom sync server not found in config"
|
|
127
|
-
fi
|
|
128
|
-
|
|
129
|
-
if grep -q "$CUSTOM_STORAGE_ID" clone-custom/.pushwork/config.json; then
|
|
130
|
-
log_success "Custom storage ID in config"
|
|
131
|
-
else
|
|
132
|
-
log_error "Custom storage ID not found in config"
|
|
133
|
-
fi
|
|
134
|
-
fi
|
|
135
|
-
else
|
|
136
|
-
log_error "Clone with custom sync server failed"
|
|
137
|
-
fi
|
|
138
|
-
|
|
139
|
-
# Test error cases
|
|
140
|
-
log_test "Clone with incomplete sync server options"
|
|
141
|
-
|
|
142
|
-
# Only sync server (should fail)
|
|
143
|
-
if $PUSHWORK_CMD clone "$ROOT_URL" clone-fail1 --sync-server "$CUSTOM_SYNC_SERVER" 2>/dev/null; then
|
|
144
|
-
log_error "Clone with only sync-server should have failed"
|
|
145
|
-
else
|
|
146
|
-
log_success "Clone correctly failed with only sync-server"
|
|
147
|
-
fi
|
|
148
|
-
|
|
149
|
-
# Only storage ID (should fail)
|
|
150
|
-
if $PUSHWORK_CMD clone "$ROOT_URL" clone-fail2 --sync-server-storage-id "$CUSTOM_STORAGE_ID" 2>/dev/null; then
|
|
151
|
-
log_error "Clone with only storage-id should have failed"
|
|
152
|
-
else
|
|
153
|
-
log_success "Clone correctly failed with only storage-id"
|
|
154
|
-
fi
|
|
155
|
-
|
|
156
|
-
# Test force overwrite
|
|
157
|
-
mkdir -p existing-dir
|
|
158
|
-
echo "existing content" > existing-dir/existing.txt
|
|
159
|
-
|
|
160
|
-
log_test "Clone to non-empty directory without force"
|
|
161
|
-
if $PUSHWORK_CMD clone "$ROOT_URL" existing-dir 2>/dev/null; then
|
|
162
|
-
log_error "Clone to non-empty directory should have failed"
|
|
163
|
-
else
|
|
164
|
-
log_success "Clone correctly failed for non-empty directory"
|
|
165
|
-
fi
|
|
166
|
-
|
|
167
|
-
log_test "Clone to non-empty directory with force"
|
|
168
|
-
if $PUSHWORK_CMD clone "$ROOT_URL" existing-dir --force; then
|
|
169
|
-
log_success "Clone with force succeeded"
|
|
170
|
-
|
|
171
|
-
# Check that original files were replaced
|
|
172
|
-
if [ -f existing-dir/hello.txt ]; then
|
|
173
|
-
log_success "Force clone replaced existing content"
|
|
174
|
-
else
|
|
175
|
-
log_error "Force clone did not replace content properly"
|
|
176
|
-
fi
|
|
177
|
-
else
|
|
178
|
-
log_error "Clone with force failed"
|
|
179
|
-
fi
|
|
180
|
-
|
|
181
|
-
else
|
|
182
|
-
log_error "No valid root URL found"
|
|
183
|
-
fi
|
|
184
|
-
else
|
|
185
|
-
log_error "Snapshot missing - repository not properly initialized"
|
|
186
|
-
fi
|
|
187
|
-
|
|
188
|
-
cd ..
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
# Test status commands in cloned directories
|
|
192
|
-
test_cloned_directory_status() {
|
|
193
|
-
log_info "=== Testing Status in Cloned Directories ==="
|
|
194
|
-
|
|
195
|
-
if [ -d clone-default ]; then
|
|
196
|
-
cd clone-default
|
|
197
|
-
|
|
198
|
-
log_test "Status in cloned directory"
|
|
199
|
-
if $PUSHWORK_CMD status; then
|
|
200
|
-
log_success "Status command works in cloned directory"
|
|
201
|
-
else
|
|
202
|
-
log_error "Status command failed in cloned directory"
|
|
203
|
-
fi
|
|
204
|
-
|
|
205
|
-
# Make some changes and test
|
|
206
|
-
echo "Modified in clone" >> hello.txt
|
|
207
|
-
echo "New file in clone" > new-file.txt
|
|
208
|
-
|
|
209
|
-
log_test "Status after changes in clone"
|
|
210
|
-
if $PUSHWORK_CMD status; then
|
|
211
|
-
log_success "Status shows changes in clone"
|
|
212
|
-
else
|
|
213
|
-
log_error "Status failed to show changes"
|
|
214
|
-
fi
|
|
215
|
-
|
|
216
|
-
log_test "Diff in cloned directory"
|
|
217
|
-
if $PUSHWORK_CMD diff --name-only; then
|
|
218
|
-
log_success "Diff command works in cloned directory"
|
|
219
|
-
else
|
|
220
|
-
log_error "Diff command failed in cloned directory"
|
|
221
|
-
fi
|
|
222
|
-
|
|
223
|
-
cd ..
|
|
224
|
-
else
|
|
225
|
-
log_error "Clone directory not available for status testing"
|
|
226
|
-
fi
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
# Compare configurations between source and cloned repos
|
|
230
|
-
compare_configurations() {
|
|
231
|
-
log_info "=== Comparing Configurations ==="
|
|
232
|
-
|
|
233
|
-
if [ -f source-repo/.pushwork/config.json ] && [ -f clone-default/.pushwork/config.json ]; then
|
|
234
|
-
log_test "Comparing default clone configuration"
|
|
235
|
-
|
|
236
|
-
if command -v jq &> /dev/null; then
|
|
237
|
-
SOURCE_SYNC_SERVER=$(jq -r '.sync_server' source-repo/.pushwork/config.json 2>/dev/null || echo "")
|
|
238
|
-
CLONE_SYNC_SERVER=$(jq -r '.sync_server' clone-default/.pushwork/config.json 2>/dev/null || echo "")
|
|
239
|
-
|
|
240
|
-
if [ "$SOURCE_SYNC_SERVER" = "$CLONE_SYNC_SERVER" ]; then
|
|
241
|
-
log_success "Sync server matches between source and clone"
|
|
242
|
-
else
|
|
243
|
-
log_error "Sync server differs: source=[$SOURCE_SYNC_SERVER] clone=[$CLONE_SYNC_SERVER]"
|
|
244
|
-
fi
|
|
245
|
-
else
|
|
246
|
-
log_success "Sync server comparison (jq not available)"
|
|
247
|
-
fi
|
|
248
|
-
fi
|
|
249
|
-
|
|
250
|
-
if [ -f clone-custom/.pushwork/config.json ]; then
|
|
251
|
-
log_test "Verifying custom clone configuration"
|
|
252
|
-
|
|
253
|
-
if command -v jq &> /dev/null; then
|
|
254
|
-
CUSTOM_CLONE_SERVER=$(jq -r '.sync_server' clone-custom/.pushwork/config.json 2>/dev/null || echo "")
|
|
255
|
-
CUSTOM_CLONE_STORAGE=$(jq -r '.sync_server_storage_id' clone-custom/.pushwork/config.json 2>/dev/null || echo "")
|
|
256
|
-
|
|
257
|
-
if [ "$CUSTOM_CLONE_SERVER" = "$CUSTOM_SYNC_SERVER" ]; then
|
|
258
|
-
log_success "Custom sync server correctly set in clone"
|
|
259
|
-
else
|
|
260
|
-
log_error "Custom sync server incorrect: expected=[$CUSTOM_SYNC_SERVER] actual=[$CUSTOM_CLONE_SERVER]"
|
|
261
|
-
fi
|
|
262
|
-
|
|
263
|
-
if [ "$CUSTOM_CLONE_STORAGE" = "$CUSTOM_STORAGE_ID" ]; then
|
|
264
|
-
log_success "Custom storage ID correctly set in clone"
|
|
265
|
-
else
|
|
266
|
-
log_error "Custom storage ID incorrect: expected=[$CUSTOM_STORAGE_ID] actual=[$CUSTOM_CLONE_STORAGE]"
|
|
267
|
-
fi
|
|
268
|
-
else
|
|
269
|
-
log_success "Custom configuration verification (jq not available)"
|
|
270
|
-
fi
|
|
271
|
-
fi
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
# Main test execution
|
|
275
|
-
main() {
|
|
276
|
-
echo "======================================"
|
|
277
|
-
echo "Pushwork Clone Functionality Test"
|
|
278
|
-
echo "======================================"
|
|
279
|
-
|
|
280
|
-
# Trap cleanup on exit
|
|
281
|
-
trap cleanup EXIT
|
|
282
|
-
|
|
283
|
-
# Setup
|
|
284
|
-
setup
|
|
285
|
-
|
|
286
|
-
# Create test repository
|
|
287
|
-
create_test_repo
|
|
288
|
-
|
|
289
|
-
# Run clone tests
|
|
290
|
-
test_clone_functionality
|
|
291
|
-
test_cloned_directory_status
|
|
292
|
-
compare_configurations
|
|
293
|
-
|
|
294
|
-
echo ""
|
|
295
|
-
echo "======================================"
|
|
296
|
-
echo "Clone Test Complete"
|
|
297
|
-
echo "======================================"
|
|
298
|
-
|
|
299
|
-
log_success "All clone functionality tests completed!"
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
# Check dependencies
|
|
303
|
-
if ! command -v jq &> /dev/null; then
|
|
304
|
-
log_warning "jq is not installed - some configuration tests will be skipped"
|
|
305
|
-
echo "To install jq: brew install jq (macOS) or apt-get install jq (Ubuntu)"
|
|
306
|
-
echo ""
|
|
307
|
-
fi
|
|
308
|
-
|
|
309
|
-
# Run the tests
|
|
310
|
-
main "$@"
|