Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 41 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
# Branches reduce reproducibility - builds should fail fast with clear errors
# if dependencies are missing, not silently fall back to different behavior.

# Platform detection for cross-platform compatibility
ifeq ($(OS),Windows_NT)
# Windows: Use npm/npx because bun x doesn't correctly pass arguments on Windows
RUNNER := npx
else
# Non-Windows: Use bun x for better performance
RUNNER := bun x
endif

# Enable parallel execution by default (only if user didn't specify -j)
ifeq (,$(filter -j%,$(MAKEFLAGS)))
MAKEFLAGS += -j
Expand Down Expand Up @@ -97,8 +106,9 @@ help: ## Show this help message

## Development
dev: node_modules/.installed build-main ## Start development server (Vite + tsgo watcher for 10x faster type checking)
@bun x concurrently -k \
"bun x concurrently \"$(TSGO) -w -p tsconfig.main.json\" \"bun x tsc-alias -w -p tsconfig.main.json\"" \
@# On Windows, use npm run because bun x doesn't correctly pass arguments
@$(RUNNER) concurrently -k \
"$(RUNNER) concurrently \"$(TSGO) -w -p tsconfig.main.json\" \"$(RUNNER) tsc-alias -w -p tsconfig.main.json\"" \
"vite"

dev-server: node_modules/.installed build-main ## Start server mode with hot reload (backend :3000 + frontend :5173). Use VITE_HOST=0.0.0.0 BACKEND_HOST=0.0.0.0 for remote access
Expand All @@ -107,15 +117,16 @@ dev-server: node_modules/.installed build-main ## Start server mode with hot rel
@echo " Frontend (with HMR): http://$(or $(VITE_HOST),localhost):$(or $(VITE_PORT),5173)"
@echo ""
@echo "For remote access: make dev-server VITE_HOST=0.0.0.0 BACKEND_HOST=0.0.0.0"
@bun x concurrently -k \
"bun x concurrently \"$(TSGO) -w -p tsconfig.main.json\" \"bun x tsc-alias -w -p tsconfig.main.json\"" \
"bun x nodemon --watch dist/main.js --watch dist/main-server.js --delay 500ms --exec 'node dist/main.js server --host $(or $(BACKEND_HOST),localhost) --port $(or $(BACKEND_PORT),3000)'" \
@# On Windows, use npm run because bun x doesn't correctly pass arguments
@$(RUNNER) concurrently -k \
"$(RUNNER) concurrently \"$(TSGO) -w -p tsconfig.main.json\" \"$(RUNNER) tsc-alias -w -p tsconfig.main.json\"" \
"$(RUNNER) nodemon --watch dist/main.js --watch dist/main-server.js --delay 500ms --exec 'node dist/main.js server --host $(or $(BACKEND_HOST),localhost) --port $(or $(BACKEND_PORT),3000)'" \
"CMUX_VITE_HOST=$(or $(VITE_HOST),127.0.0.1) CMUX_VITE_PORT=$(or $(VITE_PORT),5173) VITE_BACKEND_URL=http://$(or $(BACKEND_HOST),localhost):$(or $(BACKEND_PORT),3000) vite"



start: node_modules/.installed build-main build-preload build-static ## Build and start Electron app
@bun x electron --remote-debugging-port=9222 .
@$(RUNNER) electron --remote-debugging-port=9222 .

## Build targets (can run in parallel)
build: node_modules/.installed src/version.ts build-renderer build-main build-preload build-icons build-static ## Build all targets
Expand All @@ -125,7 +136,7 @@ build-main: node_modules/.installed dist/main.js ## Build main process
dist/main.js: src/version.ts tsconfig.main.json tsconfig.json $(TS_SOURCES)
@echo "Building main process..."
@NODE_ENV=production $(TSGO) -p tsconfig.main.json
@NODE_ENV=production bun x tsc-alias -p tsconfig.main.json
@NODE_ENV=production $(RUNNER) tsc-alias -p tsconfig.main.json

build-preload: node_modules/.installed dist/preload.js ## Build preload script

Expand All @@ -140,7 +151,7 @@ dist/preload.js: src/preload.ts $(TS_SOURCES)

build-renderer: node_modules/.installed src/version.ts ## Build renderer process
@echo "Building renderer..."
@bun x vite build
@$(RUNNER) vite build

build-static: ## Copy static assets to dist
@echo "Copying static assets..."
Expand Down Expand Up @@ -192,15 +203,16 @@ lint-fix: node_modules/.installed ## Run linter with --fix
@./scripts/lint.sh --fix

typecheck: node_modules/.installed src/version.ts ## Run TypeScript type checking (uses tsgo for 10x speedup)
@bun x concurrently -g \
@# On Windows, use npm run because bun x doesn't correctly pass arguments
@$(RUNNER) concurrently -g \
"$(TSGO) --noEmit" \
"$(TSGO) --noEmit -p tsconfig.main.json"

