diff --git a/InitializrApi.sln b/Steeltoe.Initializr.sln similarity index 69% rename from InitializrApi.sln rename to Steeltoe.Initializr.sln index 69497b9..a7b0808 100644 --- a/InitializrApi.sln +++ b/Steeltoe.Initializr.sln @@ -3,9 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.28307.329 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InitializrApiTests", "tests\InitializrApiTests.csproj", "{E1CCB76F-904D-4B24-BF5F-B3B7DF9897C9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Initializr.Tests", "tests\Steeltoe.Initializr.Tests.csproj", "{E1CCB76F-904D-4B24-BF5F-B3B7DF9897C9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InitializrApi", "src\InitializrApi.csproj", "{945A8C33-08A6-4D07-A3B6-51D7802A4DC0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Initializr", "src\Steeltoe.Initializr.csproj", "{945A8C33-08A6-4D07-A3B6-51D7802A4DC0}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{42A583D3-DB7F-49E9-A89B-58FE16391C6C}" + ProjectSection(SolutionItems) = preProject + shared.props = shared.props + stylecop.json = stylecop.json + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/shared.props b/shared.props new file mode 100644 index 0000000..45ec768 --- /dev/null +++ b/shared.props @@ -0,0 +1,11 @@ + + + SA1101;SA1124;SA1201;SA1309;SA1310;SA1401;SA1600;SA1652;1591;CS8002 + + + + stylecop.json + Always + + + diff --git a/src/Controllers/HomeController.cs b/src/Controllers/HomeController.cs deleted file mode 100644 index 47008af..0000000 --- a/src/Controllers/HomeController.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using InitializrApi.Services; -using Microsoft.AspNetCore.Mvc; -using testDir.Models; - -namespace InitializrApi.Controllers -{ - public class HomeController : Controller - { - ISteeltoeTemplateService _templateService; - public HomeController(ISteeltoeTemplateService templateService) - { - _templateService = templateService; - } - //[Route("/all")] - //public IActionResult Index() - //{ - // var templates = _templateService.GetAvailableTemplates(); - // if (Request.Headers["Accept"].Any(x => x.Contains("text/html"))) - // { - // ViewData.Model = templates; - // return View(); - // } - - // else - // { - // return Content("Hi result"); - // } - //} - } -} diff --git a/src/Controllers/TemplatesController.cs b/src/Controllers/TemplatesController.cs index cea7170..75791bf 100644 --- a/src/Controllers/TemplatesController.cs +++ b/src/Controllers/TemplatesController.cs @@ -1,3 +1,17 @@ +// Copyright 2017 the original author or authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + using System; using System.Collections.Generic; using System.Globalization; @@ -18,10 +32,10 @@ using Microsoft.TemplateEngine.Edge.Settings; using Microsoft.TemplateEngine.Edge.Template; using Microsoft.AspNetCore.Hosting; using System.Text; -using InitializrApi.Models; -using InitializrApi.Services; +using Steeltoe.Initializr.Models; +using Steeltoe.Initializr.Services; -namespace InitializrApi.Controllers +namespace Steeltoe.Initializr.Controllers { [Route("api/[controller]")] [ApiController] @@ -54,39 +68,10 @@ namespace InitializrApi.Controllers [Route("/createtest")] public ActionResult GenerateProjectTest([FromQuery(Name = "templateShortName")] string templateShortName) { - return GenerateProject(new GeneratorModel { templateShortName = templateShortName ?? DEFAULT_TEMPLATE, projectName = "mytest", dependencies = new[] { "actuators,mysql" } }); ; + return GenerateProject(new GeneratorModel { TemplateShortName = templateShortName ?? DEFAULT_TEMPLATE, ProjectName = "mytest", Dependencies = new[] { "actuators,mysql" } }); ; } - private ActionResult GenerateProject(GeneratorModel model) - { - //var form = Request.Form; - var list = _templateService.GetAvailableTemplates(); - var currentTemplate = (model.templateShortName ?? DEFAULT_TEMPLATE).ToLower(); - - - if (list == null || !list.Any(x => x.ShortName.ToLower() == currentTemplate)) - { - return NotFound($"Template {currentTemplate} was not found"); - } - var templateParameters = model.dependencies.ToList(); - if(!string.IsNullOrEmpty(model.steeltoeVersion)) - { - templateParameters.Add($"SteeltoeVersion={model.steeltoeVersion}"); - } - string outFolder = _templateService.GenerateProject(currentTemplate, model.projectName, templateParameters.ToArray() ).Result; - var zipName = (model.projectName ?? "steeltoeProject")+".zip"; - - var zipFile = Path.Combine(outFolder,"..", zipName); - ZipFile.CreateFromDirectory(outFolder, zipFile); - - var cd = new ContentDispositionHeaderValue("attachment") - { - FileNameStar = zipName - }; - Response.Headers.Add("Content-Disposition", cd.ToString()); - return File(System.IO.File.ReadAllBytes(zipFile), "application/zip"); - - } + // GET api/templates [Route("/dependencies")] public ActionResult GetDependencies() @@ -99,14 +84,52 @@ namespace InitializrApi.Controllers { return _templateService.GetAvailableTemplates(); } + [Route("stall")] public ActionResult> GetSteeltoeTemplates() { return _sttemplateService.GetAvailableTemplates(); } - + private ActionResult GenerateProject(GeneratorModel model) + { + //var form = Request.Form; + var list = _templateService.GetAvailableTemplates(); + var currentTemplate = (model.TemplateShortName ?? DEFAULT_TEMPLATE).ToLower(); - } - + + if (list == null || !list.Any(x => x.ShortName.ToLower() == currentTemplate)) + { + return NotFound($"Template {currentTemplate} was not found"); + } + var templateParameters = model.Dependencies.ToList(); + + if (!string.IsNullOrEmpty(model.SteeltoeVersion)) + { + if (model.SteeltoeVersion == "3.0") + { + currentTemplate = "steeltoe"; + } + else + { + templateParameters.Add($"SteeltoeVersion={model.SteeltoeVersion}"); + } + } + + string outFolder = _templateService.GenerateProject(currentTemplate, model.ProjectName, templateParameters.ToArray()).Result; + var zipName = (model.ProjectName ?? "steeltoeProject") + ".zip"; + + var zipFile = Path.Combine(outFolder, "..", zipName); + ZipFile.CreateFromDirectory(outFolder, zipFile); + + var cd = new ContentDispositionHeaderValue("attachment") + { + FileNameStar = zipName + }; + Response.Headers.Add("Content-Disposition", cd.ToString()); + return File(System.IO.File.ReadAllBytes(zipFile), "application/zip"); + + } + + } } diff --git a/src/InitializrApi.xml b/src/InitializrApi.xml new file mode 100644 index 0000000..d660b97 --- /dev/null +++ b/src/InitializrApi.xml @@ -0,0 +1,8 @@ + + + + Steeltoe.Initializr + + + + diff --git a/src/Models/ErrorViewModel.cs b/src/Models/ErrorViewModel.cs deleted file mode 100644 index cd88689..0000000 --- a/src/Models/ErrorViewModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace testDir.Models -{ - public class ErrorViewModel - { - public string RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - } -} \ No newline at end of file diff --git a/src/Models/GeneratorModel.cs b/src/Models/GeneratorModel.cs index 86a6f58..c3e4dcd 100644 --- a/src/Models/GeneratorModel.cs +++ b/src/Models/GeneratorModel.cs @@ -1,23 +1,35 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +// Copyright 2017 the original author or authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. -namespace InitializrApi.Models +namespace Steeltoe.Initializr.Models { public class GeneratorModel { private string[] _dependencies; - public string[] dependencies + public string[] Dependencies { get => _dependencies; set => _dependencies = (value == null || value.Length == 0 || value[0] == null) ? value : value[0].ToLower().Split(','); } - public string projectName { get; set; } - public string templateShortName { get; set; } - - public string description { get; set; } - public string steeltoeVersion { get; set; } + + public string ProjectName { get; set; } + + public string TemplateShortName { get; set; } + + public string Description { get; set; } + + public string SteeltoeVersion { get; set; } } } diff --git a/src/Models/ProjectDependency.cs b/src/Models/ProjectDependency.cs index 1173f6b..fbdc2ef 100644 --- a/src/Models/ProjectDependency.cs +++ b/src/Models/ProjectDependency.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace InitializrApi.Models +namespace Steeltoe.Initializr.Models { public class ProjectDependency { diff --git a/src/Models/TemplateViewModel.cs b/src/Models/TemplateViewModel.cs index 9e917d5..72931e3 100644 --- a/src/Models/TemplateViewModel.cs +++ b/src/Models/TemplateViewModel.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace InitializrApi.Models +namespace Steeltoe.Initializr.Models { public class TemplateViewModel { diff --git a/src/Pages/Error.cshtml b/src/Pages/Error.cshtml deleted file mode 100644 index 6f92b95..0000000 --- a/src/Pages/Error.cshtml +++ /dev/null @@ -1,26 +0,0 @@ -@page -@model ErrorModel -@{ - ViewData["Title"] = "Error"; -} - -

Error.

-

An error occurred while processing your request.

- -@if (Model.ShowRequestId) -{ -

- Request ID: @Model.RequestId -

-} - -

Development Mode

-

- Swapping to the Development environment displays detailed information about the error that occurred. -

-

- The Development environment shouldn't be enabled for deployed applications. - It can result in displaying sensitive information from exceptions to end users. - For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development - and restarting the app. -

diff --git a/src/Pages/Error.cshtml.cs b/src/Pages/Error.cshtml.cs deleted file mode 100644 index 3914328..0000000 --- a/src/Pages/Error.cshtml.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace testDir.Pages -{ - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public class ErrorModel : PageModel - { - public string RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; - } - } -} diff --git a/src/Pages/_ViewImports.cshtml b/src/Pages/_ViewImports.cshtml deleted file mode 100644 index c8fcfcd..0000000 --- a/src/Pages/_ViewImports.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@using testDir -@namespace testDir.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/Program.cs b/src/Program.cs index c5e440e..003e51a 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -9,7 +9,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace InitializrApi +namespace Steeltoe.Initializr { public class Program { diff --git a/src/Properties/launchSettings.json b/src/Properties/launchSettings.json index 096c3c3..b82674f 100644 --- a/src/Properties/launchSettings.json +++ b/src/Properties/launchSettings.json @@ -17,7 +17,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, - "InitializrApi": { + "Steeltoe.Initializr": { "commandName": "Project", "launchBrowser": true, "launchUrl": "https://localhost:5001/api/templates/all", diff --git a/src/Services/ITemplateService.cs b/src/Services/ITemplateService.cs index 7338fb8..0511be0 100644 --- a/src/Services/ITemplateService.cs +++ b/src/Services/ITemplateService.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Threading.Tasks; -using InitializrApi.Models; +using Steeltoe.Initializr.Models; -namespace InitializrApi.Services +namespace Steeltoe.Initializr.Services { public interface ITemplateService { diff --git a/src/Services/InitializrComponentManager.cs b/src/Services/InitializrComponentManager.cs index c10aa31..fd4d3d8 100644 --- a/src/Services/InitializrComponentManager.cs +++ b/src/Services/InitializrComponentManager.cs @@ -1,4 +1,4 @@ -using System; + using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -11,7 +11,7 @@ using Microsoft.TemplateEngine.Edge.Mount.Archive; using Microsoft.TemplateEngine.Edge.Mount.FileSystem; using Microsoft.TemplateEngine.Edge.Settings; -namespace InitializrApi.Services +namespace Steeltoe.Initializr.Services { internal class InitializrComponentManager : IComponentManager { diff --git a/src/Services/InitializrSettingsLoader.cs b/src/Services/InitializrSettingsLoader.cs index b89242a..c172b76 100644 --- a/src/Services/InitializrSettingsLoader.cs +++ b/src/Services/InitializrSettingsLoader.cs @@ -13,7 +13,7 @@ using Microsoft.TemplateEngine.Utils; using Newtonsoft.Json.Linq; -namespace InitializrApi.Services +namespace Steeltoe.Initializr.Services { public class InitializrSettingsLoader : ISettingsLoader { diff --git a/src/Services/InitializrTemplateCache.cs b/src/Services/InitializrTemplateCache.cs index dcaf3f7..7e3c3c4 100644 --- a/src/Services/InitializrTemplateCache.cs +++ b/src/Services/InitializrTemplateCache.cs @@ -11,7 +11,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -namespace InitializrApi.Services +namespace Steeltoe.Initializr.Services { public class InitializrTemplateCache { diff --git a/src/Services/MountpointManager.cs b/src/Services/MountpointManager.cs index c057f3c..fa724d0 100644 --- a/src/Services/MountpointManager.cs +++ b/src/Services/MountpointManager.cs @@ -5,7 +5,7 @@ using Microsoft.TemplateEngine.Abstractions.Mount; using Microsoft.TemplateEngine.Utils; -namespace InitializrApi.Services +namespace Steeltoe.Initializr.Services { internal class InitializrMountPointManager : IMountPointManager { diff --git a/src/Services/TemplateService.cs b/src/Services/TemplateService.cs index fbdc01b..249089a 100644 --- a/src/Services/TemplateService.cs +++ b/src/Services/TemplateService.cs @@ -5,7 +5,7 @@ using System.IO; using System.Linq; using System.Reflection; using System.Threading.Tasks; -using InitializrApi.Models; +using Steeltoe.Initializr.Models; using Microsoft.TemplateEngine.Abstractions; using Microsoft.TemplateEngine.Cli; using Microsoft.TemplateEngine.Cli.PostActionProcessors; @@ -16,7 +16,7 @@ using Microsoft.TemplateEngine.Edge.TemplateUpdates; using Microsoft.TemplateEngine.Orchestrator.RunnableProjects; using Microsoft.TemplateEngine.Utils; -namespace InitializrApi.Services +namespace Steeltoe.Initializr.Services { public class TemplateService : ITemplateService { diff --git a/src/Startup.cs b/src/Startup.cs index d6064db..b6fc7d8 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -1,4 +1,4 @@ -using InitializrApi.Services; +using Steeltoe.Initializr.Services; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -8,7 +8,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace InitializrApi +namespace Steeltoe.Initializr { public class Startup { diff --git a/src/InitializrApi.csproj b/src/Steeltoe.Initializr.csproj similarity index 88% rename from src/InitializrApi.csproj rename to src/Steeltoe.Initializr.csproj index e88b110..12301a3 100644 --- a/src/InitializrApi.csproj +++ b/src/Steeltoe.Initializr.csproj @@ -1,5 +1,5 @@  - + netcoreapp2.2 true @@ -13,6 +13,9 @@ .zip + + + C:\Users\Hananiel\projects\InitializrApi\src\InitializrApi.xml @@ -46,6 +49,10 @@ + + all + runtime; build; native; contentfiles; analyzers + diff --git a/src/InitializrApi.csproj.user b/src/Steeltoe.Initializr.csproj.user similarity index 100% rename from src/InitializrApi.csproj.user rename to src/Steeltoe.Initializr.csproj.user diff --git a/src/SteeltoeTemplates/ISteeltoeTemplateService.cs b/src/SteeltoeTemplates/ISteeltoeTemplateService.cs index 054b2f6..73e4fbe 100644 --- a/src/SteeltoeTemplates/ISteeltoeTemplateService.cs +++ b/src/SteeltoeTemplates/ISteeltoeTemplateService.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.IO; -using InitializrApi.Models; +using Steeltoe.Initializr.Models; -namespace InitializrApi.Services +namespace Steeltoe.Initializr.Services { public interface ISteeltoeTemplateService { diff --git a/src/SteeltoeTemplates/SteeltoeTemplateService.cs b/src/SteeltoeTemplates/SteeltoeTemplateService.cs index 190c17b..410f8b7 100644 --- a/src/SteeltoeTemplates/SteeltoeTemplateService.cs +++ b/src/SteeltoeTemplates/SteeltoeTemplateService.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using InitializrApi.Models; +using Steeltoe.Initializr.Models; using Newtonsoft.Json; using Stubble.Core; using Stubble.Core.Builders; @@ -11,7 +11,7 @@ using System.Text; using Microsoft.Extensions.Logging; using System; -namespace InitializrApi.Services +namespace Steeltoe.Initializr.Services { public class SteeltoeTemplateService : ISteeltoeTemplateService { @@ -40,7 +40,7 @@ namespace InitializrApi.Services var templatePath = Path.Combine(current, "SteeltoeTemplates", "templates", name); var json = File.ReadAllText(Path.Combine(templatePath, "mustache.json")); var dataView = JsonConvert.DeserializeObject>(json); - foreach(var dependency in model.dependencies) + foreach(var dependency in model.Dependencies) { if(dataView.ContainsKey(dependency)) { diff --git a/src/manifest.yml b/src/manifest.yml index 325cae0..e412bf0 100644 --- a/src/manifest.yml +++ b/src/manifest.yml @@ -4,7 +4,7 @@ applications: buildpacks: - dotnet_core_buildpack memory: 512M - command: cd ${HOME} && ./InitializrApi + command: cd ${HOME} && ./Steeltoe.Initializr env: ASPNETCORE_ENVIRONMENT: Production services: diff --git a/stylecop.json b/stylecop.json new file mode 100644 index 0000000..664ac93 --- /dev/null +++ b/stylecop.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "documentationRules": { + "copyrightText": "Copyright {copyrightYear} the original author or authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttps://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.", + "xmlHeader": false, + "variables": { + "copyrightYear": "2017" + }, + "documentExposedElements": false, + "documentInternalElements": false, + "documentPrivateElements": false + }, + "indentation": { + "useTabs": false, + "indentationSize": 4 + }, + "namingRules": { + }, + "orderingRules": { + "usingDirectivesPlacement": "outsideNamespace", + "systemUsingDirectivesFirst": false + }, + "readabilityRules": { + } + } +} \ No newline at end of file diff --git a/templates/Steeltoe-CSharp-2.x/Startup.cs b/templates/Steeltoe-CSharp-2.x/Startup.cs index fbeea8e..a3bd096 100644 --- a/templates/Steeltoe-CSharp-2.x/Startup.cs +++ b/templates/Steeltoe-CSharp-2.x/Startup.cs @@ -21,9 +21,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -#if (MSSql) -using Steeltoe.CloudFoundry.Connector.MySql; -#endif + #if(Actuators || CloudFoundry) using Steeltoe.Management.CloudFoundry; using Steeltoe.Management.Endpoint; diff --git a/templates/settings.json b/templates/settings.json index 42c3145..2308aae 100644 --- a/templates/settings.json +++ b/templates/settings.json @@ -46,7 +46,7 @@ "ac33c6a1-52ca-4215-b72d-2dce7f6a1d2f": "Microsoft.TemplateEngine.Edge.TemplateUpdates.NupkgInstallUnitDescriptorFactory, Microsoft.TemplateEngine.Edge, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35" }, "ProbingPaths": [ - "C:\\Users\\Hananiel\\projects\\InitializrApi\\templates\\content" + "C:\\Users\\Hananiel\\projects\\Steeltoe.Initializr\\templates\\content" ], "ComponentTypeToGuidList": { "Microsoft.TemplateEngine.Abstractions.IGenerator, Microsoft.TemplateEngine.Abstractions, Version=1.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60": [ diff --git a/templates/xclude/settings.json b/templates/xclude/settings.json index ca1fb8c..ba4f9bd 100644 --- a/templates/xclude/settings.json +++ b/templates/xclude/settings.json @@ -5,7 +5,7 @@ "ParentMountPointId": "00000000-0000-0000-0000-000000000000", "MountPointFactoryId": "8c19221b-dea3-4250-86fe-2d4e189a11d2", "MountPointId": "1815274a-f735-4189-9f1c-cbc16a31dd3a", - "Place": "C:\\Users\\Hananiel\\projects\\InitializrApi\\templates\\Steeltoe-CSharp-2.2" + "Place": "C:\\Users\\Hananiel\\projects\\Steeltoe.Initializr\\templates\\Steeltoe-CSharp-2.2" } ], "ComponentGuidToAssemblyQualifiedName": { @@ -39,7 +39,7 @@ "ac33c6a1-52ca-4215-b72d-2dce7f6a1d2f": "Microsoft.TemplateEngine.Edge.TemplateUpdates.NupkgInstallUnitDescriptorFactory, Microsoft.TemplateEngine.Edge, Version=42.42.42.42, Culture=neutral, PublicKeyToken=31bf3856ad364e35" }, "ProbingPaths": [ - "C:\\Users\\Hananiel\\projects\\InitializrApi\\templates\\content" + "C:\\Users\\Hananiel\\projects\\Steeltoe.Initializr\\templates\\content" ], "ComponentTypeToGuidList": { "Microsoft.TemplateEngine.Abstractions.IGenerator, Microsoft.TemplateEngine.Abstractions, Version=1.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60": [ diff --git a/tests/InitializrApiTests.csproj b/tests/Steeltoe.Initializr.Tests.csproj similarity index 92% rename from tests/InitializrApiTests.csproj rename to tests/Steeltoe.Initializr.Tests.csproj index 0278559..a982c6f 100644 --- a/tests/InitializrApiTests.csproj +++ b/tests/Steeltoe.Initializr.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/tests/TemplateServiceTests.cs b/tests/TemplateServiceTests.cs index fcea960..ec033f0 100644 --- a/tests/TemplateServiceTests.cs +++ b/tests/TemplateServiceTests.cs @@ -1,11 +1,11 @@ using System; using System.IO; -using InitializrApi.Models; -using InitializrApi.Services; +using Steeltoe.Initializr.Models; +using Steeltoe.Initializr.Services; using Xunit; using Xunit.Abstractions; -namespace InitializrApiTests +namespace Steeltoe.InitializrTests { public class TemplateServiceTests: XunitLoggingBase { @@ -135,6 +135,25 @@ namespace InitializrApiTests Assert.DoesNotContain("services.AddCloudFoundryActuators(Configuration, MediaTypeVersion.V2, ActuatorContext.ActuatorAndCloudFoundry);", startUpContents); Assert.Contains("services.AddCloudFoundryActuators(Configuration);", startUpContents); + } + + [Fact] + public void CreateTemplate_actuators_v3() + { + var templateService = new TemplateService(); + + Assert.NotNull(templateService); + + var outFolder = templateService.GenerateProject("steeltoe", "testProject", new[] { "Actuators", "SteeltoeVersion=2.1.0" }).Result; + Console.WriteLine("outFolder " + outFolder); + Assert.NotNull(outFolder); + Assert.True(Directory.Exists(outFolder)); + var startupPath = Path.Combine(outFolder, "Startup.cs"); + Assert.True(File.Exists(startupPath)); + string startUpContents = File.ReadAllText(startupPath); + Assert.Contains("services.AddCloudFoundryActuators(Configuration, MediaTypeVersion.V2, ActuatorContext.ActuatorAndCloudFoundry);", startUpContents); + Assert.DoesNotContain("services.AddCloudFoundryActuators(Configuration);", startUpContents); + } [Fact] public void CreateTemplate_empty()