Skip to content

Commit 8ebb0cf

Browse files
committed
Merge feat/fixes-and-niceties-2: Phase 2 UX improvements
- Fix duplicate drifted dotfiles in status - Improve dotfile column headers ($HOME/$PLONKDIR) - Fix diff output column ordering - Add 'plonk add -y' to sync drifted files - Add selective file deployment 'plonk apply <file1> <file2>' - Comprehensive BATS test coverage (11 new tests) - Updated all command documentation All tests pass.
2 parents f2907b5 + 3b0eda1 commit 8ebb0cf

File tree

15 files changed

+596
-117
lines changed

15 files changed

+596
-117
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ The `clone` command:
118118
```bash
119119
# Package management
120120
plonk install ripgrep fd # Install and track packages
121-
plonk install pnpm cargo # Bootstrap package managers automatically
121+
plonk install pnpm cargo # Install package managers (must be available via another manager)
122122
plonk uninstall ripgrep # Uninstall and stop tracking
123123
plonk upgrade # Upgrade all packages to latest versions
124124
plonk upgrade brew:ripgrep # Upgrade specific package
@@ -127,13 +127,15 @@ plonk info ripgrep # Show package details
127127

128128
# Dotfile management
129129
plonk add ~/.vimrc ~/.zshrc # Start tracking dotfiles
130+
plonk add -y # Sync all drifted files from $HOME to $PLONKDIR
130131
plonk rm ~/.vimrc # Stop tracking (doesn't delete file)
131132
plonk dotfiles # List dotfiles with state info
132133

133134
# System state
134135
plonk status # Show all managed items (including drift)
135136
plonk apply # Sync system to desired state
136-
plonk diff # Show differences between desired and actual state
137+
plonk apply ~/.vimrc ~/.zshrc # Apply only specific dotfiles
138+
plonk diff # Show differences for drifted dotfiles
137139
plonk doctor # Check system health
138140

139141
# Configuration

docs/cli.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ plonk upgrade htop neovim # Upgrade multiple packages
8181

8282
### plonk add
8383

84-
Add dotfiles to management.
84+
Add dotfiles to management or sync drifted files back.
8585

8686
```bash
8787
plonk add ~/.vimrc ~/.zshrc # Add files
8888
plonk add ~/.config/nvim/ # Add directory
89-
plonk add --dry-run ~/.vimrc # Preview
89+
plonk add -y # Sync all drifted files from $HOME to $PLONKDIR
90+
plonk add -y --dry-run # Preview drift sync
91+
plonk add --dry-run ~/.vimrc # Preview add
9092
```
9193

9294
### plonk rm
@@ -133,9 +135,10 @@ Install missing packages and deploy missing dotfiles.
133135

134136
```bash
135137
plonk apply # Apply all changes
138+
plonk apply ~/.vimrc ~/.zshrc # Apply only specific dotfiles
136139
plonk apply --dry-run # Preview changes
137-
plonk apply --packages # Apply packages only
138-
plonk apply --dotfiles # Apply dotfiles only
140+
plonk apply --packages # Apply packages only
141+
plonk apply --dotfiles # Apply dotfiles only
139142
```
140143

141144
### plonk search

docs/cmds/apply.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ Reconciles system state by installing missing packages and deploying missing dot
55
## Synopsis
66

77
```bash
8-
plonk apply [options]
8+
plonk apply [options] [files...]
99
```
1010

1111
## Description
1212

1313
The apply command reconciles the system state with the desired configuration by installing packages listed in `plonk.lock` and deploying dotfiles from `$PLONK_DIR`. It acts like a sync operation, bringing the local environment in line with the managed configuration.
1414

15+
When file arguments are provided, apply validates that the specified files are managed by plonk before proceeding.
16+
1517
Apply targets "missing" resources (tracked but not present) and "drifted" dotfiles (modified since deployment), transitioning them to "managed" state. The command uses plonk's internal reconciliation system to identify what needs to be applied.
1618

1719
## Options
@@ -68,6 +70,9 @@ Files matching `ignore_patterns` are excluded from deployment.
6870
# Apply all changes (packages and dotfiles)
6971
plonk apply
7072

73+
# Apply only specific dotfiles
74+
plonk apply ~/.vimrc ~/.zshrc
75+
7176
# Preview what would be changed
7277
plonk apply --dry-run
7378

@@ -87,3 +92,5 @@ plonk apply --dotfiles
8792
## Notes
8893

8994
- The `--packages` and `--dotfiles` flags cannot be used together
95+
- File arguments cannot be combined with `--packages` or `--dotfiles` flags
96+
- All specified files must be managed by plonk or command will fail

docs/cmds/diff.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ The diff command accepts various path formats for the file argument:
3939
### Default Behavior
4040

4141
- Uses `git diff --no-index` by default (zero-config)
42-
- Shows differences with source file first, deployed file second
42+
- Shows differences with deployed file ($HOME) first, source file ($PLONKDIR) second
43+
- Follows standard diff conventions (current state vs. source of truth)
4344
- Processes all drifted files when no argument provided
4445
- Continues with remaining files if individual diff fails
4546
- GUI diff tools open in their own windows
@@ -58,7 +59,7 @@ Common configurations:
5859
- `diff_tool: "code --diff --wait"` - VS Code diff
5960
- `diff_tool: "meld"` - GUI diff tool
6061
61-
The diff tool is executed as: `{tool} {source_path} {deployed_path}`
62+
The diff tool is executed as: `{tool} {deployed_path} {source_path}`
6263

6364
### Error Handling
6465

@@ -86,8 +87,8 @@ plonk diff .vimrc
8687
## Integration
8788

8889
- Use `plonk status` to see which files have drifted
89-
- Use `plonk apply` to restore drifted files from source
90-
- Use `plonk add` to update source with current deployed version
90+
- Use `plonk apply` to restore drifted files from $PLONKDIR
91+
- Use `plonk add -y` to sync all drifted files from $HOME back to $PLONKDIR
9192

9293
## Notes
9394

docs/cmds/dotfile-management.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ Copies dotfiles from their current location to `$PLONK_DIR` for management.
2525
### Synopsis
2626

2727
```bash
28-
plonk add [options] <file>...
28+
plonk add [options] [files...]
2929
```
3030

3131
### Options
3232

3333
- `--dry-run, -n` - Preview changes without adding files
34+
- `--sync-drifted, -y` - Sync all drifted files from $HOME back to $PLONKDIR
3435

3536
### Behavior
3637

@@ -62,6 +63,12 @@ plonk add ~/.zshrc ~/.gitconfig ~/.tmux.conf
6263
# Add entire directory
6364
plonk add ~/.config/nvim/
6465

66+
# Sync all drifted files back to $PLONKDIR
67+
plonk add -y
68+
69+
# Preview drift sync without making changes
70+
plonk add -y --dry-run
71+
6572
# Preview changes
6673
plonk add --dry-run ~/.vimrc
6774
```