check-deadcode: node_modules/.installed ## Check for potential dead code (manual only, not in static-check)
@echo "Checking for potential dead code with ts-prune..."
@echo "(Note: Some unused exports are legitimate - types, public APIs, entry points, etc.)"
@echo ""
@bun x ts-prune -i '(test|spec|mock|bench|debug|storybook)' \
@$(RUNNER) ts-prune -i '(test|spec|mock|bench|debug|storybook)' \
| grep -v "used in module" \
| grep -v "src/App.tsx.*default" \
| grep -v "src/types/" \
Expand All @@ -210,7 +222,7 @@ check-deadcode: node_modules/.installed ## Check for potential dead code (manual
## Testing
test-integration: node_modules/.installed build-main ## Run all tests (unit + integration)
@bun test src
@TEST_INTEGRATION=1 bun x jest tests
@TEST_INTEGRATION=1 $(RUNNER) jest tests

test-unit: node_modules/.installed build-main ## Run unit tests
@bun test src
Expand All @@ -225,52 +237,52 @@ test-coverage: ## Run tests with coverage

test-e2e: ## Run end-to-end tests
@$(MAKE) build
@CMUX_E2E_LOAD_DIST=1 CMUX_E2E_SKIP_BUILD=1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 bun x playwright test --project=electron $(PLAYWRIGHT_ARGS)
@CMUX_E2E_LOAD_DIST=1 CMUX_E2E_SKIP_BUILD=1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 $(RUNNER) playwright test --project=electron $(PLAYWRIGHT_ARGS)

## Distribution
dist: build ## Build distributable packages
@bun x electron-builder --publish never
@$(RUNNER) electron-builder --publish never

# Parallel macOS builds - notarization happens concurrently
dist-mac: build ## Build macOS distributables (x64 + arm64)
@if [ -n "$$CSC_LINK" ]; then \
echo "🔐 Code signing enabled - building sequentially to avoid keychain conflicts..."; \
bun x electron-builder --mac --x64 --publish never && \
bun x electron-builder --mac --arm64 --publish never; \
$(RUNNER) electron-builder --mac --x64 --publish never && \
$(RUNNER) electron-builder --mac --arm64 --publish never; \
else \
echo "Building macOS architectures in parallel..."; \
bun x electron-builder --mac --x64 --publish never & pid1=$$! ; \
bun x electron-builder --mac --arm64 --publish never & pid2=$$! ; \
$(RUNNER) electron-builder --mac --x64 --publish never & pid1=$$! ; \
$(RUNNER) electron-builder --mac --arm64 --publish never & pid2=$$! ; \
wait $$pid1 && wait $$pid2; \
fi
@echo "✅ Both architectures built successfully"

dist-mac-release: build ## Build and publish macOS distributables (x64 + arm64)
@if [ -n "$$CSC_LINK" ]; then \
echo "🔐 Code signing enabled - building sequentially to avoid keychain conflicts..."; \
bun x electron-builder --mac --x64 --publish always && \
bun x electron-builder --mac --arm64 --publish always; \
$(RUNNER) electron-builder --mac --x64 --publish always && \
$(RUNNER) electron-builder --mac --arm64 --publish always; \
else \
echo "Building and publishing macOS architectures in parallel..."; \
bun x electron-builder --mac --x64 --publish always & pid1=$$! ; \
bun x electron-builder --mac --arm64 --publish always & pid2=$$! ; \
$(RUNNER) electron-builder --mac --x64 --publish always & pid1=$$! ; \
$(RUNNER) electron-builder --mac --arm64 --publish always & pid2=$$! ; \
wait $$pid1 && wait $$pid2; \
fi
@echo "✅ Both architectures built and published successfully"

dist-mac-x64: build ## Build macOS x64 distributable only
@echo "Building macOS x64..."
@bun x electron-builder --mac --x64 --publish never
@$(RUNNER) electron-builder --mac --x64 --publish never

dist-mac-arm64: build ## Build macOS arm64 distributable only
@echo "Building macOS arm64..."
@bun x electron-builder --mac --arm64 --publish never
@$(RUNNER) electron-builder --mac --arm64 --publish never

dist-win: build ## Build Windows distributable
@bun x electron-builder --win --publish never
@$(RUNNER) electron-builder --win --publish never

dist-linux: build ## Build Linux distributable
@bun x electron-builder --linux --publish never
@$(RUNNER) electron-builder --linux --publish never

## VS Code Extension (delegates to vscode/Makefile)

Expand All @@ -293,19 +305,19 @@ docs-watch: ## Watch and rebuild documentation
## Storybook
storybook: node_modules/.installed ## Start Storybook development server
$(check_node_version)
@bun x storybook dev -p 6006 $(STORYBOOK_OPEN_FLAG)
@$(RUNNER) storybook dev -p 6006 $(STORYBOOK_OPEN_FLAG)

storybook-build: node_modules/.installed src/version.ts ## Build static Storybook
$(check_node_version)
@bun x storybook build
@$(RUNNER) storybook build

test-storybook: node_modules/.installed ## Run Storybook interaction tests (requires Storybook to be running or built)
$(check_node_version)
@bun x test-storybook
@$(RUNNER) test-storybook

chromatic: node_modules/.installed ## Run Chromatic for visual regression testing
$(check_node_version)
@bun x chromatic --exit-zero-on-changes
@$(RUNNER) chromatic --exit-zero-on-changes

## Benchmarks
benchmark-terminal: ## Run Terminal-Bench with the cmux agent (use TB_DATASET/TB_SAMPLE_SIZE/TB_TIMEOUT/TB_ARGS to customize)
Expand Down