Support netcoreapp3.0
This commit is contained in:
Родитель
9631646848
Коммит
8842f23ceb
|
@ -19,8 +19,9 @@ export class Home extends Component {
|
|||
showMore: false,
|
||||
templateType: ".NET Templates",
|
||||
level2SelectorType: "net",
|
||||
lang: "C#"
|
||||
|
||||
lang: "C#",
|
||||
steeltoeVersion: "2.4.0",
|
||||
targetFrameworkVersion: "netcoreapp2.2"
|
||||
}
|
||||
|
||||
this.toggleMore = this.toggleMore.bind(this);
|
||||
|
@ -64,11 +65,18 @@ export class Home extends Component {
|
|||
}
|
||||
handleInputChange(name, selectedValue) {
|
||||
|
||||
if (name === "templateType") {
|
||||
this.setState({ level2SelectorType: selectedValue === ".NET Templates" ? "net" : "steeltoe"})
|
||||
//if (name === "templateType") {
|
||||
// this.setState({ level2SelectorType: selectedValue === ".NET Templates" ? "net" : "steeltoe"})
|
||||
//}
|
||||
if (name == "targetFrameworkVersion" && selectedValue == "netcoreapp3.0" && this.state.steeltoeVersion == "2.3.0") {
|
||||
this.setState({
|
||||
"steeltoeVersion": "2.4.0",
|
||||
[name]: selectedValue
|
||||
})
|
||||
}
|
||||
else {
|
||||
this.setState({ [name]: selectedValue });
|
||||
}
|
||||
|
||||
this.setState({ [name]: selectedValue });
|
||||
console.log("parent setting hanglechange" , name, selectedValue)
|
||||
}
|
||||
|
||||
|
@ -80,8 +88,7 @@ export class Home extends Component {
|
|||
<div>
|
||||
<form name="form" action="/starter.zip" method="post" autoComplete="off" onSubmit={this.trackSubmitEvent} >
|
||||
<div>
|
||||
<InputSelector id="steeltoeVersion" title="Steeltoe Version" name="steeltoeVersion" values={[ "2.3.0", "2.4.0"]} defaultValue="2.3.0" onChange={this.handleInputChange} />
|
||||
|
||||
<InputSelector id="steeltoeVersion" title="Steeltoe Version" name="steeltoeVersion" values={["2.3.0", "2.4.0"]} defaultValue="2.4.0" selectedValue={this.state.steeltoeVersion} onChange={this.handleInputChange} />
|
||||
|
||||
<div className="line">
|
||||
<div className="left">Project Metadata</div>
|
||||
|
@ -91,7 +98,7 @@ export class Home extends Component {
|
|||
<InputText title="Project Name" name="projectName" defaultValue="MyCompany.SteeltoeExample" tabIndex="1" required pattern="^(?:((?!\d)\w+(?:\.(?!\d)\w+)*)\.)?((?!\d)\w+)$" onInput={(e) => e.target.setCustomValidity("")} onInvalid={(e) => e.target.setCustomValidity("ProjectName must be a valid C# Identifier: ex. MyCompany.MyProject")} />
|
||||
<div id="more-block">
|
||||
<InputText title="Description" name="description" defaultValue="Demo project for Steeltoe" tabIndex="2" />
|
||||
<RightInputSelector title='Target Framework' name="targetFrameworkVersion" values={["netcoreapp2.1", "netcoreapp2.2"]} defaultValue="netcoreapp2.2" />
|
||||
<RightInputSelector title='Target Framework' name="targetFrameworkVersion" values={["netcoreapp2.1", "netcoreapp2.2", "netcoreapp3.0"]} defaultValue="netcoreapp2.2" selectedValue={this.state.targetFrameworkVersion} onChange={this.handleInputChange} />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -4,18 +4,11 @@ export class InputSelector extends Component {
|
|||
super(props);
|
||||
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.state = { selectedValue: this.props.defaultValue };
|
||||
// console.log("in constructor ", this.props.name)
|
||||
//this.state = { selectedValue: this.props.defaultValue };
|
||||
|
||||
}
|
||||
handleChange(e) {
|
||||
console.log('setting state from ' + this.state.selectedValue);
|
||||
|
||||
var selection = e.target.attributes['data-value'].value
|
||||
this.setState({
|
||||
selectedValue: selection
|
||||
});
|
||||
this.props.onChange(this.props.name, selection)
|
||||
//console.log('to ' + this.selection);
|
||||
this.props.onChange(this.props.name, e.target.attributes['data-value'].value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,12 +21,12 @@ export class InputSelector extends Component {
|
|||
<div className="radios">
|
||||
{
|
||||
this.props.values.map((item, i ) => {
|
||||
return <div key={ 'option'+i } className={'radio ' + (this.state.selectedValue === item ? 'active' : '')} onClick={this.handleChange} >
|
||||
return <div key={ 'option'+i } className={'radio ' + (this.props.selectedValue === item ? 'active' : '')} onClick={this.handleChange} >
|
||||
<a href={hrefLink} data-value={item}>{item}</a>
|
||||
</div>
|
||||
})
|
||||
}
|
||||
<input type="hidden" name={this.props.name} value={this.state.selectedValue} />
|
||||
<input type="hidden" name={this.props.name} value={this.props.selectedValue} />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,15 +3,11 @@ export class RightInputSelector extends Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.state = { selectedValue: props.defaultValue };
|
||||
// this.state = { selectedValue: props.defaultValue };
|
||||
|
||||
}
|
||||
handleChange(e) {
|
||||
console.log('setting state from ' + this.state.selectedValue);
|
||||
this.setState({
|
||||
selectedValue: e.target.attributes['data-value'].value
|
||||
});
|
||||
console.log('to ' + this.state.selectedValue);
|
||||
this.props.onChange(this.props.name, e.target.attributes['data-value'].value)
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,12 +18,12 @@ export class RightInputSelector extends Component {
|
|||
<div className="radios">
|
||||
{
|
||||
this.props.values.map((item, i ) => {
|
||||
return <div id={"rdio" + i} key= { "rdio"+i } className={'radio ' + (this.state.selectedValue === item ? 'active' : '')} onClick={this.handleChange}>
|
||||
return <div id={"rdio" + i} key= { "rdio"+i } className={'radio ' + (this.props.selectedValue === item ? 'active' : '')} onClick={this.handleChange}>
|
||||
<a href={hrefLink} data-value={item}>{item}</a>
|
||||
</div>
|
||||
})
|
||||
}
|
||||
<input type="hidden" name={this.props.name} value={this.state.selectedValue} />
|
||||
}
|
||||
<input type="hidden" name={this.props.name} value={this.props.selectedValue} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -89,6 +89,10 @@ namespace Steeltoe.Initializr.Services.Mustache
|
|||
{
|
||||
dataView[steeltoeVersionName] = model.SteeltoeVersion.ToLower();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidDataException("SteeltoeVersion: InvalidParamValues");
|
||||
}
|
||||
}
|
||||
|
||||
if (model.TargetFrameworkVersion != null)
|
||||
|
|
|
@ -164,6 +164,7 @@ namespace Steeltoe.Initializr.Services.Mustache
|
|||
using (var entryStream = ef.Open())
|
||||
using (var fileToCompress = new MemoryStream(Encoding.UTF8.GetBytes(value)))
|
||||
{
|
||||
ef.ExternalAttributes = 27262976; // RW_(Owner)/R__(Group)/___(Other)
|
||||
fileToCompress.CopyTo(entryStream);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,18 +284,10 @@
|
|||
"SteeltoeVersion": {
|
||||
"type": "parameter",
|
||||
"datatype": "choice",
|
||||
"defaultValue": "2.3.0",
|
||||
"defaultValue": "2.4.0",
|
||||
"description": "Target the appropriate Steeltoe version",
|
||||
"replaces": "SteeltoeVersion",
|
||||
"choices": [
|
||||
{
|
||||
"choice": "2.2.0",
|
||||
"description": "Target Steeltoe version 2.2.0"
|
||||
},
|
||||
{
|
||||
"choice": "2.3.0",
|
||||
"description": "Target Steeltoe version 2.3.0"
|
||||
},
|
||||
{
|
||||
"choice": "2.4.0",
|
||||
"description": "Target Steeltoe version 2.4.0"
|
||||
|
|
|
@ -121,12 +121,6 @@ namespace Company.WebApplication1
|
|||
services.AddSqlServerConnection(Configuration);
|
||||
#endif
|
||||
|
||||
#if (FrameworkVersion == "netcoreapp2.2")
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||
#else
|
||||
services.AddMvc();
|
||||
#endif
|
||||
|
||||
// In production, the React files will be served from this directory
|
||||
services.AddSpaStaticFiles(configuration =>
|
||||
{
|
||||
|
@ -176,7 +170,6 @@ namespace Company.WebApplication1
|
|||
app.UseStaticFiles();
|
||||
app.UseSpaStaticFiles();
|
||||
|
||||
|
||||
|
||||
app.UseSpa(spa =>
|
||||
{
|
||||
|
|
|
@ -404,7 +404,7 @@
|
|||
"SteeltoeVersion": {
|
||||
"type": "parameter",
|
||||
"datatype": "choice",
|
||||
"defaultValue": "2.3.0",
|
||||
"defaultValue": "2.4.0",
|
||||
"description": "Target steeltoe version",
|
||||
"replaces": "SteeltoeVersion",
|
||||
"choices": [
|
||||
|
@ -412,14 +412,6 @@
|
|||
"choice": "3.0",
|
||||
"description": "Target Steeltoe version 3.0"
|
||||
},
|
||||
{
|
||||
"choice": "2.2.0",
|
||||
"description": "Target Steeltoe version 2.2.0"
|
||||
},
|
||||
{
|
||||
"choice": "2.3.0",
|
||||
"description": "Target Steeltoe version 2.3.0-rc2"
|
||||
},
|
||||
{
|
||||
"choice": "2.4.0",
|
||||
"description": "Target Steeltoe version 2.4.0"
|
||||
|
|
|
@ -30,9 +30,16 @@
|
|||
{{#CloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/CloudFoundry}}
|
||||
|
||||
<PackageReference Include="Steeltoe.Management.ExporterCore" Version="{{SteeltoeVersion}}"/>
|
||||
|
||||
{{#ConfigServer}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.ConfigServerCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ConfigServer}}
|
||||
{{#PlaceholderConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/PlaceholderConfig}}
|
||||
{{#RandomValueConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.RandomValueBase" Version="{{SteeltoeVersion}}" />
|
||||
{{/RandomValueConfig}}
|
||||
{{#ActuatorsOrCloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ActuatorsOrCloudFoundry}}
|
||||
|
@ -55,7 +62,7 @@
|
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="{{AspNetCoreVersion}}" />
|
||||
{{/SQLServer}}
|
||||
{{#Redis}}
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="3.0.0-preview8.18405.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="3.1.0" />
|
||||
{{/Redis}}
|
||||
{{#AnyEFCore}}
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="{{AspNetCoreVersion}}" />
|
||||
|
@ -65,7 +72,7 @@
|
|||
<PackageReference Include="Steeltoe.CloudFoundry.ConnectorCore" Version="{{SteeltoeVersion}}"/>
|
||||
{{/AnyConnector}}
|
||||
{{#PostgresEFCore}}
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.0.0-preview8" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
|
||||
{{/PostgresEFCore}}
|
||||
{{#MongoDB}}
|
||||
<PackageReference Include="MongoDB.Driver" Version="{{MongoDBVersion}}" />
|
||||
|
|
|
@ -129,12 +129,7 @@ namespace {{ProjectNameSpace}}
|
|||
{{#SQLServer}}
|
||||
services.AddSqlServerConnection(Configuration);
|
||||
{{/SQLServer}}
|
||||
{{#TargetFrameworkVersion22}}
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||
{{/TargetFrameworkVersion22}}
|
||||
{{^TargetFrameworkVersion22}}
|
||||
services.AddMvc();
|
||||
{{/TargetFrameworkVersion22}}
|
||||
|
||||
services.AddSpaStaticFiles(configuration =>
|
||||
{
|
||||
configuration.RootPath = "ClientApp/build";
|
||||
|
|
|
@ -146,12 +146,7 @@
|
|||
},
|
||||
{
|
||||
"Name": "AspNetCoreVersion",
|
||||
"Expression": "TargetFrameworkVersion,netcoreapp3.0=3.0.0-preview8.19405.11,default=False",
|
||||
"ExpressionType": "Case"
|
||||
},
|
||||
{
|
||||
"Name": "TargetFrameworkVersion22",
|
||||
"Expression": "TargetFrameworkVersion,netcoreapp2.2=true,default=False",
|
||||
"Expression": "TargetFrameworkVersion,netcoreapp3.0=3.1.0,default=False",
|
||||
"ExpressionType": "Case"
|
||||
},
|
||||
{
|
||||
|
@ -177,16 +172,13 @@
|
|||
"Versions": [
|
||||
{
|
||||
"Name": "SteeltoeVersion",
|
||||
"DefaultValue": "2.3.0",
|
||||
"DefaultValue": "2.4.0",
|
||||
"Description": "Target the appropriate Steeltoe version",
|
||||
"choices": [
|
||||
|
||||
{
|
||||
"choice": "2.2.0",
|
||||
"Description": "Target Steeltoe version 2.2.0"
|
||||
},
|
||||
{
|
||||
"choice": "2.3.0",
|
||||
"Description": "Target Steeltoe version 2.3.0"
|
||||
"choice": "3.0.0",
|
||||
"Description": "Target Steeltoe version 3.0.0"
|
||||
},
|
||||
{
|
||||
"choice": "2.4.0",
|
||||
|
@ -212,7 +204,7 @@
|
|||
|
||||
{
|
||||
"Name": "NpgSqlVersion",
|
||||
"DefaultValue": "4.0.4"
|
||||
"DefaultValue": "4.1.2"
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -24,7 +24,15 @@
|
|||
{{#CloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/CloudFoundry}}
|
||||
|
||||
{{#ConfigServer}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.ConfigServerCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ConfigServer}}
|
||||
{{#PlaceholderConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/PlaceholderConfig}}
|
||||
{{#RandomValueConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.RandomValueBase" Version="{{SteeltoeVersion}}" />
|
||||
{{/RandomValueConfig}}
|
||||
{{#ActuatorsOrCloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Management.ExporterCore" Version="{{SteeltoeVersion}}"/>
|
||||
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
|
@ -46,7 +54,7 @@
|
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="{{AspNetCoreVersion}}" />
|
||||
{{/SQLServer}}
|
||||
{{#Redis}}
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="3.0.0-preview8.18405.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="3.1.0" />
|
||||
{{/Redis}}
|
||||
{{#AnyEFCore}}
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="{{AspNetCoreVersion}}" />
|
||||
|
@ -56,7 +64,7 @@
|
|||
<PackageReference Include="Steeltoe.CloudFoundry.ConnectorCore" Version="{{SteeltoeVersion}}"/>
|
||||
{{/AnyConnector}}
|
||||
{{#PostgresEFCore}}
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.0.0-preview8" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
|
||||
{{/PostgresEFCore}}
|
||||
{{#MongoDB}}
|
||||
<PackageReference Include="MongoDB.Driver" Version="{{MongoDBVersion}}" />
|
||||
|
|
|
@ -129,48 +129,48 @@ namespace {{ProjectNameSpace}}
|
|||
{{#SQLServer}}
|
||||
services.AddSqlServerConnection(Configuration);
|
||||
{{/SQLServer}}
|
||||
{{#TargetFrameworkVersion22}}
|
||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||
{{/TargetFrameworkVersion22}}
|
||||
{{^TargetFrameworkVersion22}}
|
||||
services.AddMvc();
|
||||
{{/TargetFrameworkVersion22}}
|
||||
}
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
services.AddControllers();
|
||||
}
|
||||
{{#RequiresHttps}}
|
||||
else
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
{{#RequiresHttps}}
|
||||
else
|
||||
{
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
{{/RequiresHttps}}
|
||||
app.UseHttpsRedirection();
|
||||
{{/RequiresHttps}}
|
||||
|
||||
|
||||
{{#Auth}}
|
||||
app.UseAuthentication();
|
||||
{{/Auth}}
|
||||
{{#Auth}}
|
||||
app.UseAuthentication();
|
||||
{{/Auth}}
|
||||
|
||||
{{#Actuators}}
|
||||
{{#CloudFoundry}}
|
||||
app.UseCloudFoundryActuators(MediaTypeVersion.V2, ActuatorContext.ActuatorAndCloudFoundry);
|
||||
{{/CloudFoundry}}
|
||||
{{^CloudFoundry}}
|
||||
app.UseCloudFoundryActuators();
|
||||
{{/CloudFoundry}}
|
||||
{{/Actuators}}
|
||||
{{#Actuators}}
|
||||
{{#CloudFoundry}}
|
||||
app.UseCloudFoundryActuators(MediaTypeVersion.V2, ActuatorContext.ActuatorAndCloudFoundry);
|
||||
{{/CloudFoundry}}
|
||||
{{^CloudFoundry}}
|
||||
app.UseCloudFoundryActuators();
|
||||
{{/CloudFoundry}}
|
||||
{{/Actuators}}
|
||||
|
||||
{{#Discovery}}
|
||||
app.UseDiscoveryClient();
|
||||
{{/Discovery}}
|
||||
app.UseMvc();
|
||||
{{#Discovery}}
|
||||
app.UseDiscoveryClient();
|
||||
{{/Discovery}}
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,12 +151,7 @@
|
|||
},
|
||||
{
|
||||
"Name": "AspNetCoreVersion",
|
||||
"Expression": "TargetFrameworkVersion,netcoreapp3.0=3.0.0-preview8.19405.11,default=False",
|
||||
"ExpressionType": "Case"
|
||||
},
|
||||
{
|
||||
"Name": "TargetFrameworkVersion22",
|
||||
"Expression": "TargetFrameworkVersion,netcoreapp2.2=true,default=False",
|
||||
"Expression": "TargetFrameworkVersion,netcoreapp3.0=3.1.0,default=False",
|
||||
"ExpressionType": "Case"
|
||||
}
|
||||
],
|
||||
|
@ -177,15 +172,11 @@
|
|||
"Versions": [
|
||||
{
|
||||
"Name": "SteeltoeVersion",
|
||||
"DefaultValue": "2.3.0",
|
||||
"DefaultValue": "2.4.0",
|
||||
"Description": "Target the appropriate Steeltoe version",
|
||||
"choices": [
|
||||
{
|
||||
"choice": "2.2.0",
|
||||
"Description": "Target Steeltoe version 2.2.0"
|
||||
},
|
||||
{
|
||||
"choice": "2.3.0",
|
||||
"choice": "3.0.0",
|
||||
"Description": "Target Steeltoe version 2.3.0"
|
||||
},
|
||||
{
|
||||
|
@ -212,7 +203,7 @@
|
|||
|
||||
{
|
||||
"Name": "NpgSqlVersion",
|
||||
"DefaultValue": "4.0.4"
|
||||
"DefaultValue": "4.1.2"
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
// 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 Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Steeltoe.Initializr.Services;
|
||||
using Steeltoe.Initializr.Services.DotNetTemplateEngine;
|
||||
using Steeltoe.Initializr.Services.Mustache;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Steeltoe.Initializr.Tests
|
||||
{
|
||||
public class AllImplementationsAndTemplateNames : IEnumerable<object[]>
|
||||
{
|
||||
private readonly List<object[]> _data;
|
||||
|
||||
public AllImplementationsAndTemplateNames()
|
||||
{
|
||||
IConfigurationRoot configuration = TestHelper.GetConfiguration();
|
||||
|
||||
var implementations = new ITemplateService[]
|
||||
{
|
||||
new TemplateService(configuration, new MemoryCache(new MemoryCacheOptions()), new LoggerFactory().CreateLogger<TemplateService>()),
|
||||
new MustacheTemplateService(configuration, new LoggerFactory().CreateLogger<MustacheTemplateService>()),
|
||||
};
|
||||
var templateNames = new string[]
|
||||
{
|
||||
"Steeltoe-React",
|
||||
"Steeltoe-WebApi",
|
||||
};
|
||||
var templateVersions = (TemplateVersion[])Enum.GetValues(typeof(TemplateVersion));
|
||||
var data = from implementation in implementations
|
||||
from templateName in templateNames
|
||||
select new object[] { implementation, templateName };
|
||||
_data = data.ToList();
|
||||
}
|
||||
|
||||
public IEnumerator<object[]> GetEnumerator() => _data.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
}
|
|
@ -480,7 +480,7 @@ using System.Threading;", valuesController);
|
|||
});
|
||||
|
||||
string fileContents = files.Find(x => x.Key == "testProject.csproj").Value;
|
||||
Assert.Contains(@"<PackageReference Include=""Steeltoe.Extensions.Logging.DynamicLogger"" Version=""2.3.0""/>", fileContents);
|
||||
Assert.Contains(@"<PackageReference Include=""Steeltoe.Extensions.Logging.DynamicLogger"" Version=", fileContents);
|
||||
|
||||
string programFileContents = files.Find(x => x.Key == "Program.cs").Value;
|
||||
Assert.Contains(@"using Steeltoe.Extensions.Logging;", programFileContents);
|
||||
|
@ -514,7 +514,7 @@ using System.Threading;", valuesController);
|
|||
var files = await templateService.GenerateProjectFiles(new Models.GeneratorModel()
|
||||
{
|
||||
Dependencies = "Actuators",
|
||||
SteeltoeVersion = "2.2.0",
|
||||
SteeltoeVersion = version == TemplateVersion.V2 ? "2.2.0" : "2.4.0",
|
||||
TemplateShortName = templateName,
|
||||
TemplateVersion = version,
|
||||
});
|
||||
|
@ -531,7 +531,7 @@ using System.Threading;", valuesController);
|
|||
var files = await templateService.GenerateProjectFiles(new Models.GeneratorModel()
|
||||
{
|
||||
Dependencies = "Actuators",
|
||||
SteeltoeVersion = "2.3.0",
|
||||
SteeltoeVersion = version == TemplateVersion.V2 ? "2.3.0" : "2.4.0",
|
||||
TemplateShortName = templateName,
|
||||
TemplateVersion = version,
|
||||
});
|
||||
|
@ -557,23 +557,22 @@ using System.Threading;", valuesController);
|
|||
|
||||
Assert.Contains("services.AddCloudFoundryActuators(Configuration);", startUpContents);
|
||||
}
|
||||
////[Fact]
|
||||
////public void CreateTemplate_actuators_v3()
|
||||
////{
|
||||
//// var templateService = new MustacheTemplateService(_logger);
|
||||
|
||||
//// Assert.NotNull(templateService);
|
||||
|
||||
//// var outFolder = templateService.GenerateProject("steeltoe", "testProject", new[] { "Actuators" }).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.Actuator);", startUpContents);
|
||||
//// Assert.DoesNotContain("services.AddCloudFoundryActuators(Configuration);", startUpContents);
|
||||
////}
|
||||
[Theory]
|
||||
[ClassData(typeof(AllImplementationsAndTemplateNames))]
|
||||
public void CreateTemplate_v3_invalid(ITemplateService templateService, string templateName)
|
||||
{
|
||||
Assert.ThrowsAsync<InvalidDataException>(async () =>
|
||||
{
|
||||
var files = await templateService.GenerateProjectFiles(new Models.GeneratorModel()
|
||||
{
|
||||
Dependencies = "Actuators",
|
||||
SteeltoeVersion = "2.3.0",
|
||||
TemplateShortName = templateName,
|
||||
TemplateVersion = TemplateVersion.V3,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(AllImplementationsAndTemplates))]
|
||||
|
|
Загрузка…
Ссылка в новой задаче