Skip to content

Commit 2e1c65e

Browse files
refactor: address code review findings and bump to beta.5
- Extract shared executeBatch<T>() in batch-operations.ts (264→127 lines) - Extract pool initialization logic to pool-initialization.ts (332→225 lines) - Extract batch handler from taglib-worker.ts (257→143 lines) - Remove stale build-dual.sh reference in setup-dev-env.sh - Bump version to 1.0.0-beta.5 - Fix CHANGELOG accuracy - Install beads git hooks
1 parent f1b86e2 commit 2e1c65e

File tree

15 files changed

+354
-571
lines changed

15 files changed

+354
-571
lines changed

.githooks/post-checkout

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env sh
2+
# bd-shim v1
3+
# bd-hooks-version: 0.49.6
4+
#
5+
# bd (beads) post-checkout hook - thin shim
6+
#
7+
# This shim delegates to 'bd hook post-checkout' which contains
8+
# the actual hook logic. This pattern ensures hook behavior is always
9+
# in sync with the installed bd version - no manual updates needed.
10+
#
11+
# The 'bd hook' command (singular) supports:
12+
# - Guard against frequent firing (only imports if JSONL changed)
13+
# - Per-worktree state tracking
14+
# - Dolt branch-then-merge pattern
15+
# - Hook chaining configuration
16+
17+
# Check if bd is available
18+
if ! command -v bd >/dev/null 2>&1; then
19+
# Silently skip - post-checkout is called frequently
20+
exit 0
21+
fi
22+
23+
exec bd hook post-checkout "$@"

.githooks/post-merge

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,24 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
2+
# bd-shim v1
3+
# bd-hooks-version: 0.49.6
24
#
3-
# bd (beads) post-merge hook (chained)
5+
# bd (beads) post-merge hook - thin shim
46
#
5-
# This hook chains bd functionality with your existing post-merge hook.
6-
7-
# Run existing hook first
8-
if [ -x "" ]; then
9-
"" "$@"
10-
EXIT_CODE=$?
11-
if [ $EXIT_CODE -ne 0 ]; then
12-
exit $EXIT_CODE
13-
fi
14-
fi
7+
# This shim delegates to 'bd hook post-merge' which contains
8+
# the actual hook logic. This pattern ensures hook behavior is always
9+
# in sync with the installed bd version - no manual updates needed.
10+
#
11+
# The 'bd hook' command (singular) supports:
12+
# - Branch-then-merge pattern for Dolt (cell-level conflict resolution)
13+
# - Per-worktree state tracking
14+
# - Hook chaining configuration
1515

1616
# Check if bd is available
1717
if ! command -v bd >/dev/null 2>&1; then
18-
echo "Warning: bd command not found, skipping post-merge import" >&2
19-
exit 0
20-
fi
21-
22-
# Check if we're in a bd workspace
23-
# For worktrees, .beads is in the main repository root, not the worktree
24-
BEADS_DIR=""
25-
if git rev-parse --git-dir >/dev/null 2>&1; then
26-
# Check if we're in a worktree
27-
if [ "$(git rev-parse --git-dir)" != "$(git rev-parse --git-common-dir)" ]; then
28-
# Worktree: .beads is in main repo root
29-
MAIN_REPO_ROOT="$(git rev-parse --git-common-dir)"
30-
MAIN_REPO_ROOT="$(dirname "$MAIN_REPO_ROOT")"
31-
if [ -d "$MAIN_REPO_ROOT/.beads" ]; then
32-
BEADS_DIR="$MAIN_REPO_ROOT/.beads"
33-
fi
34-
else
35-
# Regular repo: check current directory
36-
if [ -d .beads ]; then
37-
BEADS_DIR=".beads"
38-
fi
39-
fi
40-
fi
41-
42-
if [ -z "$BEADS_DIR" ]; then
18+
echo "Warning: bd command not found in PATH, skipping post-merge hook" >&2
19+
echo " Install bd: brew install beads" >&2
20+
echo " Or add bd to your PATH" >&2
4321
exit 0
4422
fi
4523

