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

update portacode #338

Merged
merged 7 commits into from
Feb 20, 2019
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
15 changes: 15 additions & 0 deletions DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ On Windows:
.\build Test
```

## Dev Notes - Testing LiveUpdate

Use the CounterApp to test. To run the equivalent of the `fabulous` CLI tool use this:

cd Samples\CounterApp\CounterApp
adb -d forward tcp:9867 tcp:9867
dotnet run --project ..\..\..\src\Fabulous.Cli\Fabulous.Cli.fsproj -- --watch --send

If you want to update your (global!) install of the `fabulous-cli` tool, first bump the version number to avoid clashes, then:

dotnet pack src\Fabulous.Cli
dotnet tool uninstall --global fabulous-cli
dotnet tool install --global --add-source C:\GitHub\dsyme\Fabulous\src\Fabulous.Cli\bin\Debug\ fabulous-cli
fabulous --watch --send

## Dev Notes - Releasing

Before releasing a new version, add a new entry at the top of [RELEASE_NOTES.md](RELEASE_NOTES.md) (FAKE will use that version when building).
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
<PropertyGroup Condition="$(TargetFramework) == 'netstandard2.0' OR $(TargetFramework) == 'netcoreapp2.0'">
<OtherFlags>/warnon:1182</OtherFlags>
</PropertyGroup>
</Project>
</Project>
5 changes: 3 additions & 2 deletions docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ At the time of writing this has been trialled with

Some manual set-up is required. The following assumes your app is called `SqueakyApp`:

1. Install `fabulous-cli` as a global tool
1. Install or update `fabulous-cli` as a global tool

dotnet tool install -g fabulous-cli
dotnet tool update -g fabulous-cli

2. Check your projects have a reference to nuget package `Fabulous.LiveUpdate` for all projects in your app.
This is the default for apps created with templates 0.13.10 and higher. Do a clean build.
Expand All @@ -44,7 +45,7 @@ Some manual set-up is required. The following assumes your app is called `Squea
6. Run the following from your core project directory (e.g. `SqueakyApp\SqueakyApp`)

cd SqueakyApp\SqueakyApp
fabulous --watch --webhook:http://localhost:9867/update
fabulous --watch --send

Now, whenever you save a file in your core project directory, the `fabulous` watcher will attempt to recompile your changed file and
send a representation of its contents to your app via a PUT request to the given webhook. The app then deserializes this representation and
Expand Down
24 changes: 12 additions & 12 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ NUGET
System.Reflection.Extensions (4.3)
System.Reflection.Primitives (4.3)
System.Resources.ResourceManager (4.3)
System.Runtime (4.3)
System.Runtime.Extensions (4.3)
System.Runtime (4.3.1)
System.Runtime.Extensions (4.3.1)
System.Runtime.Handles (4.3)
System.Runtime.InteropServices (4.3)
System.Runtime.InteropServices.RuntimeInformation (4.3)
Expand Down Expand Up @@ -376,8 +376,8 @@ NUGET
System.Reflection.Extensions (4.3)
System.Reflection.Primitives (4.3)
System.Resources.ResourceManager (4.3)
System.Runtime (4.3)
System.Runtime.Extensions (4.3)
System.Runtime (4.3.1)
System.Runtime.Extensions (4.3.1)
System.Runtime.Handles (4.3)
System.Runtime.InteropServices (4.3)
System.Runtime.InteropServices.RuntimeInformation (4.3)
Expand Down Expand Up @@ -513,8 +513,8 @@ NUGET
System.Reflection.Extensions (4.3)
System.Reflection.Primitives (4.3)
System.Resources.ResourceManager (4.3)
System.Runtime (4.3)
System.Runtime.Extensions (4.3)
System.Runtime (4.3.1)
System.Runtime.Extensions (4.3.1)
System.Runtime.Handles (4.3)
System.Runtime.InteropServices (4.3)
System.Runtime.InteropServices.RuntimeInformation (4.3)
Expand Down Expand Up @@ -559,12 +559,12 @@ NUGET
Xamarin.Forms (>= 2.3.3.180)
GITHUB
remote: fsprojects/FSharp.Compiler.PortaCode
src/CodeModel.fs (a21e622bca42dd58e186c32f9be0505335f3c4a7)
src/FromCompilerService.fs (a21e622bca42dd58e186c32f9be0505335f3c4a7)
src/Interpreter.fs (a21e622bca42dd58e186c32f9be0505335f3c4a7)
src/ProcessCommandLine.fs (a21e622bca42dd58e186c32f9be0505335f3c4a7)
src/ProjectCracker.fs (a21e622bca42dd58e186c32f9be0505335f3c4a7)
tests/PortaCodeTests.fs (a21e622bca42dd58e186c32f9be0505335f3c4a7)
src/CodeModel.fs (0c6686bcc518246d879bb3d0e3cd4cdbbc72d5ad)
src/FromCompilerService.fs (0c6686bcc518246d879bb3d0e3cd4cdbbc72d5ad)
src/Interpreter.fs (0c6686bcc518246d879bb3d0e3cd4cdbbc72d5ad)
src/ProcessCommandLine.fs (0c6686bcc518246d879bb3d0e3cd4cdbbc72d5ad)
src/ProjectCracker.fs (0c6686bcc518246d879bb3d0e3cd4cdbbc72d5ad)
tests/PortaCodeTests.fs (0c6686bcc518246d879bb3d0e3cd4cdbbc72d5ad)
GROUP wpfapp
RESTRICTION: == net472
NUGET
Expand Down
2 changes: 2 additions & 0 deletions samples/CounterApp/CounterApp/CounterApp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type CounterApp () as app =
let runner = App.program |> Program.runWithDynamicView app

