-
-
Notifications
You must be signed in to change notification settings - Fork 13
Rewritten in C# #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Rewritten in C# #45
Conversation
* Introduce new `PowerForge` project with core abstractions and models: * `ILogger`, `IFileSystem`, `IFormatter`, `ILineEndingsNormalizer`, `IPowerShellRunner` * `ModuleInstallerOptions`, `ModuleInstallerResult`, `InstallationStrategy`, `FormatterResult`, `NormalizationResult` * Add concrete implementations and services: * `ConsoleLogger`, `RealFileSystem`, `LineEndingsNormalizer`, `PowerShellRunner` * `PssaFormatter` (out-of-proc PSScriptAnalyzer formatter), `ModuleInstaller` (versioned installs + pruning) * `PowerForgeFacade` wiring defaults for quick consumption * Add `PowerForge.Cli` dotnet tool (`powerforge`) with `Program.cs` supporting: * `normalize`, `format`, and `install` commands (verbose flag, argument parsing) * Update solution and `PSPublishModule.csproj`: * Add `PowerForge` and `PowerForge.Cli` projects to solution * Reference `PowerForge` from `PSPublishModule` for non-netstandard targets * Add `TODO.md` describing migration goals, architecture and roadmap * Key behaviors & safeguards: * Deterministic line-ending/encoding normalization (CRLF default, BOM configurable) * Out-of-proc formatting with timeouts and graceful fallback when PowerShell/PSSA is unavailable * Atomic staged installs, auto-revision strategy and pruning of old versions
…options * Add `FormatOptions` to configure preprocessing, PSSA settings, timeout, line endings and BOM. * Introduce `FormattingPipeline` to orchestrate preprocessing, PSSA formatting and normalization. * Add `Preprocessor` service that runs an out-of-process PowerShell script to strip comments and trim empty lines (flags passed as base64 JSON) and reports per-file results. * Extend `PssaFormatter` and `IFormatter` with `FormatFilesWithSettings` to accept PSScriptAnalyzer settings (passed as base64 JSON) and apply them when invoking `Invoke-Formatter`. * Ensure graceful fallbacks for missing PowerShell runtime and timeouts; return consistent `FormatterResult` entries for all inputs.
…ersionedInstallKeep` docs; remove deprecated Convert-* docs * Add `VersionedInstallStrategy` and `VersionedInstallKeep` parameter documentation to `New-ConfigurationBuild` (synopsis, examples, parameter details). Defaults: `AutoRevision` and `3`. * Update example splat to include `VersionedInstallStrategy = 'AutoRevision'` and `VersionedInstallKeep = 3`. * Remove obsolete help files `Convert-ProjectEncoding.md` and `Convert-ProjectLineEnding.md`. * Clean up `Module/Docs/Readme.md` by removing references to the removed Convert-* cmdlet docs.
…; remove legacy PS scripts; extend build config * Add `ConvertProjectEncodingCommand.cs` and `ConvertProjectLineEndingCommand.cs` as thin C# wrappers around `PowerForge.EncodingConverter` and `PowerForge.LineEndingConverter`. * New cmdlets accept the same high-level options (`ProjectKind`, custom patterns, backups, `PassThru`, etc.) and produce per-file results or a concise summary. * Preserve safety defaults (e.g. prefer UTF8-BOM for PowerShell) and backup handling. * Remove legacy public PowerShell implementations: * `Module/Public/Convert-ProjectEncoding.ps1` * `Module/Public/Convert-ProjectLineEnding.ps1` * Extend `New-ConfigurationBuild.ps1` with new build/install options: * Add `VersionedInstallStrategy` and `VersionedInstallKeep` parameters and include them in build metadata when provided. * Add locker control flags: `KillLockersBeforeInstall`, `KillLockersForce`. * Add `AutoSwitchExactOnPublish` and include behavior to emit corresponding `BuildModule` metadata entries. * Motivation/context: * Move heavy-lifting into typed .NET implementations (PowerForge) for better reliability, testability and reuse. * Remove duplicated/legacy PS implementations in favor of centralized converters. * Expose versioned-install and locker control options in build configuration to support safer iterative development and deployment workflows.
…ditor, lock inspector, enumerator; harden installer and add PS SDK refs * Add project/file conversion abstractions: `ProjectConversionOptions` types (`ProjectEnumeration`, `FileConversion`, `ProjectConversionResult`, `EncodingConversionOptions`, `LineEndingConversionOptions`, `TextEncodingKind`, `ProjectKind`). * Implement `EncodingConverter` and `LineEndingConverter` with detection, backup/verification, BOM handling and options for force/only-mixed/ensure-final-newline. * Add `ProjectFileEnumerator` to discover files by project kind or custom patterns while honoring exclude directories. * Add `ManifestEditor` to safely read/modify PSD1 hashtable entries using the PowerShell AST (get/set strings and arrays, insert keys). * Add `LockInspector` to report and optionally terminate processes locking files via Windows Restart Manager (no-op on non-Windows). * Harden `ModuleInstaller`: fallback copy locations for permission/IO issues, cross-volume rename handling, collect installation failures, expose `ResolveTargetVersion`, and best-effort directory deletion. * Update `PowerForge.csproj` to reference `Microsoft.PowerShell.SDK` for `net8.0` and `Microsoft.PowerShell.5.ReferenceAssemblies` for `net472`. * Provides core tooling for project-wide encoding/line-ending fixes, manifest manipulation and safer installs.
…ersioned install * Add `PSPublishModule/BuildServices.cs` — C# facade exposing `Format`, `FormatFiles`, `NormalizeFiles`, `InstallVersioned`, `GetLockingProcesses` and `TerminateLockingProcesses` to drive robust formatting, normalization and versioned installation from PowerShell. * Remove legacy `Format-Code.ps1` and update `Merge-Module`, `Start-ModuleBuilding` to call into `PSPublishModule.BuildServices::Format(...)`. Convert `FormatterSettings` to JSON and pass to C# pipeline. * Implement versioned installs in `Start-ModuleBuilding` using `BuildServices.InstallVersioned`: support `VersionedInstallStrategy` (`AutoRevision`/`Exact`), retention via `VersionedInstallKeep`, optional locker detection/termination (`KillLockersBeforeInstall`/`KillLockersForce`) and resolved-version install. * Improve self-build resilience: load `PowerForge.dll`/`PSPublishModule.dll` from project `Lib` when assemblies are missing. * Harden module import fallback in `Start-ImportingModules` — attempt PSD1/PSM1 under user module roots with clear errors. * Bump `PSPublishModule.psd1` `ModuleVersion` to `2.0.27`, update exported functions and enable exporting `Cmdlet '*'` in `PSPublishModule.psm1`. * Tidy `PSPublishModule.csproj` (formatting, enable nullable/docs/warnings) and add nullable annotations in `OnImportAndRemove`. * Update `TODO.md` to reflect CLI/branding rename and recommended dev build settings.
* Removed support for `netstandard2.0` and updated project references. * Added new methods for detecting script functions, cmdlets, and aliases. * Improved manifest export settings handling. * Cleaned up code by removing unnecessary preprocessor directives.
…detection * Refactor `Merge-Module` to use `[PowerForge.BuildServices]` instead of `[PSPublishModule.BuildServices]`. * Implement auto-detection of exports (functions/cmdlets/aliases) and write into PSD1 using C# services. * Enhance error handling for export detection failures.
… new classes and methods for export detection and manifest editing * Introduced `ExportSet` class to represent detected exports for module manifests. * Added `BuildServices` class with methods for file formatting, normalization, and module installation. * Implemented `ExportDetector` for detecting functions, cmdlets, and aliases from scripts and binaries. * Enhanced `ManifestEditor` with methods for managing `RequiredModules` in PSD1 files. * Updated project dependencies to include `System.Reflection.MetadataLoadContext`.
…ionaries method and new ManifestWriter class * Implemented `SetRequiredModulesFromDictionaries` to handle PowerShell dictionaries for required modules. * Introduced `ManifestWriter` class to generate well-formatted PSD1 manifests. * Enhanced modularity and maintainability of the codebase.
…e `Show-ProjectDocumentation` * Enhanced the `New-ConfigurationBuild` documentation with new parameters `-VersionedInstallStrategy` and `-VersionedInstallKeep`. * Removed the obsolete `Show-ProjectDocumentation` file to streamline documentation.
…ry important links and PSData sub-hashtable arrays * Implemented `SetDeliveryImportantLinks` in `BuildServices` to set `PrivateData.PSData.Delivery.ImportantLinks` from PowerShell dictionaries. * Added `TrySetPsDataSubHashtableArray` in `ManifestEditor` for setting PSData sub-hashtable arrays, enhancing manifest editing capabilities.
…y loading and module build options * Improved handling of local assemblies in `ExportDetector` for better resolution. * Added detailed XML documentation for `ModuleBuilder` options and methods. * Refactored `Build` method to `BuildInPlace` for clarity and separation of concerns. * Enhanced export detection logic to ensure proper handling of module DLLs.
* Implemented the `build` command to facilitate module building. * Added argument parsing for module properties such as `--name`, `--project-root`, `--csproj`, and `--version`. * Introduced staging directory management with error handling for existing directories. * Enhanced logging for build success and errors.
… improve output structure * Added XML documentation for parameters to clarify their purpose. * Updated output structure to use `ResolvedVersion` for better clarity.
* Added handling for null or empty arguments by appending `""` to the command. * Enhanced the argument construction logic to ensure proper formatting.
* Preserve existing manifest metadata when updating the module version and key fields. * Introduce conditional logic to either patch the manifest or generate a new one based on its existence.
- Introduced multiple cmdlets to facilitate the configuration of PowerShell module publishing, including: - `New-ConfigurationImportModule`: Configures module import settings. - `New-ConfigurationInformation`: Describes module build inclusion/exclusion. - `New-ConfigurationManifest`: Creates a manifest configuration for modules. - `New-ConfigurationModule`: Configures required, external, or approved modules. - `New-ConfigurationModuleSkip`: Allows skipping certain modules during the build. - `New-ConfigurationPlaceHolder`: Defines custom placeholders for content replacement. - `New-ConfigurationPublish`: Configures publishing settings for PowerShell Gallery or GitHub. - `New-ConfigurationTest`: Configures Pester test execution in the build. - `Set-ProjectVersion`: Updates version numbers across multiple project files. These cmdlets enhance the module publishing workflow, providing better control and flexibility for developers.
…gument completion and value pruning * Introduced `AutoLatestCompleter` to provide argument completion for "Auto" and "Latest". * Added `EmptyValuePruner` to remove empty values from dictionaries, with optional recursive pruning. * Implemented `ProjectVersionScanner` to discover project version information from various file types.
* Deleted obsolete functions for retrieving module versions from various files: - `Get-CurrentVersionFromBuildScript` - `Get-CurrentVersionFromCsProj` - `Get-CurrentVersionFromPsd1` - `Update-VersionInBuildScript` - `Update-VersionInCsProj` - `Update-VersionInPsd1` - `Update-VersionNumber` * Streamlined the module by removing unused code to enhance maintainability.
…tation * Introduced enums for `PublishDestination`, `ModuleDependencyKind`, `FileConsistencyEncoding`, `FileConsistencyLineEnding`, `DeliveryBundleDestination`, `DocumentationTool`, and `ArtefactType`. * These enums enhance the configuration options for module publishing and documentation generation.
…ands - Introduced `Get-ProjectEncoding` cmdlet to analyze encoding consistency across project files. - Introduced `Get-ProjectLineEnding` cmdlet to analyze line ending consistency across project files. - Both cmdlets support customizable project types, exclusion of directories, and export of detailed reports to CSV. - Enhanced user feedback with detailed summaries and recommendations for fixing issues.
…g detection * Introduced `DetectEncodingName` method to identify file encoding based on BOM and content. * Added `DetectLineEnding` method to analyze line endings and determine if a final newline exists. * Implemented `ComputeRelativePath` for generating relative paths based on base directory.
…nctionality * Removed legacy PowerShell scripts for test failure analysis and comment removal. * Introduced new C# cmdlets: `Get-ModuleTestFailures` and `Remove-Comments`. * Enhanced error handling and output formatting in the new cmdlets. * Improved performance and maintainability by leveraging C# features. * Updated documentation to reflect changes in cmdlet usage and parameters.
* Updated the module import in the test file to use a local path instead of the installed copy. * This change ensures that tests run against the latest version of the module from the repository.
- Deleted several private functions that are no longer in use: * `Get-FilteredScriptCommands` * `Get-ProjectCleanupPatterns` * `Get-ProjectItemsToRemove` * `Get-RestMethodExceptionDetailsOrNull` * `Get-ScriptCommands` * `Invoke-RestMethodAndThrowDescriptiveErrorOnFailure` * `New-ProjectItemBackups` * `Register-DataForInitialModule` * `Remove-ChildItems` * `Remove-FileItem` * `Remove-ProjectItemsWithMethod` * `Send-FilesToGitHubRelease` * `Test-AllFilePathsAndThrowErrorIfOneIsNotValid` * `Test-ExcludedPath` - These functions were removed to streamline the codebase and eliminate redundancy.
- Deleted `Publish-GitHubReleaseAsset.ps1`, `Publish-NugetPackage.ps1`, `Register-Certificate.ps1`, `Remove-ProjectFiles.ps1`, and `Send-GitHubRelease.ps1` scripts. - These scripts are no longer needed and have been removed to streamline the module.
* Implemented `Remove-ProjectFiles` cmdlet for safe deletion of project files and folders with backup options. * Introduced `Send-GitHubRelease` cmdlet to create GitHub releases and upload assets. * Both cmdlets include comprehensive parameter sets for flexibility and user control. * Enhanced error handling and user feedback for improved usability.
…tion settings * Introduced `CompatibilitySettings` and `FileConsistencySettings` properties in `ModulePipelinePlan`. * Enhanced `ModulePipelineResult` to include reports and statuses for file consistency and compatibility checks. * Updated `ModulePipelineRunner` to process and validate configurations for compatibility and file consistency. * Added validation steps in `ModulePipelineStep` for checking file consistency and PowerShell compatibility. * Implemented a new `ConfigurationSegmentJsonConverter` for polymorphic JSON conversion of configuration segments.
…y and compatibility * Implemented validation checks for file consistency and compatibility settings in the pipeline summary. * Enhanced user feedback by displaying the status and compliance percentage for file consistency. * Added support for displaying compatibility status and cross-compatibility percentage.
… compatibility * Introduced a new test `Create_IncludesValidationSteps_WhenEnabled` to verify that validation steps for file consistency and compatibility are included in the module pipeline. * Ensured that the validation steps are correctly ordered and enabled based on the configuration settings.
…ipeline configuration - Introduced `JsonOnly` switch parameter to generate a PowerForge pipeline JSON file without executing the build. - Added `JsonPath` parameter to specify the output path for the generated JSON file. - Implemented methods to prepare and write the pipeline specification to JSON format. - Enhanced logging to indicate success or failure of JSON generation. feat(SpectrePipelineConsoleUi): ✨ Improve validation summary display - Added file consistency and compatibility validation summaries to the console output. - Implemented methods to count issues in the project consistency report.
* Introduced parameters for `Runtime`, `Configuration`, `Framework`, and `Flavor` to enhance build customization. * Implemented logic for output directory management and staging options. * Added support for zipping the output files after the build process.
…olution * Default to clearing the output directory when using a staging publish directory unless specified otherwise. * Include a new parameter `/p:IncludeAllContentForSelfExtract` for better content management. * Improve template location resolution by allowing callers to specify `TemplateRootPath`, enhancing reliability.
* Expanded the `Runtime` parameter options to include `linux-x64`, `linux-arm64`, `linux-musl-x64`, `linux-musl-arm64`, `osx-x64`, and `osx-arm64`. * Updated the logic for determining the friendly executable name to accommodate the new runtime options.
* Added `DotNetPublishStyle`, `DotNetPublishTargetKind`, and `DotNetPublishStepKind` enums to define publish styles and target kinds. * Implemented `DotNetPublishPlan`, `DotNetPublishTarget`, `DotNetPublishResult`, and `DotNetPublishSpec` classes to structure the publish process. * Included detailed properties for managing publish configurations, outputs, and steps in the pipeline.
- Added `DotNetPublishPipelineRunner` to manage the configuration-driven `dotnet publish` workflow. - Introduced `IDotNetPublishProgressReporter` interface for reporting progress during the publish steps. - Enhanced `ModuleBuilder` to support exporting specified assembly files and their XML documentation. - Implemented documentation synchronization in `ModulePipelineRunner` to keep project documentation up-to-date.
- Introduced `dotnet` command to handle publishing of .NET projects. - Added support for configuration via `--config` option. - Implemented interactive view handling for better user experience. - Enhanced error handling and output for JSON responses.
…alues * Changed `ProjectPath` in `InvokeDotNetReleaseBuildCommand` and `PublishGitHubReleaseAssetCommand` to accept an array of strings. * Enhanced `PublishNugetPackageCommand` to handle multiple paths for NuGet package publishing. * Added `SkipDuplicate` parameter to `PublishNugetPackageCommand` for idempotent publishing.
* Introduced `powerforge.dotnetpublish.schema.json` for validating DotNet publish configurations. * Added `powerforge.dotnetpublish.json` to define DotNet publish settings and targets. * Updated `JSON_SCHEMA.md` to include the new DotNet publish schema reference.
…upport * Changed `$Runtime` from a single string to a string array to allow multiple runtimes. * Introduced `Resolve-OutDir` function to dynamically determine output directories based on runtime. * Updated publishing logic to handle multiple runtimes and staging directories effectively. * Improved output management and cleanup processes for better build stability.
* Introduced `UpdateProjectRoot` option in `FormattingOptions` and `FileConsistencySettings` to apply formatting and consistency checks to the project root. * Updated `ModulePipelineStep` to include formatting as a step in the pipeline. * Enhanced `DotNetPublishResult` to capture failure details, including optional logs and output. * Added new properties in `ModulePipelineResult` for project-root file consistency reports and formatting results.
…cessing * Added support for `formatting` in the module pipeline. * Improved error handling for PSScriptAnalyzer not found scenarios. * Introduced `PssaFormattingDefaults` for default settings management. * Enhanced zip file creation to avoid self-referencing during compression.
…h commands * Refactored progress bar width calculation into `ComputeBarWidth` method for better readability. * Enhanced error reporting by adding detailed failure information in the console output. * Updated command usage instructions to include new options for validation and target specifications.
…text * Refactored multiple cmdlets to invoke script blocks directly, addressing module context limitations. * Added `UpdateProjectRoot` parameter to `NewConfigurationFileConsistencyCommand` and `NewConfigurationFormatCommand` for enhanced file consistency checks.
…oot options * Added `minLength` validation for `Framework` property. * Introduced `Frameworks` array with `minItems` validation. * Updated `anyOf` requirement to allow either `Framework` or `Frameworks`. * Added `UpdateProjectRoot` boolean property to relevant schemas.
Comprehensive PR Review: PowerForge Architecture MigrationExecutive SummaryThis PR represents a massive architectural transformation with 36,679 additions across ~100 files and 48 commits. This is a fundamental rewrite that migrates PSPublishModule from PowerShell-only to a modern hybrid C#/PowerShell architecture centered around the new PowerForge core library. 🔴 Critical Status: All CI builds are currently FAILING. This PR cannot be merged in its current state. Overall Score: 5.5/10 - Outstanding architecture, but critical security and testing gaps prevent merge. 🏗️ ARCHITECTURE (8/10)✅ Strengths
|
* Introduced properties for `GenerateInstallCommand` and `GenerateUpdateCommand` in `DeliveryOptionsConfiguration`. * Added optional command name overrides for generated commands. * Updated `ModulePipelinePlan` to include delivery metadata configuration.
…stallation and updates * Added `DeliveryCommandGenerator` class to generate PowerShell commands for installing and updating modules. * Enhanced `ModulePipelineRunner` to apply delivery metadata and generate commands based on configuration. * Updated `ModuleDependencyInstaller` and `PSResourceGetClient` to support new delivery options and credential handling.
* Implement tests to verify the creation of install and update scripts. * Ensure that scripts are not regenerated if they already exist.
…ry commands * Introduced new parameters in `NewConfigurationArtefactCommand` for handling repository credentials and paths. * Added options in `NewConfigurationDeliveryCommand` for generating install and update commands with customizable names. * Updated JSON schema to reflect new configuration options for modules and commands.
Pull Request Review: PowerForge Architecture Migration (PR #45)Executive SummaryThis PR represents a transformational architectural migration - rewriting PSPublishModule from PowerShell-only to a modern hybrid C#/PowerShell architecture with a new PowerForge core library. This is a massive change affecting 365+ files with 37,374 additions and 20,365 deletions. Overall Assessment: EXCELLENT WORK ⭐⭐⭐⭐½ (4.5/5) Recommendation: APPROVE with minor observations This is high-quality, well-architected code that significantly modernizes the module. The architectural decisions are sound, code quality is strong, and backward compatibility is maintained. While there are areas for improvement (primarily test coverage), none are blockers for merging. 🎯 Architectural Strengths1. Clean Separation of Concerns ⭐⭐⭐⭐⭐
This separation enables reuse across PowerShell, CLI, and future VSCode extensions without code duplication. 2. Strong Type Safety ⭐⭐⭐⭐⭐
3. Multi-Targeting Excellence ⭐⭐⭐⭐⭐
4. Robust Abstractions ⭐⭐⭐⭐⭐Clean interfaces enable testability and flexibility:
5. Backward Compatibility ⭐⭐⭐⭐⭐
💻 Code Quality AssessmentStrengths ✅
Areas for Improvement
|
… generating fallback examples - Introduced `SyncExternalHelpToProjectRoot` to sync generated external help files back to the project root during updates. - Added `IncludeAboutTopics` to convert help topic files into markdown pages. - Implemented `GenerateFallbackExamples` to create basic example blocks for cmdlets lacking examples.
… examples * Added `AboutTopicWriter` to generate about topics from help files. * Introduced `DocumentationFallbackEnricher` to enrich command documentation with fallback examples. * Updated `MarkdownHelpWriter` to include online version and improved markdown formatting. * Enhanced `DocumentationExtractionPayload` with additional properties for module version and project URI. * Implemented logic to resolve XML documentation paths more effectively in `ModuleBuilder`. * Improved error handling and logging throughout the documentation generation process. * Added support for deleting existing external help files in `DocumentationEngine`.
* Enables access to internal members for the "PowerForge.Tests" assembly. * Facilitates unit testing of internal functionalities.
…opicMarkdown * Implement tests to verify example generation from syntax in `DocumentationFallbackEnricher`. * Add test to ensure correct conversion of help text to Markdown in `AboutTopicMarkdown`.
* Introduced `SyncExternalHelpToProjectRoot`, `IncludeAboutTopics`, and `GenerateFallbackExamples` boolean options to the documentation configuration schema. * These enhancements allow for more flexible documentation generation and management in PowerForge.
Pull Request Review: PSPublishModule Rewrite in C#OverviewThis is a massive architectural transformation that rewrites PSPublishModule from a PowerShell-only implementation to a multi-component system with:
Scope: 100+ files changed, 38,320 additions, 20,365 deletions (300+ files affected - exceeds GitHub's diff display limit) ✅ Strengths1. Excellent Documentation & Migration Support
2. Well-Structured C# Architecture
3. Backward Compatibility Maintained
4. Smart Module Loading Strategy
5. Modern Build Tooling
6. Proper Dependency Management
|
No description provided.