Skip to content

Commit 4b71dcc

Browse files
docs: Updated .gitignore and Testing README.md
1 parent 2358ded commit 4b71dcc

File tree

2 files changed

+371
-0
lines changed

2 files changed

+371
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Thumbs.db
6060
.project
6161
.classpath
6262
.settings/
63+
.cursor/
6364

6465
# Temporary files
6566
*.tmp

scripts/README.md

Lines changed: 370 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,370 @@
1+
# Labcommitr Testing Sandbox
2+
3+
A testing environment for safely experimenting with Labcommitr commands without affecting your real repository.
4+
5+
## TLDR; Quick Start
6+
7+
```bash
8+
# Create sandbox with config (if available in project root)
9+
pnpm run test:sandbox
10+
11+
# Create sandbox without config (start from scratch)
12+
pnpm run test:sandbox:bare
13+
14+
# Enter sandbox and test
15+
cd .sandbox/*/
16+
node ../../dist/index.js commit
17+
18+
# Quick reset (faster, keeps repo structure)
19+
pnpm run test:sandbox:reset
20+
21+
# Full recreation (slower, completely fresh)
22+
pnpm run test:sandbox
23+
24+
# Clean up (remove sandbox)
25+
pnpm run test:sandbox:clean
26+
```
27+
28+
---
29+
30+
## Table of Contents
31+
32+
- [Overview](#overview)
33+
- [Quick Start](#tldr-quick-start)
34+
- [Usage](#usage)
35+
- [Creating a Sandbox](#creating-a-sandbox)
36+
- [Testing Commands](#testing-commands)
37+
- [Resetting the Sandbox](#resetting-the-sandbox)
38+
- [Cleaning Up](#cleaning-up)
39+
- [Sandbox Contents](#sandbox-contents)
40+
- [Testing Scenarios](#testing-scenarios)
41+
- [Troubleshooting](#troubleshooting)
42+
- [Safety Guarantees](#safety-guarantees)
43+
44+
---
45+
46+
## Overview
47+
48+
The testing sandbox creates an isolated git repository with pre-configured file states to test Labcommitr's commit command. Each sandbox gets a randomized scientific name (e.g., `quark`, `photon`, `neutron`) and is stored in `.sandbox/` directory.
49+
50+
**Key Features:**
51+
- ✅ Completely isolated from your real repository
52+
- ✅ Pre-populated with various git file states (modified, added, deleted, renamed, copied)
53+
- ✅ Automatically copies your project's `.labcommitr.config.yaml` if it exists
54+
- ✅ Safe to delete anytime
55+
- ✅ Quick reset option for iterative testing
56+
57+
---
58+
59+
## Usage
60+
61+
### Creating a Sandbox
62+
63+
You have two options for creating a sandbox:
64+
65+
**Option 1: With Config (Default)**
66+
```bash
67+
# Using npm script (recommended)
68+
pnpm run test:sandbox
69+
70+
# Or direct script execution
71+
bash scripts/labcommitr-sandbox.sh
72+
```
73+
74+
This will:
75+
1. Create a new sandbox directory in `.sandbox/<random-name>/`
76+
2. Initialize a git repository
77+
3. Copy your project's `.labcommitr.config.yaml` if it exists (ready to test immediately)
78+
4. Create test files with various git states
79+
5. Stage all changes ready for testing
80+
81+
**Option 2: Without Config (Start from Scratch)**
82+
```bash
83+
# Using npm script (recommended)
84+
pnpm run test:sandbox:bare
85+
86+
# Or direct script execution
87+
bash scripts/labcommitr-sandbox.sh --no-config
88+
```
89+
90+
This will:
91+
1. Create a new sandbox directory in `.sandbox/<random-name>/`
92+
2. Initialize a git repository
93+
3. **Skip copying config** (sandbox starts without configuration)
94+
4. Create test files with various git states
95+
5. Stage all changes ready for testing
96+
97+
After creating a bare sandbox, you can set up configuration:
98+
```bash
99+
cd .sandbox/*/
100+
lab init # Interactive setup (or lab init --force to overwrite if config exists)
101+
```
102+
103+
**Note:** If a sandbox already exists, it will be completely recreated (full reset).
104+
105+
### Testing Commands
106+
107+
Once the sandbox is created, navigate to it and test Labcommitr:
108+
109+
```bash
110+
# Find your sandbox (it has a random scientific name)
111+
cd .sandbox/*/
112+
113+
# Test commit command (recommended method)
114+
node ../../dist/index.js commit
115+
116+
# Alternative: If you've linked globally
117+
lab commit
118+
```
119+
120+
**⚠️ Important:** Do NOT use `npx lab commit` - it will use the wrong 'lab' package (Node.js test framework).
121+
122+
### Resetting the Sandbox
123+
124+
You have two reset options:
125+
126+
**Quick Reset** (recommended for iterative testing)
127+
```bash
128+
pnpm run test:sandbox:reset
129+
# or
130+
bash scripts/labcommitr-sandbox.sh --reset
131+
```
132+
- Faster (keeps repository structure)
133+
- Resets git state and re-applies test file changes
134+
- Use this when you want to test again quickly
135+
136+
**Full Recreation** (slower but completely fresh)
137+
```bash
138+
pnpm run test:sandbox
139+
# or
140+
bash scripts/labcommitr-sandbox.sh
141+
```
142+
- Removes entire sandbox and recreates from scratch
143+
- Ensures all file types are properly staged
144+
- Use this if quick reset doesn't work or you want a clean slate
145+
146+
### Cleaning Up
147+
148+
To completely remove the sandbox:
149+
150+
```bash
151+
pnpm run test:sandbox:clean
152+
# or
153+
bash scripts/labcommitr-sandbox.sh --clean
154+
```
155+
156+
This removes the sandbox directory entirely. The `.sandbox/` base directory is also removed if empty.
157+
158+
---
159+
160+
## Sandbox Contents
161+
162+
Each sandbox contains a git repository with the following pre-staged file states:
163+
164+
### File States (17 total files staged)
165+
166+
- **Modified (4 files)**: `src/component-{a,b,c,d}.ts` - Files with changes
167+
- **Added (4 files)**: `src/service-{a,b,c}.ts`, `docs/guide.md` - New files
168+
- **Deleted (4 files)**: `utils/old-util-{1,2,3,4}.js` - Files marked for deletion
169+
- **Renamed (4 files)**: `lib/{helpers→helper-functions, constants→app-constants, types→type-definitions, config→configuration}.ts` - Files moved/renamed
170+
- **Copied (4 files)**: `src/model-{1,2}-backup.ts`, `lib/model-{3,4}-copy.ts` - Files copied (Git detects with `-C50` flag)
171+
- **Pre-staged (1 file)**: `pre-staged.ts` - Already staged file for testing
172+
173+
### Directory Structure
174+
175+
```
176+
.sandbox/
177+
└── <random-name>/ # e.g., quark, photon, neutron
178+
├── .labcommitr.config.yaml # Copied from project root (if exists)
179+
├── README.md
180+
├── package.json
181+
├── src/
182+
│ ├── component-{a,b,c,d}.ts
183+
│ ├── service-{a,b,c}.ts
184+
│ ├── model-{1,2,3,4}.ts
185+
│ └── model-{1,2}-backup.ts
186+
├── docs/
187+
│ └── guide.md
188+
├── lib/
189+
│ ├── helper-functions.ts
190+
│ ├── app-constants.ts
191+
│ ├── type-definitions.ts
192+
│ ├── configuration.ts
193+
│ └── model-{3,4}-copy.ts
194+
├── utils/
195+
└── pre-staged.ts
196+
```
197+
198+
---
199+
200+
## Testing Scenarios
201+
202+
### Test Different Configurations
203+
204+
1. **Modify config in sandbox:**
205+
```bash
206+
cd .sandbox/*/
207+
# Edit .labcommitr.config.yaml
208+
# Test with different settings:
209+
# - auto_stage: true vs false
210+
# - Different commit types
211+
# - Validation rules
212+
# - editor_preference: "auto" | "inline" | "editor"
213+
```
214+
215+
2. **Test auto-stage behavior:**
216+
- Set `auto_stage: true` - tool should stage files automatically
217+
- Set `auto_stage: false` - tool should only commit already-staged files
218+
219+
3. **Test validation rules:**
220+
- Try invalid commit types
221+
- Test scope requirements
222+
- Test subject length limits
223+
224+
4. **Test editor preferences:**
225+
- `inline`: Type body directly in terminal
226+
- `editor`: Opens your default editor
227+
- `auto`: Detects available editor automatically
228+
229+
### Verify Commit Results
230+
231+
```bash
232+
# Check git log
233+
git log --oneline -5
234+
235+
# See last commit details
236+
git show HEAD
237+
238+
# Check git status
239+
git status
240+
git status --porcelain # Compact format
241+
242+
# See staged files
243+
git diff --cached --name-only
244+
```
245+
246+
---
247+
248+
## Troubleshooting
249+
250+
### Files Don't Appear Correctly
251+
252+
If git status doesn't show the expected file states:
253+
254+
1. **Full recreation:**
255+
```bash
256+
pnpm run test:sandbox
257+
```
258+
259+
2. **Check git status manually:**
260+
```bash
261+
cd .sandbox/*/
262+
git status
263+
git status --porcelain
264+
```
265+
266+
### Config Not Found
267+
268+
If you see "No config file found" or created a bare sandbox:
269+
270+
1. **Create config in sandbox (recommended):**
271+
```bash
272+
cd .sandbox/*/
273+
lab init # Interactive setup
274+
```
275+
276+
2. **Or create config in project root first, then recreate sandbox:**
277+
```bash
278+
# From project root
279+
lab init
280+
# Then recreate sandbox to copy the config
281+
pnpm run test:sandbox
282+
```
283+
284+
3. **To overwrite existing config in sandbox:**
285+
```bash
286+
cd .sandbox/*/
287+
lab init --force # Overwrites existing config
288+
```
289+
290+
### Reset Not Working
291+
292+
If quick reset fails:
293+
294+
1. **Use full recreation instead:**
295+
```bash
296+
pnpm run test:sandbox
297+
```
298+
299+
2. **Or manually reset:**
300+
```bash
301+
cd .sandbox/*/
302+
git reset --hard HEAD
303+
git clean -fd
304+
```
305+
306+
### Can't Find Sandbox
307+
308+
Sandbox location is randomized. To find it:
309+
310+
```bash
311+
# List all sandboxes
312+
ls -la .sandbox/
313+
314+
# Or use find
315+
find .sandbox -name ".git" -type d
316+
```
317+
318+
---
319+
320+
## Safety Guarantees
321+
322+
The sandbox is **100% safe**:
323+
324+
1. **No push to remote**: Sandbox is completely separate, no remote configured
325+
2. **Isolated**: No connection to your real repository
326+
3. **Easy cleanup**: Delete directory when done (`pnpm run test:sandbox:clean`)
327+
4. **No side effects**: Changes only exist in test environment
328+
5. **Git-ignored**: `.sandbox/` is in `.gitignore`, won't be committed
329+
330+
---
331+
332+
## Pro Tips
333+
334+
1. **Keep sandbox open in separate terminal** for quick iteration
335+
2. **Use quick reset** (`--reset`) for faster testing cycles
336+
3. **Use bare sandbox** (`--no-config`) to test the full `lab init` flow
337+
4. **Test both `auto_stage: true` and `false`** configurations
338+
5. **Test editor preferences** (`inline`, `editor`, `auto`)
339+
6. **Test validation rules** by intentionally breaking them
340+
7. **Check git log** after commits to verify message formatting
341+
8. **Use `lab init --force`** in sandbox to test different presets and configurations
342+
343+
---
344+
345+
## Script Options
346+
347+
The `labcommitr-sandbox.sh` script supports the following options:
348+
349+
```bash
350+
# Create or recreate sandbox with config (default)
351+
bash scripts/labcommitr-sandbox.sh
352+
353+
# Create sandbox without config (start from scratch)
354+
bash scripts/labcommitr-sandbox.sh --no-config
355+
356+
# Quick reset (faster, keeps repo structure)
357+
bash scripts/labcommitr-sandbox.sh --reset
358+
359+
# Remove sandbox completely
360+
bash scripts/labcommitr-sandbox.sh --clean
361+
362+
# Show help
363+
bash scripts/labcommitr-sandbox.sh --help
364+
```
365+
366+
---
367+
368+
**Last Updated**: January 2025
369+
**Script Location**: `scripts/labcommitr-sandbox.sh`
370+
**Sandbox Location**: `.sandbox/<random-name>/`

0 commit comments

Comments
 (0)