Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to TypeScript #114

Merged
merged 11 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions #scripts/build.ps1
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
param (
$configuration = 'Debug'
)

Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'

Write-Output 'npm'
try {
Write-Output ' WebAssets'
Push-Location 'WebAssets'
npm install
npm run build
Pop-Location

Write-Output ' Owin.Demo'
Push-Location 'Owin.Demo'
npm install
Pop-Location

Write-Output ' AspNetCore.Demo/wwwroot'
Push-Location 'AspNetCore.Demo/wwwroot'
npm install
}
finally {
Pop-Location
Write-Output 'dotnet build'
dotnet build --no-restore --configuration $configuration
if ($LastExitCode -ne 0) {
throw "dotnet build exited with code $LastExitCode"
}

Write-Output 'dotnet build'
dotnet build
Write-Output 'npm run build'
@('WebAssets', 'Owin.Demo', 'AspNetCore.Demo') | % {
try {
Write-Output " $_"
Push-Location $_
npm run build
if ($LastExitCode -ne 0) {
throw "npm run build exited with code $LastExitCode"
}
}
finally {
Pop-Location
}
}
29 changes: 8 additions & 21 deletions #scripts/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ param (
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'

function Invoke-External($command) {
Write-Host
Write-Host $command -ForegroundColor White

Invoke-Expression $command
if ($LastExitCode -ne 0) {
throw "Command finished with exit code $LastExitCode"
}
}

$output = (Resolve-Path .)

@(
Expand All @@ -23,16 +13,13 @@ $output = (Resolve-Path .)
'Owin', 'AspNetCore',
'Testing'
) | % {
Invoke-External "dotnet pack $_ --version-suffix=$versionSuffix --output '$output' --configuration Release"
}

Push-Location WebAssets
try {
Invoke-External "npm install"
Invoke-External "npm run build"
}
finally {
Pop-Location
dotnet pack $_ --version-suffix=$versionSuffix --output $output --configuration Release --no-build --no-restore
if ($LastExitCode -ne 0) {
throw "dotnet pack exited with code $LastExitCode"
}
}

Invoke-External "npm pack ./WebAssets/dist"
npm pack ./WebAssets/dist
if ($LastExitCode -ne 0) {
throw "npm pack exited with code $LastExitCode"
}
24 changes: 24 additions & 0 deletions #scripts/restore.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'

Write-Output 'dotnet restore'
dotnet restore
if ($LastExitCode -ne 0) {
throw "dotnet restore exited with code $LastExitCode"
}

Write-Output 'npm install'
@('WebAssets', 'Owin.Demo', 'AspNetCore.Demo') | % {
try {
Write-Output " $_"
Push-Location $_
# not worth using npm ci until https://github.com/npm/npm/issues/20104
npm install --no-audit
if ($LastExitCode -ne 0) {
throw "npm ci exited with code $LastExitCode"
}
}
finally {
Pop-Location
}
}
5 changes: 5 additions & 0 deletions #scripts/setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'

./restore.ps1
./build.ps1
20 changes: 20 additions & 0 deletions #scripts/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'

Write-Output 'dotnet test'
dotnet test
if ($LastExitCode -ne 0) {
throw "dotnet test exited with code $LastExitCode"
}

Write-Output 'npm test'
try {
Push-Location 'WebAssets'
npm test
if ($LastExitCode -ne 0) {
throw "npm test exited with code $LastExitCode"
}
}
finally {
Pop-Location
}
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ project.lock.json
.vs/
bower_components/
node_modules/
.cache/
bin/
obj/
/*.tgz
WebAssets/dist/*.css
WebAssets/dist/*.less
WebAssets/dist/*.js
WebAssets/dist/*.json
WebAssets/dist/*.md
WebAssets/dist/*.d.ts
/WebAssets/dist
/WebAssets/coverage
/Owin.Demo/wwwroot
/AspNetCore.Demo/wwwroot
25 changes: 25 additions & 0 deletions AspNetCore.Demo/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import mirrorsharp from 'mirrorsharp';

const params = window.location.search.replace(/^\?/, '').split('&').reduce(function (o, item) {
const parts = item.split('=');
o[parts[0]] = parts[1];
return o;
}, {});
const language = (params['language'] || 'CSharp').replace('Sharp', '#');
const mode = params['mode'] || 'regular';

const textarea = document.getElementsByTagName('textarea')[0];
if (language === 'F#') {
textarea.value = '[<EntryPoint>]\r\nlet main argv = \r\n 0';
}
else if (mode === 'script') {
textarea.value = '// C# Script uses Random as the host object.\r\nvar m = Next();';
}

const ms = mirrorsharp(textarea, {
serviceUrl: window.location.href.replace(/^http(s?:\/\/[^/]+).*$/i, 'ws$1/mirrorsharp'),
selfDebugEnabled: true,
language: language
});
if (mode !== 'regular')
ms.sendServerOptions({ 'language': language, 'x-mode': mode });
38 changes: 38 additions & 0 deletions AspNetCore.Demo/app.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@import './node_modules/mirrorsharp/mirrorsharp.less';
@import (less) './node_modules/typeface-open-sans/index.css';

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; }

body {
padding: 0;
margin: 0;
font-size: 16px;
display: flex;
flex-direction: column;
padding: 10px;
}

nav { display: flex; font-family: 'Open Sans', sans-serif; }

nav ul {
list-style: none;
display: flex;
padding: 0;
margin: 0;
}

nav li {
margin-left: 10px;
}

a { text-decoration: none; }

a:hover { text-decoration: underline; }

.CodeMirror {
flex-grow: 1;
margin-top: 10px;
border: 1px solid #ddd;
}
38 changes: 38 additions & 0 deletions AspNetCore.Demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MirrorSharp Demo</title>
<link rel="stylesheet" href="app.less">
</head>
<body>
<nav>
Language:
<ul>
<li><a href="index.html?language=CSharp">C#</a></li>
<li><a href="index.html?language=CSharp&mode=script">C# (Script)</a></li>
<li><a href="index.html?language=FSharp">F#</a></li>
</ul>
</nav>
<textarea>using System;
class C {
const int C2 = 5;
string f;
string P { get; set; }
event EventHandler e;
event EventHandler E { add {} remove {} }

C() {
}

void M(int p) {
var l = p;
}
}

class G&lt;T&gt; {
}</textarea>

<script src="app.js"></script>
</body>
</html>
Loading