Skip to content

Commit d4b2db4

Browse files
committed
refactor(install): improve bootstrap and installer architecture
- Move PostgreSQL repo setup from bootstrap.sh to Python installers module - Add odoo_minimal.toml for bootstrap initial setup - Replace pnpm references with npm for better compatibility - Improve error handling with graceful degradation for missing tools - Update .gitignore to exclude .claude/ and .opencode/ directories - Simplify bootstrap.sh by removing inline PostgreSQL setup logic Breaking changes: - NPM packages installed via npm instead of pnpm by default
1 parent 2430b5b commit d4b2db4

11 files changed

Lines changed: 309 additions & 85 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,5 @@ __marimo__/
219219
plans/**/*
220220
!plans/templates/*
221221
repomix-output.xml
222+
.claude/
223+
.opencode/

assets/odoo_minimal.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Minimal config to set up latest Odoo for development
2+
# Place this file at ~/code/config.toml (or set TLC_CODE_DIR)
3+
4+
versions = ["18.0"]
5+
6+
[tools]
7+
uv = ["odoo-venv"]
8+
9+
[repos]
10+
odoo = ["odoo"]

bootstrap.sh

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export DEBIAN_FRONTEND=noninteractive
44
export PATH="$HOME/.local/bin:$PATH"
55

66
# Bootstrap script for trobz_local (tlc)
7-
# Installs: uv, git, gh, and the trobz_local package
7+
# Installs prerequisites: git, gh, uv, and trobz_local CLI
8+
# Note: Tool installation (Odoo, PostgreSQL, etc.) is done separately via `tlc install-tools`
89

910
echo "=== Bootstrap trobz_local ==="
1011

@@ -41,33 +42,6 @@ detect_os() {
4142
OS=$(detect_os)
4243
echo "Detected OS: $OS"
4344

44-
# Install prerequisite packages (Debian/Ubuntu only)
45-
install_prerequisites() {
46-
if [[ "$OS" != "debian" ]]; then
47-
return
48-
fi
49-
echo "Installing prerequisite packages..."
50-
sudo apt-get update
51-
sudo apt-get install -y apt-utils apt-transport-https lsb-release
52-
}
53-
54-
# Add PostgreSQL APT repository (Debian/Ubuntu only)
55-
setup_postgresql_repo() {
56-
if [[ "$OS" != "debian" ]]; then
57-
return
58-
fi
59-
if [ -f /usr/share/keyrings/postgresql-keyring.gpg ]; then
60-
echo "PostgreSQL APT repository already configured"
61-
return
62-
fi
63-
echo "Adding PostgreSQL APT repository..."
64-
local codename
65-
codename=$(lsb_release -cs)
66-
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql-keyring.gpg
67-
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/postgresql-keyring.gpg] https://apt.postgresql.org/pub/repos/apt ${codename}-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list > /dev/null
68-
sudo apt-get update
69-
}
70-
7145
# Install git
7246
install_git() {
7347
if command -v git &>/dev/null; then
@@ -132,9 +106,7 @@ install_trobz_local() {
132106
echo "trobz_local installed (CLI: tlc)"
133107
}
134108

135-
# Main
136-
install_prerequisites
137-
setup_postgresql_repo
109+
# Main execution
138110
install_git
139111
install_gh
140112
install_uv
@@ -143,4 +115,23 @@ install_trobz_local
143115

144116
echo ""
145117
echo "=== Bootstrap complete ==="
146-
echo "Run 'tlc --help' to get started"
118+
echo ""
119+
echo "Prerequisites installed successfully!"
120+
echo " ✓ git"
121+
echo " ✓ gh (GitHub CLI)"
122+
echo " ✓ uv"
123+
echo " ✓ trobz_local (tlc command available)"
124+
echo ""
125+
echo "Next steps:"
126+
echo ""
127+
echo " 1. Install development tools (Odoo, PostgreSQL, etc.):"
128+
echo " tlc install-tools"
129+
echo ""
130+
echo " 2. Initialize your development environment:"
131+
echo " tlc init # Create directory structure"
132+
echo " tlc pull-repos # Clone repositories"
133+
echo " tlc create-venvs # Create virtual environments"
134+
echo ""
135+
echo " 3. Get help:"
136+
echo " tlc --help"
137+
echo ""

docs/code-standards.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Four-layer modular design with clear separation of concerns:
2323
- **Line Length**: Max 120 characters (ruff.toml config)
2424
- **Import Order**: stdlib → third-party → local (ruff-managed)
2525
- **Active Rules**: YTT, S (security), B, A, C4, T10, SIM, I, C90, E, W, F, PGH, UP, RUF, TRY
26+
- **UI Library**: Rich (progress bars, colored output, trees)
2627

2728
### Type Safety (Mandatory)
2829
- All function signatures must have type hints
@@ -170,11 +171,11 @@ Follow [Conventional Commits](https://www.conventionalcommits.org/):
170171

171172
## File Structure
172173

173-
**Max file size**: 500 LOC (split if larger)
174-
- `main.py`: CLI commands and orchestration (473+ LOC)
175-
- `installers.py`: Installation strategies (282 LOC)
176-
- `postgres.py`: PostgreSQL user management (191 LOC)
177-
- `utils.py`: Config, platform detection, helpers (264 LOC)
174+
**Target file size**: 500 LOC; main.py at 523 LOC is exception due to command density.
175+
- `main.py`: CLI commands and orchestration (523 LOC - consolidates 5 command implementations)
176+
- `installers.py`: Installation strategies (389 LOC - 5 installation strategies)
177+
- `postgres.py`: PostgreSQL user management (173 LOC)
178+
- `utils.py`: Config, platform detection, helpers (277 LOC)
178179
- `concurrency.py`: Task runner with progress (60 LOC)
179180
- `exceptions.py`: Custom exception classes (38 LOC)
180181
- `tests/`: pytest unit tests for all modules

docs/codebase-summary.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ Technical overview of the `trobz_local` codebase structure, implementation patte
66

77
| Metric | Value |
88
|---|---|
9-
| **Language** | Python 3.12+ |
10-
| **Total LOC** | ~1,287 lines (core logic) + tests |
9+
| **Version** | 0.2.0 |
10+
| **Language** | Python 3.10+ |
11+
| **Total LOC** | ~1,460 lines (core logic) + tests |
1112
| **Core Modules** | 7 files (main, installers, utils, postgres, concurrency, exceptions, \__init\_\_) |
1213
| **Test Modules** | tests/ directory with pytest unit tests |
1314
| **Primary Frameworks** | Typer (CLI), Pydantic (validation), Rich (UI), GitPython (git) |
@@ -16,14 +17,15 @@ Technical overview of the `trobz_local` codebase structure, implementation patte
1617

1718
## Module Breakdown
1819

19-
### `main.py` (473+ LOC)
20+
### `main.py` (523 LOC)
2021
**Purpose**: CLI entry point and command orchestration
2122

2223
**Responsibilities**:
2324
- Define Typer application with 5 main commands
2425
- Manage "newcomer mode" state (interactive confirmations)
2526
- Orchestrate calls to installers, git operations, venv creation, and PostgreSQL user management
2627
- Handle user interaction and progress reporting
28+
- Coordinate PostgreSQL repo setup before system package installation
2729

2830
**Key Commands**:
2931
- `init`: Create directory structure
@@ -43,18 +45,20 @@ Technical overview of the `trobz_local` codebase structure, implementation patte
4345

4446
---
4547

46-
### `installers.py` (282 LOC)
48+
### `installers.py` (389 LOC)
4749
**Purpose**: Multi-source tool installation strategies
4850

4951
**Strategies**:
50-
1. **Scripts**: Download via wget/curl, execute with /bin/sh
51-
2. **System Packages**: OS-aware (apt-get, pacman, brew) with platform defaults
52-
3. **NPM Packages**: Global via pnpm install -g
53-
4. **UV Tools**: Global via uv tool install
52+
1. **PostgreSQL Repository Setup**: Idempotent APT repo configuration with GPG verification (Debian/Ubuntu)
53+
2. **Scripts**: Download via wget/curl, execute with /bin/sh
54+
3. **System Packages**: OS-aware (apt-get, pacman, brew) with platform defaults
55+
4. **NPM Packages**: Global via pnpm install -g
56+
5. **UV Tools**: Global via uv tool install
5457

5558
**Key Functions**:
59+
- `setup_postgresql_repo()` - Configure PGDG repository with GPG verification (idempotent)
5660
- `install_scripts()` - Download and execute shell scripts with progress
57-
- `install_system_packages()` - OS detection and package manager invocation
61+
- `install_system_packages()` - OS detection and package manager invocation (runs after PostgreSQL repo setup)
5862
- `install_npm_packages()` - Parallel npm package installation
5963
- `install_uv_tools()` - Parallel UV tool installation
6064

@@ -66,7 +70,7 @@ Technical overview of the `trobz_local` codebase structure, implementation patte
6670

6771
---
6872

69-
### `utils.py` (264 LOC)
73+
### `utils.py` (277 LOC)
7074
**Purpose**: Configuration validation, platform detection, utilities
7175

7276
**Pydantic Models**:
@@ -127,7 +131,7 @@ class TaskResult:
127131

128132
---
129133

130-
### `postgres.py` (191 LOC)
134+
### `postgres.py` (173 LOC)
131135
**Purpose**: PostgreSQL user management for Odoo development
132136

133137
**Responsibilities**:
@@ -202,7 +206,9 @@ The `get_code_root()` function (utils.py) resolves the code root directory by:
202206
| `rich` | Latest | Terminal UI (progress bars, colors, trees) |
203207
| `gitpython` | Latest | Programmatic git operations |
204208
| `tomllib` | Built-in (Python 3.11+) | TOML parsing for Python 3.11+ |
205-
| `tomli` | Latest (optional) | TOML parsing fallback for Python < 3.11 |
209+
| `tomli` | Latest | TOML parsing fallback for Python < 3.11 |
210+
211+
**Note**: Rich is used extensively throughout for progress bars, colored output, and tree display.
206212

207213
---
208214

docs/project-overview-pdr.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ The tool uses declarative configuration: developers specify desired environment
2222

2323
## Core Features
2424

25+
### 0. Bootstrap Script (`bootstrap.sh`)
26+
Automated installation of prerequisites before using `tlc`:
27+
- **Dependencies**: Installs git, gh (GitHub CLI), and uv
28+
- **SSH Setup**: Configures GitHub SSH keys in known_hosts
29+
- **Installation**: Installs `trobz_local` CLI (tlc) via uv
30+
- **Idempotent**: Skips already-installed tools
31+
- **OS-aware**: Supports macOS (brew), Debian/Ubuntu (apt), Fedora (dnf), Arch (pacman)
32+
33+
**Usage**:
34+
```bash
35+
curl -fsSL https://raw.githubusercontent.com/trobz/local.py/main/bootstrap.sh | sh
36+
```
37+
38+
After bootstrap, use `tlc` commands to complete environment setup.
39+
40+
---
41+
2542
### 1. Environment Initialization (`init`)
2643
Creates standardized directory structure (default: `~/code/`):
2744
```
@@ -46,11 +63,12 @@ Clones or updates Odoo and OCA repositories:
4663
- **Operations**: Clone new repos, fetch and hard-reset existing ones
4764

4865
### 3. Tool Installation (`install-tools`)
49-
Four-stage installation pipeline:
50-
1. **Shell Scripts**: Download and execute scripts (e.g., uv installer)
51-
2. **System Packages**: OS-aware installation via apt/pacman/brew
52-
3. **NPM Packages**: Global packages via pnpm
53-
4. **UV Tools**: Python tools via uv tool install
66+
Five-stage installation pipeline:
67+
1. **PostgreSQL Repository** (Debian/Ubuntu only): Setup PGDG APT repository with GPG verification (idempotent)
68+
2. **Shell Scripts**: Download and execute scripts (e.g., uv installer)
69+
3. **System Packages**: OS-aware installation via apt/pacman/brew (runs after PostgreSQL repo setup on Debian/Ubuntu)
70+
4. **NPM Packages**: Global packages via pnpm
71+
5. **UV Tools**: Python tools via uv tool install
5472

5573
### 4. Virtual Environment Management (`create-venvs`)
5674
Creates Odoo-specific environments:
@@ -278,7 +296,7 @@ Create Python virtual environments for each Odoo version.
278296
---
279297

280298
### `tlc install-tools`
281-
Install tools from four sources in order: scripts, system packages, npm, uv.
299+
Install tools from five sources in order: PostgreSQL repo, scripts, system packages, npm, uv.
282300

283301
**Usage**: `tlc install-tools [OPTIONS]`
284302

@@ -287,10 +305,11 @@ Install tools from four sources in order: scripts, system packages, npm, uv.
287305
- `--newcomer / --no-newcomer`: Enable interactive mode (default: True)
288306

289307
**Execution Order**:
290-
1. **Scripts**: Download and execute via `wget` or `curl`, then `sh`
291-
2. **System Packages**: OS-aware installation (apt/pacman/brew)
292-
3. **NPM Packages**: Global installation via `pnpm install -g`
293-
4. **UV Tools**: Global installation via `uv tool install`
308+
1. **PostgreSQL Repository** (Debian/Ubuntu): Setup PGDG APT repository with GPG verification
309+
2. **Scripts**: Download and execute via `wget` or `curl`, then `sh`
310+
3. **System Packages**: OS-aware installation (apt/pacman/brew) - runs after PostgreSQL repo on Debian/Ubuntu
311+
4. **NPM Packages**: Global installation via `pnpm install -g`
312+
5. **UV Tools**: Global installation via `uv tool install`
294313

295314
**Behavior**:
296315
- Reads `[tools]` section from `{CODE_ROOT}/config.toml` (default: `~/code/config.toml`)

0 commit comments

Comments
 (0)