Skip to content

Commit

Permalink
Exprimental parser and Monaco integration
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetricek committed Jul 8, 2016
0 parents commit 6fc8ba6
Show file tree
Hide file tree
Showing 23 changed files with 2,797 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
.paket/paket.exe
node_modules/
paket-files/
packages/

out/

obj
bin
.vs
*.suo
Binary file added .paket/paket.bootstrapper.exe
Binary file not shown.
8 changes: 8 additions & 0 deletions README.md
@@ -0,0 +1,8 @@
To run things, install Node, then:

npm install uglifyjs
npm install babel-cli

And then:

./build.sh
14 changes: 14 additions & 0 deletions build.cmd
@@ -0,0 +1,14 @@
@echo off
.paket\paket.bootstrapper.exe
if errorlevel 1 (
exit /b %errorlevel%
)
if not exist paket.lock (
.paket\paket.exe install
) else (
.paket\paket.exe restore
)
if errorlevel 1 (
exit /b %errorlevel%
)
packages\FAKE\tools\FAKE.exe %* --fsiargs build.fsx
71 changes: 71 additions & 0 deletions build.fsx
@@ -0,0 +1,71 @@
// --------------------------------------------------------------------------------------
// A simple FAKE build script that:
// 1) Hosts Suave server locally & reloads web part that is defined in 'app.fsx'
// 2) Deploys the web application to Azure web sites when called with 'build deploy'
// --------------------------------------------------------------------------------------

#r "packages/Suave/lib/net40/Suave.dll"
#r "packages/FAKE/tools/FakeLib.dll"
open Fake

open System
open System.IO
open Suave
open Suave.Operators
open Suave.Web

// --------------------------------------------------------------------------------------
// Suave server
// --------------------------------------------------------------------------------------

let server =
Writers.setHeader "Cache-Control" "no-cache, no-store, must-revalidate"
>=> Writers.setHeader "Pragma" "no-cache"
>=> Writers.setHeader "Expires" "0"
>=> Files.browseHome

let config =
{ defaultConfig with
homeFolder = Some __SOURCE_DIRECTORY__
logger = Logging.Loggers.saneDefaultsFor Logging.LogLevel.Debug
bindings = [ HttpBinding.mkSimple HTTP "127.0.0.1" 8899 ] }

Target "run" (fun _ ->
let _, server = startWebServerAsync config server
Async.Start(server)
System.Diagnostics.Process.Start("http://localhost:8899/index.html") |> ignore
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite)
)

// --------------------------------------------------------------------------------------
//
// --------------------------------------------------------------------------------------

let npm command args workingDir =
let args = sprintf "%s %s" command (String.concat " " args)
let cmd, args = if EnvironmentHelper.isUnix then "npm", args else "cmd", ("/C npm " + args)
let ok =
execProcess (fun info ->
info.FileName <- cmd
info.WorkingDirectory <- workingDir
info.Arguments <- args) TimeSpan.MaxValue
if not ok then failwith (sprintf "'%s %s' task failed" cmd args)

let spawnNode command args workingDir =
let args = sprintf "%s %s" command (String.concat " " args)
let cmd, args = if EnvironmentHelper.isUnix then "node", args else "cmd", ("/C node " + args)
async {
execProcess (fun info ->
info.FileName <- cmd
info.WorkingDirectory <- workingDir
info.Arguments <- args) TimeSpan.MaxValue |> ignore } |> Async.Start

let fable = "paket-files/github.com/fsprojects/Fable/build/fable"

Target "fable" (fun _ ->
__SOURCE_DIRECTORY__ |> npm "install" []
__SOURCE_DIRECTORY__ |> spawnNode fable ["-w"]
)

"fable" ==> "run"
RunTargetOrDefault "run"
26 changes: 26 additions & 0 deletions build.sh
@@ -0,0 +1,26 @@
#!/bin/bash
if test "$OS" = "Windows_NT"
then
MONO=""
else
# Mono fix for https://github.com/fsharp/FAKE/issues/805
export MONO_MANAGED_WATCHER=false
MONO="mono"
fi

