-
-
Notifications
You must be signed in to change notification settings - Fork 85
Add automated upgrade assistant for appsettings.json migrations #463
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed as the current release is version 11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed Migration_8_To_9 and Migration_9_To_11 since users are upgrading from version 11.0. Only the 11.0β12.0 migration is needed now. (2fe1a4d)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed as the current release is version 11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed Migration_8_To_9 and Migration_9_To_11. Only keeping Migration_11_To_12 for the current upgrade path. (2fe1a4d)
| @@ -0,0 +1,48 @@ | |||
| namespace LinkDotNet.Blog.UpgradeAssistant; | |||
|
|
|||
| public static class ConsoleOutput | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use Spectre.Console instead of your own solution. Which may allow automation later on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced custom ConsoleOutput with Spectre.Console. Now using AnsiConsole.MarkupLine for colorful output with better formatting. (2fe1a4d)
|
|
||
| public sealed class MigrationManager | ||
| { | ||
| private const string CurrentVersion = "12.0"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should resolve this from the current highest ToVersion of IMigration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CurrentVersion is now dynamically resolved from the highest ToVersion in the migrations list. Makes it easier to extend in the future. (2fe1a4d)
| @@ -0,0 +1,119 @@ | |||
| ο»Ώusing CommandLine; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if Spectre.Console might be also a solution so we only have one external dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced CommandLineParser with Spectre.Console. Now using simple argument parsing with Spectre.Console for beautiful help display with FigletText and formatted tables. (2fe1a4d)
| ``` | ||
|
|
||
| This will: | ||
| 1. Find all `appsettings*.json` files in the current directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically the appsettings.json should have no need of migration, as this should be from the repository. Make also sure that is the case in the Migrationmanager itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added check to skip version-controlled appsettings.json file. The tool now only migrates environment-specific files like appsettings.Development.json, appsettings.Production.json, etc. Also updated GetAppsettingsFiles() to filter out appsettings.json. (2fe1a4d)
|
@copilot Add the two projects to the root level solution file (LinkDotNet.Blog.sln). |
Added both LinkDotNet.Blog.UpgradeAssistant and LinkDotNet.Blog.UpgradeAssistant.Tests to LinkDotNet.Blog.sln. Removed inline comments and replaced them with descriptive method names like |
|
@copilot Very good. |
Added comprehensive documentation about the Automated Upgrade Assistant:
|
- Created LinkDotNet.Blog.UpgradeAssistant console tool in tools folder - Implemented migration framework with version tracking - Added migrations for 8.0β9.0, 9.0β11.0, and 11.0β12.0 - Colorful console output using ANSI colors - Automatic backup functionality with timestamps - Dry-run mode to preview changes - Comprehensive documentation in docs/Migrations/UpgradeAssistant.md - Updated MIGRATION.md to reference the new tool - Added ConfigVersion field to appsettings.json - Added backups/ to .gitignore Co-authored-by: linkdotnet <[email protected]>
- Created test project LinkDotNet.Blog.UpgradeAssistant.Tests - Added comprehensive tests for Migration8To9, Migration9To11, Migration11To12 - Added tests for MigrationManager including end-to-end scenarios - All 17 tests passing Co-authored-by: linkdotnet <[email protected]>
- Remove OutputType from test project csproj - Fix document disposal pattern in MigrationManager - Use separate variable for each migration document Co-authored-by: linkdotnet <[email protected]>
β¦p appsettings.json - Replace CommandLineParser with Spectre.Console for CLI and colorful output - Remove Migration_8_To_9 and Migration_9_To_11 (current version is 11.0) - Make CurrentVersion dynamic based on highest ToVersion from migrations - Skip version-controlled appsettings.json file during migration - Update tests to reflect changes (9 tests passing) - Enhanced help and version output with Figlet text and tables Co-authored-by: linkdotnet <[email protected]>
- Added LinkDotNet.Blog.UpgradeAssistant and LinkDotNet.Blog.UpgradeAssistant.Tests to LinkDotNet.Blog.sln - Removed inline comments from code, using descriptive method names instead - Extracted ParseCommandLineArguments method for better code organization - Created DetermineCurrentVersionFromMigrations and IsVersionControlledAppsettingsFile methods - Kept only XML documentation comments (///) which are standard - All tests passing (9/9) Co-authored-by: linkdotnet <[email protected]>
- Added chapter about Automated Configuration Migration (Version 12+) in docs/Migrations/Readme.md - Documented Upgrade Assistant features, usage examples, and benefits - Added "Automated Configuration Migration" as a feature in main Readme.md - Provided clear migration path: automated for v12+, manual for pre-v12 Co-authored-by: linkdotnet <[email protected]>
14f358f to
5e48cf1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work.
I have added a suggestion which you can consider in future if needed.
| AnsiConsole.MarkupLine($"[dim]Target Blog Version: 12.0[/]"); | ||
| } | ||
|
|
||
| static void ParseCommandLineArguments(string[] args, ref string targetPath, ref string backupDirectory, ref bool dryRun, ref bool showHelp, ref bool showVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use something like timewarp-nuru to parse command line arguments more easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will use CommandLineParser as this is already used in CriticalCSS project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But thanks for the hint - I was missing that.
Much appreciated @Arnab-Developer
Upgrade Assistant for appsettings.json β
Successfully implemented an automated upgrade assistant tool for migrating
appsettings.jsonfiles between major versions of the blog application.π― Recent Changes
β Documentation Updates
docs/Migrations/Readme.mdReadme.mdβ Added projects to solution file
β Removed unnecessary inline comments
DetermineCurrentVersionFromMigrations()instead of comment about determining versionIsVersionControlledAppsettingsFile()instead of comment about skipping filesParseCommandLineArguments()extracted as named methodπ Implementation Summary
Migration Tool (
tools/LinkDotNet.Blog.UpgradeAssistant)-p/--path,-d/--dry-run,-b/--backup-diroptionsConfigVersionfieldDocumentation (
docs/Migrations/)Tests: 9/9 passing β
π Usage Example
All feedback addressed!
Original prompt
application.jsonΒ #372π‘ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.