From c894eeb81205047036859dce1aee240dadc6a0c5 Mon Sep 17 00:00:00 2001 From: Bart Koelman <104792814+bart-vmware@users.noreply.github.com> Date: Mon, 21 Jul 2025 15:20:37 +0200 Subject: [PATCH] Update version spec, replace deprecated command-line arguments --- Dockerfile | 2 +- install-template.sh | 2 +- .../Controllers/NewController.cs | 8 ++++---- .../Controllers/NewControllerTest.cs | 18 +++++++++--------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11db87c..67a62cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN dotnet build src/NetCoreToolService --configuration Release --no-restore RUN dotnet publish src/NetCoreToolService --output /srv --no-build FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine -ARG templates_version=1.4.1 +ARG templates_version=1.*-* ARG TEMPLATE_CHECKOUT_TARGET WORKDIR /srv COPY --from=build /srv . diff --git a/install-template.sh b/install-template.sh index 9763a38..504a2ab 100644 --- a/install-template.sh +++ b/install-template.sh @@ -4,7 +4,7 @@ dotnet nuget add source https://pkgs.dev.azure.com/dotnet/Steeltoe/_packaging/ci if [[ -z "$TEMPLATE_CHECKOUT_TARGET" ]] ;then dotnet new install Steeltoe.NetCoreTool.Templates::${templates_version} &&\ - dotnet new --list | grep steeltoe-webapi + dotnet new list | grep steeltoe-webapi else cd /usr/local/src git clone https://github.com/SteeltoeOSS/NetCoreToolTemplates diff --git a/src/NetCoreToolService/Controllers/NewController.cs b/src/NetCoreToolService/Controllers/NewController.cs index b0025dd..ca835b7 100644 --- a/src/NetCoreToolService/Controllers/NewController.cs +++ b/src/NetCoreToolService/Controllers/NewController.cs @@ -67,9 +67,9 @@ public async Task GetTemplates() [HttpPut("nuget/{nuGetId}")] public async Task InstallTemplates(string nuGetId) { - await _commandExecutor.ExecuteAsync($"{NetCoreTool.Command} new --uninstall {nuGetId}"); + await _commandExecutor.ExecuteAsync($"{NetCoreTool.Command} new uninstall {nuGetId}"); var oldTemplates = await GetTemplateDictionary(); - var installCommand = await _commandExecutor.ExecuteAsync($"{NetCoreTool.Command} new --install {nuGetId}"); + var installCommand = await _commandExecutor.ExecuteAsync($"{NetCoreTool.Command} new install {nuGetId}"); const string notFoundError = "error NU1101: "; if (installCommand.Output.Contains(notFoundError)) { @@ -98,7 +98,7 @@ public async Task UninstallTemplates(string nuGetId) { var oldTemplates = await GetTemplateDictionary(); var uninstallCommand = - await _commandExecutor.ExecuteAsync($"{NetCoreTool.Command} new --uninstall {nuGetId}"); + await _commandExecutor.ExecuteAsync($"{NetCoreTool.Command} new uninstall {nuGetId}"); if (uninstallCommand.Output.Contains($"Could not find something to uninstall")) { return NotFound($"No templates with NuGet ID '{nuGetId}' installed."); @@ -255,7 +255,7 @@ public async Task GetTemplateProject( private async Task GetTemplateDictionary() { - var listCommand = await _commandExecutor.ExecuteAsync($"{NetCoreTool.Command} new --list"); + var listCommand = await _commandExecutor.ExecuteAsync($"{NetCoreTool.Command} new list"); var lines = listCommand.Output.Split('\n').ToList() .FindAll(line => !string.IsNullOrWhiteSpace(line)); diff --git a/test/NetCoreToolService.Test/Controllers/NewControllerTest.cs b/test/NetCoreToolService.Test/Controllers/NewControllerTest.cs index 44dd03e..b7710ed 100644 --- a/test/NetCoreToolService.Test/Controllers/NewControllerTest.cs +++ b/test/NetCoreToolService.Test/Controllers/NewControllerTest.cs @@ -24,7 +24,7 @@ public async Task GetTemplates_Should_Return_AllTemplates() { // Arrange var executor = new Mock(); - executor.Setup(expression: c => c.ExecuteAsync($"{NetCoreTool.Command} new --list", null, -1)) + executor.Setup(expression: c => c.ExecuteAsync($"{NetCoreTool.Command} new list", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, @@ -59,7 +59,7 @@ public async Task InstallTemplates_Should_Return_InstalledTemplates() { // Arrange var executor = new Mock(); - executor.SetupSequence(c => c.ExecuteAsync($"{NetCoreTool.Command} new --list", null, -1)) + executor.SetupSequence(c => c.ExecuteAsync($"{NetCoreTool.Command} new list", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, @@ -82,7 +82,7 @@ Other New Template ont bigtalk otherstuff ", } ); - executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new --install My.Templates", null, -1)) + executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new install My.Templates", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, @@ -111,7 +111,7 @@ public async Task UninstallTemplates_Should_Return_UninstalledTemplates() { // Arrange var executor = new Mock(); - executor.SetupSequence(c => c.ExecuteAsync($"{NetCoreTool.Command} new --list", null, -1)) + executor.SetupSequence(c => c.ExecuteAsync($"{NetCoreTool.Command} new list", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, @@ -134,7 +134,7 @@ My Other Template myot otherlang othertags ", } ); - executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new --uninstall My.Templates", null, -1)) + executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new uninstall My.Templates", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, @@ -296,7 +296,7 @@ public async Task InstallTemplates_UnknownNuGet_Should_Return_BadRequest() { // Arrange var executor = new Mock(); - executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new --list", null, -1)) + executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new list", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, @@ -308,7 +308,7 @@ My Other Template myot otherlang othertags } ); executor.Setup(c => - c.ExecuteAsync($"{NetCoreTool.Command} new --install No.Such.Template", null, -1)) + c.ExecuteAsync($"{NetCoreTool.Command} new install No.Such.Template", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 2, @@ -335,7 +335,7 @@ public async Task UninstallTemplates_UnknownNuGet_Should_Return_NotFound() { // Arrange var executor = new Mock(); - executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new --list", null, -1)) + executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new list", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0, @@ -344,7 +344,7 @@ public async Task UninstallTemplates_UnknownNuGet_Should_Return_NotFound() ", } ); - executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new --uninstall My.Templates", null, -1)) + executor.Setup(c => c.ExecuteAsync($"{NetCoreTool.Command} new uninstall My.Templates", null, -1)) .ReturnsAsync(new CommandResult { ExitCode = 0,