vibefast-cli 0.1.3 → 0.2.0
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/AUTO-DETECT-DEPS.md +607 -0
- package/CHANGELOG.md +86 -0
- package/FINAL-PACKAGE-STRATEGY.md +583 -0
- package/FINAL-SIMPLE-PLAN.md +487 -0
- package/FLOW-DIAGRAM.md +1629 -0
- package/GOTCHAS-AND-RISKS.md +801 -0
- package/IMPLEMENTATION-COMPLETE.md +477 -0
- package/IMPLEMENTATION-PLAN.md +1360 -0
- package/PRE-PUBLISH-CHECKLIST.md +558 -0
- package/PRODUCTION-READINESS.md +684 -0
- package/PRODUCTION-TEST-RESULTS.md +465 -0
- package/README.md +73 -7
- package/READY-TO-PUBLISH.md +419 -0
- package/SIMPLIFIED-PLAN.md +578 -0
- package/TEST-SUMMARY.md +261 -0
- package/USER-MODIFICATIONS.md +448 -0
- package/cloudflare-worker/worker.js +39 -11
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +192 -15
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/checklist.d.ts +3 -0
- package/dist/commands/checklist.d.ts.map +1 -0
- package/dist/commands/checklist.js +64 -0
- package/dist/commands/checklist.js.map +1 -0
- package/dist/commands/remove.d.ts.map +1 -1
- package/dist/commands/remove.js +85 -2
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +40 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/core/__tests__/fsx.test.d.ts +2 -0
- package/dist/core/__tests__/fsx.test.d.ts.map +1 -0
- package/dist/core/__tests__/fsx.test.js +79 -0
- package/dist/core/__tests__/fsx.test.js.map +1 -0
- package/dist/core/__tests__/hash.test.d.ts +2 -0
- package/dist/core/__tests__/hash.test.d.ts.map +1 -0
- package/dist/core/__tests__/hash.test.js +84 -0
- package/dist/core/__tests__/hash.test.js.map +1 -0
- package/dist/core/__tests__/journal.test.js +65 -0
- package/dist/core/__tests__/journal.test.js.map +1 -1
- package/dist/core/__tests__/prompt.test.d.ts +2 -0
- package/dist/core/__tests__/prompt.test.d.ts.map +1 -0
- package/dist/core/__tests__/prompt.test.js +56 -0
- package/dist/core/__tests__/prompt.test.js.map +1 -0
- package/dist/core/fsx.d.ts +7 -1
- package/dist/core/fsx.d.ts.map +1 -1
- package/dist/core/fsx.js +18 -3
- package/dist/core/fsx.js.map +1 -1
- package/dist/core/hash.d.ts +13 -0
- package/dist/core/hash.d.ts.map +1 -0
- package/dist/core/hash.js +69 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/journal.d.ts +10 -1
- package/dist/core/journal.d.ts.map +1 -1
- package/dist/core/journal.js +23 -1
- package/dist/core/journal.js.map +1 -1
- package/dist/core/prompt.d.ts +11 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +34 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
- package/src/commands/add.ts +234 -16
- package/src/commands/checklist.ts +71 -0
- package/src/commands/remove.ts +105 -3
- package/src/commands/status.ts +47 -0
- package/src/core/__tests__/fsx.test.ts +101 -0
- package/src/core/__tests__/hash.test.ts +112 -0
- package/src/core/__tests__/journal.test.ts +76 -0
- package/src/core/__tests__/prompt.test.ts +72 -0
- package/src/core/fsx.ts +38 -5
- package/src/core/hash.ts +84 -0
- package/src/core/journal.ts +40 -2
- package/src/core/prompt.ts +40 -0
- package/src/index.ts +5 -1
- package/text.md +27 -0
package/TEST-SUMMARY.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# ✅ Test Summary
|
|
2
|
+
|
|
3
|
+
## Test Results
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
Test Files 5 passed (5)
|
|
7
|
+
Tests 34 passed (34)
|
|
8
|
+
Duration 481ms
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
All tests passing! ✅
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Test Coverage
|
|
16
|
+
|
|
17
|
+
### 1. Hash Module (`src/core/__tests__/hash.test.ts`) - 8 tests ✅
|
|
18
|
+
|
|
19
|
+
**Tests:**
|
|
20
|
+
- ✅ Should hash file content correctly
|
|
21
|
+
- ✅ Should return empty string for non-existent file
|
|
22
|
+
- ✅ Should detect file modifications
|
|
23
|
+
- ✅ Should produce same hash for same content
|
|
24
|
+
- ✅ Should hash multiple files
|
|
25
|
+
- ✅ Should skip binary files
|
|
26
|
+
- ✅ Should handle empty array
|
|
27
|
+
- ✅ Should handle non-existent files gracefully
|
|
28
|
+
|
|
29
|
+
**Coverage:**
|
|
30
|
+
- File hashing with SHA-256
|
|
31
|
+
- Performance optimizations (binary file skipping)
|
|
32
|
+
- Error handling for missing files
|
|
33
|
+
- Batch processing
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### 2. Prompt Module (`src/core/__tests__/prompt.test.ts`) - 5 tests ✅
|
|
38
|
+
|
|
39
|
+
**Tests:**
|
|
40
|
+
- ✅ Should return default value in non-TTY environment
|
|
41
|
+
- ✅ Should return default value in CI environment
|
|
42
|
+
- ✅ Should detect GitHub Actions
|
|
43
|
+
- ✅ Should detect GitLab CI
|
|
44
|
+
- ✅ Should detect CircleCI
|
|
45
|
+
|
|
46
|
+
**Coverage:**
|
|
47
|
+
- TTY detection
|
|
48
|
+
- CI/CD environment detection
|
|
49
|
+
- Default value handling
|
|
50
|
+
- Multiple CI platforms
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### 3. Journal Module (`src/core/__tests__/journal.test.ts`) - 9 tests ✅
|
|
55
|
+
|
|
56
|
+
**Tests:**
|
|
57
|
+
- ✅ Should return empty journal if file missing
|
|
58
|
+
- ✅ Should write and read journal
|
|
59
|
+
- ✅ Should add entry
|
|
60
|
+
- ✅ Should replace existing entry for same feature+target
|
|
61
|
+
- ✅ Should remove entry
|
|
62
|
+
- ✅ Should get entry
|
|
63
|
+
- ✅ Should handle new format with file hashes (NEW)
|
|
64
|
+
- ✅ Should migrate old format to new format (NEW)
|
|
65
|
+
- ✅ Should store manifest data (NEW)
|
|
66
|
+
|
|
67
|
+
**Coverage:**
|
|
68
|
+
- Basic CRUD operations
|
|
69
|
+
- New format with file hashes
|
|
70
|
+
- Auto-migration from old format
|
|
71
|
+
- Manifest data storage
|
|
72
|
+
- Backward compatibility
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### 4. FSX Module (`src/core/__tests__/fsx.test.ts`) - 6 tests ✅
|
|
77
|
+
|
|
78
|
+
**Tests:**
|
|
79
|
+
- ✅ Should copy files successfully
|
|
80
|
+
- ✅ Should detect conflicts
|
|
81
|
+
- ✅ Should overwrite with force flag
|
|
82
|
+
- ✅ Should handle dry-run mode
|
|
83
|
+
- ✅ Should copy nested directories
|
|
84
|
+
- ✅ Should handle empty directory
|
|
85
|
+
|
|
86
|
+
**Coverage:**
|
|
87
|
+
- File copying
|
|
88
|
+
- Conflict detection
|
|
89
|
+
- Force mode
|
|
90
|
+
- Dry-run mode
|
|
91
|
+
- Nested directory handling
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### 5. Validate Module (`src/core/__tests__/validate.test.ts`) - 6 tests ✅
|
|
96
|
+
|
|
97
|
+
**Tests:**
|
|
98
|
+
- ✅ Should validate signature file
|
|
99
|
+
- ✅ Should throw on missing signature
|
|
100
|
+
- ✅ Should validate target
|
|
101
|
+
- ✅ Should throw on invalid target
|
|
102
|
+
- ✅ Should validate native target
|
|
103
|
+
- ✅ Should validate web target
|
|
104
|
+
|
|
105
|
+
**Coverage:**
|
|
106
|
+
- Signature validation
|
|
107
|
+
- Target validation
|
|
108
|
+
- Error handling
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Test Files Created
|
|
113
|
+
|
|
114
|
+
1. ✅ `src/core/__tests__/hash.test.ts` (NEW)
|
|
115
|
+
2. ✅ `src/core/__tests__/prompt.test.ts` (NEW)
|
|
116
|
+
3. ✅ `src/core/__tests__/fsx.test.ts` (NEW)
|
|
117
|
+
4. ✅ `src/core/__tests__/journal.test.ts` (UPDATED - added 3 new tests)
|
|
118
|
+
5. ✅ `src/core/__tests__/validate.test.ts` (EXISTING)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## What's Tested
|
|
123
|
+
|
|
124
|
+
### Core Functionality ✅
|
|
125
|
+
- File hashing (SHA-256)
|
|
126
|
+
- User prompts with CI/CD detection
|
|
127
|
+
- Journal CRUD operations
|
|
128
|
+
- File copying with conflict detection
|
|
129
|
+
- Repository validation
|
|
130
|
+
|
|
131
|
+
### New Features ✅
|
|
132
|
+
- File hash storage in journal
|
|
133
|
+
- Auto-migration from old journal format
|
|
134
|
+
- Manifest data storage
|
|
135
|
+
- Conflict detection in copyTree
|
|
136
|
+
- Interactive mode support
|
|
137
|
+
- Force mode support
|
|
138
|
+
- Dry-run mode support
|
|
139
|
+
|
|
140
|
+
### Edge Cases ✅
|
|
141
|
+
- Non-existent files
|
|
142
|
+
- Binary files
|
|
143
|
+
- Empty directories
|
|
144
|
+
- Nested directories
|
|
145
|
+
- CI/CD environments (no TTY)
|
|
146
|
+
- Multiple CI platforms
|
|
147
|
+
- Old journal format migration
|
|
148
|
+
- Missing files during hashing
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## What's NOT Tested (Integration Tests Needed)
|
|
153
|
+
|
|
154
|
+
### Commands (Need Manual/Integration Testing)
|
|
155
|
+
- ❌ `vf add` command (full flow)
|
|
156
|
+
- ❌ `vf remove` command (full flow)
|
|
157
|
+
- ❌ `vf status` command
|
|
158
|
+
- ❌ `vf checklist` command
|
|
159
|
+
|
|
160
|
+
### Complex Scenarios
|
|
161
|
+
- ❌ Interactive prompts (requires user input)
|
|
162
|
+
- ❌ Navigation injection
|
|
163
|
+
- ❌ Watermark addition
|
|
164
|
+
- ❌ Recipe fetching from API
|
|
165
|
+
- ❌ Zip extraction
|
|
166
|
+
- ❌ Full end-to-end flow
|
|
167
|
+
|
|
168
|
+
**Note:** These require integration tests or manual testing as they involve:
|
|
169
|
+
- User interaction
|
|
170
|
+
- Network requests
|
|
171
|
+
- File system operations across multiple modules
|
|
172
|
+
- External dependencies (API, recipes)
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Running Tests
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Run all tests
|
|
180
|
+
npm test
|
|
181
|
+
|
|
182
|
+
# Run tests once (no watch)
|
|
183
|
+
npm test -- --run
|
|
184
|
+
|
|
185
|
+
# Run specific test file
|
|
186
|
+
npm test -- hash.test.ts
|
|
187
|
+
|
|
188
|
+
# Run with coverage
|
|
189
|
+
npm test -- --coverage
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Test Quality
|
|
195
|
+
|
|
196
|
+
### Good Practices ✅
|
|
197
|
+
- ✅ Isolated tests (each test is independent)
|
|
198
|
+
- ✅ Cleanup after tests (afterEach hooks)
|
|
199
|
+
- ✅ Descriptive test names
|
|
200
|
+
- ✅ Testing both success and error cases
|
|
201
|
+
- ✅ Testing edge cases
|
|
202
|
+
- ✅ Using temporary directories
|
|
203
|
+
- ✅ No test interdependencies
|
|
204
|
+
|
|
205
|
+
### Coverage
|
|
206
|
+
- **Unit Tests:** 34 tests covering core modules
|
|
207
|
+
- **Integration Tests:** Manual testing needed
|
|
208
|
+
- **E2E Tests:** Manual testing needed
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Next Steps for Testing
|
|
213
|
+
|
|
214
|
+
### 1. Integration Tests (Future)
|
|
215
|
+
Create integration tests for commands:
|
|
216
|
+
```typescript
|
|
217
|
+
describe('vf add integration', () => {
|
|
218
|
+
it('should install feature end-to-end', async () => {
|
|
219
|
+
// Setup test repo
|
|
220
|
+
// Run vf add
|
|
221
|
+
// Verify files copied
|
|
222
|
+
// Verify journal updated
|
|
223
|
+
// Verify navigation added
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### 2. E2E Tests (Future)
|
|
229
|
+
Test full user workflows:
|
|
230
|
+
```bash
|
|
231
|
+
# Test script
|
|
232
|
+
vf login --token TEST_TOKEN
|
|
233
|
+
vf add charts --dry-run
|
|
234
|
+
vf add charts
|
|
235
|
+
vf status
|
|
236
|
+
vf checklist charts
|
|
237
|
+
vf remove charts
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### 3. Manual Testing Checklist
|
|
241
|
+
- [ ] Test with real VibeFast monorepo
|
|
242
|
+
- [ ] Test with real recipes
|
|
243
|
+
- [ ] Test interactive prompts
|
|
244
|
+
- [ ] Test in CI/CD environment
|
|
245
|
+
- [ ] Test with conflicts
|
|
246
|
+
- [ ] Test with modified files
|
|
247
|
+
- [ ] Test migration from old journal
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Summary
|
|
252
|
+
|
|
253
|
+
✅ **34 unit tests passing**
|
|
254
|
+
✅ **All core modules tested**
|
|
255
|
+
✅ **New features tested**
|
|
256
|
+
✅ **Edge cases covered**
|
|
257
|
+
✅ **Good test quality**
|
|
258
|
+
|
|
259
|
+
The CLI has solid unit test coverage for all core functionality. Integration and E2E tests can be added later as needed.
|
|
260
|
+
|
|
261
|
+
**Ready for manual testing and production use!** 🚀
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
# 🔧 User Modifications & File Management
|
|
2
|
+
|
|
3
|
+
## What is mini-native?
|
|
4
|
+
|
|
5
|
+
**mini-native** is a **demo/test feature** used for testing the VibeFast CLI. It's not a real production feature, but rather a minimal example to validate the entire installation flow.
|
|
6
|
+
|
|
7
|
+
### Purpose
|
|
8
|
+
- Test the CLI installation process
|
|
9
|
+
- Validate the worker API
|
|
10
|
+
- Demonstrate the recipe format
|
|
11
|
+
- Used in E2E tests and documentation examples
|
|
12
|
+
|
|
13
|
+
### What it contains
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"name": "mini-native",
|
|
17
|
+
"version": "0.1.0",
|
|
18
|
+
"description": "Demo feature (Expo)",
|
|
19
|
+
"copy": [
|
|
20
|
+
{
|
|
21
|
+
"from": "apps/native/src/app/mini",
|
|
22
|
+
"to": "apps/native/src/app/(root)/(protected)/mini"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"nav": {
|
|
26
|
+
"href": "/(root)/(protected)/mini",
|
|
27
|
+
"label": "Mini"
|
|
28
|
+
},
|
|
29
|
+
"target": "native"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
It's essentially a single screen/page that gets installed to demonstrate that the CLI works correctly.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## What Happens When Users Modify Files?
|
|
38
|
+
|
|
39
|
+
This is a **critical question** about the CLI's behavior. Here's the complete breakdown:
|
|
40
|
+
|
|
41
|
+
### Scenario 1: User Modifies Files After Installation
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
Day 1: Install charts
|
|
45
|
+
$ vf add charts
|
|
46
|
+
✓ 17 files installed
|
|
47
|
+
|
|
48
|
+
Day 5: User edits files
|
|
49
|
+
User modifies: apps/native/src/app/(root)/(protected)/charts/index.tsx
|
|
50
|
+
- Adds custom styling
|
|
51
|
+
- Removes some components
|
|
52
|
+
- Adds new features
|
|
53
|
+
|
|
54
|
+
Day 10: User removes charts
|
|
55
|
+
$ vf remove charts
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**What happens?**
|
|
59
|
+
|
|
60
|
+
### ⚠️ The CLI Will Delete ALL Files - Including User Modifications!
|
|
61
|
+
|
|
62
|
+
The CLI **does NOT track file modifications**. Here's why:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// From src/core/fsx.ts
|
|
66
|
+
export async function deleteFile(path: string): Promise<void> {
|
|
67
|
+
try {
|
|
68
|
+
await rm(path, { recursive: true, force: true });
|
|
69
|
+
} catch (err: any) {
|
|
70
|
+
if (err.code !== 'ENOENT') throw err;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// From src/commands/remove.ts
|
|
77
|
+
// Delete files
|
|
78
|
+
for (const file of entry.files) {
|
|
79
|
+
log.info(`Deleting ${file}`);
|
|
80
|
+
if (!options.dryRun) {
|
|
81
|
+
await deleteFile(file);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### How It Works
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
90
|
+
│ FILE DELETION PROCESS │
|
|
91
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
92
|
+
|
|
93
|
+
Step 1: Read Journal
|
|
94
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
95
|
+
│ .vibefast/journal.json contains: │
|
|
96
|
+
│ { │
|
|
97
|
+
│ "feature": "charts", │
|
|
98
|
+
│ "files": [ │
|
|
99
|
+
│ "/path/to/apps/native/src/app/charts/index.tsx", │
|
|
100
|
+
│ "/path/to/apps/native/src/app/charts/chart-card.tsx", │
|
|
101
|
+
│ ... (15 more files) │
|
|
102
|
+
│ ] │
|
|
103
|
+
│ } │
|
|
104
|
+
└──────────────────────────────────────────────────────────────┘
|
|
105
|
+
|
|
106
|
+
Step 2: Delete Each File
|
|
107
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
108
|
+
│ For each file in the list: │
|
|
109
|
+
│ • No check if file was modified │
|
|
110
|
+
│ • No backup created │
|
|
111
|
+
│ • No diff comparison │
|
|
112
|
+
│ • Just: rm -rf <file> │
|
|
113
|
+
│ │
|
|
114
|
+
│ Result: ALL files deleted, regardless of modifications │
|
|
115
|
+
└──────────────────────────────────────────────────────────────┘
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Scenario 2: Reinstalling After Modifications
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
Day 1: Install charts
|
|
124
|
+
$ vf add charts
|
|
125
|
+
✓ 17 files installed
|
|
126
|
+
|
|
127
|
+
Day 5: User modifies files
|
|
128
|
+
User edits multiple chart files
|
|
129
|
+
|
|
130
|
+
Day 10: User tries to reinstall
|
|
131
|
+
$ vf add charts
|
|
132
|
+
⚠ charts is already installed for native
|
|
133
|
+
ℹ Use --force to reinstall
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Using --force Flag
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
$ vf add charts --force
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**What happens?**
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
146
|
+
│ FORCE REINSTALL PROCESS │
|
|
147
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
148
|
+
|
|
149
|
+
Step 1: Check Existing Installation
|
|
150
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
151
|
+
│ Journal shows charts is installed │
|
|
152
|
+
│ BUT --force flag is present │
|
|
153
|
+
│ → Skip the "already installed" warning │
|
|
154
|
+
│ → Proceed with installation │
|
|
155
|
+
└──────────────────────────────────────────────────────────────┘
|
|
156
|
+
|
|
157
|
+
Step 2: Copy Files (with force)
|
|
158
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
159
|
+
│ From src/core/fsx.ts: │
|
|
160
|
+
│ │
|
|
161
|
+
│ if (destExists && !options?.force) { │
|
|
162
|
+
│ throw new Error(`File exists: ${destPath}`); │
|
|
163
|
+
│ } │
|
|
164
|
+
│ │
|
|
165
|
+
│ With --force: │
|
|
166
|
+
│ • Existing files are OVERWRITTEN │
|
|
167
|
+
│ • User modifications are LOST │
|
|
168
|
+
│ • No backup is created │
|
|
169
|
+
│ • Fresh files from recipe replace everything │
|
|
170
|
+
└──────────────────────────────────────────────────────────────┘
|
|
171
|
+
|
|
172
|
+
Step 3: Update Journal
|
|
173
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
174
|
+
│ Journal is updated with new file list │
|
|
175
|
+
│ (Usually the same files, but fresh timestamps) │
|
|
176
|
+
└──────────────────────────────────────────────────────────────┘
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Scenario 3: User Deletes Some Files Manually
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
Day 1: Install charts (17 files)
|
|
185
|
+
$ vf add charts
|
|
186
|
+
|
|
187
|
+
Day 5: User manually deletes 3 files
|
|
188
|
+
User removes:
|
|
189
|
+
- chart-card.tsx
|
|
190
|
+
- chart-utils.ts
|
|
191
|
+
- chart-types.ts
|
|
192
|
+
|
|
193
|
+
Day 10: User removes charts
|
|
194
|
+
$ vf remove charts
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**What happens?**
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
201
|
+
│ PARTIAL FILE DELETION │
|
|
202
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
203
|
+
|
|
204
|
+
The CLI tries to delete ALL 17 files from journal:
|
|
205
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
206
|
+
│ File 1: index.tsx → Deleted ✓ │
|
|
207
|
+
│ File 2: chart-card.tsx → Already gone (OK) │
|
|
208
|
+
│ File 3: chart-utils.ts → Already gone (OK) │
|
|
209
|
+
│ File 4: chart-types.ts → Already gone (OK) │
|
|
210
|
+
│ File 5: chart-preview.tsx → Deleted ✓ │
|
|
211
|
+
│ ... (continue for remaining files) │
|
|
212
|
+
│ │
|
|
213
|
+
│ From src/core/fsx.ts: │
|
|
214
|
+
│ catch (err: any) { │
|
|
215
|
+
│ if (err.code !== 'ENOENT') throw err; │
|
|
216
|
+
│ } │
|
|
217
|
+
│ │
|
|
218
|
+
│ ENOENT = "File not found" → Silently ignored │
|
|
219
|
+
│ Result: No error, removal completes successfully │
|
|
220
|
+
└──────────────────────────────────────────────────────────────┘
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Scenario 4: User Adds New Files to Feature Directory
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
Day 1: Install charts (17 files)
|
|
229
|
+
$ vf add charts
|
|
230
|
+
|
|
231
|
+
Day 5: User adds custom files
|
|
232
|
+
User creates:
|
|
233
|
+
- apps/native/src/app/charts/my-custom-chart.tsx
|
|
234
|
+
- apps/native/src/app/charts/my-utils.ts
|
|
235
|
+
- apps/native/src/features/charts/my-hook.ts
|
|
236
|
+
|
|
237
|
+
Day 10: User removes charts
|
|
238
|
+
$ vf remove charts
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**What happens?**
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
245
|
+
│ ORPHANED FILES PROBLEM │
|
|
246
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
247
|
+
|
|
248
|
+
The CLI only deletes tracked files:
|
|
249
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
250
|
+
│ Journal contains 17 original files │
|
|
251
|
+
│ CLI deletes those 17 files │
|
|
252
|
+
│ │
|
|
253
|
+
│ User's custom files are NOT in journal: │
|
|
254
|
+
│ • my-custom-chart.tsx → NOT DELETED (orphaned) │
|
|
255
|
+
│ • my-utils.ts → NOT DELETED (orphaned) │
|
|
256
|
+
│ • my-hook.ts → NOT DELETED (orphaned) │
|
|
257
|
+
│ │
|
|
258
|
+
│ Result: │
|
|
259
|
+
│ ✓ Original 17 files deleted │
|
|
260
|
+
│ ⚠ User's 3 custom files remain in the directory │
|
|
261
|
+
│ ⚠ Empty directories may remain │
|
|
262
|
+
└──────────────────────────────────────────────────────────────┘
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## The Problem: No Modification Tracking
|
|
268
|
+
|
|
269
|
+
### What the CLI Does NOT Do
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
❌ Does NOT check if files were modified
|
|
273
|
+
❌ Does NOT create backups before deletion
|
|
274
|
+
❌ Does NOT warn about modified files
|
|
275
|
+
❌ Does NOT track user-added files
|
|
276
|
+
❌ Does NOT show diffs
|
|
277
|
+
❌ Does NOT ask for confirmation (except dry-run)
|
|
278
|
+
❌ Does NOT preserve user changes
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### What the CLI DOES Do
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
✓ Tracks original file paths in journal
|
|
285
|
+
✓ Deletes files by path (regardless of content)
|
|
286
|
+
✓ Ignores missing files (ENOENT)
|
|
287
|
+
✓ Supports --dry-run to preview
|
|
288
|
+
✓ Supports --force to overwrite
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Best Practices for Users
|
|
294
|
+
|
|
295
|
+
### 1. Use Version Control (Git)
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Before installing any feature
|
|
299
|
+
$ git status
|
|
300
|
+
$ git commit -am "Before installing charts"
|
|
301
|
+
|
|
302
|
+
# Install feature
|
|
303
|
+
$ vf add charts
|
|
304
|
+
|
|
305
|
+
# Review changes
|
|
306
|
+
$ git diff
|
|
307
|
+
$ git add .
|
|
308
|
+
$ git commit -m "Add charts feature"
|
|
309
|
+
|
|
310
|
+
# If you modify files
|
|
311
|
+
$ git commit -am "Customize charts"
|
|
312
|
+
|
|
313
|
+
# If you want to remove
|
|
314
|
+
$ vf remove charts
|
|
315
|
+
$ git diff # See what was deleted
|
|
316
|
+
$ git checkout -- . # Restore if needed
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### 2. Use --dry-run Before Operations
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Preview installation
|
|
323
|
+
$ vf add charts --dry-run
|
|
324
|
+
[DRY RUN] No changes will be made
|
|
325
|
+
ℹ Files that would be added: 17
|
|
326
|
+
|
|
327
|
+
# Preview removal
|
|
328
|
+
$ vf remove charts --dry-run
|
|
329
|
+
[DRY RUN] No changes will be made
|
|
330
|
+
ℹ Files that would be deleted: 17
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### 3. Don't Modify Feature Files Directly
|
|
334
|
+
|
|
335
|
+
**Instead of modifying feature files:**
|
|
336
|
+
```
|
|
337
|
+
❌ apps/native/src/features/charts/chart-card.tsx
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Create wrapper components:**
|
|
341
|
+
```
|
|
342
|
+
✓ apps/native/src/components/custom-chart-card.tsx
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
This way:
|
|
346
|
+
- Feature files remain untouched
|
|
347
|
+
- Your customizations are separate
|
|
348
|
+
- Removal doesn't affect your code
|
|
349
|
+
- Updates are easier
|
|
350
|
+
|
|
351
|
+
### 4. Fork Features Into Your Own Code
|
|
352
|
+
|
|
353
|
+
If you need heavy customization:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
# Install feature
|
|
357
|
+
$ vf add charts
|
|
358
|
+
|
|
359
|
+
# Copy to your own directory
|
|
360
|
+
$ cp -r apps/native/src/features/charts apps/native/src/features/my-charts
|
|
361
|
+
|
|
362
|
+
# Remove original
|
|
363
|
+
$ vf remove charts
|
|
364
|
+
|
|
365
|
+
# Now you own the code completely
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## Potential Improvements (Not Currently Implemented)
|
|
371
|
+
|
|
372
|
+
### Idea 1: Modification Detection
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
// Hypothetical future feature
|
|
376
|
+
interface JournalEntry {
|
|
377
|
+
feature: string;
|
|
378
|
+
files: Array<{
|
|
379
|
+
path: string;
|
|
380
|
+
hash: string; // SHA-256 of original content
|
|
381
|
+
}>;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Before removal, check:
|
|
385
|
+
for (const file of entry.files) {
|
|
386
|
+
const currentHash = await hashFile(file.path);
|
|
387
|
+
if (currentHash !== file.hash) {
|
|
388
|
+
log.warn(`${file.path} was modified by user`);
|
|
389
|
+
// Ask for confirmation or create backup
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Idea 2: Backup Before Deletion
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
// Hypothetical future feature
|
|
398
|
+
$ vf remove charts --backup
|
|
399
|
+
|
|
400
|
+
// Creates:
|
|
401
|
+
.vibefast/backups/charts-2024-11-13/
|
|
402
|
+
├── index.tsx
|
|
403
|
+
├── chart-card.tsx
|
|
404
|
+
└── ...
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Idea 3: Smart Merge on Reinstall
|
|
408
|
+
|
|
409
|
+
```typescript
|
|
410
|
+
// Hypothetical future feature
|
|
411
|
+
$ vf add charts --force --merge
|
|
412
|
+
|
|
413
|
+
// Would:
|
|
414
|
+
// 1. Detect modifications
|
|
415
|
+
// 2. Create .orig files
|
|
416
|
+
// 3. Install new version
|
|
417
|
+
// 4. Show merge conflicts
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## Summary
|
|
423
|
+
|
|
424
|
+
### mini-native
|
|
425
|
+
- Demo/test feature for CLI validation
|
|
426
|
+
- Contains minimal code (single screen)
|
|
427
|
+
- Used in examples and tests
|
|
428
|
+
- Not a production feature
|
|
429
|
+
|
|
430
|
+
### User Modifications
|
|
431
|
+
- **CLI does NOT track modifications**
|
|
432
|
+
- `vf remove` deletes ALL tracked files (modified or not)
|
|
433
|
+
- `vf add --force` overwrites ALL files (losing modifications)
|
|
434
|
+
- User-added files are orphaned (not deleted)
|
|
435
|
+
- **Best practice: Use Git for safety**
|
|
436
|
+
- **Best practice: Don't modify feature files directly**
|
|
437
|
+
|
|
438
|
+
### Key Takeaway
|
|
439
|
+
|
|
440
|
+
The VibeFast CLI treats features as **atomic units**:
|
|
441
|
+
- Install = Copy all files
|
|
442
|
+
- Remove = Delete all files
|
|
443
|
+
- No middle ground, no modification tracking
|
|
444
|
+
|
|
445
|
+
This is simple and predictable, but requires users to:
|
|
446
|
+
1. Use version control
|
|
447
|
+
2. Keep customizations separate
|
|
448
|
+
3. Understand that modifications will be lost on remove/reinstall
|