Skip to content

Commit 582fe5c

Browse files
author
Pete
committed
Merge branch 'release-1.3'
2 parents 5b849ad + 9dd7cac commit 582fe5c

File tree

156 files changed

+70487
-21951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+70487
-21951
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("ServicePulse.Host.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ServicePulse.Host.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("113a09cc-9665-4e87-9fc7-7e5c8c0afe71")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace ServicePulse.Host.Tests
2+
{
3+
using System;
4+
using System.IO;
5+
using System.Text.RegularExpressions;
6+
using NUnit.Framework;
7+
8+
[TestFixture, Serializable]
9+
public class RegExTests
10+
{
11+
[Ignore]
12+
[Test]
13+
public void find_service_control_url()
14+
{
15+
var pathToConfig = Path.Combine("app.constants.js");
16+
var config = File.ReadAllText(pathToConfig);
17+
Assert.IsTrue(!string.IsNullOrWhiteSpace(config));
18+
var match = Regex.Match(config, @"(service_control_url: ')([\w:/]*)(')");
19+
Assert.IsTrue(match.Success);
20+
Assert.IsTrue(!string.IsNullOrWhiteSpace(match.Value));
21+
}
22+
23+
[Ignore]
24+
[Test]
25+
public void match_service_control_url_in_string()
26+
{
27+
var test = "service_control_url: 'http://localhost:33333/api',";
28+
var match = Regex.Match(test, @"(service_control_url: ')([\w:/]*)(')");
29+
Assert.AreEqual("http://localhost:33333/api", match.Groups[2].Value);
30+
}
31+
32+
33+
34+
}
35+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{113A09CC-9665-4E87-9FC7-7E5C8C0AFE71}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>ServicePulse.Host.Tests</RootNamespace>
11+
<AssemblyName>ServicePulse.Host.Tests</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
34+
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
35+
<Private>True</Private>
36+
</Reference>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Net.Http" />
44+
<Reference Include="System.Xml" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Compile Include="RegExTests.cs" />
48+
<Compile Include="Properties\AssemblyInfo.cs" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<None Include="packages.config" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Content Include="..\ServicePulse.Host\app\js\app.constants.js">
55+
<Link>app.constants.js</Link>
56+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
57+
</Content>
58+
</ItemGroup>
59+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
60+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
61+
Other similar extension points exist, see Microsoft.Common.targets.
62+
<Target Name="BeforeBuild">
63+
</Target>
64+
<Target Name="AfterBuild">
65+
</Target>
66+
-->
67+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NUnit" version="2.6.4" targetFramework="net452" />
4+
</packages>

src/ServicePulse.Host/Commands/AbstractCommand.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
using System.Text.RegularExpressions;
55
using Hosting;
66

7-
internal abstract class AbstractCommand
7+
abstract class AbstractCommand
88
{
99
public abstract void Execute(HostArguments args);
1010

11-
public static void UpdateConfig(string directoryPath, string serviceControlUrl)
11+
public static void MigrateServiceControlUrl(HostArguments args, string filePath)
1212
{
13-
var appJsPath = Path.Combine(directoryPath, "config.js");
14-
var appJsCode = File.ReadAllText(appJsPath);
13+
var config = File.ReadAllText(filePath);
14+
var match = Regex.Match(config, @"(service_control_url: ')([\w:/]*)(')");
1515

16-
File.WriteAllText(appJsPath,
17-
Regex.Replace(appJsCode, @"(service_control_url: ')([\w:/]*)(')", "$1" + serviceControlUrl + "$3"));
16+
// if the installer was given a value use it otherwise use any existing value
17+
if (match.Success && string.IsNullOrWhiteSpace(args.ServiceControlUrl))
18+
{
19+
args.ServiceControlUrl = match.Groups[2].Value;
20+
}
1821
}
1922
}
2023
}

src/ServicePulse.Host/Commands/UpdateVersionCommand.cs renamed to src/ServicePulse.Host/Commands/ExtractAndUpdateConstantsCommand.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,32 @@
55
using System.Text.RegularExpressions;
66
using Hosting;
77

8-
internal class UpdateVersionCommand : AbstractCommand
8+
internal class ExtractAndUpdateConstantsCommand : AbstractCommand
99
{
1010
public override void Execute(HostArguments args)
1111
{
12-
ExtractApp(args.OutputPath);
12+
#if !DEBUG
13+
ExtractApp(args);
1314
UpdateVersion(args.OutputPath);
15+
UpdateConfig(args.OutputPath, args.ServiceControlUrl);
16+
#endif
1417
}
1518

16-
static void ExtractApp(string directoryPath)
19+
static void ExtractApp(HostArguments args)
1720
{
21+
string directoryPath = args.OutputPath;
1822
var assembly = Assembly.GetExecutingAssembly();
1923

20-
using (var resourceStream = assembly.GetManifestResourceStream(@"app\js\app.js"))
24+
using (var resourceStream = assembly.GetManifestResourceStream(@"app\js\app.constants.js"))
2125
{
22-
var destinationPath = Path.Combine(directoryPath, "js/app.js");
26+
var destinationPath = Path.Combine(directoryPath, "js\\app.constants.js");
2327

2428
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
2529

2630
if (File.Exists(destinationPath))
2731
{
32+
MigrateServiceControlUrl(args, destinationPath);
33+
2834
File.Delete(destinationPath);
2935
}
3036

@@ -36,9 +42,19 @@ static void ExtractApp(string directoryPath)
3642
}
3743
}
3844

39-
static void UpdateVersion(string directoryPath)
45+
46+
public static void UpdateConfig(string directoryPath, string serviceControlUrl)
47+
{
48+
var appJsPath = Path.Combine(directoryPath, "js/app.constants.js");
49+
var appJsCode = File.ReadAllText(appJsPath);
50+
51+
File.WriteAllText(appJsPath,
52+
Regex.Replace(appJsCode, @"(service_control_url: ')([\w:/]*)(')", "$1" + serviceControlUrl + "$3"));
53+
}
54+
55+
public static void UpdateVersion(string directoryPath)
4056
{
41-
var appJsPath = Path.Combine(directoryPath, "js/app.js");
57+
var appJsPath = Path.Combine(directoryPath, "js/app.constants.js");
4258
var appJsCode = File.ReadAllText(appJsPath);
4359

4460
var updatedContent = Regex.Replace(appJsCode, @"(constant\('version', ')([\w:/.-]*)(')", "${1}" + GetFileVersion() + "$3");

src/ServicePulse.Host/Commands/ExtractCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public override void Execute(HostArguments args)
1717
return;
1818
}
1919

20-
UpdateConfig(args.OutputPath, args.ServiceControlUrl);
20+
ExtractAndUpdateConstantsCommand.UpdateVersion(args.OutputPath);
21+
ExtractAndUpdateConstantsCommand.UpdateConfig(args.OutputPath, args.ServiceControlUrl);
2122
}
2223

2324
static void ExtractResources(string directoryPath)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace ServicePulse.Host.Commands
2+
{
3+
using System.IO;
4+
using System.Text.RegularExpressions;
5+
using ServicePulse.Host.Hosting;
6+
7+
class RemoveDeprecatedOveridesCommand : AbstractCommand
8+
{
9+
public override void Execute(HostArguments args)
10+
{
11+
DeleteAppJsFile(args);
12+
}
13+
14+
static void DeleteAppJsFile(HostArguments args)
15+
{
16+
17+
var directoryPath = args.OutputPath;
18+
19+
var configPath = Path.Combine(directoryPath, "config.js");
20+
21+
if (File.Exists(configPath))
22+
{
23+
MigrateServiceControlUrl(args, configPath);
24+
25+
File.Delete(configPath);
26+
}
27+
28+
var destinationPath = Path.Combine(directoryPath, "js\\app.js");
29+
30+
if (File.Exists(destinationPath))
31+
{
32+
MigrateServiceControlUrl(args, destinationPath);
33+
File.Delete(destinationPath);
34+
}
35+
}
36+
37+
38+
}
39+
}

src/ServicePulse.Host/Commands/UpdateConfigCommand.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/ServicePulse.Host/Hosting/HostArguments.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public HostArguments(string[] args)
1717
{
1818
var executionMode = ExecutionMode.Run;
1919

20-
commands = new List<Type> { typeof(UpdateConfigCommand), typeof(UpdateVersionCommand), typeof(RunCommand) };
20+
commands = new List<Type> { typeof(RemoveDeprecatedOveridesCommand), typeof(ExtractAndUpdateConstantsCommand), typeof(RunCommand) };
2121
startMode = StartMode.Automatic;
2222
url = "http://localhost:8081";
2323
ServiceName = "Particular.ServicePulse";
@@ -60,7 +60,7 @@ public HostArguments(string[] args)
6060
@"Extract files to be installed in a Web Server."
6161
, s =>
6262
{
63-
commands = new List<Type> { typeof(UpdateConfigCommand), typeof(UpdateVersionCommand), typeof(ExtractCommand) };
63+
commands = new List<Type> { typeof(ExtractAndUpdateConstantsCommand), typeof(ExtractCommand) };
6464
executionMode = ExecutionMode.Extract;
6565
}
6666
},
@@ -109,7 +109,7 @@ public HostArguments(string[] args)
109109
@"Install the endpoint as a Windows service."
110110
, s =>
111111
{
112-
commands = new List<Type> { typeof(UpdateConfigCommand), typeof(UpdateVersionCommand), typeof(InstallCommand) };
112+
commands = new List<Type> { typeof(RemoveDeprecatedOveridesCommand), typeof(ExtractAndUpdateConstantsCommand), typeof(InstallCommand) };
113113
executionMode = ExecutionMode.Install;
114114
}
115115
},
@@ -230,6 +230,7 @@ public string Url
230230
public string ServiceControlUrl
231231
{
232232
get { return serviceControlUrl; }
233+
set { serviceControlUrl = value; }
233234
}
234235

235236
public string DisplayName { get; set; }

0 commit comments

Comments
 (0)