$MONO .paket/paket.bootstrapper.exe
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
if [ -e "paket.lock" ]
then
$MONO .paket/paket.exe restore
else
$MONO .paket/paket.exe install
fi
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
$MONO packages/FAKE/tools/FAKE.exe $@ --fsiargs build.fsx
18 changes: 18 additions & 0 deletions fableconfig.json
@@ -0,0 +1,18 @@
{
"outDir": "out",
"sourceMaps": true,
"projFile": "src/thegamma/thegamma.fsproj",
"refs": {
"bindings": "src/bindings"
},
"scripts": {
},
"targets": {
"debug": {
"watch": true
},
"production": {
"sourceMaps": false
}
}
}
25 changes: 25 additions & 0 deletions index.html
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</head>
<body>

<div id="container" style="width:800px;height:600px;border:1px solid grey"></div>

<!-- <script src="node_modules/core-js/client/core.min.js"></script> -->
<script src="node_modules/requirejs/require.js"></script>
<script>
require.config({
paths: { 'vs': 'node_modules/monaco-editor/dev/vs' },
map: {
"*": {
"monaco": "vs/editor/editor.main",
"fable-core": "paket-files/github.com/fsprojects/Fable/src/fable/Fable.Core/fable-core.min.js"
}
}})
require(["out/main"])
</script>
</body>
</html>
17 changes: 17 additions & 0 deletions package.json
@@ -0,0 +1,17 @@
{
"private": true,
"name": "the-gamma",
"version": "0.0.1",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server"
},
"author": "Tomas Petricek",
"license": "Apache-2.0",
"dependencies": {
"core-js": "^2.4.0",
"monaco-editor": "^0.5.1",
"requirejs": "^2.2.0"
}
}
6 changes: 6 additions & 0 deletions paket.dependencies
@@ -0,0 +1,6 @@
source https://www.nuget.org/api/v2
nuget FAKE
nuget Suave

git https://github.com/fsprojects/Fable.git master build: "build.cmd", OS: windows
git https://github.com/fsprojects/Fable.git master build: "build.sh", OS: mono
14 changes: 14 additions & 0 deletions paket.lock
@@ -0,0 +1,14 @@
NUGET
remote: https://www.nuget.org/api/v2
FAKE (4.29.2)
FSharp.Core (4.0.0.1)
Suave (1.1.3)
FSharp.Core (>= 3.1.2.5)
GIT
remote: https://github.com/fsprojects/Fable.git
(ce7cdcef07dd48aced6422d828f677c0f42e6c85)
build: build.cmd
os: windows
(ce7cdcef07dd48aced6422d828f677c0f42e6c85)
build: build.sh
os: mono
28 changes: 28 additions & 0 deletions src/TheGamma.sln
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "thegamma", "thegamma\thegamma.fsproj", "{AE8310C8-1F2B-4F9C-83F6-5D188B7517B2}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "bindings", "bindings\bindings.fsproj", "{278A68FC-0256-417C-AF13-9A4AF7381CCF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE8310C8-1F2B-4F9C-83F6-5D188B7517B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE8310C8-1F2B-4F9C-83F6-5D188B7517B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE8310C8-1F2B-4F9C-83F6-5D188B7517B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE8310C8-1F2B-4F9C-83F6-5D188B7517B2}.Release|Any CPU.Build.0 = Release|Any CPU
{278A68FC-0256-417C-AF13-9A4AF7381CCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{278A68FC-0256-417C-AF13-9A4AF7381CCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{278A68FC-0256-417C-AF13-9A4AF7381CCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{278A68FC-0256-417C-AF13-9A4AF7381CCF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
75 changes: 75 additions & 0 deletions src/bindings/bindings.fsproj
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>278a68fc-0256-417c-af13-9a4af7381ccf</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>bindings</RootNamespace>
<AssemblyName>bindings</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Name>bindings</Name>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\bindings.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\bindings.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Fable.Core">
<HintPath>..\..\paket-files\github.com\fsprojects\Fable\build\fable\bin\Fable.Core.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="monaco.fs" />
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

0 comments on commit 6fc8ba6

Please sign in to comment.