docs/cmds/status.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Using both `--packages` and `--dotfiles` together has the same effect as using n
5555
- STATUS: Current state with icon
5656

5757
**Dotfiles Table** (managed/missing):
58-
- SOURCE: Path relative to `$PLONK_DIR`
59-
- TARGET: Full path in `$HOME`
58+
- $HOME: Full path in home directory (deployed location)
59+
- $PLONKDIR: Path relative to plonk configuration directory
6060
- STATUS: Current state with icon
6161

6262
**Dotfiles List** (unmanaged):
@@ -108,7 +108,7 @@ plonk status -o json
108108

109109
- Use before `plonk apply` to see what will be changed
110110
- Missing items can be resolved with `plonk apply`
111-
- Drifted dotfiles can be restored with `plonk apply` or updated with `plonk add`
111+
- Drifted dotfiles can be restored with `plonk apply` or synced back with `plonk add -y`
112112
- Unmanaged items can be added with `plonk install` or `plonk add`
113113

114114
## Notes

docs/plans/fixes-and-niceties.md

Lines changed: 68 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -192,76 +192,88 @@ func KeyForPackage(managerName, packageName string) string {
192192

193193
## UX/Display Improvements
194194

195-
### 8. Fix duplicate listing of drifted dotfiles
195+
### 8. Fix duplicate listing of drifted dotfiles (COMPLETED)
196196
**Priority**: Medium (UX bug)
197197
**Command**: `plonk status`
198+
**Status**: ✅ Completed (commit 55e9249)
198199

199200
**Problem**: When a dotfile is in drifted status, it appears twice in the output.
200201

201-
**Fix**: Ensure drifted files only appear once in the status output with their drift state clearly indicated.
202+
**Fix Applied**:
203+
- Removed misleading comment about handling drifted items separately
204+
- Drifted files (State==StateDegraded) already in Managed list now display once with "drifted" status
205+
- File: `internal/output/status_formatter.go`
202206

203-
### 9. Improve dotfile column headers in status
207+
### 9. Improve dotfile column headers in status (COMPLETED)
204208
**Priority**: Medium (UX improvement)
205209
**Command**: `plonk status`
210+
**Status**: ✅ Completed (commit 55e9249)
206211

207212
**Problem**: Column headers "source" and "target" are confusing for dotfiles.
208213

209-
**Fix**:
210-
- Use actual expanded paths like `/Users/username` and `/Users/username/.config/plonk` instead of generic "source/target"
211-
- Reorder columns to: `$HOME`, `$PLONKDIR`, `STATUS`
212-
- Makes it immediately clear which file is where
214+
**Fix Applied**:
215+
- Changed headers from "SOURCE", "TARGET", "STATUS" to "$HOME", "$PLONKDIR", "STATUS"
216+
- Reordered columns: $HOME (deployed location), $PLONKDIR (source), STATUS
217+
- Updated all AddRow calls to match new column order
218+
- File: `internal/output/status_formatter.go`
213219

214-
### 10. Fix diff output column ordering
220+
### 10. Fix diff output column ordering (COMPLETED)
215221
**Priority**: Medium (UX improvement)
216222
**Command**: `plonk diff`
223+
**Status**: ✅ Completed (commit 55e9249)
217224

218225
**Problem**: Current ordering is inconsistent with user mental model.
219226

220-
**Fix**: Display `$HOME` (deployed location) on the left and `$PLONKDIR` (source) on the right, matching standard diff conventions where "original" is on left and "modified" is on right.
227+
**Fix Applied**:
228+
- Swapped diff arguments from `source, dest` to `dest, source`
229+
- Now shows $HOME (deployed) on left and $PLONKDIR (source) on right
230+
- Matches standard diff conventions (current state vs. source)
231+
- File: `internal/commands/diff.go`
221232

222233
## Feature Additions
223234

224-
### 11. Add `plonk add -y` to sync drifted files back to $PLONKDIR
235+
### 11. Add `plonk add -y` to sync drifted files back to $PLONKDIR (COMPLETED)
225236
**Priority**: Medium (Feature enhancement)
226237
**Command**: `plonk add`
238+
**Status**: ✅ Completed (commit 55e9249)
227239

228240
**Feature**: Add a `-y` or `--sync-drifted` flag to automatically copy all drifted files from $HOME back to $PLONKDIR (reverse of `apply`).
229241

230-
**Use case**: When you've edited dotfiles in $HOME and want to quickly capture all changes back to your managed config directory.
231-
232-
**Behavior**:
242+
**Implementation**:
233243
```bash
234-
plonk add -y
235-
# Finds all files with "drifted" status
236-
# Copies them from $HOME to $PLONKDIR
237-
# Updates timestamps/hashes
244+
plonk add -y # Sync all drifted files
245+
plonk add -y --dry-run # Preview what would be synced
238246
```
239247

240-
**Implementation considerations**:
241-
- Should show which files will be synced before copying (or require `-y` for non-interactive)
242-
- Consider `--dry-run` option to preview changes
243-
- Respect `.plonkignore` or similar patterns if implemented
244-
245-
### 12. Add selective file deployment to `plonk apply`
248+
**Changes Applied**:
249+
- Added `--sync-drifted` flag (short: `-y`) to add command
250+
- Finds all files with State==StateDegraded (drifted)
251+
- Copies them from $HOME back to $PLONKDIR
252+
- Shows summary of synced files
253+
- Works with `--dry-run` for preview
254+
- Shows appropriate message when no files are drifted
255+
- File: `internal/commands/add.go`
256+
257+
### 12. ✅ Add selective file deployment to `plonk apply` (COMPLETED)
246258
**Priority**: Medium (Feature enhancement)
247259
**Command**: `plonk apply`
260+
**Status**: ✅ Completed (commit 55e9249)
248261

249262
**Feature**: Allow `plonk apply <file1> <file2> ...` to selectively deploy only specified files from $PLONKDIR to $HOME.
250263

251-
**Use case**: When you've updated specific dotfiles and only want to deploy those without touching others.
252-
253-
**Behavior**:
264+
**Implementation**:
254265
```bash
255-
plonk apply ~/.vimrc ~/.zshrc
256-
# Only deploys vimrc and zshrc from $PLONKDIR to $HOME
257-
# Leaves other managed dotfiles untouched
266+
plonk apply ~/.vimrc ~/.zshrc # Apply only specified files
267+
plonk apply # Apply all (original behavior)
258268
```
259269

260-
**Implementation considerations**:
261-
- Accept both $HOME paths (`.vimrc`) and $PLONKDIR paths
262-
- Validate files are actually managed by plonk
263-
- Provide clear error if file not found or not managed
264-
- Still show before/after status for specified files
270+
**Changes Applied**:
271+
- Modified command to accept optional file arguments: `apply [files...]`
272+
- Validates that specified files are managed by plonk before proceeding
273+
- Shows clear error if file not found or not managed
274+
- Prevents combining file arguments with `--packages` or `--dotfiles` flags
275+
- Updated help text with examples
276+
- File: `internal/commands/apply.go`
265277

266278
## Nice-to-Haves
267279

@@ -295,11 +307,19 @@ func NewIsolatedRegistry() *ManagerRegistry {
295307
}
296308
```
297309

298-
### 16. Add comprehensive tests
299-
**Recommended test additions**:
300-
1. Self-install path tests per manager (verify correct installer commands via mock executor)
301-
2. Concurrency smoke test for parallel manager reconciliation
302-
3. Symlink traversal tests for dotfile operations
310+
### 16. ✅ Add comprehensive tests (PARTIALLY COMPLETED)
311+
**Status**: ✅ Added drift and sync tests (commit 5800789, f2646a0)
312+
313+
**Completed**:
314+
- ✅ Created `tests/bats/behavioral/10-drift-and-sync.bats` with 11 new tests
315+
- ✅ Tests for duplicate drifted dotfiles, column headers, diff ordering
316+
- ✅ Tests for `plonk add -y` sync functionality
317+
- ✅ Tests for selective `plonk apply <files>`
318+
- ✅ Integration test for complete drift workflow
319+
320+
**Remaining**:
321+
1. Concurrency smoke test for parallel manager reconciliation
322+
2. Symlink traversal tests for dotfile operations
303323

304324
### 17. Documentation updates
305325
**Files**: README.md
@@ -332,12 +352,15 @@ func NewIsolatedRegistry() *ManagerRegistry {
332352
**Completed**: 2025-01-06 in commits 619924f, 10e9002
333353
**Results**: 3 critical fixes, 26 files changed, 1 file deleted, -293 LOC, all tests passing
334354

335-
### Phase 2: UX Improvements
336-
4. Fix duplicate drifted dotfiles in status (#8)
337-
5. Improve dotfile column headers in status (#9)
338-
6. Fix diff output column ordering (#10)
339-
7. Add `plonk add -y` to sync drifted files (#11)
340-
8. Add selective file deployment to `plonk apply` (#12)
355+
### Phase 2: UX Improvements ✅ COMPLETED
356+
4. ✅ Fix duplicate drifted dotfiles in status (#8)
357+
5. ✅ Improve dotfile column headers in status (#9)
358+
6. ✅ Fix diff output column ordering (#10)
359+
7. ✅ Add `plonk add -y` to sync drifted files (#11)
360+
8. ✅ Add selective file deployment to `plonk apply` (#12)
361+
362+
**Completed**: 2025-01-06 in commit 55e9249
363+
**Results**: 5 UX improvements, 4 files changed, +190 LOC, all tests passing
341364

342365
### Phase 3: Architecture & Performance
343366
9. Standardize V2 registration (#5)

0 commit comments

Comments
 (0)