From 8feaa113db1aeed09cd2f1b9db64b4a4db64e77b Mon Sep 17 00:00:00 2001 From: ibetitsmike <203725896+ibetitsmike@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:50:54 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20feat:=20add=20Windows=20compatib?= =?UTF-8?q?ility=20to=20Makefile=20build=20system?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add RUNNER variable that uses npx on Windows, bun x elsewhere - Windows: bun x doesn't correctly pass arguments, so use npm run/npx - Non-Windows: Continue using bun x for better performance - Update all commands to use $(RUNNER) instead of hardcoded bun x - Add comments explaining why Windows needs different approach This ensures consistent build behavior across all platforms while working around Windows-specific limitations with bun's argument passing. --- Makefile | 70 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 9a5e0f96a..1c4762984 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 @@ -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 @@ -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..." @@ -192,7 +203,8 @@ 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" @@ -200,7 +212,7 @@ check-deadcode: node_modules/.installed ## Check for potential dead code (manual @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/" \ @@ -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 @@ -225,22 +237,22 @@ 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" @@ -248,29 +260,29 @@ dist-mac: build ## Build macOS distributables (x64 + arm64) 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) @@ -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)