undoai 0.1.0-beta.2 โ 1.0.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/CONTRIBUTING.md +287 -0
- package/QUICKSTART.md +90 -0
- package/USAGE.md +474 -0
- package/demo-feature/README.md +1 -0
- package/demo-feature/config.ts +1 -0
- package/demo-feature/index.ts +1 -0
- package/demo-feature/types.ts +1 -0
- package/demo-feature/user-service.ts +1 -0
- package/dist/cli/index.js +0 -0
- package/fitur_premium.md +5 -0
- package/package.json +7 -28
- package/run-all-tests.sh +30 -0
- package/src/cli/commands/restore.ts +222 -0
- package/src/cli/commands/status.ts +51 -0
- package/src/cli/commands/stop.ts +22 -0
- package/src/cli/commands/watch.ts +162 -0
- package/src/cli/index.ts +52 -0
- package/src/core/daemon.ts +104 -0
- package/src/core/snapshot.ts +144 -0
- package/src/core/storage.ts +250 -0
- package/src/example.ts +33 -0
- package/src/utils/logger.ts +69 -0
- package/src/watcher.ts +163 -0
- package/test-1-burst.sh +36 -0
- package/test-2-selective.sh +27 -0
- package/test-3-compression.sh +95 -0
- package/test-burst-1.ts +1 -0
- package/test-burst-2.ts +1 -0
- package/test-burst-3.ts +1 -0
- package/test-compression/file1.txt +2 -0
- package/test-compression/file2.txt +2 -0
- package/test-compression/file3.txt +1 -0
- package/test-watcher.sh +21 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Test 2: Selective Restore (Manual Test)
|
|
3
|
+
|
|
4
|
+
echo "๐งช Test 2: Selective Restore"
|
|
5
|
+
echo "============================"
|
|
6
|
+
echo ""
|
|
7
|
+
|
|
8
|
+
echo "Step 1: Delete some test files..."
|
|
9
|
+
rm -f test-burst-1.ts test-burst-2.ts 2>/dev/null
|
|
10
|
+
echo "โ
Deleted test-burst-1.ts and test-burst-2.ts"
|
|
11
|
+
echo ""
|
|
12
|
+
|
|
13
|
+
echo "Step 2: Now run selective restore:"
|
|
14
|
+
echo ""
|
|
15
|
+
echo " node dist/cli/index.js restore -i"
|
|
16
|
+
echo ""
|
|
17
|
+
echo "Expected behavior:"
|
|
18
|
+
echo " 1. Shows list of snapshots"
|
|
19
|
+
echo " 2. Select latest snapshot"
|
|
20
|
+
echo " 3. Shows checkbox list of files"
|
|
21
|
+
echo " 4. Use SPACE to select files"
|
|
22
|
+
echo " 5. Use ENTER to confirm"
|
|
23
|
+
echo " 6. Shows preview before restore"
|
|
24
|
+
echo " 7. Confirm to restore"
|
|
25
|
+
echo ""
|
|
26
|
+
echo "Try it now! ๐"
|
|
27
|
+
echo ""
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Test 3: Compression Verification
|
|
3
|
+
|
|
4
|
+
echo "๐งช Test 3: Compression Verification"
|
|
5
|
+
echo "===================================="
|
|
6
|
+
echo ""
|
|
7
|
+
|
|
8
|
+
echo "Checking snapshot files..."
|
|
9
|
+
echo ""
|
|
10
|
+
|
|
11
|
+
SNAPSHOTS=$(ls -1 ~/.undoai/snapshots/ 2>/dev/null)
|
|
12
|
+
|
|
13
|
+
if [ -z "$SNAPSHOTS" ]; then
|
|
14
|
+
echo "โ No snapshots found!"
|
|
15
|
+
echo " Run test-1-burst.sh first"
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# Get latest snapshot
|
|
20
|
+
LATEST=$(ls -1t ~/.undoai/snapshots/ | head -n 1)
|
|
21
|
+
FILES_DIR="$HOME/.undoai/snapshots/$LATEST/files"
|
|
22
|
+
|
|
23
|
+
echo "๐ Latest snapshot: $LATEST"
|
|
24
|
+
echo ""
|
|
25
|
+
|
|
26
|
+
if [ ! -d "$FILES_DIR" ]; then
|
|
27
|
+
echo "โ No files directory found!"
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
echo "๐ Files in snapshot:"
|
|
32
|
+
echo ""
|
|
33
|
+
ls -lh "$FILES_DIR/"
|
|
34
|
+
echo ""
|
|
35
|
+
|
|
36
|
+
echo "๐ Checking compression..."
|
|
37
|
+
echo ""
|
|
38
|
+
|
|
39
|
+
GZ_COUNT=$(ls -1 "$FILES_DIR"/*.gz 2>/dev/null | wc -l)
|
|
40
|
+
ALL_COUNT=$(ls -1 "$FILES_DIR"/ 2>/dev/null | wc -l)
|
|
41
|
+
|
|
42
|
+
echo "Total files: $ALL_COUNT"
|
|
43
|
+
echo "Compressed (.gz): $GZ_COUNT"
|
|
44
|
+
echo ""
|
|
45
|
+
|
|
46
|
+
if [ "$GZ_COUNT" -gt 0 ]; then
|
|
47
|
+
echo "โ
Compression is working!"
|
|
48
|
+
echo ""
|
|
49
|
+
echo "Verifying gzip format:"
|
|
50
|
+
for f in "$FILES_DIR"/*.gz; do
|
|
51
|
+
if [ -f "$f" ]; then
|
|
52
|
+
FILE_TYPE=$(file "$f" | grep -o "gzip compressed")
|
|
53
|
+
if [ -n "$FILE_TYPE" ]; then
|
|
54
|
+
echo " โ
$(basename $f): $FILE_TYPE"
|
|
55
|
+
else
|
|
56
|
+
echo " โ $(basename $f): NOT gzip!"
|
|
57
|
+
fi
|
|
58
|
+
fi
|
|
59
|
+
done
|
|
60
|
+
|
|
61
|
+
echo ""
|
|
62
|
+
echo "๐ Storage savings calculation:"
|
|
63
|
+
|
|
64
|
+
# Try to calculate savings
|
|
65
|
+
TOTAL_COMPRESSED=0
|
|
66
|
+
TOTAL_ORIGINAL=0
|
|
67
|
+
|
|
68
|
+
for f in "$FILES_DIR"/*.gz; do
|
|
69
|
+
if [ -f "$f" ]; then
|
|
70
|
+
COMPRESSED_SIZE=$(stat -f%z "$f" 2>/dev/null || stat -c%s "$f" 2>/dev/null)
|
|
71
|
+
TOTAL_COMPRESSED=$((TOTAL_COMPRESSED + COMPRESSED_SIZE))
|
|
72
|
+
|
|
73
|
+
# Decompress to temp and measure
|
|
74
|
+
TEMP_FILE=$(mktemp)
|
|
75
|
+
gunzip -c "$f" > "$TEMP_FILE" 2>/dev/null
|
|
76
|
+
ORIGINAL_SIZE=$(stat -f%z "$TEMP_FILE" 2>/dev/null || stat -c%s "$TEMP_FILE" 2>/dev/null)
|
|
77
|
+
TOTAL_ORIGINAL=$((TOTAL_ORIGINAL + ORIGINAL_SIZE))
|
|
78
|
+
rm "$TEMP_FILE"
|
|
79
|
+
fi
|
|
80
|
+
done
|
|
81
|
+
|
|
82
|
+
if [ $TOTAL_ORIGINAL -gt 0 ]; then
|
|
83
|
+
SAVINGS=$((100 - (TOTAL_COMPRESSED * 100 / TOTAL_ORIGINAL)))
|
|
84
|
+
echo " Original size: $TOTAL_ORIGINAL bytes"
|
|
85
|
+
echo " Compressed size: $TOTAL_COMPRESSED bytes"
|
|
86
|
+
echo " Savings: $SAVINGS%"
|
|
87
|
+
fi
|
|
88
|
+
else
|
|
89
|
+
echo "โ No compressed files found!"
|
|
90
|
+
echo " Expected files ending with .gz"
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
echo ""
|
|
94
|
+
echo "โ
Test 3 completed!"
|
|
95
|
+
echo ""
|
package/test-burst-1.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const test1 = 'hello';
|
package/test-burst-2.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const test2 = 'world';
|
package/test-burst-3.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const test3 = 'foo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
change
|
package/test-watcher.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
echo "๐งช Testing File Watcher - Creating test files..."
|
|
4
|
+
echo ""
|
|
5
|
+
|
|
6
|
+
# Create test directory
|
|
7
|
+
mkdir -p test-files
|
|
8
|
+
|
|
9
|
+
# Create 5 files quickly (to trigger burst)
|
|
10
|
+
echo "Creating 5 files..."
|
|
11
|
+
for i in {1..5}; do
|
|
12
|
+
echo "Test content $i" > test-files/test-file-$i.txt
|
|
13
|
+
echo " โ Created test-file-$i.txt"
|
|
14
|
+
done
|
|
15
|
+
|
|
16
|
+
echo ""
|
|
17
|
+
echo "โ
Done! Wait 2 seconds for burst detection..."
|
|
18
|
+
echo " The watcher should trigger the callback now!"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2020"
|
|
7
|
+
],
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"declarationMap": true,
|
|
18
|
+
"sourceMap": true
|
|
19
|
+
},
|
|
20
|
+
"include": [
|
|
21
|
+
"src/**/*"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules",
|
|
25
|
+
"dist",
|
|
26
|
+
"build"
|
|
27
|
+
]
|
|
28
|
+
}
|