Skip to content

Commit

Permalink
Merge pull request #216 from nfdi4plants/developer_issues2
Browse files Browse the repository at this point in the history
Issues
  • Loading branch information
Freymaurer authored Sep 27, 2023
2 parents cb1254b + 83d5aaf commit 98b0e41
Show file tree
Hide file tree
Showing 28 changed files with 447 additions and 347 deletions.
68 changes: 28 additions & 40 deletions build/PackageTasks.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module PackageTasks

open ProjectInfo

open MessagePrompts
open BasicTasks
open TestTasks
Expand All @@ -18,91 +16,81 @@ let private replaceCommitLink input =
Regex.Replace(input,commitLinkPattern,"")

let packDotNet = BuildTask.create "PackDotNet" [clean; build; runTests] {
if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag )
if promptYesNo (sprintf "[NUGET] creating stable package with version %s OK?" ProjectInfo.stableVersionTag )
then
!! "src/**/*.*proj"
-- "src/bin/*"
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"Version",stableVersionTag
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.concat "\r\n" )
"Version", ProjectInfo.stableVersionTag
"PackageReleaseNotes", (ProjectInfo.release.Notes |> List.map replaceCommitLink |> String.concat "\r\n" )
] @ p.MSBuildParams.Properties)
}
{
p with
MSBuildParams = msBuildParams
OutputPath = Some pkgDir
OutputPath = Some ProjectInfo.pkgDir
}
))
else failwith "aborted"
}

let packDotNetPrerelease = BuildTask.create "PackDotNetPrerelease" [setPrereleaseTag; clean; build; (*runTests*)] {
if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag )
if promptYesNo (sprintf "[NUGET] package tag will be %s OK?" ProjectInfo.prereleaseTag )
then
!! "src/**/*.*proj"
-- "src/bin/*"
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"Version", prereleaseTag
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.toLines )
"Version", ProjectInfo.prereleaseTag
"PackageReleaseNotes", (ProjectInfo.release.Notes |> List.map replaceCommitLink |> String.toLines )
] @ p.MSBuildParams.Properties)
}
{
p with
VersionSuffix = Some prereleaseSuffix
OutputPath = Some pkgDir
VersionSuffix = Some ProjectInfo.prereleaseSuffix
OutputPath = Some ProjectInfo.pkgDir
MSBuildParams = msBuildParams
}
))
else
failwith "aborted"
}

let packJS = BuildTask.create "PackJS" [clean; build; runTests] {
if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag )
then
Fake.JavaScript.Npm.run "bundlejs" (fun o -> o)
Fake.IO.File.readAsString "build/release_package.json"
|> Fake.IO.File.writeString false "dist/js/package.json"

Fake.IO.File.readAsString "README.md"
|> Fake.IO.File.writeString false "dist/js/README.md"

"" // "fable-library.**/**"
|> Fake.IO.File.writeString false "dist/js/fable_modules/.npmignore"

Fake.JavaScript.Npm.exec "pack" (fun o ->
{ o with
WorkingDirectory = "./dist/js/"
})
else failwith "aborted"
}


let packJSPrerelease = BuildTask.create "PackJSPrerelease" [setPrereleaseTag; clean; build; runTests] {
if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag ) then
module BundleJs =
let bundle (versionTag: string) =
Fake.JavaScript.Npm.run "bundlejs" (fun o -> o)

GenerateIndexJs.ARCtrl_generate ProjectInfo.npmPkgDir
Fake.IO.File.readAsString "build/release_package.json"
|> fun t ->
let t = t.Replace(stableVersionTag, prereleaseTag)
Fake.IO.File.writeString false "dist/js/package.json" t
let t = t.Replace(ProjectInfo.stableVersionTag, versionTag)
Fake.IO.File.writeString false $"{ProjectInfo.npmPkgDir}/package.json" t

Fake.IO.File.readAsString "README.md"
|> Fake.IO.File.writeString false "dist/js/README.md"
|> Fake.IO.File.writeString false $"{ProjectInfo.npmPkgDir}/README.md"

"" // "fable-library.**/**"
|> Fake.IO.File.writeString false "dist/js/fable_modules/.npmignore"
|> Fake.IO.File.writeString false $"{ProjectInfo.npmPkgDir}/fable_modules/.npmignore"

Fake.JavaScript.Npm.exec "pack" (fun o ->
{ o with
WorkingDirectory = "./dist/js/"
WorkingDirectory = ProjectInfo.npmPkgDir
})

let packJS = BuildTask.create "PackJS" [clean; build; runTests] {
if promptYesNo (sprintf "[NPM] creating stable package with version %s OK?" ProjectInfo.stableVersionTag )
then
BundleJs.bundle ProjectInfo.stableVersionTag
else failwith "aborted"
}

