mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 06:00:21 +00:00 
			
		
		
		
	Added update app version method
This commit is contained in:
		
							parent
							
								
									948b8918f7
								
							
						
					
					
						commit
						3b5bcd87ea
					
				
							
								
								
									
										10
									
								
								app/Build/Commands/PrepareAction.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/Build/Commands/PrepareAction.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					namespace Build.Commands;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public enum PrepareAction
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    NONE,
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    PATCH,
 | 
				
			||||||
 | 
					    MINOR,
 | 
				
			||||||
 | 
					    MAJOR,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -15,6 +15,49 @@ public sealed partial class UpdateMetadataCommands
 | 
				
			|||||||
        await this.UpdateTauriVersion();
 | 
					        await this.UpdateTauriVersion();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private async Task UpdateAppVersion(PrepareAction action)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        const int APP_VERSION_INDEX = 0;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (action == PrepareAction.NONE)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Console.WriteLine("- No action specified. Skipping app version update.");
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        var pathMetadata = Environment.GetMetadataPath();
 | 
				
			||||||
 | 
					        var lines = await File.ReadAllLinesAsync(pathMetadata, Encoding.UTF8);
 | 
				
			||||||
 | 
					        var currentAppVersionLine = lines[APP_VERSION_INDEX].Trim();
 | 
				
			||||||
 | 
					        var currentAppVersion = AppVersionRegex().Match(currentAppVersionLine);
 | 
				
			||||||
 | 
					        var currentPatch = int.Parse(currentAppVersion.Groups["patch"].Value);
 | 
				
			||||||
 | 
					        var currentMinor = int.Parse(currentAppVersion.Groups["minor"].Value);
 | 
				
			||||||
 | 
					        var currentMajor = int.Parse(currentAppVersion.Groups["major"].Value);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        switch (action)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            case PrepareAction.PATCH:
 | 
				
			||||||
 | 
					                currentPatch++;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            case PrepareAction.MINOR:
 | 
				
			||||||
 | 
					                currentPatch = 0;
 | 
				
			||||||
 | 
					                currentMinor++;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            case PrepareAction.MAJOR:
 | 
				
			||||||
 | 
					                currentPatch = 0;
 | 
				
			||||||
 | 
					                currentMinor = 0;
 | 
				
			||||||
 | 
					                currentMajor++;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        var updatedAppVersion = $"{currentMajor}.{currentMinor}.{currentPatch}";
 | 
				
			||||||
 | 
					        Console.WriteLine($"- Updating app version from '{currentAppVersionLine}' to '{updatedAppVersion}'.");
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        lines[APP_VERSION_INDEX] = updatedAppVersion;
 | 
				
			||||||
 | 
					        await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private async Task UpdateLicenceYear(string licenceFilePath)
 | 
					    private async Task UpdateLicenceYear(string licenceFilePath)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        var currentYear = DateTime.UtcNow.Year.ToString();
 | 
					        var currentYear = DateTime.UtcNow.Year.ToString();
 | 
				
			||||||
@ -224,4 +267,7 @@ public sealed partial class UpdateMetadataCommands
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    [GeneratedRegex("""([0-9]{4})""")]
 | 
					    [GeneratedRegex("""([0-9]{4})""")]
 | 
				
			||||||
    private static partial Regex ReplaceCopyrightYearRegex();
 | 
					    private static partial Regex ReplaceCopyrightYearRegex();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    [GeneratedRegex("""(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<patch>[0-9]+)""")]
 | 
				
			||||||
 | 
					    private static partial Regex AppVersionRegex();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user