Skip to content

Commit a309dae

Browse files
committed
feat: expand brew.lock file with more metadata
1 parent ccb59fb commit a309dae

13 files changed

Lines changed: 1847 additions & 738 deletions

README.md

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
- **Transparent wrapper**: Alias `brewlock` to `brew` and use Homebrew normally
1414
- **Automatic version tracking**: Every install/uninstall/upgrade updates `brew.lock`
1515
- **Version-locked bundle install**: Install packages with version verification
16-
- **Full package support**: Tracks formulae, casks, taps, and Mac App Store apps
16+
- **Full package support**: Tracks formulae, casks, taps (with commit SHAs), and Mac App Store apps
17+
- **JSONC format**: Human-readable lock file with comment support
18+
- **Custom tap URLs**: Tracks custom tap repository URLs for reproducibility
1719

1820
## Installation
1921

@@ -136,22 +138,104 @@ export BREWLOCK=/path/to/your/brew.lock
136138
export BREWLOCK="$HOME/dotfiles/brew.lock"
137139
```
138140

139-
The lock file uses standard Brewfile syntax with added version information:
141+
The lock file uses JSONC (JSON with Comments) format, organized by package type:
142+
143+
```jsonc
144+
{
145+
"version": 1,
146+
"tap": {
147+
"homebrew/core": {
148+
"commit": "a1b2c3d4e5f6...",
149+
"official": true
150+
},
151+
"homebrew/cask": {
152+
"commit": "f6e5d4c3b2a1...",
153+
"official": true
154+
},
155+
"shipworthyai/brewlock": {
156+
"url": "https://github.com/ShipWorthyAI/brewlock.git",
157+
"commit": "abc123def456..."
158+
}
159+
},
160+
"brew": {
161+
"git": {
162+
"version": "2.52.0",
163+
"installed": ["2.52.0", "2.51.0"],
164+
"revision": 1,
165+
"tap": "homebrew/core",
166+
"pinned": false,
167+
"dependencies": ["gettext", "pcre2"],
168+
"sha256": "c19806bab...",
169+
"installed_as_dependency": false,
170+
"installed_on_request": true
171+
},
172+
"node": {
173+
"version": "21.5.0",
174+
"tap": "homebrew/core",
175+
"installed_on_request": true
176+
}
177+
},
178+
"cask": {
179+
"docker": {
180+
"version": "4.26.1,123456",
181+
"tap": "homebrew/cask",
182+
"sha256": "0a55468...",
183+
"auto_updates": true
184+
},
185+
"visual-studio-code": {
186+
"version": "1.85.1",
187+
"tap": "homebrew/cask",
188+
"auto_updates": true
189+
}
190+
},
191+
"mas": {
192+
"Xcode": {
193+
"id": 497799835,
194+
"version": "15.2"
195+
}
196+
}
197+
}
198+
```
140199

141-
```ruby
142-
# brewlock v1
143-
tap "homebrew/cask"
144-
tap "homebrew/bundle"
200+
### Lock File Fields
145201

146-
brew "git", version: "2.43.0"
147-
brew "node", version: "21.5.0"
148-
brew "python@3.11", version: "3.11.7_1"
202+
#### Tap Fields
149203

150-
cask "docker", version: "4.26.1"
151-
cask "visual-studio-code", version: "1.85.1"
204+
| Field | Description |
205+
|-------|-------------|
206+
| `url` | Custom GitHub repo URL (for non-official taps) |
207+
| `commit` | Git commit SHA for reproducibility |
208+
| `official` | Whether this is an official Homebrew tap |
152209

153-
mas "Xcode", id: 497799835, version: "15.2"
154-
```
210+
#### Brew (Formula) Fields
211+
212+
| Field | Description |
213+
|-------|-------------|
214+
| `version` | Linked (active) version |
215+
| `installed` | All installed versions in Cellar (if multiple) |
216+
| `revision` | Formula revision (e.g., distinguishes `2.43.0` from `2.43.0_1`) |
217+
| `tap` | Source tap (e.g., `homebrew/core`) |
218+
| `pinned` | Whether the formula is pinned |
219+
| `dependencies` | Direct dependencies |
220+
| `sha256` | Platform-specific bottle SHA256 for verification |
221+
| `installed_as_dependency` | Whether installed as a dependency of another package |
222+
| `installed_on_request` | Whether user explicitly installed it |
223+
224+
#### Cask Fields
225+
226+
| Field | Description |
227+
|-------|-------------|
228+
| `version` | Installed cask version |
229+
| `tap` | Source tap (e.g., `homebrew/cask`) |
230+
| `sha256` | Download SHA256 for verification |
231+
| `auto_updates` | Whether the app self-updates |
232+
233+
#### Mac App Store (mas) Fields
234+
235+
| Field | Description |
236+
|-------|-------------|
237+
| `id` | App Store ID (required for installation) |
238+
| `version` | Installed app version |
155239

156240
## How It Works
157241

@@ -199,16 +283,16 @@ bun run build:release
199283
```
200284
brewlock/
201285
src/
202-
index.ts # CLI entry point
203-
parser.ts # Command parser
204-
executor.ts # Brew command executor
205-
lock-manager.ts # Lock file read/write
286+
index.ts # CLI entry point
287+
parser.ts # Command parser
288+
executor.ts # Brew command executor
289+
lock-manager.ts # Lock file read/write (JSONC format)
206290
version-resolver.ts # Version querying
207-
bundle-handler.ts # Bundle install with versions
208-
types.ts # Shared type definitions
291+
bundle-install.ts # Bundle install with versions
292+
types.ts # Shared type definitions
209293
tests/
210-
mocks/ # Test mocking utilities
211-
*.test.ts # Test files
294+
mocks/ # Test mocking utilities
295+
*.test.ts # Test files
212296
package.json
213297
tsconfig.json
214298
```

bun.lock

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "brewlock",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"module": "src/index.ts",
55
"type": "module",
66
"bin": {
@@ -14,12 +14,13 @@
1414
"lint": "biome lint",
1515
"lint.fix": "biome lint --write"
1616
},
17+
"dependencies": {
18+
"zod": "4.3.5"
19+
},
1720
"devDependencies": {
1821
"@biomejs/biome": "2.3.11",
19-
"@types/bun": "latest"
20-
},
21-
"peerDependencies": {
22-
"typescript": "^5"
22+
"@types/bun": "latest",
23+
"typescript": "5.9.3"
2324
},
2425
"engines": {
2526
"node": "24",

0 commit comments

Comments
 (0)