46-
# Skip for Dolt backend (uses its own sync mechanism, not JSONL import)
47-
if [ -f "$BEADS_DIR/metadata.json" ]; then
48-
if grep -q '"backend"[[:space:]]*:[[:space:]]*"dolt"' "$BEADS_DIR/metadata.json" 2>/dev/null; then
49-
exit 0
50-
fi
51-
fi
52-
53-
# Check if issues.jsonl exists and was updated
54-
if [ ! -f "$BEADS_DIR/issues.jsonl" ]; then
55-
exit 0
56-
fi
57-
58-
# Import the updated JSONL
59-
if ! bd import -i "$BEADS_DIR/issues.jsonl" >/dev/null 2>&1; then
60-
echo "Warning: Failed to import bd changes after merge" >&2
61-
echo "Run 'bd import -i $BEADS_DIR/issues.jsonl' manually to see the error" >&2
62-
fi
63-
64-
exit 0
24+
exec bd hook post-merge "$@"

.githooks/pre-commit

Lines changed: 16 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,24 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
2+
# bd-shim v1
3+
# bd-hooks-version: 0.49.6
24
#
3-
# bd (beads) pre-commit hook (chained)
5+
# bd (beads) pre-commit hook - thin shim
46
#
5-
# This hook chains bd functionality with your existing pre-commit hook.
6-
7-
# Run existing hook first
8-
if [ -x "/Users/Charles/Projects/taglib-wasm/.githooks/pre-commit.old" ]; then
9-
"/Users/Charles/Projects/taglib-wasm/.githooks/pre-commit.old" "$@"
10-
EXIT_CODE=$?
11-
if [ $EXIT_CODE -ne 0 ]; then
12-
exit $EXIT_CODE
13-
fi
14-
fi
7+
# This shim delegates to 'bd hook pre-commit' which contains
8+
# the actual hook logic. This pattern ensures hook behavior is always
9+
# in sync with the installed bd version - no manual updates needed.
10+
#
11+
# The 'bd hook' command (singular) supports:
12+
# - Per-worktree export state tracking
13+
# - Dolt branch-then-merge pattern for cell-level conflict resolution
14+
# - Hook chaining configuration
1515

1616
# Check if bd is available
1717
if ! command -v bd >/dev/null 2>&1; then
18-
echo "Warning: bd command not found, skipping pre-commit flush" >&2
19-
exit 0
20-
fi
21-
22-
# Check if we're in a bd workspace
23-
# For worktrees, .beads is in the main repository root, not the worktree
24-
BEADS_DIR=""
25-
if git rev-parse --git-dir >/dev/null 2>&1; then
26-
# Check if we're in a worktree
27-
if [ "$(git rev-parse --git-dir)" != "$(git rev-parse --git-common-dir)" ]; then
28-
# Worktree: .beads is in main repo root
29-
MAIN_REPO_ROOT="$(git rev-parse --git-common-dir)"
30-
MAIN_REPO_ROOT="$(dirname "$MAIN_REPO_ROOT")"
31-
if [ -d "$MAIN_REPO_ROOT/.beads" ]; then
32-
BEADS_DIR="$MAIN_REPO_ROOT/.beads"
33-
fi
34-
else
35-
# Regular repo: check current directory
36-
if [ -d .beads ]; then
37-
BEADS_DIR=".beads"
38-
fi
39-
fi
40-
fi
41-
42-
if [ -z "$BEADS_DIR" ]; then
18+
echo "Warning: bd command not found in PATH, skipping pre-commit hook" >&2
19+
echo " Install bd: brew install beads" >&2
20+
echo " Or add bd to your PATH" >&2
4321
exit 0
4422
fi
4523

46-
# Skip for Dolt backend (uses its own sync mechanism, not JSONL)
47-
if [ -f "$BEADS_DIR/metadata.json" ]; then
48-
if grep -q '"backend"[[:space:]]*:[[:space:]]*"dolt"' "$BEADS_DIR/metadata.json" 2>/dev/null; then
49-
exit 0
50-
fi
51-
fi
52-
53-
# Flush pending changes to JSONL
54-
if ! bd sync --flush-only >/dev/null 2>&1; then
55-
echo "Error: Failed to flush bd changes to storage" >&2
56-
echo "Run 'bd sync --flush-only' manually to diagnose" >&2
57-
exit 1
58-
fi
59-
60-
# If the JSONL file was modified, stage it
61-
# For worktrees, the JSONL is in the main repo's working tree, not the worktree,
62-
# so we can't use git add. Skip this step for worktrees.
63-
if [ -f "$BEADS_DIR/issues.jsonl" ]; then
64-
if [ "$(git rev-parse --git-dir)" = "$(git rev-parse --git-common-dir)" ]; then
65-
# Regular repo: file is in the working tree, safe to add
66-
git add "$BEADS_DIR/issues.jsonl" 2>/dev/null || true
67-
fi
68-
# For worktrees: .beads is in the main repo's working tree, not this worktree
69-
# Git rejects adding files outside the worktree, so we skip it.
70-
# The main repo will see the changes on the next pull/sync.
71-
fi
72-
73-
exit 0
24+
exec bd hook pre-commit "$@"