let packJSPrerelease = BuildTask.create "PackJSPrerelease" [setPrereleaseTag; clean; build; runTests] {
if promptYesNo (sprintf "[NPM] package tag will be %s OK?" ProjectInfo.prereleaseTag ) then
BundleJs.bundle ProjectInfo.prereleaseTag
else failwith "aborted"
}

Expand Down
2 changes: 1 addition & 1 deletion build/ProjectInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let gitHome = $"https://github.com/{gitOwner}"
let projectRepo = $"https://github.com/{gitOwner}/{project}"

let pkgDir = "dist/pkg"
let npmPkgDir = "dist/js"
let npmPkgDir = "./dist/js"

// Create RELEASE_NOTES.md if not existing. Or "release" would throw an error.
Fake.Extensions.Release.ReleaseNotes.ensure()
Expand Down
4 changes: 1 addition & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/ARCtrl/ARCtrl.fs → src/ARCtrl/ARC.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste
with get() = _isa
and set(newISA : ArcInvestigation option) =
_isa <- newISA
this.UpdateFileSystem()

member this.CWL
with get() = cwl
Expand Down Expand Up @@ -225,8 +226,8 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste
)

| None ->
//printfn "ARC contains no ISA part."
workbooks.Add (Path.InvestigationFileName, (DTOType.ISA_Investigation, ISA.Spreadsheet.ArcInvestigation.toFsWorkbook (ArcInvestigation.create(Identifier.MISSING_IDENTIFIER))))
printfn "ARC contains no ISA part."

// Iterates over filesystem and creates a write contract for every file. If possible, include DTO.
_fs.Tree.ToFilePaths(true)
Expand Down Expand Up @@ -355,6 +356,9 @@ type ARC(?isa : ISA.ArcInvestigation, ?cwl : CWL.CWL, ?fs : FileSystem.FileSyste
|> Option.bind (fun tree -> if ignoreHidden then tree |> FileSystemTree.filterFolders (fun n -> not (n.StartsWith("."))) else Some tree)
|> Option.defaultValue (FileSystemTree.fromFilePaths [||])

static member DefaultContracts = Map<string,Contract> [|
ARCtrl.Contract.Git.gitignoreFileName, ARCtrl.Contract.Git.gitignoreContract
|]

//-Pseudo code-//
//// Option 1
Expand Down
2 changes: 1 addition & 1 deletion src/ARCtrl/ARCtrl.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<Compile Include="Templates\Template.Spreadsheet.fs" />
<Compile Include="Templates\Template.Web.fs" />
<None Include="README.md" />
<Compile Include="ARCtrl.fs" />
<Compile Include="ARC.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contract\ARCtrl.Contract.fsproj" />
Expand Down
10 changes: 5 additions & 5 deletions src/ARCtrl/Templates/Template.Json.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ module Template =
)
)

let decodeFromString (jsonString: string) =
let fromJsonString (jsonString: string) =
match Decode.fromString decode jsonString with
| Ok template -> template
| Error exn -> failwithf "Error. Given json string cannot be parsed to Template: %A" exn

let encodeToString (spaces: int) (template:Template) =
let toJsonString (spaces: int) (template:Template) =
Encode.toString spaces (encode template)

module Templates =
Expand All @@ -125,12 +125,12 @@ module Templates =
let d = Decode.dict Template.decode
Decode.fromString d

let decodeFromString (jsonString: string) =
let fromJsonString (jsonString: string) =
match decode jsonString with
| Ok templateMap -> templateMap
| Error exn -> failwithf "Error. Given json string cannot be parsed to Templates map: %A" exn

let encodeToString (spaces: int) (templateList: (string*Template) []) =
let toJsonString (spaces: int) (templateList: (string*Template) []) =
Encode.toString spaces (encode templateList)


Expand All @@ -140,4 +140,4 @@ module Extension =
type Template with
member this.ToJson(?spaces: int) =
let spaces = defaultArg spaces 0
Template.encodeToString(spaces)
Template.toJsonString(spaces)
2 changes: 1 addition & 1 deletion src/ARCtrl/Templates/Template.Web.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let getTemplates(url: string option) =
let url = defaultArg url defaultURL
async {
let! jsonString = ARCtrl.WebRequest.downloadFile url
let mapResult = Json.Templates.decodeFromString jsonString
let mapResult = Json.Templates.fromJsonString jsonString
return mapResult
}

Expand Down
3 changes: 3 additions & 0 deletions src/FileSystem/DefaultGitignore.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module ARCtrl.FileSystem.DefaultGitignore

