Skip to content
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

[Topic] Move to New Command Line #2202

Merged
merged 13 commits into from
Jul 25, 2024
Merged

[Topic] Move to New Command Line #2202

merged 13 commits into from
Jul 25, 2024

Conversation

MrHinsh
Copy link
Member

@MrHinsh MrHinsh commented Jul 23, 2024

The plan is to move to Spectre.Console for the command line and away from the old tool. This should give us the ability to incorporate more commands easily and have better docs and easier execution.

Actions:

  • Remove the old Command Line and move it to Spectre
  • Move Host Startup inside of the CLI by adding a CommandBase so that the logo, version check, and telemitery check all happen inside...
  • Recreate the access to the config file.
  • .... more....

…rsion and InformationalVersion for better versioning control

feat(MigrationTools.sln): add NKDAgility.AzureDevOps.Tools.CommandHost project to solution for extended functionality
chore(test projects): update MSTest.TestAdapter and MSTest.TestFramework to version 3.5.0 for latest features and bug fixes
chore(MigrationTools.ConsoleDataGenerator.csproj): update YamlDotNet to version 16.0.0 for improved YAML processing
chore(MigrationTools.Host.csproj): update Serilog.Settings.Configuration to version 8.0.2 for enhanced logging configuration

chore: update MSTest.TestAdapter and MSTest.TestFramework versions from 3.4.3 to 3.5.0 in MigrationTools.Integration.Tests, MigrationTools.Tests, and VstsSyncMigrator.Core.Tests projects for latest features and bug fixes
feat: add new project NKDAgility.AzureDevOps.Tools.CommandHost with .NET 8.0 and Newtonsoft.Json 13.0.3 package reference for new functionality
…ommands for better organization and clarity

feat(MigrationTools.Host): introduce new command classes for migration execution and initialization
fix(MigrationTools.Host): update command options to use Spectre.Console.Cli for better command line interface handling

refactor(MigrationTools.Host): remove ExecuteHostedService.cs and InitHostedService.cs, replace with MigrationService.cs for simplified service execution
feat(MigrationTools.Host): add Spectre.Console.Cli and YamlDotNet packages for enhanced CLI and YAML support
chore(MigrationTools.Host): remove unused CommandLineParser package reference from MigrationTools.Host.csproj
style(MigrationTools.Host): remove unused imports in MigrationToolHost.cs for cleaner code
…ct commands

refactor(MigrationExecuteCommand.cs, MigrationInitCommand.cs): change logger type to improve logging context
refactor(MigrationInitCommand.cs): change ExecuteAsync method to async to improve readability and performance
refactor(MigrationService.cs): skip first command line argument to avoid application name in arguments
refactor(MigrationToolHost.cs): refactor host configuration and services setup to improve code readability and maintainability
style(HostExtensions.cs): remove unused import to improve code cleanliness
style(MigrationToolHost.cs): remove commented out code to improve code cleanliness

feat(MigrationTools.Host.csproj): add Spectre.Console.Cli.Extensions.DependencyInjection package to support dependency injection
… to reduce code duplication

refactor(MigrationExecuteCommandSettings.cs, MigrationInitCommandSettings.cs): change base class to CommandSettingsBase to utilize common settings
fix(MigrationExecuteCommandSettings.cs): remove DisableTelemetry property as it's now in CommandSettingsBase
…d execute migration command

Introduce `CommandBase` class to handle common command logic, including
startup logic, telemetry, and version checks. Add `ExecuteMigrationCommand`
to handle the execution of migration tasks, utilizing the `CommandBase`
class for shared functionality. Also, add `ExecuteMigrationCommandSettings`
to define the settings required for the migration command.

These changes are made to modularize the command logic, making it easier
to manage and extend. The `CommandBase` class centralizes common tasks
like telemetry and version checks, reducing code duplication. The
`ExecuteMigrationCommand` class focuses on the specific logic needed to
execute a migration, improving code readability and maintainability.

✨ (InitMigrationCommand): add InitMigrationCommand to initialize migration configurations

✨ (InitMigrationCommandSettings): add settings for InitMigrationCommand

🔧 (MigrationToolHost): update command registration for InitMigrationCommand

The InitMigrationCommand is introduced to allow users to initialize migration configurations with various options. This command supports different configuration modes such as Reference, Basic, WorkItemTracking, Fullv2, and WorkItemTrackingv2, making it flexible for different migration scenarios.

