Skip to content

Commit d42bb8d

Browse files
committed
Some work on documentation for the project. Still need to update ReadMe with objects for new config
1 parent 5508199 commit d42bb8d

File tree

7 files changed

+82
-18
lines changed

7 files changed

+82
-18
lines changed

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
# Code Updater
22

3-
The purpose of this project is to update all code versioning and dependencies below a directory. This is useful when you have a large number of projects that you want to update all at once. This application is assumed to run on a local machine, and then the changes are manually committed to source control. This allows for a more controlled update process, because a developer is meant to manually check the changes before committing them.
3+
The purpose of this project is to update specific aspects of code below a directory. This is useful when you have a large number of projects that you want to update all at once. This application is assumed to run on a local machine, and then the changes are manually committed to source control. This allows for a more controlled update process, because a developer is meant to manually check the changes before committing them.
44

5-
It would be great to get this to work for all kinds of languages/frameworks someday, but for now it's just .NET and NPM.
5+
It would be great to get this to work for all kinds of languages/frameworks someday, but for now it's just .NET and a little bit for NPM.
66

7-
## What Updates Are Done
7+
## What Updates Cane Be Done
88

9-
- Updates .NET *.csproj files to use a specified C# Language Version
10-
- Updates .NET *.csproj files to use a specified .NET SDK Version (AKA TargetFramework element)
11-
- Updates all NuGet packages in all *.csproj files to the latest version
12-
- Updates all NPM packages in all package.json files to the latest version
9+
- Update .NET *.csproj files to use a specified C# Language Version
10+
- Update .NET *.csproj files to use a specified .NET SDK Version (AKA TargetFramework element)
11+
- Enable/Disable .NET Analyzers in all *.csproj files
12+
- Run `dotnet format` command on all *.csproj files
13+
- Update all NuGet packages in all *.csproj files to the latest version
14+
- Add Nuget auditing properties to all *.csproj files
15+
- Update all NPM packages in all package.json files to the latest version
1316

1417
## How to Use It
1518

16-
Remember, the purpose of this is to update code. It is assumed, and recommended, a developer runs this locally and verifies the changes before comitting to source control. Below are the steps assumed steps a user would follow.
19+
Remember, the purpose of this is to update code. It is assumed, and recommended, a developer runs this locally and verifies the changes before comitting to source control. Below are the assumed steps a user would follow.
1720

1821
There are 2 ways to run this. As a .NET Tool installed on your machine, or downloading the repository and running the code yourself.
1922

2023
1. Install the application. Choose one:
21-
- Install the tool globally by running `dotnet tool install --global ProgrammerAL.Tools.CodeUpdater --version 1.0.0`
24+
- Install the tool globally by running `dotnet tool install --global ProgrammerAL.Tools.CodeUpdater --version <<version number>>`
2225
- Or clone this repository locally
2326
2. Run the application
2427
- If you installed the tool, run it with the command: `code-updater --config "C:/my-repos/my-app-1"`
2528
- If you downloaded the code, open a terminal to the `~/src/CodeUpdater/CodeUpdater` directory and run the application using dotnet run while passing in the required arguments. Example: `dotnet run -- --config "C:/my-repos/my-app-1"`
2629
3. Wait for the application to finish. It will output the number of projects updated, and the number of projects that failed to update.
2730
4. Manually check a diff of all the file changes to ensure everything is as you expect
31+
- Make any manual changes you feel you need to
32+
- If there were any build failures that were caused by the updates, fix those
2833
5. Commit the code changes to source control. Wait for a CI/CD pipeline to run and ensure everything is still working as expected.
2934

3035
## CLI Options
@@ -108,7 +113,7 @@ Below are the list of properties in the config file.
108113

109114
The Code Updater application has a default set of paths to ignore. The list is below. Note that all paths are in the list using both forwardslashes and backslashes. These are in addition to any skip paths passed in with the `IgnorePatterns` config file property. As of right now, there is no way to remove these.
110115

111-
Ignore all obj and bin folders:
116+
Ignore all C# `obj` and `bin` folders:
112117
- /obj/Debug/
113118
- /obj/Release/
114119
- /bin/Debug/
@@ -142,3 +147,14 @@ PowerShell is required as a workaround. The NPM executable on Windows doesn't ru
142147
When updating *.csproj files to a specific `TargetFramework` version, the project is skipped if using .NET Standard. Those are usually set for a specific level of API compatibility so we don't want to mess with those.
143148

144149