#if DEBUG
// Run LiveUpdate using:
//
do runner.EnableLiveUpdate ()
#endif

Expand Down
8 changes: 4 additions & 4 deletions src/Fabulous.Cli/fscd.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

// F# Compiler Daemon sample
//
// Sample use, assumes app has a reference to ELmish.XamrinForms.LiveUpdate:
// Sample use during development, assumes app has a reference to Fabulous.LiveUpdate:
//
// cd Fabulous\Samples\CounterApp\CounterApp
// adb -d forward tcp:9867 tcp:9867
// dotnet run --project ..\..\..\Fabulous.Cli\Fabulous.Cli.fsproj -- --eval @out.args
// dotnet run --project ..\..\..\Fabulous.Cli\Fabulous.Cli.fsproj -- --watch --webhook:http://localhost:9867/update @out.args
// adb -d forward tcp:9867 tcp:9867
// dotnet run --project ..\..\..\src\Fabulous.Cli\Fabulous.Cli.fsproj -- --eval @out.args
// dotnet run --project ..\..\..\src\Fabulous.Cli\Fabulous.Cli.fsproj -- --watch --send

module FSharpDaemon.Driver

Expand Down
19 changes: 14 additions & 5 deletions src/Fabulous.LiveUpdate/LiveUpdate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,24 @@ type BroadcastInfo =
elif Device.RuntimePlatform = Device.Android then
printfn " LiveUpdate: On USB connect using:"
printfn " adb -d forward tcp:%d tcp:%d" httpPort httpPort
printfn " fabulous --watch --webhook:http://localhost:%d/update" httpPort
if httpPort = Ports.DefaultPort then
printfn " fabulous --watch --send"
else
printfn " fabulous --watch --webhook:http://localhost:%d/update" httpPort
printfn " "
printfn " LiveUpdate: On Emulator connect using:"
printfn " adb -e forward tcp:%d tcp:%d" httpPort httpPort
printfn " fabulous --watch --webhook:http://localhost:%d/update" httpPort
if httpPort = Ports.DefaultPort then
printfn " fabulous --watch --send"
else
printfn " fabulous --watch --webhook:http://localhost:%d/update" httpPort
else
printfn " LiveUpdate: %s is not officially supported" Device.RuntimePlatform
printfn " LiveUpdate: You can still try to connect using:"
printfn " fabulous --watch --webhook:http://localhost:%d/update" httpPort
if httpPort = Ports.DefaultPort then
printfn " fabulous --watch --send"
else
printfn " fabulous --watch --webhook:http://localhost:%d/update" httpPort

printfn " "
printfn " See https://fsprojects.github.io/Fabulous/tools.html for more details"
Expand Down Expand Up @@ -192,7 +201,7 @@ module Extensions =
let rec tryFindMemberByName name (decls: DDecl[]) =
decls |> Array.tryPick (function
| DDeclEntity (_, ds) -> tryFindMemberByName name ds
| DDeclMember (membDef, body) -> if membDef.Name = name then Some (membDef, body) else None
| DDeclMember (membDef, body, _range) -> if membDef.Name = name then Some (membDef, body) else None
| _ -> None)

/// Trace all the updates to the console
Expand Down Expand Up @@ -255,7 +264,7 @@ module Extensions =

printfn "LiveUpdate: evaluating 'program'...."
let entity = interp.ResolveEntity(membDef.EnclosingEntity)
let programObj = interp.GetExprDeclResult(entity, membDef.Name)
let (_, programObj) = interp.GetExprDeclResult(entity, membDef.Name)
match getVal programObj with

| :? Program<obj, obj, obj -> (obj -> unit) -> ViewElement> as programErased ->
Expand Down
2 changes: 1 addition & 1 deletion tests/Fabulous.Cli.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace FSharpDaemon.Tests
open System
open NUnit.Framework
open FsUnit
open FSharp.Compiler.PortaCode.Tests // for TestHelpers
open FSharp.Compiler.PortaCode.Tests.Basic// for TestHelpers

module Versions =
let XamarinForms = "3.4.0.1009999"
Expand Down