The InitMigrationCommandSettings class is added to handle the settings for the InitMigrationCommand, including the output mode which determines the type of configuration to be generated.

The MigrationToolHost is updated to register the new InitMigrationCommand, ensuring it is available for use within the application. This enhances the tool's functionality by providing a straightforward way to set up migration configurations.

♻️ (StartupService.cs): remove version check and telemetry logging for simplification

Remove the extensive version check and telemetry logging to simplify the startup process. This reduces the complexity and potential overhead during application startup, making the codebase easier to maintain and understand. The removed code includes checks for package manager installation, version updates, and telemetry notes, which are deemed unnecessary for the current scope of the application.
…d organization

♻️ (MigrationToolHost.cs): refactor logging configuration for improved log management and filtering

The launch profiles in `launchSettings.json` are updated to rename and reorganize the profiles for better clarity. The "MigrationTools.ConsoleUI" profile is renamed to "execute" to better reflect its purpose.

In `MigrationToolHost.cs`, the logging configuration is refactored to:
- Introduce a static variable `logs` to manage log file naming.
- Add filtering to exclude logs from specific sources.
- Update the Application Insights connection string to include additional endpoints.
- Use a static `logDate` variable to ensure consistent log directory naming.

These changes improve log management, make the configuration more maintainable, and enhance the clarity of the launch profiles.
…mand-line config file option

⬆️ (MigrationTools.Host.csproj): add System.CommandLine package

Add support for specifying the configuration file via command-line options `--config`, `--configFile`, or `-c`. This enhances flexibility by allowing users to specify a custom configuration file when running the application. The `System.CommandLine` package is added to facilitate this functionality. The `ForceGetConfigFile` method is introduced to parse the command-line arguments and extract the configuration file path. The `CreateDefaultBuilder` method in `MigrationToolHost.cs` is updated to use this configuration file path, ensuring the application loads the correct configuration.
… commit details

♻️ (MigrationToolHost.cs): refactor version logging to use GetRunningVersion method
🔧 (MigrationTools.csproj): add GitVersion property to disable GitVersion during build

The Git metadata in the MigrationTools.xml file is updated to reflect the new branch, commit, and version details. The version logging in MigrationToolHost.cs is refactored to use a new method, GetRunningVersion, which provides a more accurate and detailed version string. Additionally, the GitVersion property is added to the MigrationTools.csproj file to disable GitVersion during the build process, ensuring that the build process does not rely on Git metadata.
…ntation

- Update `MigrationTools.xml` to reflect the latest commit and version info.
- Replace `GetRunningVersion` with `DetectVersionService2.GetRunningVersion` in `MigrationToolHost.cs`.
- Remove the `GetRunningVersion` method from `MigrationToolHost.cs`.
- Enhance `DetectVersionService2` to handle local version detection more robustly.

The changes improve the maintainability and accuracy of version detection by centralizing the logic in `DetectVersionService2`. This also ensures that the XML documentation is up-to-date with the latest commit and version information.
@MrHinsh MrHinsh marked this pull request as ready for review July 25, 2024 13:17
@MrHinsh MrHinsh marked this pull request as draft July 25, 2024 13:17
…Tools.ConsoleFull

♻️ (MigrationToolHost.cs): uncomment log filter for StartupService and add null check for configFile

Adding the 'empty' launch profile provides a new configuration option for running the project without any command line arguments, which can be useful for debugging or initial setup. Uncommenting the log filter for `MigrationTools.Host.StartupService` ensures that logs from this source are excluded, improving log readability. Adding a null check for `configFile` before adding it to the configuration builder prevents potential runtime errors if the file does not exist or the path is empty.
@MrHinsh MrHinsh self-assigned this Jul 25, 2024
@github-actions github-actions bot added the documentation This is an item for a Documentation enhancement label Jul 25, 2024
@MrHinsh MrHinsh removed the request for review from ovebastiansen July 25, 2024 13:29
@MrHinsh MrHinsh marked this pull request as ready for review July 25, 2024 13:29
@MrHinsh MrHinsh enabled auto-merge July 25, 2024 13:30
@MrHinsh MrHinsh merged commit d0cde62 into main Jul 25, 2024
9 checks passed
@MrHinsh MrHinsh deleted the topic/move-cmd branch July 25, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rebuild Launcher with Specter Command and Seralog!
1 participant