Skip to content

Commit bc012e9

Browse files
committed
feat: auto-increment version for main branch and fix compiler warnings
- Implement automatic version incrementing for main branch builds (0.1.2 -> 0.1.3) - Update Build-WindowsInstaller.ps1 to auto-increment patch version on main branch - Fix compiler warning: remove unused device_id field from Device struct - Fix compiler warning: optimize mut usage in connection.rs (TCP_NODELAY setup) - Add rustdoc documentation for all API endpoints in main.rs - Improve error handling and CORS configuration - Update documentation (AI_RULES.md, BUILD_WINDOWS.md, README.md) - Add CODE_REVIEW.md with code quality improvements - Update Cargo.toml version to 0.1.3
1 parent fca8823 commit bc012e9

15 files changed

Lines changed: 1593 additions & 1921 deletions

‎.cursorrules‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Cursor AI Rules for ScaleIT Bridge Project
2+
3+
## 🔨 BUILDING AND TESTING - CRITICAL RULE
4+
5+
**ALWAYS use the automated build script for rebuilding the project:**
6+
7+
```powershell
8+
.\scripts\Build-WindowsInstaller.ps1
9+
```
10+
11+
**NEVER use direct `cargo build`, `cargo check`, or `cargo run` commands!**
12+
13+
### Why?
14+
- The project requires MinGW toolchain setup (handled by build-rust-mingw.ps1)
15+
- AVG firewall blocking issues (handled automatically)
16+
- Permission and environment configuration (handled automatically)
17+
- Frontend build integration (handled automatically)
18+
- Installer creation (handled automatically)
19+
20+
Direct cargo commands will fail with:
21+
- `dlltool.exe: program not found`
22+
- `cannot find 'ld'`
23+
- Permission denied errors
24+
- AVG blocking file access
25+
26+
### Build Process
27+
The `Build-WindowsInstaller.ps1` script:
28+
1. Calls `build-rust-mingw.ps1 --release --skip-tests` for backend
29+
2. Calls `npm run build` for frontend
30+
3. Sets up NSSM for Windows Service
31+
4. Creates Inno Setup installer
32+
33+
### Quick Reference
34+
- **Full rebuild + installer:** `.\scripts\Build-WindowsInstaller.ps1`
35+
- **Backend only (advanced):** `.\build-rust-mingw.ps1 --release --skip-tests`
36+
- **Frontend only (advanced):** `npm run build`
37+
38+
### Version Management
39+
- **Main branch:** Version is automatically incremented (patch version: X.Y.Z → X.Y.Z+1)
40+
- Cargo.toml is updated automatically
41+
- Installer: `ScaleCmdBridge-Setup-x64-v0.1.2.exe`
42+
- **Feature branches:** Version stays the same, branch name is appended
43+
- Installer: `ScaleCmdBridge-Setup-x64-v0.1.1-feature-name.exe`
44+
45+
## Project Structure
46+
- Backend: `src-rust/` (Rust workspace with host/ and miernik/ sub-projects)
47+
- Frontend: `src/` (React + TypeScript + Vite)
48+
- Build scripts: `scripts/` and root directory
49+
- Installer: `installer/ScaleCmdBridge.iss`
50+
51+
## Testing
52+
- Backend tests: Run via `build-rust-mingw.ps1` (includes tests by default)
53+
- Frontend tests: `npm test` or `npm run test:ui`
54+
- E2E tests: `npm run test:e2e`

‎AI_RULES.md‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,74 @@ Available packages and libraries:
1717
- You ALREADY have ALL the shadcn/ui components and their dependencies installed. So you don't need to install them again.
1818
- You have ALL the necessary Radix UI components installed.
1919
- Use prebuilt components from the shadcn/ui library after importing them. Note that these files shouldn't be edited, so make new components if you need to change them.
20+
21+
---
22+
23+
# ⚠️ CRITICAL BUILD INSTRUCTIONS - ALWAYS READ THIS FIRST!
24+
25+
## 🚨 REMEMBER: NEVER use `cargo build` directly! Always use Build-WindowsInstaller.ps1!
26+
27+
## 🔨 Building and Testing the Project
28+
29+
**IMPORTANT: To rebuild the Rust backend and create installer, ALWAYS use the build script:**
30+
31+
```powershell
32+
.\scripts\Build-WindowsInstaller.ps1
33+
```
34+
35+
**NEVER use direct `cargo build` or `cargo check` commands!** The build process requires:
36+
1. MinGW toolchain setup (handled by build-rust-mingw.ps1)
37+
2. AVG firewall handling
38+
3. Proper environment configuration
39+
4. Frontend build integration
40+
5. Installer creation
41+
42+
### Build Process Steps:
43+
1. **Backend (Rust):** Uses `build-rust-mingw.ps1 --release` (called by Build-WindowsInstaller.ps1)
44+
2. **Frontend (React):** Uses `npm run build` (called by Build-WindowsInstaller.ps1)
45+
3. **Installer:** Uses Inno Setup compiler (called by Build-WindowsInstaller.ps1)
46+
47+
### Quick Commands:
48+
49+
**Full rebuild + installer:**
50+
```powershell
51+
.\scripts\Build-WindowsInstaller.ps1
52+
```
53+
54+
**Rebuild backend only (if you must, but prefer Build-WindowsInstaller.ps1):**
55+
```powershell
56+
.\build-rust-mingw.ps1 --release --skip-tests
57+
```
58+
59+
**Test compilation (if needed, but be aware of MinGW/AVG issues):**
60+
```powershell
61+
cd src-rust
62+
cargo check
63+
```
64+
65+
**Frontend only:**
66+
```powershell
67+
npm run build
68+
```
69+
70+
### Version Management:
71+
72+
**Automatic Version Incrementing:**
73+
- When building from `main` branch: Version is automatically incremented (patch version)
74+
- Example: `0.1.1` → `0.1.2`
75+
- Cargo.toml is automatically updated with new version
76+
- Installer name: `ScaleCmdBridge-Setup-x64-v0.1.2.exe`
77+
78+
**Feature Branches:**
79+
- When building from feature branches: Version stays the same, branch name is added
80+
- Example: `refactor/host-device-separation` → `ScaleCmdBridge-Setup-x64-v0.1.1-refactor-host-device-separation.exe`
81+
- Timestamp may be added if file already exists
82+
83+
---
84+
85+
## 🚨 Common Issues:
86+
87+
- **AVG blocking build:** The build script handles this automatically
88+
- **Permission errors:** Build script resets file attributes
89+
- **MinGW not found:** Build script checks and reports errors
90+
- **dlltool errors:** Normal when running cargo directly - use build script instead

