Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Initial commit of Toby launcher
Browse files Browse the repository at this point in the history
- Preparing for release that is easy to run in all 3 platforms
  • Loading branch information
frankhale committed Apr 21, 2017
1 parent 3fb9981 commit 6f3b994
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ node.exe
node.lib
npm-debug.log
.vscode/
debug.log
.vs/
bin/
packages/
obj/
debug.log
*.exe
*.dll
*.csproj.user
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ Start the server up:
```
Then open a browser to `http://127.0.0.1:62374`

### Running using the Toby Launcher

I've wrote a rudimentary launcher in C# .NET to assist with launching Toby easily. By default if you run the launcher without command line args it will run Toby using NW.js. There is only one command line option at this time.

After building the launcher copy the TobyLauncher.exe, NDesk.Options.dll and Newtonsoft.Json.dll files to the root of the Toby repository.

- Command Line Options:
- /p `[nw, electron, web]`

Examples:

Launching Toby in a web browser: `TobyLauncher.exe /p web`
Launching Toby in Electron: `TobyLauncher.exe /p electron`

NOTE: The launcher is crude and there is not enough error checking yet. Things will likely go wrong if Toby is not set up correctly as stated above.

### Usage

**Important Key Combos:**
Expand Down
22 changes: 22 additions & 0 deletions TobyLauncher/TobyLauncher.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TobyLauncher", "TobyLauncher\TobyLauncher.csproj", "{E34D48A1-7101-4DF8-8814-7D5AA400E6C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E34D48A1-7101-4DF8-8814-7D5AA400E6C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E34D48A1-7101-4DF8-8814-7D5AA400E6C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E34D48A1-7101-4DF8-8814-7D5AA400E6C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E34D48A1-7101-4DF8-8814-7D5AA400E6C6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions TobyLauncher/TobyLauncher/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
61 changes: 61 additions & 0 deletions TobyLauncher/TobyLauncher/Launcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using NDesk.Options;
using Newtonsoft.Json;
using System.Diagnostics;
using System.IO;

// This is primitive and there is not enough error checking yet. This was done as a quick and dirty proof of concept
// so that I can prepare for a release that will be easy to use.

namespace TobyLauncher
{
class Launcher
{
static void Main(string[] args)
{
var json = "";
using (var sr = new StreamReader("package.json"))
{
json = sr.ReadToEnd();
}

dynamic pkgJSON = JsonConvert.DeserializeObject(json);
string platform = "nw";
var opts = new OptionSet() {
{ "p|platform=", "The platform to use for running Toby (nw, electron, web)", v => platform = v }
};

opts.Parse(args);

switch(platform)
{
case "nw":
pkgJSON.main = "./build/index.html";
using (StreamWriter outputFile = new StreamWriter("package.json"))
{
outputFile.WriteLine(JsonConvert.SerializeObject(pkgJSON, Formatting.Indented));
}
Process.Start(@".\browsers\nw\nw.exe", ".");
break;
case "electron":
pkgJSON.main = "./build/electron.js";
using (StreamWriter outputFile = new StreamWriter("package.json"))
{
outputFile.WriteLine(JsonConvert.SerializeObject(pkgJSON, Formatting.Indented));
}
Process.Start(@".\browsers\electron\electron.exe", ".");
break;
case "web":
// Up in the air about this, I want to suppress the window but if I do that you'd have to kill the Node process in the
// task manager if you wanted to quit Toby.
Process.Start(new ProcessStartInfo()
{
FileName = @".\node",
Arguments = "./build/server.js",
//CreateNoWindow = true
});
Process.Start("http://localhost:62374");
break;
}
}
}
}
36 changes: 36 additions & 0 deletions TobyLauncher/TobyLauncher/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TobyLauncher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TobyLauncher")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e34d48a1-7101-4df8-8814-7d5aa400e6c6")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
95 changes: 95 additions & 0 deletions TobyLauncher/TobyLauncher/TobyLauncher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E34D48A1-7101-4DF8-8814-7D5AA400E6C6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>TobyLauncher</RootNamespace>
<AssemblyName>TobyLauncher</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>toby.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="NDesk.Options, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Launcher.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="toby.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
5 changes: 5 additions & 0 deletions TobyLauncher/TobyLauncher/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NDesk.Options" version="0.2.1" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net462" />
</packages>
Binary file added TobyLauncher/TobyLauncher/toby.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
"title-case": "^2.1.1",
"youtube-search": "^1.0.9"
}
}
}

0 comments on commit 6f3b994

Please sign in to comment.