From 7c1513c80038862ada969a3cbafdf44aeb990787 Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Thu, 29 Nov 2018 16:44:06 +0100 Subject: [PATCH] Publish fable-compiler 2.1.1 --- build.fsx | 2 +- src/dotnet/Fable.Compiler/CLI/CLI.Util.fs | 63 ++++++++++++------- .../Fable.Compiler/CLI/ProjectCracker.fs | 9 ++- src/js/fable-compiler/RELEASE_NOTES.md | 4 ++ src/js/fable-compiler/package-lock.json | 2 +- src/js/fable-compiler/package.json | 2 +- src/js/fable-compiler/src/index.ts | 13 +--- 7 files changed, 57 insertions(+), 38 deletions(-) diff --git a/build.fsx b/build.fsx index 8d26d9bbab..010868578c 100644 --- a/build.fsx +++ b/build.fsx @@ -194,7 +194,7 @@ let githubRelease releaseNotesDir () = // release on github createClient user pw - |> createDraft gitOwner project release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes + |> createRelease gitOwner project release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes // |> uploadFile (buildDir("FSharp.Compiler.Service." + release.NugetVersion + ".nupkg")) |> releaseDraft |> Async.RunSynchronously diff --git a/src/dotnet/Fable.Compiler/CLI/CLI.Util.fs b/src/dotnet/Fable.Compiler/CLI/CLI.Util.fs index 2fd673c34b..c067737e54 100644 --- a/src/dotnet/Fable.Compiler/CLI/CLI.Util.fs +++ b/src/dotnet/Fable.Compiler/CLI/CLI.Util.fs @@ -2,7 +2,7 @@ namespace Fable.CLI module Literals = - let [] VERSION = "2.1.0" + let [] VERSION = "2.1.1" let [] CORE_VERSION = "2.0.2" let [] DEFAULT_PORT = 61225 let [] FORCE = "force:" @@ -173,26 +173,47 @@ module Process = p.Start() |> ignore p - let run workingDir fileName args = - let p = - Options() - |> start workingDir fileName args - p.WaitForExit() - match p.ExitCode with - | 0 -> () - | c -> failwithf "Process %s %s finished with code %i" fileName args c - - let tryRunAndGetOutput workingDir fileName args = - try - let p = - Options(redirectOutput=true) - |> start workingDir fileName args - let output = p.StandardOutput.ReadToEnd() - // printfn "%s" output - p.WaitForExit() - output - with ex -> - "ERROR: " + ex.Message + // Adapted from https://github.com/enricosada/dotnet-proj-info/blob/1e6d0521f7f333df7eff3148465f7df6191e0201/src/dotnet-proj/Program.fs#L155 + let runCmd log errorLog workingDir exePath args = + log (workingDir + "> " + exePath + " " + (args |> String.concat " ")) + + let logOut = System.Collections.Concurrent.ConcurrentQueue() + let logErr = System.Collections.Concurrent.ConcurrentQueue() + + let runProcess (workingDir: string) (exePath: string) (args: string) = + let psi = System.Diagnostics.ProcessStartInfo() + psi.FileName <- exePath + psi.WorkingDirectory <- workingDir + psi.RedirectStandardOutput <- true + psi.RedirectStandardError <- true + psi.Arguments <- args + psi.CreateNoWindow <- true + psi.UseShellExecute <- false + + use p = new System.Diagnostics.Process() + p.StartInfo <- psi + + p.OutputDataReceived.Add(fun ea -> logOut.Enqueue (ea.Data)) + p.ErrorDataReceived.Add(fun ea -> logErr.Enqueue (ea.Data)) + + try + p.Start() |> ignore + p.BeginOutputReadLine() + p.BeginErrorReadLine() + p.WaitForExit() + p.ExitCode + with ex -> + errorLog ("Cannot run: " + ex.Message) + -1 + + let exitCode = + String.concat " " args + |> runProcess workingDir exePath + + for x in logOut.ToArray() do log x + for x in logErr.ToArray() do errorLog x + + exitCode [] module Async = diff --git a/src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs b/src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs index 91d2107103..5d419d5aed 100644 --- a/src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs +++ b/src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs @@ -198,9 +198,12 @@ let fullCrack (projFile: string): CrackedFsproj = // may have a different case, see #1227 let dllRefs = Dictionary(StringComparer.OrdinalIgnoreCase) // Try restoring project - // TODO: Detect if `dotnet` is not installed globally? How does Dotnet.ProjInfo detect it? - Process.tryRunAndGetOutput (IO.Path.GetDirectoryName projFile) "dotnet" ("restore " + (IO.Path.GetFileName projFile)) - |> Console.WriteLine + do + Process.runCmd + Console.WriteLine Console.WriteLine + (IO.Path.GetDirectoryName projFile) + "dotnet" ["restore"; IO.Path.GetFileName projFile] + |> ignore let projOpts, projRefs, _msbuildProps = ProjectCoreCracker.GetProjectOptionsFromProjectFile projFile // let targetFramework = diff --git a/src/js/fable-compiler/RELEASE_NOTES.md b/src/js/fable-compiler/RELEASE_NOTES.md index a9941ae618..291eee86b9 100644 --- a/src/js/fable-compiler/RELEASE_NOTES.md +++ b/src/js/fable-compiler/RELEASE_NOTES.md @@ -1,3 +1,7 @@ +### 2.1.1 + +* Try not to stop compilation if `dotnet restore` fails. + ### 2.1.0 * Release _stablish_ version diff --git a/src/js/fable-compiler/package-lock.json b/src/js/fable-compiler/package-lock.json index 3637949c8e..433b22bd00 100644 --- a/src/js/fable-compiler/package-lock.json +++ b/src/js/fable-compiler/package-lock.json @@ -1,6 +1,6 @@ { "name": "fable-compiler", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/js/fable-compiler/package.json b/src/js/fable-compiler/package.json index d108058ef2..00e44d13a0 100644 --- a/src/js/fable-compiler/package.json +++ b/src/js/fable-compiler/package.json @@ -1,6 +1,6 @@ { "name": "fable-compiler", - "version": "2.1.0", + "version": "2.1.1", "main": "dist/index.js", "description": "Fable compiler", "keywords": [ diff --git a/src/js/fable-compiler/src/index.ts b/src/js/fable-compiler/src/index.ts index 29b1e4945b..49995ca333 100644 --- a/src/js/fable-compiler/src/index.ts +++ b/src/js/fable-compiler/src/index.ts @@ -19,14 +19,6 @@ function uuid() { } /* tslint:enable:no-bitwise */ -function parseJson(json) { - try { - return JSON.parse(json); - } catch { - return json; - } -} - function getVersion(): string { try { return require("../package.json").version; @@ -83,14 +75,13 @@ export default function start(cliArgs?: {}): ICompilerProxy { input: child.stdout, }); linereader.on("line", (data: string) => { - const pattern = /^JSON:([\w-]+):(.*)$/.exec(data); + const pattern = /^JSON:([\w-]+):/.exec(data); if (pattern != null) { const id = pattern[1]; const resolve = pending.get(id); if (resolve != null) { - const response = parseJson(pattern[2]); - resolve(response); pending.delete(id); + resolve(JSON.parse(data.substr(pattern[0].length))); } } else { // LOG console.log(data);