.githooks/pre-push

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env sh
2+
# bd-shim v1
3+
# bd-hooks-version: 0.49.6
4+
#
5+
# bd (beads) pre-push hook - thin shim
6+
#
7+
# This shim delegates to 'bd hooks run pre-push' which contains
8+
# the actual hook logic. This pattern ensures hook behavior is always
9+
# in sync with the installed bd version - no manual updates needed.
10+
11+
# Check if bd is available
12+
if ! command -v bd >/dev/null 2>&1; then
13+
echo "Warning: bd command not found in PATH, skipping pre-push hook" >&2
14+
echo " Install bd: brew install beads" >&2
15+
echo " Or add bd to your PATH" >&2
16+
exit 0
17+
fi
18+
19+
exec bd hooks run pre-push "$@"

.githooks/prepare-commit-msg

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env sh
2+
# bd-shim v1
3+
# bd-hooks-version: 0.48.0
4+
#
5+
# bd (beads) prepare-commit-msg hook - thin shim
6+
#
7+
# This shim delegates to 'bd hooks run prepare-commit-msg' which contains
8+
# the actual hook logic. This pattern ensures hook behavior is always
9+
# in sync with the installed bd version - no manual updates needed.
10+
#
11+
# Arguments:
12+
# $1 = path to the commit message file
13+
# $2 = source of commit message (message, template, merge, squash, commit)
14+
# $3 = commit SHA-1 (if -c, -C, or --amend)
15+
16+
# Check if bd is available
17+
if ! command -v bd >/dev/null 2>&1; then
18+
echo "Warning: bd command not found in PATH, skipping prepare-commit-msg hook" >&2
19+
echo " Install bd: brew install beads" >&2
20+
echo " Or add bd to your PATH" >&2
21+
exit 0
22+
fi
23+
24+
exec bd hooks run prepare-commit-msg "$@"

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## 1.0.0
3+
## 1.0.0-beta.5
44

55
### Breaking Changes
66

@@ -28,6 +28,7 @@
2828
### Internal
2929

3030
- Migrated all tests to BDD syntax (135 tests passing)
31-
- Split 10 oversized source files into directory modules (all under 250 lines)
31+
- Split 10 oversized source files into directory modules
32+
- Deduplicated batch operation scaffolding with shared `executeBatch` helper
3233
- Removed stale build scripts and migration guides
3334
- Updated SonarCloud configuration

build/setup-dev-env.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,15 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
305305
echo ""
306306
echo "Next steps:"
307307
echo ""
308-
echo "1. Build both targets:"
309-
echo -e " ${CYAN}./build/build-dual.sh${NC}"
310-
echo ""
311-
echo "2. Build Emscripten only:"
308+
echo "1. Build Emscripten:"
312309
echo -e " ${CYAN}./build/build-emscripten.sh${NC}"
313310
echo ""
314-
echo "3. Build WASI only:"
311+
echo "2. Build WASI:"
315312
echo -e " ${CYAN}source ./build/wasi-env.sh${NC}"
316313
echo -e " ${CYAN}./build/build-wasi.sh${NC}"
317314
echo ""
318-
echo "4. Run tests:"
319-
echo -e " ${CYAN}npm test${NC} # Node.js tests"
315+
echo "3. Run tests:"
316+
echo -e " ${CYAN}deno task test${NC}"
320317
echo -e " ${CYAN}deno task test${NC} # Deno tests"
321318
echo -e " ${CYAN}bun test${NC} # Bun tests"
322319
echo ""

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@charlesw/taglib-wasm",
3-
"version": "1.0.0",
3+
"version": "1.0.0-beta.5",
44
"description": "TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps",
55
"license": "MIT",
66
"nodeModulesDir": "auto",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "taglib-wasm",
3-
"version": "1.0.0",
3+
"version": "1.0.0-beta.5",
44
"description": "TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps",
55
"type": "module",
66
"main": "dist/index.js",

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
sonar.projectKey=CharlesWiltgen_taglib-wasm
66
sonar.organization=charles-wiltgen
77
sonar.projectName=taglib-wasm
8-
sonar.projectVersion=1.0.0
8+
sonar.projectVersion=1.0.0-beta.5
99

1010
# Source code configuration
1111
sonar.sources=src,index.ts,mod.ts,simple.ts,workers.ts

0 commit comments

Comments
 (0)