150+
## Update Script Sample
151+
152+
You can create a script to make it easy to run Code Updater on a regular basis. A sample PowerShell script to do that is in the `/code-update-runner-sample` directory of this repo. It has the below files:
153+
154+
- `code-updater-config.json`
155+
- Example config file to use when running Code Updater
156+
- `run-code-updater.ps1`
157+
- PowerShell script that runs Code Updater one directory up in the tree, using the given `code-updater-config.json` file as config
158+
159+
Feel free to use those files as a base, and modify them for your repositories as needed. For extra points, commit them to your repository too.
160+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"RootDirectory": "./",
3+
"IgnorePatterns": [],
4+
"CSharpOptions": {
5+
"CsProjVersioningOptions": {
6+
"TreatWarningsAsErrors": true,
7+
"TargetFramework": "net8.0",
8+
"LangVersion": "latest"
9+
},
10+
"CsProjDotNetAnalyzerOptions": {
11+
"EnableNetAnalyzers": true,
12+
"EnforceCodeStyleInBuild": true
13+
},
14+
"CSharpStyleOptions": {
15+
"RunDotnetFormat": true
16+
},
17+
"NugetAuditOptions": {
18+
"NuGetAudit": true,
19+
"AuditMode": "all",
20+
"AuditLevel": "low"
21+
},
22+
"NuGetUpdateOptions": {
23+
"UpdateTopLevelNugetsInCsProj": true,
24+
"UpdateTopLevelNugetsNotInCsProj": true
25+
}
26+
},
27+
"NpmOptions": {
28+
"NpmBuildCommand": "publish"
29+
},
30+
"LoggingOptions": {
31+
"LogLevel": "Verbose",
32+
"OutputFile": "./code-updater-output.txt"
33+
}
34+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
$configPath = "$PSScriptRoot/code-updater-config.json"
3+
$runLocation = "$PSScriptRoot/../"
4+
5+
$startPath = Get-Location
6+
7+
# Change path so the updater runs 1 directory higher, not inside this directory
8+
Set-Location $runLocation
9+
& "code-updater" --config "$configPath"
10+
11+
# Go back to the original path
12+
Set-Location $startPath
13+
14+
Read-Host "Press enter to exit..."

src/CodeUpdater/CodeUpdater/Options/UpdateOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public class CSharpOptions
6767
/// Settings to use for configuring Nuget Audit settings in csproj files.
6868
/// You can read more at https://learn.microsoft.com/en-us/nuget/concepts/auditing-packages#configuring-nuget-audit
6969
/// </summary>
70-
public NugetAuditOptions? NugetAudit { get; set; }
70+
public NugetAuditOptions? NugetAuditOptions { get; set; }
7171

7272
/// <summary>
7373
/// Settings to use for updating NuGet packages in csproj files
7474
/// </summary>
75-
public NuGetUpdateOptions? NuGetUpdates { get; set; }
75+
public NuGetUpdateOptions? NuGetUpdateOptions { get; set; }
7676
}
7777

7878
public class CsProjVersioningOptions

src/CodeUpdater/CodeUpdater/Updaters/CSharpUpdater.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ private async ValueTask<NugetUpdateResults> UpdateNugetPackagesAsync(string csPr
6161
{
6262
try
6363
{
64-
if (cSharpOptions.NuGetUpdates is null)
64+
if (cSharpOptions.NuGetUpdateOptions is null)
6565
{
6666
_logger.Information("No NuGet options provided, skipping NuGet updates");
6767
return new NugetUpdateResults(RetrievedPackageListSuccessfully: true, ImmutableArray<NugetUpdateResult>.Empty);
6868
}
6969

70-
return await _nugetUpdater.UpdateNugetPackagesAsync(csProjFilePath, cSharpOptions.NuGetUpdates);
70+
return await _nugetUpdater.UpdateNugetPackagesAsync(csProjFilePath, cSharpOptions.NuGetUpdateOptions);
7171
}
7272
catch (Exception ex)
7373
{

src/CodeUpdater/CodeUpdater/Updaters/CsProjUpdater.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ private ImmutableArray<ImmutableArray<CsprojUpdateGroupTracker>> DetermineProjec
6161
}
6262
}
6363

64-
if (cSharpOptions.NugetAudit is object)
64+
if (cSharpOptions.NugetAuditOptions is object)
6565
{
66-
var nugetAuditUpdates = GenerateUpdateGroupForNugetAudit(cSharpOptions.NugetAudit);
66+
var nugetAuditUpdates = GenerateUpdateGroupForNugetAudit(cSharpOptions.NugetAuditOptions);
6767

6868
if (nugetAuditUpdates.Any())
6969
{

src/CodeUpdater/CodeUpdater/sampleUpdateOptions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"CSharpStyleOptions": {
1515
"RunDotnetFormat": true
1616
},
17-
"NugetAudit": {
17+
"NugetAuditOptions": {
1818
"NuGetAudit": true,
1919
"AuditMode": "all",
2020
"AuditLevel": "low"
2121
},
22-
"NuGetUpdates": {
22+
"NuGetUpdateOptions": {
2323
"UpdateTopLevelNugetsInCsProj": true,
2424
"UpdateTopLevelNugetsNotInCsProj": true
2525
}

0 commit comments

Comments
 (0)