/// <summary>
/// A string containing the default .gitignore file content.
/// </summary>
let dgi = """# ----- macos rules -----
# taken from https://github.com/github/gitignore/blob/main/Global/macOS.gitignore
# General
Expand Down
22 changes: 11 additions & 11 deletions src/ISA/ISA.Json/Assay.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ module Assay =

let encoder (options : ConverterOptions) (oa : obj) =
[
if options.SetID then "@id", GEncode.string (oa :?> Assay |> genID)
else GEncode.tryInclude "@id" GEncode.string (oa |> GEncode.tryGetPropertyValue "ID")
if options.IncludeType then "@type", GEncode.string "Assay"
GEncode.tryInclude "filename" GEncode.string (oa |> GEncode.tryGetPropertyValue "FileName")
if options.SetID then "@id", GEncode.toJsonString (oa :?> Assay |> genID)
else GEncode.tryInclude "@id" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "ID")
if options.IncludeType then "@type", GEncode.toJsonString "Assay"
GEncode.tryInclude "filename" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "FileName")
GEncode.tryInclude "measurementType" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "MeasurementType")
GEncode.tryInclude "technologyType" (OntologyAnnotation.encoder options) (oa |> GEncode.tryGetPropertyValue "TechnologyType")
GEncode.tryInclude "technologyPlatform" GEncode.string (oa |> GEncode.tryGetPropertyValue "TechnologyPlatform")
GEncode.tryInclude "technologyPlatform" GEncode.toJsonString (oa |> GEncode.tryGetPropertyValue "TechnologyPlatform")
GEncode.tryInclude "dataFiles" (Data.encoder options) (oa |> GEncode.tryGetPropertyValue "DataFiles")
GEncode.tryInclude "materials" (AssayMaterials.encoder options) (oa |> GEncode.tryGetPropertyValue "Materials")
GEncode.tryInclude "characteristicCategories" (MaterialAttribute.encoder options) (oa |> GEncode.tryGetPropertyValue "CharacteristicCategories")
Expand Down Expand Up @@ -71,10 +71,10 @@ module Assay =
}
)

let fromString (s:string) =
GDecode.fromString (decoder (ConverterOptions())) s
let fromJsonString (s:string) =
GDecode.fromJsonString (decoder (ConverterOptions())) s

let toString (p:Assay) =
let toJsonString (p:Assay) =
encoder (ConverterOptions()) p
|> Encode.toString 2

Expand All @@ -95,11 +95,11 @@ module ArcAssay =

open Assay

let fromString (s:string) =
GDecode.fromString (decoder (ConverterOptions())) s
let fromJsonString (s:string) =
GDecode.fromJsonString (decoder (ConverterOptions())) s
|> ArcAssay.fromAssay

let toString (a:ArcAssay) =
let toJsonString (a:ArcAssay) =
encoder (ConverterOptions()) (a.ToAssay())
|> Encode.toString 2

Expand Down
16 changes: 8 additions & 8 deletions src/ISA/ISA.Json/Comment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ module Comment =

let encoder (options : ConverterOptions) (comment : obj) =
[
if options.SetID then "@id", GEncode.string (comment :?> Comment |> genID)
else GEncode.tryInclude "@id" GEncode.string (comment |> GEncode.tryGetPropertyValue "ID")
if options.IncludeType then "@type", GEncode.string "Comment"
GEncode.tryInclude "name" GEncode.string (comment |> GEncode.tryGetPropertyValue "Name")
GEncode.tryInclude "value" GEncode.string (comment |> GEncode.tryGetPropertyValue "Value")
if options.SetID then "@id", GEncode.toJsonString (comment :?> Comment |> genID)
else GEncode.tryInclude "@id" GEncode.toJsonString (comment |> GEncode.tryGetPropertyValue "ID")
if options.IncludeType then "@type", GEncode.toJsonString "Comment"
GEncode.tryInclude "name" GEncode.toJsonString (comment |> GEncode.tryGetPropertyValue "Name")
GEncode.tryInclude "value" GEncode.toJsonString (comment |> GEncode.tryGetPropertyValue "Value")
]
|> GEncode.choose
|> Encode.object
Expand All @@ -40,10 +40,10 @@ module Comment =
}
)

let fromString (s:string) =
GDecode.fromString (decoder (ConverterOptions())) s
let fromJsonString (s:string) =
GDecode.fromJsonString (decoder (ConverterOptions())) s

let toString (c:Comment) =
let toJsonString (c:Comment) =
encoder (ConverterOptions()) c
|> Encode.toString 2

Expand Down
Loading

0 comments on commit 98b0e41

Please sign in to comment.