‎BUILD_WINDOWS.md‎

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,45 @@ cargo --version
5555

5656
## Building the Project
5757

58-
### Backend (Rust)
58+
### ⚠️ IMPORTANT: Use the Automated Build Script
59+
60+
**ALWAYS use the automated build script for complete rebuilds and installer creation:**
61+
62+
```powershell
63+
# From repository root - Builds everything (backend + frontend + installer)
64+
.\scripts\Build-WindowsInstaller.ps1
65+
```
66+
67+
This script automatically:
68+
1. Builds Rust backend (release) using MinGW toolchain
69+
2. Builds React frontend (production)
70+
3. Sets up NSSM for Windows Service
71+
4. Creates Inno Setup installer package
72+
73+
**DO NOT use direct `cargo build` commands** - they will fail due to MinGW/AVG/permission issues. The build script handles all of this automatically.
74+
75+
### Backend (Rust) - Manual Build (Only if needed)
76+
77+
If you MUST build backend manually (not recommended):
5978

6079
```powershell
6180
# Navigate to backend directory
6281
cd src-rust
6382
64-
# Run tests
65-
cargo test --lib --release
66-
67-
# Build release binary
68-
cargo build --release
83+
# Use the MinGW build script (handles environment setup)
84+
..\build-rust-mingw.ps1 --release --skip-tests
6985
7086
# Output will be at: target/release/scaleit-bridge.exe
87+
# OR target/x86_64-pc-windows-gnu/release/scaleit-bridge.exe
7188
```
7289

73-
For automated releases that target the installer bundle, run `powershell.exe -ExecutionPolicy Bypass -File "..\build-rust-mingw.ps1"` from the repository root to configure the MinGW toolchain and produce the `x86_64-pc-windows-gnu` release binary. This script also handles the `PATH` environment, linker overrides and cleanup required for downstream packaging.
90+
**Note:** Direct `cargo build --release` will likely fail with dlltool/permission errors. Always use `build-rust-mingw.ps1` instead.
7491

7592
> **GNU linker path**: the scripts depend on `ld.exe` living under `D:\msys64\mingw64\x86_64-w64-mingw32\bin`. Make sure that directory is exported into `%PATH%` before the regular `mingw64\bin` so the linker is discoverable when `cargo` invokes `ld`. The scripts (`build-rust-mingw.ps1`, `build-mingw.ps1`, `test-rust-mingw.ps1`) already include that path, so rerunning them will refresh the environment.
7693
77-
### Frontend (React + TypeScript)
94+
### Frontend (React + TypeScript) - Manual Build (Only if needed)
95+
96+
If you MUST build frontend manually (usually handled by Build-WindowsInstaller.ps1):
7897

7998
```powershell
8099
# Install dependencies
@@ -90,11 +109,27 @@ pnpm build
90109
# Output will be at: dist/
91110
```
92111

112+
**Note:** The `Build-WindowsInstaller.ps1` script automatically handles frontend build, so manual build is usually unnecessary.
113+
93114
---
94115

95116
## Creating the Installer Package
96117

97-
### Package Structure
118+
### ⚠️ RECOMMENDED: Automated Installer Creation
119+
120+
**Use the automated installer script (recommended):**
121+
122+
```powershell
123+
# Builds backend + frontend + creates installer
124+
.\scripts\Build-WindowsInstaller.ps1
125+
```
126+
127+
The installer will be created in `release/` directory with a name like:
128+
`ScaleCmdBridge-Setup-x64-v0.1.1-<branch>-<timestamp>.exe`
129+
130+
### Manual Package Creation (Advanced)
131+
132+
If you need to create the package manually:
98133
```
99134
ScaleIT_Bridge_Windows_v1.0.0/
100135
├── bin/

0 commit comments

Comments
 (0)