diffwatch 2.0.5 → 2.0.6
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/README.md +0 -35
- package/package.json +1 -1
- package/src/components/DiffViewer.tsx +1 -1
- package/src/components/FileList.tsx +30 -2
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -8,15 +8,12 @@ A TUI app for watching git repository file changes with diffs.
|
|
|
8
8
|
|
|
9
9
|
- **File Status Tracking**: Shows all changed files in a Git repository with their status (modified, new, deleted, renamed, etc.)
|
|
10
10
|
- **Visual Diff Viewer**: Displays differences between file versions with syntax highlighting and line-by-line comparison
|
|
11
|
-
- **Interactive Terminal Interface**: Built with React-like components for terminal UI using the @opentui library
|
|
12
|
-
- **Real-time Updates**: Automatically polls for changes in the repository every 2 seconds
|
|
13
11
|
- **File Operations**:
|
|
14
12
|
- Revert changes to files
|
|
15
13
|
- Delete files safely (with trash/recycle bin support)
|
|
16
14
|
- Open files in the default editor
|
|
17
15
|
- **Search Functionality**: Allows searching for files by content within the repository
|
|
18
16
|
- **Commit History Browser**: View commit history with hash, message, author, and date
|
|
19
|
-
- **Keyboard Navigation**: Full keyboard controls for navigating files and diffs
|
|
20
17
|
|
|
21
18
|
## Installation
|
|
22
19
|
|
|
@@ -62,8 +59,6 @@ bun install
|
|
|
62
59
|
|
|
63
60
|
## Usage
|
|
64
61
|
|
|
65
|
-
### Basic Usage
|
|
66
|
-
|
|
67
62
|
To watch the current git repository:
|
|
68
63
|
```bash
|
|
69
64
|
diffwatch
|
|
@@ -97,16 +92,6 @@ Watch a specific project:
|
|
|
97
92
|
diffwatch --path ~/projects/my-app
|
|
98
93
|
```
|
|
99
94
|
|
|
100
|
-
Check version:
|
|
101
|
-
```bash
|
|
102
|
-
diffwatch --version
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Show help:
|
|
106
|
-
```bash
|
|
107
|
-
diffwatch --help
|
|
108
|
-
```
|
|
109
|
-
|
|
110
95
|
## Keyboard Shortcuts
|
|
111
96
|
|
|
112
97
|
- `↑` / `↓` - Navigate through the file list
|
|
@@ -119,26 +104,6 @@ diffwatch --help
|
|
|
119
104
|
- `Q` - Quit the application
|
|
120
105
|
- `Esc` - Exit search mode or close dialogs
|
|
121
106
|
|
|
122
|
-
## Development
|
|
123
|
-
|
|
124
|
-
### Prerequisites
|
|
125
|
-
|
|
126
|
-
- [Bun](https://bun.sh/) - Fast JavaScript runtime and package manager
|
|
127
|
-
- Node.js 18+ (for running published package)
|
|
128
|
-
|
|
129
|
-
### Setup
|
|
130
|
-
|
|
131
|
-
1. Clone the repository:
|
|
132
|
-
```bash
|
|
133
|
-
git clone https://github.com/sarfraznawaz2005/diffwatch.git
|
|
134
|
-
cd diffwatch
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
2. Install dependencies:
|
|
138
|
-
```bash
|
|
139
|
-
bun install
|
|
140
|
-
```
|
|
141
|
-
|
|
142
107
|
### Running the App in Development
|
|
143
108
|
|
|
144
109
|
```bash
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { useRenderer } from '@opentui/react';
|
|
2
3
|
import { type FileStatus } from '../utils/git';
|
|
3
4
|
|
|
4
5
|
interface FileListProps {
|
|
@@ -12,6 +13,7 @@ interface FileListProps {
|
|
|
12
13
|
|
|
13
14
|
export function FileList({ files, selectedIndex, focused, searchQuery, onSelect, onScroll }: FileListProps) {
|
|
14
15
|
const scrollRef = useRef<any>(null);
|
|
16
|
+
const renderer = useRenderer();
|
|
15
17
|
|
|
16
18
|
useEffect(() => {
|
|
17
19
|
if (scrollRef.current) {
|
|
@@ -26,6 +28,30 @@ export function FileList({ files, selectedIndex, focused, searchQuery, onSelect,
|
|
|
26
28
|
}
|
|
27
29
|
}, [selectedIndex]);
|
|
28
30
|
|
|
31
|
+
// Calculate the max length for file paths based on available width
|
|
32
|
+
// Account for the symbol, space, and padding
|
|
33
|
+
const calculateMaxPathLength = (): number => {
|
|
34
|
+
// Get the width of the container (33% of total width)
|
|
35
|
+
// Since we can't directly measure the rendered width, we'll estimate based on a percentage
|
|
36
|
+
// considering that the container is 33% of the total width
|
|
37
|
+
// and we need to account for the symbol (1 char) + space (1 char) = 2 chars
|
|
38
|
+
// Also account for potential borders and padding (approximately 2-3 chars)
|
|
39
|
+
const estimatedWidth = Math.floor((renderer.width * 0.33) - 5); // 5 chars for symbol + spaces + borders/padding
|
|
40
|
+
return Math.max(10, estimatedWidth); // minimum length of 10
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const truncatePath = (path: string, maxLength: number): string => {
|
|
44
|
+
if (path.length <= maxLength) {
|
|
45
|
+
return path;
|
|
46
|
+
}
|
|
47
|
+
if (maxLength <= 3) {
|
|
48
|
+
return '.'.repeat(maxLength);
|
|
49
|
+
}
|
|
50
|
+
return path.substring(0, maxLength - 3) + '...';
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const maxPathLength = calculateMaxPathLength();
|
|
54
|
+
|
|
29
55
|
const title = searchQuery
|
|
30
56
|
? ` Files (${files.length}) - "${searchQuery}" `
|
|
31
57
|
: ` Files (${files.length}) `;
|
|
@@ -34,7 +60,7 @@ export function FileList({ files, selectedIndex, focused, searchQuery, onSelect,
|
|
|
34
60
|
<box
|
|
35
61
|
border
|
|
36
62
|
title={title}
|
|
37
|
-
width="
|
|
63
|
+
width="33%"
|
|
38
64
|
height="100%"
|
|
39
65
|
borderColor={focused ? 'yellow' : 'grey'}
|
|
40
66
|
flexDirection="column"
|
|
@@ -74,6 +100,8 @@ export function FileList({ files, selectedIndex, focused, searchQuery, onSelect,
|
|
|
74
100
|
};
|
|
75
101
|
const symbol = symbolMap[file.status] || '?';
|
|
76
102
|
|
|
103
|
+
const truncatedPath = truncatePath(file.path, maxPathLength);
|
|
104
|
+
|
|
77
105
|
return (
|
|
78
106
|
<box
|
|
79
107
|
key={file.path}
|
|
@@ -84,7 +112,7 @@ export function FileList({ files, selectedIndex, focused, searchQuery, onSelect,
|
|
|
84
112
|
<text
|
|
85
113
|
fg={isSelected ? 'black' : color}
|
|
86
114
|
>
|
|
87
|
-
{` ${symbol} ${
|
|
115
|
+
{` ${symbol} ${truncatedPath}`}
|
|
88
116
|
</text>
|
|
89
117
|
</box>
|
|
90
118
|
);
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_VERSION = "2.0.
|
|
1
|
+
export const BUILD_VERSION = "2.0.6";
|