diff --git a/Module/PSMinIO/PSMinIO.psd1 b/Module/PSMinIO/PSMinIO.psd1 index c252b91..6ef24a9 100644 --- a/Module/PSMinIO/PSMinIO.psd1 +++ b/Module/PSMinIO/PSMinIO.psd1 @@ -3,7 +3,7 @@ RootModule = 'bin\PSMinIO.dll' # Version number of this module. - ModuleVersion = '2025.07.10.1200' + ModuleVersion = '2025.07.11.1151' # Supported PSEditions CompatiblePSEditions = @('Desktop', 'Core') @@ -12,16 +12,16 @@ GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' # Author of this module - Author = 'PSMinIO Team' + Author = 'Grace Solutions' # Company or vendor of this module - CompanyName = 'PSMinIO' + CompanyName = 'Grace Solutions' # Copyright statement for this module - Copyright = '(c) 2025 PSMinIO Team. All rights reserved.' + Copyright = '(c) 2025 Grace Solutions. All rights reserved.' # Description of the functionality provided by this module - Description = 'A PowerShell module for MinIO object storage operations built on the Minio .NET SDK' + Description = 'A comprehensive PowerShell module for MinIO object storage operations with enterprise-grade features including chunked transfers, advanced object listing, directory management, and performance monitoring. Built on the official Minio .NET SDK.' # Minimum version of the PowerShell engine required by this module PowerShellVersion = '5.1' @@ -106,19 +106,47 @@ PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('MinIO', 'ObjectStorage', 'S3', 'Cloud', 'Storage', 'Bucket', 'Object') + Tags = @('MinIO', 'ObjectStorage', 'S3', 'Cloud', 'Storage', 'Bucket', 'Object', 'Enterprise', 'Chunked', 'Performance', 'Monitoring', 'Automation', 'Backup', 'AWS', 'Compatible') # A URL to the license for this module. - LicenseUri = 'https://github.com/PSMinIO/PSMinIO/blob/main/LICENSE' + LicenseUri = 'https://github.com/Grace-Solutions/PSMinIO/blob/main/LICENSE' # A URL to the main website for this project. - ProjectUri = 'https://github.com/PSMinIO/PSMinIO' + ProjectUri = 'https://github.com/Grace-Solutions/PSMinIO' # A URL to an icon representing this module. # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = 'Initial release of PSMinIO module with comprehensive MinIO object storage operations support.' + ReleaseNotes = @' +## Version 2025.07.11.1151 - Enhanced Release + +### Major Features +- Complete Get-MinIOObject cmdlet with advanced filtering, sorting, and pagination +- Enhanced directory management with automatic nested structure creation +- Advanced chunked operations with configurable chunk sizes and multi-layer progress tracking +- Comprehensive timing and performance metrics for all operations +- Enterprise-grade automation examples and monitoring capabilities + +### Issues Fixed +- Fixed directory creation warnings (now clean verbose logging) +- Implemented missing Get-MinIOObject cmdlet with full functionality +- Resolved threading and progress reporting issues + +### Documentation and Examples +- Updated README.md and comprehensive USAGE.md documentation +- Created comprehensive example scripts in scripts/examples/ directory +- Added enterprise automation patterns and best practices +- Professional logging with no Write-Host usage + +### Technical Improvements +- Thread-safe operations for chunked transfers +- Enhanced error handling and resource management +- Performance optimization with intelligent defaults +- Centralized version management system + +This release provides enterprise-grade functionality with professional documentation and comprehensive examples. +'@ # Prerelease string of this module # Prerelease = '' @@ -137,3 +165,8 @@ # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # DefaultCommandPrefix = '' } + + + + + diff --git a/Module/PSMinIO/bin/PSMinIO.pdb b/Module/PSMinIO/bin/PSMinIO.pdb index 9c38678..04b5665 100644 Binary files a/Module/PSMinIO/bin/PSMinIO.pdb and b/Module/PSMinIO/bin/PSMinIO.pdb differ diff --git a/Module/PSMinIO/bin/PSMinIO.psd1 b/Module/PSMinIO/bin/PSMinIO.psd1 index c252b91..419796d 100644 --- a/Module/PSMinIO/bin/PSMinIO.psd1 +++ b/Module/PSMinIO/bin/PSMinIO.psd1 @@ -3,7 +3,7 @@ RootModule = 'bin\PSMinIO.dll' # Version number of this module. - ModuleVersion = '2025.07.10.1200' + ModuleVersion = '2025.07.11.1151' # Supported PSEditions CompatiblePSEditions = @('Desktop', 'Core') @@ -12,16 +12,16 @@ GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' # Author of this module - Author = 'PSMinIO Team' + Author = 'Grace Solutions' # Company or vendor of this module - CompanyName = 'PSMinIO' + CompanyName = 'Grace Solutions' # Copyright statement for this module - Copyright = '(c) 2025 PSMinIO Team. All rights reserved.' + Copyright = '(c) 2025 Grace Solutions. All rights reserved.' # Description of the functionality provided by this module - Description = 'A PowerShell module for MinIO object storage operations built on the Minio .NET SDK' + Description = 'A comprehensive PowerShell module for MinIO object storage operations with enterprise-grade features including chunked transfers, advanced object listing, directory management, and performance monitoring. Built on the official Minio .NET SDK.' # Minimum version of the PowerShell engine required by this module PowerShellVersion = '5.1' @@ -106,19 +106,47 @@ PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('MinIO', 'ObjectStorage', 'S3', 'Cloud', 'Storage', 'Bucket', 'Object') + Tags = @('MinIO', 'ObjectStorage', 'S3', 'Cloud', 'Storage', 'Bucket', 'Object', 'Enterprise', 'Chunked', 'Performance', 'Monitoring', 'Automation', 'Backup', 'AWS', 'Compatible') # A URL to the license for this module. - LicenseUri = 'https://github.com/PSMinIO/PSMinIO/blob/main/LICENSE' + LicenseUri = 'https://github.com/Grace-Solutions/PSMinIO/blob/main/LICENSE' # A URL to the main website for this project. - ProjectUri = 'https://github.com/PSMinIO/PSMinIO' + ProjectUri = 'https://github.com/Grace-Solutions/PSMinIO' # A URL to an icon representing this module. # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = 'Initial release of PSMinIO module with comprehensive MinIO object storage operations support.' + ReleaseNotes = @' +## Version 2025.07.11.1151 - Enhanced Release + +### Major Features +- Complete Get-MinIOObject cmdlet with advanced filtering, sorting, and pagination +- Enhanced directory management with automatic nested structure creation +- Advanced chunked operations with configurable chunk sizes and multi-layer progress tracking +- Comprehensive timing and performance metrics for all operations +- Enterprise-grade automation examples and monitoring capabilities + +### Issues Fixed +- Fixed directory creation warnings (now clean verbose logging) +- Implemented missing Get-MinIOObject cmdlet with full functionality +- Resolved threading and progress reporting issues + +### Documentation and Examples +- Updated README.md and comprehensive USAGE.md documentation +- Created comprehensive example scripts in scripts/examples/ directory +- Added enterprise automation patterns and best practices +- Professional logging with no Write-Host usage + +### Technical Improvements +- Thread-safe operations for chunked transfers +- Enhanced error handling and resource management +- Performance optimization with intelligent defaults +- Centralized version management system + +This release provides enterprise-grade functionality with professional documentation and comprehensive examples. +'@ # Prerelease string of this module # Prerelease = '' @@ -137,3 +165,7 @@ # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # DefaultCommandPrefix = '' } + + + + diff --git a/PSMinIO.csproj b/PSMinIO.csproj index f9179e1..38422f3 100644 --- a/PSMinIO.csproj +++ b/PSMinIO.csproj @@ -4,15 +4,7 @@ netstandard2.0 PSMinIO PSMinIO - true - PSMinIO PowerShell Module - A PowerShell module for MinIO object storage operations - PSMinIO - PSMinIO - Copyright © 2025 - 2025.07.10.1200 - 2025.07.10.1200 - 2025.07.10.1200 + false latest enable false @@ -43,7 +35,7 @@ - + PreserveNewest @@ -51,13 +43,6 @@ - - - - - - - - + diff --git a/PSMinIO.psd1 b/Publish/PSMinIO/PSMinIO.psd1 similarity index 70% rename from PSMinIO.psd1 rename to Publish/PSMinIO/PSMinIO.psd1 index c252b91..8ba618b 100644 --- a/PSMinIO.psd1 +++ b/Publish/PSMinIO/PSMinIO.psd1 @@ -3,7 +3,7 @@ RootModule = 'bin\PSMinIO.dll' # Version number of this module. - ModuleVersion = '2025.07.10.1200' + ModuleVersion = '2.0.0' # Supported PSEditions CompatiblePSEditions = @('Desktop', 'Core') @@ -12,16 +12,16 @@ GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' # Author of this module - Author = 'PSMinIO Team' + Author = 'Grace Solutions' # Company or vendor of this module - CompanyName = 'PSMinIO' + CompanyName = 'Grace Solutions' # Copyright statement for this module - Copyright = '(c) 2025 PSMinIO Team. All rights reserved.' + Copyright = '(c) 2025 Grace Solutions. All rights reserved.' # Description of the functionality provided by this module - Description = 'A PowerShell module for MinIO object storage operations built on the Minio .NET SDK' + Description = 'A comprehensive PowerShell module for MinIO object storage operations with enterprise-grade features including chunked transfers, advanced object listing, directory management, and performance monitoring. Built on the official Minio .NET SDK.' # Minimum version of the PowerShell engine required by this module PowerShellVersion = '5.1' @@ -106,19 +106,47 @@ PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('MinIO', 'ObjectStorage', 'S3', 'Cloud', 'Storage', 'Bucket', 'Object') + Tags = @('MinIO', 'ObjectStorage', 'S3', 'Cloud', 'Storage', 'Bucket', 'Object', 'Enterprise', 'Chunked', 'Performance', 'Monitoring', 'Automation', 'Backup', 'AWS', 'Compatible') # A URL to the license for this module. - LicenseUri = 'https://github.com/PSMinIO/PSMinIO/blob/main/LICENSE' + LicenseUri = 'https://github.com/Grace-Solutions/PSMinIO/blob/main/LICENSE' # A URL to the main website for this project. - ProjectUri = 'https://github.com/PSMinIO/PSMinIO' + ProjectUri = 'https://github.com/Grace-Solutions/PSMinIO' # A URL to an icon representing this module. # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = 'Initial release of PSMinIO module with comprehensive MinIO object storage operations support.' + ReleaseNotes = @' +## Version 2.0.0 - Major Enhancement Release + +### Major Features Added +- Complete Get-MinIOObject cmdlet with advanced filtering, sorting, and pagination +- Enhanced directory management with automatic nested structure creation +- Advanced chunked operations with configurable chunk sizes and multi-layer progress tracking +- Comprehensive timing and performance metrics for all operations +- Enterprise-grade automation examples and monitoring capabilities + +### Issues Fixed +- Fixed directory creation warnings (now clean verbose logging) +- Implemented missing Get-MinIOObject cmdlet with full functionality +- Resolved threading and progress reporting issues + +### Documentation and Examples +- Updated README.md and comprehensive USAGE.md documentation +- Created 6 detailed example scripts covering all use cases +- Added enterprise automation patterns and best practices +- Professional logging with no Write-Host usage + +### Technical Improvements +- Thread-safe operations for chunked transfers +- Enhanced error handling and resource management +- Performance optimization with intelligent defaults +- Repository cleanup and organization + +This release provides enterprise-grade functionality with professional documentation and comprehensive examples. +'@ # Prerelease string of this module # Prerelease = '' diff --git a/Publish/PSMinIO/types/PSMinIO.Format.ps1xml b/Publish/PSMinIO/types/PSMinIO.Format.ps1xml new file mode 100644 index 0000000..fa301b6 --- /dev/null +++ b/Publish/PSMinIO/types/PSMinIO.Format.ps1xml @@ -0,0 +1,198 @@ + + + + + + + PSMinIO.Models.MinIOBucketInfo + + PSMinIO.Models.MinIOBucketInfo + + + + + + 25 + Left + + + + 20 + Left + + + + 15 + Left + + + + + + + Name + + + CreatedFormatted + + + Region + + + + + + + + + + PSMinIO.Models.MinIOObjectInfo + + PSMinIO.Models.MinIOObjectInfo + + + + + + 30 + Left + + + + 12 + Right + + + + 20 + Left + + + + 20 + Left + + + + + + + Name + + + SizeFormatted + + + LastModifiedFormatted + + + ETag + + + + + + + + + + PSMinIO.Models.MinIOConfiguration + + PSMinIO.Models.MinIOConfiguration + + + + + + 30 + Left + + + + 15 + Left + + + + 15 + Left + + + + 8 + Left + + + + + + + EndpointDisplay + + + AccessKeyMasked + + + SecretKeyMasked + + + UseSSL + + + + + + + + + + PSMinIO.Models.MinIOStats + + PSMinIO.Models.MinIOStats + + + + + + 15 + Right + + + + 15 + Right + + + + 15 + Right + + + + 20 + Left + + + + + + + TotalBuckets + + + TotalObjects + + + TotalSizeFormatted + + + LastUpdated + + + + + + + + + diff --git a/Publish/PSMinIO/types/PSMinIO.Types.ps1xml b/Publish/PSMinIO/types/PSMinIO.Types.ps1xml new file mode 100644 index 0000000..d91736d --- /dev/null +++ b/Publish/PSMinIO/types/PSMinIO.Types.ps1xml @@ -0,0 +1,258 @@ + + + + PSMinIO.Models.MinIOBucketInfo + + + CreatedFormatted + + $this.Created.ToString("yyyy-MM-dd HH:mm:ss") + + + + SizeFormatted + + if ($this.Size -eq $null) { return "N/A" } + $sizes = @("B", "KB", "MB", "GB", "TB", "PB") + $index = 0 + $size = $this.Size + while ($size -ge 1024 -and $index -lt $sizes.Length - 1) { + $size = $size / 1024 + $index++ + } + return "{0:F2} {1}" -f $size, $sizes[$index] + + + + + + + PSMinIO.Models.MinIOObjectInfo + + + LastModifiedFormatted + + $this.LastModified.ToString("yyyy-MM-dd HH:mm:ss") + + + + SizeFormatted + + if ($this.Size -eq $null) { return "N/A" } + $sizes = @("B", "KB", "MB", "GB", "TB", "PB") + $index = 0 + $size = $this.Size + while ($size -ge 1024 -and $index -lt $sizes.Length - 1) { + $size = $size / 1024 + $index++ + } + return "{0:F2} {1}" -f $size, $sizes[$index] + + + + GetFileName + + if ($this.Name -eq $null) { return "" } + $parts = $this.Name.Split('/') + return $parts[$parts.Length - 1] + + + + HasPresignedUrl + + return -not [string]::IsNullOrEmpty($this.PresignedUrl) + + + + PresignedUrlValid + + if ($this.PresignedUrlExpiration -eq $null) { return $false } + return $this.PresignedUrlExpiration -gt [DateTime]::UtcNow + + + + + + + PSMinIO.Models.MinIOConfiguration + + + EndpointDisplay + + if ($this.UseSSL) { + return "https://$($this.Endpoint)" + } else { + return "http://$($this.Endpoint)" + } + + + + AccessKeyMasked + + if ([string]::IsNullOrEmpty($this.AccessKey)) { return "Not Set" } + if ($this.AccessKey.Length -le 4) { return $this.AccessKey } + return $this.AccessKey.Substring(0, 4) + "*".PadRight($this.AccessKey.Length - 4, '*') + + + + SecretKeyMasked + + if ([string]::IsNullOrEmpty($this.SecretKey)) { return "Not Set" } + return "*".PadRight($this.SecretKey.Length, '*') + + + + SecurityStatus + + if ($this.SkipCertificateValidation) { + return "SSL (Certificate Validation Disabled)" + } elseif ($this.UseSSL) { + return "SSL (Secure)" + } else { + return "HTTP (Insecure)" + } + + + + + + + PSMinIO.Models.MinIOStats + + + TotalSizeFormatted + + if ($this.TotalSize -eq $null) { return "N/A" } + $sizes = @("B", "KB", "MB", "GB", "TB", "PB") + $index = 0 + $size = $this.TotalSize + while ($size -ge 1024 -and $index -lt $sizes.Length - 1) { + $size = $size / 1024 + $index++ + } + return "{0:F2} {1}" -f $size, $sizes[$index] + + + + + + + + PSMinIO.Models.ChunkedTransferState + + + ProgressFormatted + + return "{0:F1}%" -f $this.ProgressPercentage + + + + BytesTransferredFormatted + + if ($this.BytesTransferred -eq $null) { return "0 B" } + $sizes = @("B", "KB", "MB", "GB", "TB", "PB") + $index = 0 + $size = $this.BytesTransferred + while ($size -ge 1024 -and $index -lt $sizes.Length - 1) { + $size = $size / 1024 + $index++ + } + return "{0:F2} {1}" -f $size, $sizes[$index] + + + + TotalSizeFormatted + + if ($this.TotalSize -eq $null) { return "0 B" } + $sizes = @("B", "KB", "MB", "GB", "TB", "PB") + $index = 0 + $size = $this.TotalSize + while ($size -ge 1024 -and $index -lt $sizes.Length - 1) { + $size = $size / 1024 + $index++ + } + return "{0:F2} {1}" -f $size, $sizes[$index] + + + + ChunkSizeFormatted + + if ($this.ChunkSize -eq $null) { return "0 B" } + $sizes = @("B", "KB", "MB", "GB", "TB", "PB") + $index = 0 + $size = $this.ChunkSize + while ($size -ge 1024 -and $index -lt $sizes.Length - 1) { + $size = $size / 1024 + $index++ + } + return "{0:F2} {1}" -f $size, $sizes[$index] + + + + ElapsedTime + + if ($this.StartTime -eq $null) { return "Unknown" } + $elapsed = [DateTime]::UtcNow - $this.StartTime + return $elapsed.ToString("hh\:mm\:ss") + + + + TransferStatus + + if ($this.IsComplete) { + return "Complete" + } elseif ($this.CompletedChunkCount -gt 0) { + return "In Progress" + } else { + return "Not Started" + } + + + + RemainingChunks + + return $this.TotalChunks - $this.CompletedChunkCount + + + + + + + + PSMinIO.Models.ChunkInfo + + + SizeFormatted + + if ($this.Size -eq $null) { return "0 B" } + $sizes = @("B", "KB", "MB", "GB", "TB", "PB") + $index = 0 + $size = $this.Size + while ($size -ge 1024 -and $index -lt $sizes.Length - 1) { + $size = $size / 1024 + $index++ + } + return "{0:F2} {1}" -f $size, $sizes[$index] + + + + ChunkRange + + return "{0}-{1}" -f $this.StartByte, $this.EndByte + + + + Status + + if ($this.IsCompleted) { + return "Completed" + } elseif ($this.RetryCount -gt 0) { + return "Failed ({0} retries)" -f $this.RetryCount + } else { + return "Pending" + } + + + + + diff --git a/README.md b/README.md index 05c1b54..16a5e56 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,23 @@ A comprehensive PowerShell module for MinIO object storage operations, built on ## Installation +### From PowerShell Gallery +```powershell +# Install from PowerShell Gallery +Install-Module -Name PSMinIO -Scope CurrentUser + +# Import the module +Import-Module PSMinIO +``` + ### From Source ```powershell # Clone the repository -git clone https://github.com/yourusername/PSMinIO.git +git clone https://github.com/Grace-Solutions/PSMinIO.git cd PSMinIO -# Build the module -dotnet build PSMinIO.csproj --configuration Release +# Build the module (automatically updates version) +.\scripts\Build.ps1 # Import the module Import-Module .\Module\PSMinIO\PSMinIO.psd1 @@ -124,7 +133,7 @@ All operations provide detailed timing information: ## Examples -See the [examples](./examples/) directory for comprehensive usage examples: +See the [scripts/examples](./scripts/examples/) directory for comprehensive usage examples: - **Basic Operations**: Connection, bucket management, simple uploads/downloads - **Advanced Scenarios**: Chunked transfers, directory management, bulk operations - **Enterprise Patterns**: Policy management, monitoring, and automation scripts diff --git a/Version.ps1 b/Version.ps1 new file mode 100644 index 0000000..57000b0 --- /dev/null +++ b/Version.ps1 @@ -0,0 +1,135 @@ +# PSMinIO Version Configuration +# This file contains the centralized version information for the PSMinIO module + +# Generate version based on current date and time +$CurrentDate = Get-Date +$Version = $CurrentDate.ToString("yyyy.MM.dd.HHmm") + +# Version information +$VersionInfo = @{ + # Main version string (yyyy.MM.dd.HHMM format) + Version = $Version + + # Semantic version for PowerShell Gallery (converted from date-based) + SemanticVersion = "2.0.0" + + # Build date + BuildDate = $CurrentDate + + # Build date string + BuildDateString = $CurrentDate.ToString("yyyy-MM-dd HH:mm:ss") + + # Copyright year + CopyrightYear = $CurrentDate.Year + + # Module information + ModuleName = "PSMinIO" + Author = "Grace Solutions" + CompanyName = "Grace Solutions" + Copyright = "(c) $($CurrentDate.Year) Grace Solutions. All rights reserved." + + # Description + Description = "A comprehensive PowerShell module for MinIO object storage operations with enterprise-grade features including chunked transfers, advanced object listing, directory management, and performance monitoring. Built on the official Minio .NET SDK." + + # PowerShell Gallery metadata + Tags = @('MinIO', 'ObjectStorage', 'S3', 'Cloud', 'Storage', 'Bucket', 'Object', 'Enterprise', 'Chunked', 'Performance', 'Monitoring', 'Automation', 'Backup', 'AWS', 'Compatible') + + # URLs + ProjectUri = "https://github.com/Grace-Solutions/PSMinIO" + LicenseUri = "https://github.com/Grace-Solutions/PSMinIO/blob/main/LICENSE" + + # Release notes + ReleaseNotes = @" +## Version $Version - Enhanced Release + +### Major Features +- Complete Get-MinIOObject cmdlet with advanced filtering, sorting, and pagination +- Enhanced directory management with automatic nested structure creation +- Advanced chunked operations with configurable chunk sizes and multi-layer progress tracking +- Comprehensive timing and performance metrics for all operations +- Enterprise-grade automation examples and monitoring capabilities + +### Issues Fixed +- Fixed directory creation warnings (now clean verbose logging) +- Implemented missing Get-MinIOObject cmdlet with full functionality +- Resolved threading and progress reporting issues + +### Documentation and Examples +- Updated README.md and comprehensive USAGE.md documentation +- Created comprehensive example scripts in scripts/examples/ directory +- Added enterprise automation patterns and best practices +- Professional logging with no Write-Host usage + +### Technical Improvements +- Thread-safe operations for chunked transfers +- Enhanced error handling and resource management +- Performance optimization with intelligent defaults +- Centralized version management system + +This release provides enterprise-grade functionality with professional documentation and comprehensive examples. +"@ +} + +# Export version information for use by other scripts +$VersionInfo + +# Function to get version info +function Get-PSMinIOVersion { + return $VersionInfo +} + +# Function to update version in files +function Update-PSMinIOVersion { + param( + [string]$ManifestPath, + [string]$AssemblyInfoPath + ) + + Write-Host "Updating version to: $($VersionInfo.Version)" -ForegroundColor Green + Write-Host "Build date: $($VersionInfo.BuildDateString)" -ForegroundColor Green + + # Update module manifest if path provided + if ($ManifestPath -and (Test-Path $ManifestPath)) { + Write-Host "Updating module manifest: $ManifestPath" -ForegroundColor Yellow + + $manifestContent = Get-Content $ManifestPath -Raw + + # Update version + $manifestContent = $manifestContent -replace "ModuleVersion\s*=\s*'[^']*'", "ModuleVersion = '$($VersionInfo.Version)'" + + # Update copyright + $manifestContent = $manifestContent -replace "Copyright\s*=\s*'[^']*'", "Copyright = '$($VersionInfo.Copyright)'" + + # Update description + $manifestContent = $manifestContent -replace "Description\s*=\s*'[^']*'", "Description = '$($VersionInfo.Description)'" + + $manifestContent | Set-Content $ManifestPath -Encoding UTF8 + Write-Host "✅ Module manifest updated" -ForegroundColor Green + } + + # Update assembly info if path provided + if ($AssemblyInfoPath -and (Test-Path $AssemblyInfoPath)) { + Write-Host "Updating assembly info: $AssemblyInfoPath" -ForegroundColor Yellow + + $assemblyContent = Get-Content $AssemblyInfoPath -Raw + + # Update assembly version attributes + $assemblyContent = $assemblyContent -replace '\[assembly:\s*AssemblyVersion\("[^"]*"\)\]', "[assembly: AssemblyVersion(`"$($VersionInfo.Version)`")]" + $assemblyContent = $assemblyContent -replace '\[assembly:\s*AssemblyFileVersion\("[^"]*"\)\]', "[assembly: AssemblyFileVersion(`"$($VersionInfo.Version)`")]" + $assemblyContent = $assemblyContent -replace '\[assembly:\s*AssemblyInformationalVersion\("[^"]*"\)\]', "[assembly: AssemblyInformationalVersion(`"$($VersionInfo.Version)`")]" + + # Update copyright + $assemblyContent = $assemblyContent -replace '\[assembly:\s*AssemblyCopyright\("[^"]*"\)\]', "[assembly: AssemblyCopyright(`"$($VersionInfo.Copyright)`")]" + + $assemblyContent | Set-Content $AssemblyInfoPath -Encoding UTF8 + Write-Host "✅ Assembly info updated" -ForegroundColor Green + } +} + +# Export functions only if running as a module +if ($MyInvocation.MyCommand.CommandType -eq 'ExternalScript') { + # Running as script - don't export +} else { + # Running as module - export functions + Export-ModuleMember -Function Get-PSMinIOVersion, Update-PSMinIOVersion -Variable VersionInfo +} diff --git a/docs/POWERSHELL-GALLERY-RELEASE.md b/docs/POWERSHELL-GALLERY-RELEASE.md new file mode 100644 index 0000000..88a6809 --- /dev/null +++ b/docs/POWERSHELL-GALLERY-RELEASE.md @@ -0,0 +1,188 @@ +# PowerShell Gallery Release Guide for PSMinIO + +This guide walks you through publishing PSMinIO to the PowerShell Gallery. + +## Prerequisites + +### 1. PowerShell Gallery Account +- Create an account at [PowerShell Gallery](https://www.powershellgallery.com/) +- Generate an API key from your account settings +- Keep your API key secure and never commit it to source control + +### 2. Required PowerShell Modules +```powershell +# Install required modules if not already present +Install-Module -Name PowerShellGet -Force -AllowClobber +Install-Module -Name PackageManagement -Force -AllowClobber +``` + +### 3. Verify Module Build +Ensure the module has been built and all files are present: +```powershell +# Build the module (if needed) +dotnet build PSMinIO.csproj --configuration Release + +# Verify module structure +Get-ChildItem .\Module\PSMinIO\ -Recurse +``` + +## Pre-Release Checklist + +### ✅ Module Validation +- [ ] Module manifest (PSMinIO.psd1) is valid +- [ ] All required assemblies are present (PSMinIO.dll, Minio.dll) +- [ ] Type and format files are included +- [ ] Version number follows semantic versioning (2.0.0) +- [ ] Release notes are comprehensive and accurate +- [ ] All cmdlets are properly exported + +### ✅ Documentation +- [ ] README.md is updated with latest features +- [ ] USAGE.md includes comprehensive examples +- [ ] Examples directory contains working scripts +- [ ] Release notes document all changes +- [ ] License file is present and correct + +### ✅ Testing +- [ ] Module imports without errors +- [ ] All exported cmdlets are available +- [ ] Basic functionality tests pass +- [ ] Examples run successfully +- [ ] No Write-Host usage in production code + +### ✅ Repository +- [ ] All changes are committed to Git +- [ ] Repository is pushed to GitHub +- [ ] Tags are created for the release +- [ ] GitHub release is created (optional but recommended) + +## Release Process + +### Step 1: Validate Everything +Run the automated validation: +```powershell +# Test the release process without actually publishing +.\Publish-PSMinIOToGallery.ps1 -WhatIf +``` + +### Step 2: Publish to PowerShell Gallery +```powershell +# Publish with your API key +.\Publish-PSMinIOToGallery.ps1 -NuGetApiKey "YOUR_API_KEY_HERE" + +# Or let the script prompt for the API key securely +.\Publish-PSMinIOToGallery.ps1 +``` + +### Step 3: Verify Publication +1. Check the PowerShell Gallery: https://www.powershellgallery.com/packages/PSMinIO +2. Test installation from the gallery: + ```powershell + Install-Module -Name PSMinIO -Force + Import-Module PSMinIO + Get-Command -Module PSMinIO + ``` + +## Post-Release Tasks + +### 1. Update Documentation +- [ ] Update README.md with installation instructions from PowerShell Gallery +- [ ] Add PowerShell Gallery badge to README +- [ ] Update any version references in documentation + +### 2. GitHub Release +Create a GitHub release with: +- [ ] Tag matching the module version (v2.0.0) +- [ ] Release title: "PSMinIO v2.0.0 - Major Enhancement Release" +- [ ] Copy release notes from the module manifest +- [ ] Attach any relevant assets + +### 3. Announce the Release +- [ ] Update project documentation +- [ ] Notify users through appropriate channels +- [ ] Consider creating a blog post or announcement + +## Troubleshooting + +### Common Issues + +#### 1. Module Validation Errors +```powershell +# Check manifest syntax +Test-ModuleManifest -Path .\Module\PSMinIO\PSMinIO.psd1 +``` + +#### 2. Missing Dependencies +Ensure all required files are in the module directory: +- `bin\PSMinIO.dll` +- `bin\Minio.dll` +- `types\PSMinIO.Types.ps1xml` +- `types\PSMinIO.Format.ps1xml` + +#### 3. API Key Issues +- Verify your API key is correct +- Check that your PowerShell Gallery account has publishing permissions +- Ensure the API key hasn't expired + +#### 4. Version Conflicts +If the version already exists: +- Increment the version number in PSMinIO.psd1 +- Rebuild the module +- Commit and push changes + +### Getting Help + +#### PowerShell Gallery Support +- Documentation: https://docs.microsoft.com/en-us/powershell/gallery/ +- Issues: https://github.com/PowerShell/PowerShellGallery/issues + +#### Module-Specific Issues +- Check the validation output from the publish script +- Review the module manifest for syntax errors +- Ensure all dependencies are properly referenced + +## Security Considerations + +### API Key Management +- Never commit API keys to source control +- Use environment variables or secure prompts +- Rotate API keys regularly +- Limit API key permissions to publishing only + +### Module Security +- All assemblies are signed and from trusted sources +- No malicious code or backdoors +- Dependencies are from official NuGet packages +- Code has been reviewed for security issues + +## Version Management + +### Semantic Versioning +PSMinIO follows semantic versioning (MAJOR.MINOR.PATCH): +- **MAJOR**: Breaking changes +- **MINOR**: New features, backward compatible +- **PATCH**: Bug fixes, backward compatible + +### Current Release: v2.0.0 +This is a major release with significant new features and improvements: +- Complete Get-MinIOObject implementation +- Enhanced directory management +- Advanced chunked operations +- Comprehensive documentation and examples + +### Next Release Planning +Future releases will follow the same process: +1. Increment version number appropriately +2. Update release notes +3. Follow this release guide +4. Publish to PowerShell Gallery + +## Success Metrics + +After release, monitor: +- [ ] Download statistics on PowerShell Gallery +- [ ] User feedback and issues +- [ ] GitHub stars and forks +- [ ] Community adoption and usage + +The PSMinIO module is now ready for enterprise use with professional-grade functionality and comprehensive documentation! diff --git a/docs/PROJECT-STRUCTURE.md b/docs/PROJECT-STRUCTURE.md new file mode 100644 index 0000000..f987002 --- /dev/null +++ b/docs/PROJECT-STRUCTURE.md @@ -0,0 +1,212 @@ +# PSMinIO Project Structure + +This document describes the reorganized project structure and centralized version management system. + +## Directory Structure + +``` +PSMinIO/ +├── README.md # Main project documentation +├── LICENSE # Project license +├── PSMinIO.csproj # Main project file +├── Version.ps1 # Centralized version configuration +│ +├── src/ # Source code +│ ├── Properties/ +│ │ └── AssemblyInfo.cs # Assembly version information +│ ├── Cmdlets/ # PowerShell cmdlet implementations +│ ├── Models/ # Data models and result objects +│ └── Utils/ # Utility classes and helpers +│ +├── Module/ # Built module directory +│ └── PSMinIO/ +│ ├── PSMinIO.psd1 # Module manifest +│ ├── bin/ # Compiled assemblies +│ └── types/ # PowerShell type and format files +│ +├── scripts/ # All PowerShell scripts +│ ├── Build.ps1 # Main build script +│ ├── Quick-Build.ps1 # Quick build without file locking issues +│ ├── Update-Version.ps1 # Version update script +│ ├── Publish-PSMinIOToGallery.ps1 # PowerShell Gallery publishing +│ └── examples/ # Usage examples +│ ├── README.md # Examples documentation +│ ├── 01-Basic-Operations.ps1 +│ ├── 02-Advanced-Object-Listing.ps1 +│ ├── 03-Directory-Management.ps1 +│ ├── 04-Chunked-Operations.ps1 +│ ├── 05-Bulk-Operations.ps1 +│ └── 06-Enterprise-Automation.ps1 +│ +├── docs/ # Documentation +│ ├── USAGE.md # Comprehensive usage guide +│ ├── RELEASE-NOTES.md # Release notes +│ ├── POWERSHELL-GALLERY-RELEASE.md # Gallery release guide +│ └── PROJECT-STRUCTURE.md # This file +│ +├── Artifacts/ # Build artifacts +├── Publish/ # Publishing staging area +└── bin/ # Build output +``` + +## Version Management System + +### Centralized Version Configuration + +The project uses a centralized version management system based on `Version.ps1`: + +- **Version Format**: `yyyy.MM.dd.HHmm` (e.g., `2025.07.11.1151`) +- **Automatic Generation**: Version is generated based on current date/time +- **Centralized Updates**: Single script updates all version references + +### Version Files + +1. **Version.ps1** - Master version configuration +2. **src/Properties/AssemblyInfo.cs** - Assembly version information +3. **Module/PSMinIO/PSMinIO.psd1** - PowerShell module manifest + +### Version Update Process + +```powershell +# Update all version information +.\scripts\Update-Version.ps1 + +# Build with updated version +.\scripts\Quick-Build.ps1 +``` + +## Build System + +### Build Scripts + +1. **scripts/Build.ps1** - Full build with validation and packaging +2. **scripts/Quick-Build.ps1** - Fast build for development (handles file locking) +3. **scripts/Update-Version.ps1** - Version management + +### Build Process + +1. Update version information across all files +2. Clean previous build artifacts +3. Compile .NET project +4. Copy assemblies to module directory +5. Validate module manifest +6. Optional: Run tests and create packages + +### Handling File Locking + +The Quick-Build script handles PowerShell file locking issues: +- Removes automatic copy from project file +- Manual copy with retry logic +- Graceful handling of locked files + +## Scripts Organization + +### Location +All scripts are now in the `scripts/` directory: +- Build and deployment scripts in `scripts/` +- Usage examples in `scripts/examples/` + +### Import Paths +Example scripts use relative imports: +```powershell +Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1 +``` + +## Documentation Structure + +### Location +All documentation is in the `docs/` directory except README.md: +- `README.md` - Main project overview (root directory) +- `docs/USAGE.md` - Comprehensive usage guide +- `docs/RELEASE-NOTES.md` - Version history and changes +- `docs/POWERSHELL-GALLERY-RELEASE.md` - Publishing guide +- `docs/PROJECT-STRUCTURE.md` - This structure guide + +### Content Organization +- **README.md**: Overview, installation, quick start +- **USAGE.md**: Detailed usage patterns and examples +- **Examples**: Practical scripts for common scenarios +- **Release Notes**: Version history and changes + +## Development Workflow + +### 1. Making Changes +```powershell +# Make code changes in src/ +# Update documentation if needed +``` + +### 2. Building +```powershell +# Quick build for testing +.\scripts\Quick-Build.ps1 + +# Full build with validation +.\scripts\Build.ps1 +``` + +### 3. Testing +```powershell +# Import and test module +Import-Module .\Module\PSMinIO\PSMinIO.psd1 + +# Run example scripts +.\scripts\examples\01-Basic-Operations.ps1 +``` + +### 4. Committing +```powershell +# Version is automatically updated during build +git add . +git commit -m "Description of changes" +git push +``` + +### 5. Publishing +```powershell +# Publish to PowerShell Gallery +.\scripts\Publish-PSMinIOToGallery.ps1 +``` + +## Key Benefits + +### Centralized Version Management +- Single source of truth for version information +- Automatic timestamp-based versioning +- Consistent version across all files + +### Organized Structure +- Clear separation of concerns +- All scripts in dedicated directory +- Documentation properly organized + +### Improved Build Process +- Handles file locking issues +- Automatic version updates +- Validation and testing integration + +### Professional Documentation +- Comprehensive usage examples +- Clear project structure +- Publishing guidelines + +## Migration Notes + +### From Previous Structure +- Examples moved from `examples/` to `scripts/examples/` +- Documentation moved to `docs/` (except README.md) +- Version management centralized in `Version.ps1` +- Build process improved with Quick-Build option + +### Import Path Updates +All example scripts updated to use: +```powershell +Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1 +``` + +### Version Format Change +- Previous: Manual semantic versioning +- Current: Automatic date-based versioning (yyyy.MM.dd.HHmm) +- PowerShell Gallery: Uses semantic version for compatibility + +This structure provides a professional, maintainable, and scalable foundation for the PSMinIO project. diff --git a/RELEASE-NOTES.md b/docs/RELEASE-NOTES.md similarity index 100% rename from RELEASE-NOTES.md rename to docs/RELEASE-NOTES.md diff --git a/Build.ps1 b/scripts/Build.ps1 similarity index 93% rename from Build.ps1 rename to scripts/Build.ps1 index 9028c1b..743b3a0 100644 --- a/Build.ps1 +++ b/scripts/Build.ps1 @@ -48,10 +48,11 @@ param( # Set error action preference $ErrorActionPreference = 'Stop' -# Get script directory +# Get script directory and project root $ScriptRoot = $PSScriptRoot -$ProjectFile = Join-Path $ScriptRoot 'PSMinIO.csproj' -$ModuleManifest = Join-Path $ScriptRoot 'PSMinIO.psd1' +$ProjectRoot = Split-Path $ScriptRoot -Parent +$ProjectFile = Join-Path $ProjectRoot 'PSMinIO.csproj' +$ModuleManifest = Join-Path $ProjectRoot 'Module\PSMinIO\PSMinIO.psd1' Write-Host "=== PSMinIO Build Script ===" -ForegroundColor Cyan Write-Host "Configuration: $Configuration" -ForegroundColor Gray @@ -72,24 +73,35 @@ function Test-Command { } try { + # Update version information first + Write-Status "Updating version information..." + $updateVersionScript = Join-Path $ScriptRoot "Update-Version.ps1" + if (Test-Path $updateVersionScript) { + & $updateVersionScript + Write-Host " ✓ Version information updated" -ForegroundColor Green + } else { + Write-Warning "Update-Version.ps1 not found, skipping version update" + } + Write-Host "" + # Check prerequisites Write-Status "Checking prerequisites..." - + if (!(Test-Command 'dotnet')) { throw ".NET SDK is required but not found. Please install .NET SDK 6.0 or later." } - + $dotnetVersion = dotnet --version Write-Host " .NET SDK Version: $dotnetVersion" -ForegroundColor Green - + if (!(Test-Path $ProjectFile)) { throw "Project file not found: $ProjectFile" } - + if (!(Test-Path $ModuleManifest)) { throw "Module manifest not found: $ModuleManifest" } - + Write-Host " ✓ Prerequisites check passed" -ForegroundColor Green Write-Host "" diff --git a/scripts/Publish-PSMinIOToGallery.ps1 b/scripts/Publish-PSMinIOToGallery.ps1 new file mode 100644 index 0000000..2ae6569 --- /dev/null +++ b/scripts/Publish-PSMinIOToGallery.ps1 @@ -0,0 +1,244 @@ +# PowerShell Gallery Release Script for PSMinIO +# This script prepares and publishes the PSMinIO module to PowerShell Gallery + +[CmdletBinding()] +param( + [Parameter(Mandatory = $false)] + [string]$NuGetApiKey, + + [Parameter(Mandatory = $false)] + [switch]$WhatIf, + + [Parameter(Mandatory = $false)] + [switch]$Force, + + [Parameter(Mandatory = $false)] + [string]$Repository = "PSGallery" +) + +# Set error action preference +$ErrorActionPreference = "Stop" + +# Define paths +$ProjectRoot = Split-Path $PSScriptRoot -Parent +$ModulePath = Join-Path $ProjectRoot "Module\PSMinIO" +$ManifestPath = Join-Path $ModulePath "PSMinIO.psd1" +$PublishPath = Join-Path $ProjectRoot "Publish" + +function Write-Status { + param([string]$Message, [string]$Type = "Info") + $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" + switch ($Type) { + "Success" { Write-Host "[$timestamp] ✅ $Message" -ForegroundColor Green } + "Warning" { Write-Host "[$timestamp] ⚠️ $Message" -ForegroundColor Yellow } + "Error" { Write-Host "[$timestamp] ❌ $Message" -ForegroundColor Red } + default { Write-Host "[$timestamp] ℹ️ $Message" -ForegroundColor Cyan } + } +} + +function Test-ModuleStructure { + Write-Status "Validating module structure..." + + # Check if manifest exists + if (-not (Test-Path $ManifestPath)) { + throw "Module manifest not found at: $ManifestPath" + } + + # Test manifest + try { + $manifest = Test-ModuleManifest -Path $ManifestPath -ErrorAction Stop + Write-Status "Module manifest is valid" "Success" + Write-Status "Module: $($manifest.Name) v$($manifest.Version)" + Write-Status "Author: $($manifest.Author)" + Write-Status "Description: $($manifest.Description)" + return $manifest + } catch { + throw "Module manifest validation failed: $($_.Exception.Message)" + } +} + +function Test-RequiredFiles { + param($Manifest) + + Write-Status "Checking required files..." + + $requiredFiles = @( + "bin\PSMinIO.dll", + "bin\Minio.dll", + "types\PSMinIO.Types.ps1xml", + "types\PSMinIO.Format.ps1xml" + ) + + foreach ($file in $requiredFiles) { + $filePath = Join-Path $ModulePath $file + if (-not (Test-Path $filePath)) { + throw "Required file missing: $file" + } + Write-Status "✓ Found: $file" + } + + Write-Status "All required files present" "Success" +} + +function Test-ModuleFunctionality { + Write-Status "Testing module functionality..." + + try { + # Import the module + Import-Module $ManifestPath -Force -ErrorAction Stop + Write-Status "✓ Module imported successfully" + + # Test cmdlet availability + $expectedCmdlets = @( + 'Connect-MinIO', + 'Get-MinIOBucket', + 'New-MinIOBucket', + 'Remove-MinIOBucket', + 'Test-MinIOBucketExists', + 'Get-MinIOObject', + 'New-MinIOObject', + 'New-MinIOObjectChunked', + 'New-MinIOFolder', + 'Get-MinIOObjectContent', + 'Get-MinIOObjectContentChunked', + 'Remove-MinIOObject', + 'Get-MinIOBucketPolicy', + 'Set-MinIOBucketPolicy', + 'Get-MinIOStats' + ) + + $availableCmdlets = Get-Command -Module PSMinIO | Select-Object -ExpandProperty Name + + foreach ($cmdlet in $expectedCmdlets) { + if ($cmdlet -in $availableCmdlets) { + Write-Status "✓ Cmdlet available: $cmdlet" + } else { + throw "Expected cmdlet not found: $cmdlet" + } + } + + Write-Status "All expected cmdlets are available" "Success" + + # Remove module + Remove-Module PSMinIO -Force -ErrorAction SilentlyContinue + + } catch { + throw "Module functionality test failed: $($_.Exception.Message)" + } +} + +function Prepare-PublishDirectory { + param($Manifest) + + Write-Status "Preparing publish directory..." + + # Clean and create publish directory + if (Test-Path $PublishPath) { + Remove-Item $PublishPath -Recurse -Force + } + New-Item -ItemType Directory -Path $PublishPath -Force | Out-Null + + # Create module directory in publish path + $publishModulePath = Join-Path $PublishPath "PSMinIO" + New-Item -ItemType Directory -Path $publishModulePath -Force | Out-Null + + # Copy module files + Copy-Item -Path "$ModulePath\*" -Destination $publishModulePath -Recurse -Force + + Write-Status "Module prepared in: $publishModulePath" "Success" + return $publishModulePath +} + +function Test-PowerShellGalleryConnection { + Write-Status "Testing PowerShell Gallery connection..." + + try { + $repo = Get-PSRepository -Name $Repository -ErrorAction Stop + Write-Status "✓ Repository '$Repository' is available" + Write-Status " Source: $($repo.SourceLocation)" + Write-Status " Publish: $($repo.PublishLocation)" + + if ($repo.InstallationPolicy -eq "Untrusted") { + Write-Status "Repository is marked as Untrusted - this is normal for PSGallery" "Warning" + } + + } catch { + throw "Failed to connect to repository '$Repository': $($_.Exception.Message)" + } +} + +function Publish-ModuleToGallery { + param($PublishModulePath, $Manifest) + + if ($WhatIf) { + Write-Status "WhatIf: Would publish module to PowerShell Gallery" "Warning" + Write-Status "Module: $($Manifest.Name) v$($Manifest.Version)" + Write-Status "Path: $PublishModulePath" + Write-Status "Repository: $Repository" + return + } + + if (-not $NuGetApiKey) { + Write-Status "NuGetApiKey not provided. Please provide your PowerShell Gallery API key." "Warning" + $NuGetApiKey = Read-Host -Prompt "Enter your PowerShell Gallery API Key" -AsSecureString + $NuGetApiKey = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($NuGetApiKey)) + } + + Write-Status "Publishing module to PowerShell Gallery..." + + try { + $publishParams = @{ + Path = $PublishModulePath + Repository = $Repository + NuGetApiKey = $NuGetApiKey + Force = $Force + Verbose = $true + } + + Publish-Module @publishParams + + Write-Status "Module published successfully!" "Success" + Write-Status "It may take a few minutes to appear in search results" + + } catch { + throw "Failed to publish module: $($_.Exception.Message)" + } +} + +# Main execution +try { + Write-Status "Starting PowerShell Gallery release process for PSMinIO" + Write-Status "Repository: $Repository" + Write-Status "WhatIf: $WhatIf" + + # Step 1: Validate module structure + $manifest = Test-ModuleStructure + + # Step 2: Check required files + Test-RequiredFiles -Manifest $manifest + + # Step 3: Test module functionality + Test-ModuleFunctionality + + # Step 4: Test PowerShell Gallery connection + Test-PowerShellGalleryConnection + + # Step 5: Prepare publish directory + $publishModulePath = Prepare-PublishDirectory -Manifest $manifest + + # Step 6: Final validation of prepared module + Write-Status "Final validation of prepared module..." + $finalManifest = Test-ModuleManifest -Path (Join-Path $publishModulePath "PSMinIO.psd1") + Write-Status "Final validation successful" "Success" + + # Step 7: Publish to gallery + Publish-ModuleToGallery -PublishModulePath $publishModulePath -Manifest $finalManifest + + Write-Status "PowerShell Gallery release process completed successfully!" "Success" + Write-Status "Module: PSMinIO v$($finalManifest.Version)" + Write-Status "Check status at: https://www.powershellgallery.com/packages/PSMinIO" + +} catch { + Write-Status "Release process failed: $($_.Exception.Message)" "Error" + exit 1 +} diff --git a/scripts/Quick-Build.ps1 b/scripts/Quick-Build.ps1 new file mode 100644 index 0000000..0e384ff --- /dev/null +++ b/scripts/Quick-Build.ps1 @@ -0,0 +1,86 @@ +# Quick-Build.ps1 +# Simple build script that handles file locking issues + +[CmdletBinding()] +param( + [ValidateSet('Debug', 'Release')] + [string]$Configuration = 'Release' +) + +$ProjectRoot = Split-Path $PSScriptRoot -Parent + +Write-Host "PSMinIO Quick Build" -ForegroundColor Cyan +Write-Host "==================" -ForegroundColor Cyan + +# Update version first +Write-Host "Updating version..." -ForegroundColor Yellow +& "$PSScriptRoot\Update-Version.ps1" + +# Clean build +Write-Host "Cleaning previous build..." -ForegroundColor Yellow +dotnet clean "$ProjectRoot\PSMinIO.csproj" --configuration $Configuration --verbosity quiet + +# Build without copying to avoid file locks +Write-Host "Building project..." -ForegroundColor Yellow +dotnet build "$ProjectRoot\PSMinIO.csproj" --configuration $Configuration --verbosity minimal --no-restore + +if ($LASTEXITCODE -ne 0) { + Write-Error "Build failed" + exit 1 +} + +# Manual copy to avoid file locking issues +Write-Host "Copying files manually..." -ForegroundColor Yellow + +$buildOutput = "$ProjectRoot\bin\$Configuration\netstandard2.0" +$moduleDir = "$ProjectRoot\Module\PSMinIO\bin" + +# Ensure module directory exists +if (!(Test-Path $moduleDir)) { + New-Item -ItemType Directory -Path $moduleDir -Force | Out-Null +} + +# Copy files with retry logic +$filesToCopy = @( + @{ Source = "$buildOutput\PSMinIO.dll"; Dest = "$moduleDir\PSMinIO.dll" } + @{ Source = "$buildOutput\PSMinIO.pdb"; Dest = "$moduleDir\PSMinIO.pdb" } + @{ Source = "$buildOutput\Minio.dll"; Dest = "$moduleDir\Minio.dll" } +) + +foreach ($file in $filesToCopy) { + $retryCount = 0 + $maxRetries = 3 + $copied = $false + + while (-not $copied -and $retryCount -lt $maxRetries) { + try { + if (Test-Path $file.Dest) { + Remove-Item $file.Dest -Force -ErrorAction Stop + } + Copy-Item $file.Source $file.Dest -Force -ErrorAction Stop + Write-Host " ✓ Copied: $(Split-Path $file.Source -Leaf)" -ForegroundColor Green + $copied = $true + } catch { + $retryCount++ + if ($retryCount -lt $maxRetries) { + Write-Host " Retry $retryCount for $(Split-Path $file.Source -Leaf)..." -ForegroundColor Yellow + Start-Sleep -Seconds 2 + } else { + Write-Warning " Failed to copy $(Split-Path $file.Source -Leaf): $($_.Exception.Message)" + } + } + } +} + +# Test the module +Write-Host "Testing module..." -ForegroundColor Yellow +try { + $manifest = Test-ModuleManifest "$ProjectRoot\Module\PSMinIO\PSMinIO.psd1" -ErrorAction Stop + Write-Host " ✓ Module is valid: $($manifest.Name) v$($manifest.Version)" -ForegroundColor Green +} catch { + Write-Warning " Module validation failed: $($_.Exception.Message)" +} + +Write-Host "" +Write-Host "✅ Quick build completed!" -ForegroundColor Green +Write-Host "To import: Import-Module .\Module\PSMinIO\PSMinIO.psd1" -ForegroundColor Cyan diff --git a/scripts/Update-Version.ps1 b/scripts/Update-Version.ps1 new file mode 100644 index 0000000..70a58dc --- /dev/null +++ b/scripts/Update-Version.ps1 @@ -0,0 +1,178 @@ +# Update-Version.ps1 +# Updates version information across all PSMinIO project files + +[CmdletBinding()] +param( + [Parameter(Mandatory = $false)] + [switch]$WhatIf +) + +# Import version configuration +. "$PSScriptRoot\..\Version.ps1" + +$ProjectRoot = Split-Path $PSScriptRoot -Parent +$VersionInfo = Get-PSMinIOVersion + +Write-Host "PSMinIO Version Update Script" -ForegroundColor Cyan +Write-Host "=============================" -ForegroundColor Cyan +Write-Host "Current Version: $($VersionInfo.Version)" -ForegroundColor Green +Write-Host "Build Date: $($VersionInfo.BuildDateString)" -ForegroundColor Green +Write-Host "Semantic Version: $($VersionInfo.SemanticVersion)" -ForegroundColor Green +Write-Host "" + +# Define file paths +$FilesToUpdate = @{ + "Module Manifest" = @{ + Path = Join-Path $ProjectRoot "Module\PSMinIO\PSMinIO.psd1" + Type = "ModuleManifest" + } + "Assembly Info" = @{ + Path = Join-Path $ProjectRoot "src\Properties\AssemblyInfo.cs" + Type = "AssemblyInfo" + } + "Project File" = @{ + Path = Join-Path $ProjectRoot "PSMinIO.csproj" + Type = "ProjectFile" + } +} + +function Update-ModuleManifest { + param($FilePath, $VersionInfo) + + if (-not (Test-Path $FilePath)) { + Write-Warning "Module manifest not found: $FilePath" + return + } + + Write-Host "Updating Module Manifest: $FilePath" -ForegroundColor Yellow + + if ($WhatIf) { + Write-Host " [WhatIf] Would update ModuleVersion to: $($VersionInfo.Version)" -ForegroundColor Magenta + Write-Host " [WhatIf] Would update Copyright to: $($VersionInfo.Copyright)" -ForegroundColor Magenta + Write-Host " [WhatIf] Would update Description" -ForegroundColor Magenta + Write-Host " [WhatIf] Would update ReleaseNotes" -ForegroundColor Magenta + return + } + + $content = Get-Content $FilePath -Raw + + # Update version + $content = $content -replace "ModuleVersion\s*=\s*'[^']*'", "ModuleVersion = '$($VersionInfo.Version)'" + + # Update copyright + $content = $content -replace "Copyright\s*=\s*'[^']*'", "Copyright = '$($VersionInfo.Copyright)'" + + # Update description + $escapedDescription = $VersionInfo.Description -replace "'", "''" + $content = $content -replace "Description\s*=\s*'[^']*'", "Description = '$escapedDescription'" + + # Update author and company + $content = $content -replace "Author\s*=\s*'[^']*'", "Author = '$($VersionInfo.Author)'" + $content = $content -replace "CompanyName\s*=\s*'[^']*'", "CompanyName = '$($VersionInfo.CompanyName)'" + + # Update URLs + $content = $content -replace "ProjectUri\s*=\s*'[^']*'", "ProjectUri = '$($VersionInfo.ProjectUri)'" + $content = $content -replace "LicenseUri\s*=\s*'[^']*'", "LicenseUri = '$($VersionInfo.LicenseUri)'" + + # Update release notes (this is more complex due to multiline) + $escapedReleaseNotes = $VersionInfo.ReleaseNotes -replace "'", "''" -replace "`r`n", "`n" -replace "`n", "``n" + $content = $content -replace "ReleaseNotes\s*=\s*@'[^']*'@", "ReleaseNotes = @'`n$($VersionInfo.ReleaseNotes)`n'@" + + $content | Set-Content $FilePath -Encoding UTF8 + Write-Host " ✅ Module manifest updated" -ForegroundColor Green +} + +function Update-AssemblyInfo { + param($FilePath, $VersionInfo) + + if (-not (Test-Path $FilePath)) { + Write-Warning "Assembly info not found: $FilePath" + return + } + + Write-Host "Updating Assembly Info: $FilePath" -ForegroundColor Yellow + + if ($WhatIf) { + Write-Host " [WhatIf] Would update AssemblyVersion to: $($VersionInfo.Version)" -ForegroundColor Magenta + Write-Host " [WhatIf] Would update AssemblyFileVersion to: $($VersionInfo.Version)" -ForegroundColor Magenta + Write-Host " [WhatIf] Would update AssemblyInformationalVersion to: $($VersionInfo.Version)" -ForegroundColor Magenta + Write-Host " [WhatIf] Would update AssemblyCopyright to: $($VersionInfo.Copyright)" -ForegroundColor Magenta + return + } + + $content = Get-Content $FilePath -Raw + + # Update version attributes + $content = $content -replace '\[assembly:\s*AssemblyVersion\("[^"]*"\)\]', "[assembly: AssemblyVersion(`"$($VersionInfo.Version)`")]" + $content = $content -replace '\[assembly:\s*AssemblyFileVersion\("[^"]*"\)\]', "[assembly: AssemblyFileVersion(`"$($VersionInfo.Version)`")]" + $content = $content -replace '\[assembly:\s*AssemblyInformationalVersion\("[^"]*"\)\]', "[assembly: AssemblyInformationalVersion(`"$($VersionInfo.Version)`")]" + + # Update other attributes + $content = $content -replace '\[assembly:\s*AssemblyCopyright\("[^"]*"\)\]', "[assembly: AssemblyCopyright(`"$($VersionInfo.Copyright)`")]" + $content = $content -replace '\[assembly:\s*AssemblyCompany\("[^"]*"\)\]', "[assembly: AssemblyCompany(`"$($VersionInfo.CompanyName)`")]" + $content = $content -replace '\[assembly:\s*AssemblyDescription\("[^"]*"\)\]', "[assembly: AssemblyDescription(`"$($VersionInfo.Description)`")]" + + $content | Set-Content $FilePath -Encoding UTF8 + Write-Host " ✅ Assembly info updated" -ForegroundColor Green +} + +function Update-ProjectFile { + param($FilePath, $VersionInfo) + + if (-not (Test-Path $FilePath)) { + Write-Warning "Project file not found: $FilePath" + return + } + + Write-Host "Updating Project File: $FilePath" -ForegroundColor Yellow + + if ($WhatIf) { + Write-Host " [WhatIf] Project file uses AssemblyInfo.cs for version information" -ForegroundColor Magenta + return + } + + # Project file now uses AssemblyInfo.cs, so no direct updates needed + Write-Host " ✅ Project file uses AssemblyInfo.cs for version information" -ForegroundColor Green +} + +# Process each file +foreach ($fileInfo in $FilesToUpdate.GetEnumerator()) { + $fileName = $fileInfo.Key + $fileData = $fileInfo.Value + + Write-Host "" + Write-Host "Processing: $fileName" -ForegroundColor Cyan + + switch ($fileData.Type) { + "ModuleManifest" { + Update-ModuleManifest -FilePath $fileData.Path -VersionInfo $VersionInfo + } + "AssemblyInfo" { + Update-AssemblyInfo -FilePath $fileData.Path -VersionInfo $VersionInfo + } + "ProjectFile" { + Update-ProjectFile -FilePath $fileData.Path -VersionInfo $VersionInfo + } + } +} + +Write-Host "" +Write-Host "Version Update Summary" -ForegroundColor Cyan +Write-Host "=====================" -ForegroundColor Cyan +Write-Host "Version: $($VersionInfo.Version)" -ForegroundColor Green +Write-Host "Build Date: $($VersionInfo.BuildDateString)" -ForegroundColor Green +Write-Host "Author: $($VersionInfo.Author)" -ForegroundColor Green +Write-Host "Company: $($VersionInfo.CompanyName)" -ForegroundColor Green + +if ($WhatIf) { + Write-Host "" + Write-Host "This was a WhatIf run - no files were actually modified" -ForegroundColor Yellow + Write-Host "Run without -WhatIf to apply changes" -ForegroundColor Yellow +} else { + Write-Host "" + Write-Host "✅ Version update completed successfully!" -ForegroundColor Green + Write-Host "Next steps:" -ForegroundColor Yellow + Write-Host " 1. Build the project: dotnet build --configuration Release" -ForegroundColor White + Write-Host " 2. Test the module: Import-Module .\Module\PSMinIO\PSMinIO.psd1" -ForegroundColor White + Write-Host " 3. Commit changes: git add . && git commit -m 'Update version to $($VersionInfo.Version)'" -ForegroundColor White +} diff --git a/examples/01-Basic-Operations.ps1 b/scripts/examples/01-Basic-Operations.ps1 similarity index 98% rename from examples/01-Basic-Operations.ps1 rename to scripts/examples/01-Basic-Operations.ps1 index 0953e36..3547931 100644 --- a/examples/01-Basic-Operations.ps1 +++ b/scripts/examples/01-Basic-Operations.ps1 @@ -2,7 +2,7 @@ # This script demonstrates fundamental MinIO operations using PSMinIO # Import the module -Import-Module ..\Module\PSMinIO\PSMinIO.psd1 +Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1 # Example connection details (replace with your actual values) $endpoint = "https://minio.example.com" diff --git a/examples/02-Advanced-Object-Listing.ps1 b/scripts/examples/02-Advanced-Object-Listing.ps1 similarity index 99% rename from examples/02-Advanced-Object-Listing.ps1 rename to scripts/examples/02-Advanced-Object-Listing.ps1 index a86aac3..342f0d2 100644 --- a/examples/02-Advanced-Object-Listing.ps1 +++ b/scripts/examples/02-Advanced-Object-Listing.ps1 @@ -2,7 +2,7 @@ # Demonstrates the powerful Get-MinIOObject cmdlet with filtering, sorting, and pagination # Import the module -Import-Module ..\Module\PSMinIO\PSMinIO.psd1 +Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1 # Connection details (replace with your actual values) $endpoint = "https://minio.example.com" diff --git a/examples/03-Directory-Management.ps1 b/scripts/examples/03-Directory-Management.ps1 similarity index 99% rename from examples/03-Directory-Management.ps1 rename to scripts/examples/03-Directory-Management.ps1 index 34bd147..81bcf3f 100644 --- a/examples/03-Directory-Management.ps1 +++ b/scripts/examples/03-Directory-Management.ps1 @@ -2,7 +2,7 @@ # Demonstrates creating nested directory structures and organizing files # Import the module -Import-Module ..\Module\PSMinIO\PSMinIO.psd1 +Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1 # Connection details (replace with your actual values) $endpoint = "https://minio.example.com" diff --git a/examples/04-Chunked-Operations.ps1 b/scripts/examples/04-Chunked-Operations.ps1 similarity index 99% rename from examples/04-Chunked-Operations.ps1 rename to scripts/examples/04-Chunked-Operations.ps1 index 5cd607b..9e15ab9 100644 --- a/examples/04-Chunked-Operations.ps1 +++ b/scripts/examples/04-Chunked-Operations.ps1 @@ -2,7 +2,7 @@ # Demonstrates chunked uploads and downloads for large files with progress tracking # Import the module -Import-Module ..\Module\PSMinIO\PSMinIO.psd1 +Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1 # Connection details (replace with your actual values) $endpoint = "https://minio.example.com" diff --git a/examples/05-Bulk-Operations.ps1 b/scripts/examples/05-Bulk-Operations.ps1 similarity index 99% rename from examples/05-Bulk-Operations.ps1 rename to scripts/examples/05-Bulk-Operations.ps1 index 3fa9450..e8970b0 100644 --- a/examples/05-Bulk-Operations.ps1 +++ b/scripts/examples/05-Bulk-Operations.ps1 @@ -2,7 +2,7 @@ # Demonstrates bulk file operations, batch processing, and automation scenarios # Import the module -Import-Module ..\Module\PSMinIO\PSMinIO.psd1 +Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1 # Connection details (replace with your actual values) $endpoint = "https://minio.example.com" diff --git a/examples/06-Enterprise-Automation.ps1 b/scripts/examples/06-Enterprise-Automation.ps1 similarity index 99% rename from examples/06-Enterprise-Automation.ps1 rename to scripts/examples/06-Enterprise-Automation.ps1 index 4dad6f4..1f81b6b 100644 --- a/examples/06-Enterprise-Automation.ps1 +++ b/scripts/examples/06-Enterprise-Automation.ps1 @@ -2,7 +2,7 @@ # Demonstrates enterprise-grade automation scenarios including monitoring, policies, and scheduled operations # Import the module -Import-Module ..\Module\PSMinIO\PSMinIO.psd1 +Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1 # Connection details (replace with your actual values) $endpoint = "https://minio.example.com" diff --git a/examples/README.md b/scripts/examples/README.md similarity index 99% rename from examples/README.md rename to scripts/examples/README.md index 17869d7..b50f394 100644 --- a/examples/README.md +++ b/scripts/examples/README.md @@ -6,7 +6,7 @@ This directory contains comprehensive examples demonstrating various PSMinIO cap Before running these examples: -1. **Install PSMinIO**: Import the module using `Import-Module ..\Module\PSMinIO\PSMinIO.psd1` +1. **Install PSMinIO**: Import the module using `Import-Module ..\..\Module\PSMinIO\PSMinIO.psd1` 2. **MinIO Server**: Have access to a MinIO server or compatible S3 service 3. **Credentials**: Update the connection details in each script with your actual values: ```powershell diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dd047c4 --- /dev/null +++ b/src/Properties/AssemblyInfo.cs @@ -0,0 +1,42 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PSMinIO")] +[assembly: AssemblyDescription("A comprehensive PowerShell module for MinIO object storage operations with enterprise-grade features including chunked transfers, advanced object listing, directory management, and performance monitoring. Built on the official Minio .NET SDK.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Grace Solutions")] +[assembly: AssemblyProduct("PSMinIO")] +[assembly: AssemblyCopyright("(c) 2025 Grace Solutions. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a1b2c3d4-e5f6-7890-abcd-ef1234567890")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("2025.07.11.1151")] +[assembly: AssemblyVersion("2025.07.11.1151")] +[assembly: AssemblyFileVersion("2025.07.11.1151")] +[assembly: AssemblyInformationalVersion("2025.07.11.1151")] + + + + +