Skip to content

Commit

Permalink
Publish TP Fable version in npm
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Aug 5, 2016
1 parent f110bce commit 13dd797
Show file tree
Hide file tree
Showing 19 changed files with 251 additions and 188 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
samples/client-provider/js/*.*

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

Expand Down
99 changes: 98 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,87 @@ let gitName = "FSharp.Data.GraphQL"
let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/bazingatechnologies"
let release = LoadReleaseNotes "RELEASE_NOTES.md"


module Util =
open System.Net

let join pathParts =
Path.Combine(Array.ofSeq pathParts)

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

let runAndReturn workingDir fileName args =
let fileName, args =
if EnvironmentHelper.isUnix
then fileName, args else "cmd", ("/C " + args)
ExecProcessAndReturnMessages (fun info ->
info.FileName <- fileName
info.WorkingDirectory <- workingDir
info.Arguments <- args) TimeSpan.MaxValue
|> fun p -> p.Messages |> String.concat "\n"

let rmdir dir =
if EnvironmentHelper.isUnix
then FileUtils.rm_rf dir
// Use this in Windows to prevent conflicts with paths too long
else run "." "cmd" ("/C rmdir /s /q " + Path.GetFullPath dir)

let compileScript symbols outDir fsxPath =
let dllFile = Path.ChangeExtension(Path.GetFileName fsxPath, ".dll")
let opts = [
yield FscHelper.Out (Path.Combine(outDir, dllFile))
yield FscHelper.Target FscHelper.TargetType.Library
yield! symbols |> List.map FscHelper.Define
]
FscHelper.compile opts [fsxPath]
|> function 0 -> () | _ -> failwithf "Cannot compile %s" fsxPath

let normalizeVersion (version: string) =
let i = version.IndexOf("-")
if i > 0 then version.Substring(0, i) else version

let assemblyInfo projectDir version extra =
let version = normalizeVersion version
let asmInfoPath = projectDir </> "AssemblyInfo.fs"
(Attribute.Version version)::extra
|> CreateFSharpAssemblyInfo asmInfoPath

module Npm =
let script workingDir script args =
sprintf "run %s -- %s" script (String.concat " " args)
|> Util.run workingDir "npm"

let install workingDir modules =
sprintf "install %s" (String.concat " " modules)
|> Util.run workingDir "npm"

let command workingDir command args =
sprintf "%s %s" command (String.concat " " args)
|> Util.run workingDir "npm"

let commandAndReturn workingDir command args =
sprintf "%s %s" command (String.concat " " args)
|> Util.runAndReturn workingDir "npm"

let getLatestVersion package tag =
let package =
match tag with
| Some tag -> package + "@" + tag
| None -> package
commandAndReturn "." "show" [package; "version"]

module Node =
let run workingDir script args =
let args = sprintf "%s %s" script (String.concat " " args)
Util.run workingDir "node" args

// --------------------------------------------------------------------------------------
// Helpers for generating AssemblyInfo
Expand Down Expand Up @@ -391,6 +471,23 @@ Target "PublishClient" (fun _ ->
}) "tools/Nuget/template.nuspec"
)

Target "PublishNpm" (fun _ ->
let binDir, prjDir = "bin/npm", "src/FSharp.Data.GraphQL.Client"
CleanDir binDir

!!("src/FSharp.Data.GraphQL.Client" </> "*.fsproj")
|> MSBuild "bin/FSharp.Data.GraphQL.Client" "Build" [
"Configuration", "Build"; "DefineConstants", "FABLE"
] |> ignore

CopyDir binDir (prjDir </> "bin" </> "Release") (fun _ -> true)
!!(prjDir </> "npm" </> "*.*")
|> Seq.iter (fun path -> FileUtils.cp path binDir)

Npm.command binDir "version" ["0.0.3"] //[string release.SemVer]
Npm.command binDir "publish" []
)

Target "BuildPackage" DoNothing

// --------------------------------------------------------------------------------------
Expand Down
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "fsharp-data-graphql",
"version": "1.0.0",
"description": "FSharp implementation of Facebook GraphQL query language",
"main": "index.js",
"directories": {
"doc": "docs",
"test": "tests"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bazingatechnologies/FSharp.Data.GraphQL.git"
},
"keywords": [
"f#",
"fsharp",
"graphql",
"provider"
],
"author": "Bazinga Technologies Inc",
"license": "MIT",
"bugs": {
"url": "https://github.com/bazingatechnologies/FSharp.Data.GraphQL/issues"
},
"homepage": "https://github.com/bazingatechnologies/FSharp.Data.GraphQL#readme",
"dependencies": {
"fable-core": "^0.5.2"
}
}
1 change: 1 addition & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ nuget FParsec
nuget Hopac
nuget Newtonsoft.Json
nuget Suave
nuget System.Runtime

group Build
source https://nuget.org/api/v2
Expand Down
5 changes: 5 additions & 0 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ NUGET
Hopac (0.2.1)
FSharp.Core (>= 3.1.2.5)
Microsoft.Diagnostics.Tracing.TraceEvent (1.0.41) - framework: >= net40, dnx451
Microsoft.NETCore.Platforms (1.0.1) - framework: dnxcore50, netstandard10, netstandard12, netstandard13, >= netstandard15
Microsoft.NETCore.Targets (1.0.1) - framework: dnxcore50, netstandard10, netstandard12, netstandard13, >= netstandard15
Newtonsoft.Json (8.0.3)
Suave (1.1.2)
FSharp.Core (>= 3.1.2.5)
System.Runtime (4.1)
Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard12, netstandard13, >= netstandard15
Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard12, netstandard13, >= netstandard15

GROUP Build
NUGET
Expand Down
56 changes: 0 additions & 56 deletions samples/client-provider/js/fable_inject.js

This file was deleted.

91 changes: 0 additions & 91 deletions samples/client-provider/js/query.js

This file was deleted.

1 change: 0 additions & 1 deletion samples/client-provider/js/query.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion samples/client-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"fable-core": "^0.2.0-alpha",
"fable-core": "^0.5.2",
"isomorphic-fetch": "^2.2.1"
}
}
4 changes: 2 additions & 2 deletions samples/client-provider/query.fsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#r "../../bin/FSharp.Data.GraphQL.Client/FSharp.Data.GraphQL.Client.dll"
#r "node_modules/fable-core/Fable.Core.dll"

open FSharp.Data.GraphQL
open System.Collections.Generic

#if FABLE
Fable.Import.Node.require.Invoke("isomorphic-fetch") |> ignore
#r "node_modules/fable-core/Fable.Core.dll"
Fable.Core.JsInterop.importAll<unit> "isomorphic-fetch"
#endif

let [<Literal>] serverUrl = "http://localhost:8083"
Expand Down
2 changes: 2 additions & 0 deletions samples/graphiql-client/server.fsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#r "../../packages/Suave/lib/net40/Suave.dll"
#r "../../packages/Newtonsoft.Json/lib/net40/Newtonsoft.Json.dll"
#r "../../packages/System.Runtime/lib/net462/System.Runtime.dll"
#r "../../bin/FSharp.Data.GraphQL/Hopac.dll"
#r "../../bin/FSharp.Data.GraphQL/Hopac.Core.dll"
#r "../../bin/FSharp.Data.GraphQL/Hopac.Platform.dll"
#r "../../bin/FSharp.Data.GraphQL/FSharp.Data.GraphQL.Shared.dll"
#r "../../bin/FSharp.Data.GraphQL/FSharp.Data.GraphQL.dll"

Expand Down
Loading

0 comments on commit 13dd797

Please sign in to comment.