Skip to content

Commit 8896c7f

Browse files
AndreaV-Lsiclaude
andcommitted
feat!: Refactor to PS 7.6 module architecture with automated Pester tests
Modernize LsiGitCheckout from a monolithic PS 5.1 script to a PS 7.6 LTS module architecture, enabling automated testing and cleaner maintainability. - Split LsiGitCheckout.ps1 (2746 lines) into entry point (~230 lines) + LsiGitCheckout.psm1 module (2522 lines) + LsiGitCheckout.psd1 manifest - Add Pester 5.x unit tests for 10 pure/near-pure functions - Add Pester 5.x integration tests covering all 16 test configs (DryRun) - Upgrade #Requires to PowerShell 7.6 LTS, use null-coalescing operators - Add CLAUDE.md project context (evolved from claude/wonderful-boyd branch) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b6e97ba commit 8896c7f

10 files changed

Lines changed: 3237 additions & 2571 deletions

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ $RECYCLE.BIN/
2222

2323
# PowerShell specific
2424
*.pssproj
25-
*.psm1
26-
*.psd1
2725
*.ps1xml
2826

2927
# Visual Studio Code

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to LsiGitCheckout will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [8.0.0] - 2026-03-20
9+
10+
### Changed
11+
- **BREAKING**: Requires PowerShell 7.6 LTS or later (previously 5.1). PowerShell 7.6 installs side-by-side with Windows PowerShell 5.1.
12+
- Refactored monolithic script into module architecture: `LsiGitCheckout.psm1` (functions) + `LsiGitCheckout.ps1` (entry point)
13+
- Post-checkout scripts now execute via `pwsh` instead of `powershell.exe`
14+
- Replaced verbose null-check patterns with `??` null-coalescing operator
15+
16+
### Added
17+
- `LsiGitCheckout.psm1` module file containing all function definitions
18+
- `LsiGitCheckout.psd1` module manifest
19+
- `Initialize-LsiGitCheckout` function for module state initialization
20+
- Automated unit tests using Pester 5.x (`tests/LsiGitCheckout.Unit.Tests.ps1`)
21+
- Automated integration tests for all 16 test configs (`tests/LsiGitCheckout.Integration.Tests.ps1`)
22+
823
## [7.1.0] - 2025-09-02
924

1025
### Added

CLAUDE.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# CLAUDE.md — LsiGitCheckout
2+
3+
## Project Overview
4+
5+
PowerShell-based dependency management tool that checks out multiple Git repositories to specified versions. Module architecture: `LsiGitCheckout.psm1` (functions) + `LsiGitCheckout.ps1` (entry point). Version 8.0.0, by LS Instruments AG.
6+
7+
## Running the Tool
8+
9+
```powershell
10+
.\LsiGitCheckout.ps1 # defaults to dependencies.json
11+
.\LsiGitCheckout.ps1 -InputFile "path/to/deps.json" # custom config
12+
.\LsiGitCheckout.ps1 -DryRun # preview without executing
13+
.\LsiGitCheckout.ps1 -EnableDebug -EnableErrorContext # full debug output
14+
```
15+
16+
Key parameters: `-InputFile`, `-CredentialsFile`, `-DryRun`, `-EnableDebug`, `-DisableRecursion`, `-MaxDepth` (default 5), `-ApiCompatibility` (Strict|Permissive), `-DisablePostCheckoutScripts`, `-EnableErrorContext`
17+
18+
## Testing
19+
20+
### Automated Tests (Pester 5.x)
21+
22+
```powershell
23+
# Install Pester if needed
24+
Install-Module Pester -Force -MinimumVersion 5.0
25+
26+
# Unit tests — fast, no network required
27+
Invoke-Pester ./tests/LsiGitCheckout.Unit.Tests.ps1 -Output Detailed
28+
29+
# Integration tests — requires network access to GitHub test repos
30+
Invoke-Pester ./tests/LsiGitCheckout.Integration.Tests.ps1 -Output Detailed
31+
```
32+
33+
### Manual Testing
34+
35+
Test configs in `tests/` can also be run manually:
36+
37+
```powershell
38+
.\LsiGitCheckout.ps1 -InputFile tests/dependencies_semver.json -DryRun
39+
```
40+
41+
There are 16 test JSON configs covering SemVer, Agnostic, API incompatibility, custom paths, post-checkout scripts, and recursive dependencies.
42+
43+
## Architecture
44+
45+
- **Module**: `LsiGitCheckout.psm1` — all function definitions (~35 functions)
46+
- **Entry point**: `LsiGitCheckout.ps1` — param block, module import, initialization, main execution
47+
- **Manifest**: `LsiGitCheckout.psd1` — module metadata, exported functions
48+
- **Two dependency resolution modes**: SemVer (recommended, automatic version resolution) and Agnostic (explicit tag-based)
49+
- **Configuration**: JSON files — `dependencies.json` for repos, `git_credentials.json` for SSH keys
50+
- **Recursive processing**: walks dependency trees with conflict detection, max depth configurable
51+
- **SSH**: PuTTY/Pageant integration for authentication (`.ppk` key format)
52+
- **Post-checkout scripts**: optional PowerShell scripts run after successful checkouts
53+
54+
## Coding Conventions
55+
56+
- **PowerShell 7.6 LTS** required (`#Requires -Version 7.6`)
57+
- **Function names**: PascalCase Verb-Noun (e.g., `Test-GitInstalled`, `Parse-VersionPattern`, `Get-SemVersionIntersection`)
58+
- **Documentation**: comment-based help blocks (`.SYNOPSIS`, `.DESCRIPTION`, `.PARAMETER`) on all functions
59+
- **Logging**: use `Write-Log` with levels: Info, Warning, Error, Debug, Verbose
60+
- **Error handling**: wrap operations in `Invoke-WithErrorContext -Context "description" -ScriptBlock { ... }`
61+
- **Module state**: `$script:` prefix for module-scoped variables (e.g., `$script:RepositoryDictionary`, `$script:DryRun`)
62+
- **Initialization**: call `Initialize-LsiGitCheckout` to set module state from entry point parameters
63+
- **CHANGELOG**: follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format with SemVer versioning
64+
65+
## Project Structure
66+
67+
```
68+
LsiGitCheckout.ps1 # Entry point script (~230 lines)
69+
LsiGitCheckout.psm1 # Module with all functions (~2520 lines)
70+
LsiGitCheckout.psd1 # Module manifest
71+
CHANGELOG.md # Version history
72+
README.md # Comprehensive user documentation
73+
docs/
74+
comparison_guide.md # vs Google Repo Tool
75+
migration_guide.md # Migration strategies
76+
examples/ # 7 example dependency JSON configs
77+
tests/ # 16 test JSON configs + Pester test files
78+
LsiGitCheckout.Unit.Tests.ps1 # Unit tests (no network)
79+
LsiGitCheckout.Integration.Tests.ps1 # Integration tests (needs network)
80+
```
81+
82+
## Key Domain Concepts
83+
84+
- **SemVer mode**: uses `"Dependency Resolution": "SemVer"` and `"Version": "x.y.z"` fields. Supports floating versions (`"2.1.*"`, `"2.*"`)
85+
- **Agnostic mode**: uses `"Tag"` and `"API Compatible Tags"` fields for explicit version control
86+
- **Repository Dictionary** (`$script:RepositoryDictionary`): central tracking structure for all repositories being processed across the dependency tree
87+
- **Immutable config**: once a repo's resolution mode is set, it cannot change during processing

LsiGitCheckout.code-workspace

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {}
8+
}

0 commit comments

Comments
 (0)