diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index e9477b8..d2cd0a6 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -1,24 +1,18 @@ { - "version": 1, - "isRoot": true, - "tools": { - "fake-cli": { - "version": "6.1.4", - "commands": [ - "fake" - ] - }, - "paket": { - "version": "10.3.1", - "commands": [ - "paket" - ] - }, - "dotnet-fsharplint": { - "version": "0.26.10", - "commands": [ - "dotnet-fsharplint" - ] - } + "version": 1, + "isRoot": true, + "tools": { + "paket": { + "version": "10.3.1", + "commands": [ + "paket" + ] + }, + "dotnet-fsharplint": { + "version": "0.26.10", + "commands": [ + "dotnet-fsharplint" + ] } + } } diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5191911 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +insert_final_newline = true + +[*.fs] +indent_size = 4 +indent_style = space +fsharp_max_record_width = 60 +fsharp_multiline_bracket_style = stroustrup +fsharp_space_before_uppercase_invocation = true + +[src/Client/*.fs] +# Feliz style +fsharp_single_argument_web_mode=true diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 2e8b738..bbed9be 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -14,11 +14,14 @@ jobs: strategy: matrix: os: - - name: macos-latest + - name: macos-14 + rid: osx-arm64 run: ./build.sh - name: ubuntu-latest + rid: linux-x64 run: ./build.sh - name: windows-latest + rid: win-x64 run: ./build.cmd dotnet: ["10.x"] runs-on: ${{ matrix.os.name }} @@ -31,25 +34,31 @@ jobs: with: dotnet-version: ${{ matrix.dotnet }} - - name: Setup Java - uses: actions/setup-java@v5 - with: - distribution: temurin - java-version: 21 - - name: Cache PlantUML uses: actions/cache@v4 with: - path: tools/plantuml/plantuml.jar - key: plantuml-${{ hashFiles('tools/plantuml/manifest.txt') }} + path: tools/plantuml/native + key: plantuml-native-${{ matrix.os.rid }}-${{ hashFiles('tools/plantuml/manifest.txt') }} enableCrossOsArchive: true - - name: Run tests + - name: Build run: ${{ matrix.os.run }} tests: - runs-on: macos-latest - name: "Check application" + strategy: + matrix: + os: + - name: macos-14 + rid: osx-arm64 + run: ./build.sh -t tests no-lint + - name: ubuntu-latest + rid: linux-x64 + run: ./build.sh -t tests no-lint + - name: windows-latest + rid: win-x64 + run: ./build.cmd -t tests no-lint + dotnet: ["10.x"] + runs-on: ${{ matrix.os.name }} steps: - uses: actions/checkout@v6 @@ -57,22 +66,14 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v5 with: - dotnet-version: 10.x - - - name: Setup Java - uses: actions/setup-java@v5 - with: - distribution: temurin - java-version: 21 + dotnet-version: ${{ matrix.dotnet }} - name: Cache PlantUML uses: actions/cache@v4 with: - path: tools/plantuml/plantuml.jar - key: plantuml-${{ hashFiles('tools/plantuml/manifest.txt') }} + path: tools/plantuml/native + key: plantuml-native-${{ matrix.os.rid }}-${{ hashFiles('tools/plantuml/manifest.txt') }} enableCrossOsArchive: true - name: Run tests - env: - DOTNET_ROLL_FORWARD: latestMajor - run: ./build.sh -t tests no-lint + run: ${{ matrix.os.run }} diff --git a/.gitignore b/.gitignore index b1f9885..00c618f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,7 @@ output .neo4j.json # Downloaded local PlantUML renderer -tools/plantuml/plantuml.jar +tools/plantuml/native/ docs dist diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..ad21264 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,9 @@ + + + + + $(AlmaBuildRuntimeIdentifier) + + + diff --git a/TUC.Console.slnx b/TUC.Console.slnx new file mode 100644 index 0000000..fa396b3 --- /dev/null +++ b/TUC.Console.slnx @@ -0,0 +1,6 @@ + + + + + + diff --git a/TucConsole.fsproj b/TucConsole.fsproj index 4ed4d43..b0a4f81 100644 --- a/TucConsole.fsproj +++ b/TucConsole.fsproj @@ -41,13 +41,21 @@ - - PreserveNewest - PreserveNewest - plantuml/plantuml.jar - contentFiles/any/any/plantuml/plantuml.jar - true - + + + + + + + + + + + + + + + diff --git a/bin/console b/bin/console index eb84c54..810fd1f 100755 --- a/bin/console +++ b/bin/console @@ -3,9 +3,15 @@ APP="TucConsole" NET="net10.0" -CONSOLE="bin/Debug/$NET/$APP.dll" +case "$(uname -s)-$(uname -m)" in + Linux-x86_64) RID="linux-x64" ;; + Darwin-arm64) RID="osx-arm64" ;; + *) echo "Unsupported platform: $(uname -s)-$(uname -m)" >&2; exit 1 ;; +esac + +CONSOLE="bin/Debug/$NET/$RID/$APP.dll" if [ ! -f "$CONSOLE" ]; then - CONSOLE="bin/Release/$NET/$APP.dll" + CONSOLE="bin/Release/$NET/$RID/$APP.dll" fi dotnet "$CONSOLE" "$@" diff --git a/build.cmd b/build.cmd old mode 100755 new mode 100644 diff --git a/build.sh b/build.sh index 5685e28..6ec2515 100755 --- a/build.sh +++ b/build.sh @@ -3,8 +3,22 @@ set -eu set -o pipefail -dotnet tool restore -dotnet tool run paket restore +run() { + if [ -n "${RTK_ACTIVE:-}" ]; then + local output + if ! output=$("$@" 2>&1); then + printf '%s\n' "$output" >&2 + return 1 + fi + else + "$@" + fi +} + +run dotnet tool restore +run dotnet tool run paket restore +# pre-build so the `dotnet run --no-build` below emits no restore/build chatter +run dotnet build ./build/build.fsproj # shellcheck disable=SC2068 -FAKE_DETAILED_ERRORS=true dotnet run --project ./build/build.fsproj -- $@ +FAKE_DETAILED_ERRORS=true dotnet run --no-build --project ./build/build.fsproj -- $@ diff --git a/build/Build.fs b/build/Build.fs index 3c3de8f..79d68e2 100644 --- a/build/Build.fs +++ b/build/Build.fs @@ -1,11 +1,4 @@ -// ======================================================================================================== -// === F# / Project fake build ==================================================================== 1.6.0 = -// -------------------------------------------------------------------------------------------------------- -// Options: -// - no-clean - disables clean of dirs in the first step (required on CI) -// - no-lint - lint will be executed, but the result is not validated -// ======================================================================================================== - +open Alma.Build open Fake.Core open Fake.Core.TargetOperators open Fake.IO.FileSystemOperators @@ -18,26 +11,29 @@ open Utils let main args = args |> Args.init + let runtimeTargets = [ + OSXArm64 + Windows + Linux + ] + + let spec = + Spec.defaultConsoleApplication runtimeTargets + |> Spec.mapConsoleApplication (fun spec -> { + spec with + RuntimeMode = RuntimeMode.AutoDetect + PublishSingleFile = false + }) + Targets.init { Project = { Name = "TUC.Console" Summary = "Console application for .tuc commands." Git = Git.init () } - Specs = - Spec.defaultConsoleApplication [ - OSX - Windows - Linux - ] + Specs = spec } - Target.create "PlantUml" (fun _ -> - match PlantUml.ensure () with - | PlantUml.Verified version -> Trace.tracefn "[PlantUML] Using verified v%s JAR." version - | PlantUml.Downloaded version -> Trace.tracefn "[PlantUML] Downloaded and verified v%s JAR." version - ) - - "PlantUml" ==> "Build" |> ignore + PlantUml.init runtimeTargets args |> Args.run diff --git a/build/PlantUml.fs b/build/PlantUml.fs index fe68a7e..55554c9 100644 --- a/build/PlantUml.fs +++ b/build/PlantUml.fs @@ -2,25 +2,50 @@ namespace ProjectBuild module internal PlantUml = open System + open System.Diagnostics open System.IO + open System.IO.Compression open System.Net.Http open System.Security.Cryptography + open Fake.Core + open Fake.Core.TargetOperators + open Alma.Build.Utils - type EnsureResult = - | Verified of version: string - | Downloaded of version: string + type private EnsureResult = + | Verified of version: string * rid: string + | Downloaded of version: string * rid: string + + type private Asset = { + Rid: string + Url: string + Sha256: string + Executable: string + } let private manifestPath = "tools/plantuml/manifest.txt" - let private jarPath = "tools/plantuml/plantuml.jar" + let private stagingRoot = "tools/plantuml/native" let private manifest = manifestPath |> File.ReadLines |> Seq.filter (String.IsNullOrWhiteSpace >> not) + |> Seq.filter (fun line -> line.StartsWith "#" |> not) |> Seq.map (fun line -> let separator = line.IndexOf '=' + + if separator < 1 then + failwithf "PlantUML manifest has malformed line %A." line + line.Substring(0, separator), line.Substring(separator + 1) ) + |> Seq.groupBy fst + |> Seq.map (fun (key, entries) -> + let values = entries |> Seq.map snd |> Seq.toList + + match values with + | [ value ] -> key, value + | _ -> failwithf "PlantUML manifest has duplicate key %A." key + ) |> Map.ofSeq let private getManifestValue key = @@ -28,33 +53,161 @@ module internal PlantUml = |> Map.tryFind key |> Option.defaultWith (fun () -> failwithf "PlantUML manifest is missing %A." key) + let private ridPrefix = "rid." + let private sha256Suffix = ".sha256" + + let private supportedRids = + manifest + |> Map.toSeq + |> Seq.choose (fun (key, _) -> + if key.StartsWith ridPrefix && key.EndsWith sha256Suffix + then Some (key.Substring(ridPrefix.Length, key.Length - ridPrefix.Length - sha256Suffix.Length)) + else None + ) + |> Set.ofSeq + + type private SupportedRid = private SupportedRid of string + + module private SupportedRid = + let create rid = + if supportedRids |> Set.contains rid + then SupportedRid rid + else failwithf "PlantUML native runtime is not available for %s. Supported runtimes: %s." rid (supportedRids |> String.concat ", ") + + let value (SupportedRid rid) = rid + let private hash path = - path - |> File.ReadAllBytes - |> SHA256.HashData - |> Convert.ToHexString - |> fun value -> value.ToLowerInvariant() + use archive = File.OpenRead path + archive |> SHA256.HashData |> Convert.ToHexString |> fun value -> value.ToLowerInvariant() + + let private asset (rid: SupportedRid) = + let rid = SupportedRid.value rid + let prefix = sprintf "rid.%s." rid + let checksum = getManifestValue (prefix + "sha256") + + if checksum.Length <> 64 || checksum |> Seq.exists (Uri.IsHexDigit >> not) then + failwithf "PlantUML manifest checksum for %s is malformed." rid + + { + Rid = rid + Url = getManifestValue (prefix + "url") + Sha256 = checksum + Executable = getManifestValue (prefix + "executable") + } + + let private archivePath asset = Path.Combine(stagingRoot, asset.Rid, "plantuml.zip") + let private stagingPath asset = Path.Combine(stagingRoot, asset.Rid, "runtime") + let private executablePath asset = Path.Combine(stagingPath asset, asset.Executable) + + let private legalEvidenceIsPresent () = + [ "license-text"; "notice"; "source-provenance" ] + |> List.iter (getManifestValue >> File.Exists >> function true -> () | false -> failwith "PlantUML legal evidence is missing.") + + let private archiveMatches asset = + let path = archivePath asset + File.Exists path && hash path = asset.Sha256 - let private isVerified path = - File.Exists path && hash path = getManifestValue "sha256" + let private stagingMatches asset = + let marker = Path.Combine(stagingPath asset, ".sha256") + File.Exists(executablePath asset) && File.Exists(marker) && File.ReadAllText(marker) = asset.Sha256 - let ensure () = + let private deleteDirectory path = + if Directory.Exists path then Directory.Delete(path, true) + + let private stage asset = + let archive = archivePath asset + + let destination = stagingPath asset + let temporary = destination + ".tmp" + deleteDirectory temporary + Directory.CreateDirectory temporary |> ignore + + ZipFile.ExtractToDirectory(archive, temporary) + + if OperatingSystem.IsWindows() |> not then + File.SetUnixFileMode(Path.Combine(temporary, asset.Executable), UnixFileMode.UserRead ||| UnixFileMode.UserWrite ||| UnixFileMode.UserExecute ||| UnixFileMode.GroupRead ||| UnixFileMode.GroupExecute ||| UnixFileMode.OtherRead ||| UnixFileMode.OtherExecute) + + File.WriteAllText(Path.Combine(temporary, ".sha256"), asset.Sha256) + + deleteDirectory destination + Directory.Move(temporary, destination) + + let private smoke asset = async { + let startInfo = ProcessStartInfo(executablePath asset) + startInfo.UseShellExecute <- false + startInfo.RedirectStandardOutput <- true + startInfo.RedirectStandardError <- true + startInfo.ArgumentList.Add "--help" + + use childProcess = Process.Start startInfo + let stdoutRead = childProcess.StandardOutput.ReadToEndAsync() |> Async.AwaitTask + let stderrRead = childProcess.StandardError.ReadToEndAsync() |> Async.AwaitTask + let! output = [ stdoutRead; stderrRead ] |> Async.Parallel + do! childProcess.WaitForExitAsync() |> Async.AwaitTask + + if childProcess.ExitCode <> 0 then + failwithf "PlantUML native executable smoke test failed for %s with exit code %d. Standard output: %s Standard error: %s" asset.Rid childProcess.ExitCode output[0] output[1] + } + + let private download (url: string) (destination: string) = async { + use client = new HttpClient() + use! source = client.GetStreamAsync url |> Async.AwaitTask + use target = File.Create destination + do! source.CopyToAsync target |> Async.AwaitTask + do! target.FlushAsync() |> Async.AwaitTask + } + + let private ensure (rid: SupportedRid) = async { + legalEvidenceIsPresent () + let asset = asset rid let version = getManifestValue "version" - if isVerified jarPath then Verified version + if archiveMatches asset then + if stagingMatches asset |> not then stage asset + return Verified(version, asset.Rid) else - if File.Exists jarPath then File.Delete jarPath + let archive = archivePath asset + Directory.CreateDirectory(Path.GetDirectoryName archive) |> ignore + if File.Exists archive then File.Delete archive + let temporary = archive + ".tmp" + if File.Exists temporary then File.Delete temporary + + do! download asset.Url temporary + let downloadedHash = hash temporary + + if downloadedHash <> asset.Sha256 then + File.Delete temporary + failwithf "Downloaded PlantUML native archive checksum mismatch. Expected %s but got %s." asset.Sha256 downloadedHash + + File.Move(temporary, archive) + stage asset + return Downloaded(version, asset.Rid) + } - let url = getManifestValue "url" - let directory = Path.GetDirectoryName jarPath - Directory.CreateDirectory directory |> ignore + let private ensureCurrent () = async { + let rid = RuntimeTarget.detect () |> RuntimeTarget.toRuntimeIdentifier |> RuntimeIdentifier.value |> SupportedRid.create + let! result = ensure rid + do! asset rid |> smoke + return result + } - use client = new HttpClient() - let jar = client.GetByteArrayAsync url |> Async.AwaitTask |> Async.RunSynchronously - let downloadedHash = jar |> SHA256.HashData |> Convert.ToHexString |> fun value -> value.ToLowerInvariant() + let private traceResult = function + | Verified(version, rid) -> Trace.tracefn "[PlantUML] Using verified v%s native runtime for %s." version rid + | Downloaded(version, rid) -> Trace.tracefn "[PlantUML] Downloaded and verified v%s native runtime for %s." version rid - if downloadedHash <> getManifestValue "sha256" then - failwithf "Downloaded PlantUML JAR checksum mismatch. Expected %s but got %s." (getManifestValue "sha256") downloadedHash + let init (runtimeTargets: RuntimeTarget list) = + let releaseRids = + runtimeTargets + |> List.map (RuntimeTarget.toRuntimeIdentifier >> RuntimeIdentifier.value >> SupportedRid.create) + + Target.create "PlantUml" (fun _ -> + ensureCurrent () |> Async.RunSynchronously |> traceResult + ) + + Target.create "PlantUmlRelease" (fun _ -> + releaseRids + |> List.iter (ensure >> Async.RunSynchronously >> traceResult) + ) - File.WriteAllBytes(jarPath, jar) - Downloaded version + "PlantUml" ==> "Build" |> ignore + "PlantUmlRelease" ==> "Release" |> ignore diff --git a/build/README.md b/build/README.md new file mode 100644 index 0000000..d9e1c4c --- /dev/null +++ b/build/README.md @@ -0,0 +1,20 @@ +# fbuild + +This repository uses the bootstrap Alma.Build build infrastructure. + +## Entry point + +`./build.sh ` restores local tools and packages, then runs `build/Build.fs`. + +## Common options + +- `no-clean` disables cleaning directories in the first step. This is useful on CI when intermediate outputs need to remain available. +- `no-lint` skips the `Lint` step entirely. + +## Updating bootstrap files + +`build.sh`, this README, and the other bootstrap support files are bundled inside the pinned `Alma.Build` package. After bumping the pinned version, run the `Bootstrap` target to redeploy them: + +```bash +./build.sh Bootstrap +``` diff --git a/build/SafeBuildHelpers.fs b/build/SafeBuildHelpers.fs deleted file mode 100644 index 7671c46..0000000 --- a/build/SafeBuildHelpers.fs +++ /dev/null @@ -1,109 +0,0 @@ -namespace ProjectBuild - -/// Helpers specific for SAFE stack application -module internal SafeBuildHelpers = - open Fake.Core - - let initializeContext () = - let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ] - Context.setExecutionContext (Context.RuntimeContext.Fake execContext) - - module Proc = - module Parallel = - open System - - let locker = obj () - - let colors = [| - ConsoleColor.Blue - ConsoleColor.Yellow - ConsoleColor.Magenta - ConsoleColor.Cyan - ConsoleColor.DarkBlue - ConsoleColor.DarkYellow - ConsoleColor.DarkMagenta - ConsoleColor.DarkCyan - |] - - let print color (colored: string) (line: string) = - lock locker (fun () -> - let currentColor = Console.ForegroundColor - Console.ForegroundColor <- color - Console.Write colored - Console.ForegroundColor <- currentColor - Console.WriteLine line - ) - - let onStdout index name (line: string) = - let color = colors[index % colors.Length] - - if isNull line then - print color $"{name}: --- END ---" "" - else if String.isNotNullOrEmpty line then - print color $"{name}: " line - - let onStderr name (line: string) = - let color = ConsoleColor.Red - - if isNull line |> not then - print color $"{name}: " line - - let redirect (index, (name, createProcess)) = - createProcess - |> CreateProcess.redirectOutputIfNotRedirected - |> CreateProcess.withOutputEvents (onStdout index name) (onStderr name) - - let printStarting indexed = - for (index, (name, c: CreateProcess<_>)) in indexed do - let color = colors[index % colors.Length] - let wd = c.WorkingDirectory |> Option.defaultValue "" - let exe = c.Command.Executable - let args = c.Command.Arguments.ToStartInfo - print color $"{name}: {wd}> {exe} {args}" "" - - let run cs = - cs - |> Seq.toArray - |> Array.indexed - |> fun x -> - printStarting x - x - |> Array.map redirect - |> Array.Parallel.map Proc.run - - let createProcess exe args dir = - // Use `fromRawCommand` rather than `fromRawCommandLine`, as its behaviour is less likely to be misunderstood. - // See https://github.com/SAFE-Stack/SAFE-template/issues/551. - CreateProcess.fromRawCommand exe args - |> CreateProcess.withWorkingDirectory dir - |> CreateProcess.ensureExitCode - - let dotnet args dir = createProcess "dotnet" args dir - - let npm args dir = - let npmPath = - match ProcessUtils.tryFindFileOnPath "npm" with - | Some path -> path - | None -> - "npm was not found in path. Please install it and make sure it's available from your path. " - + "See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info" - |> failwith - - createProcess npmPath args dir - - let run proc arg dir = proc arg dir |> Proc.run |> ignore - - let runParallel processes = - processes |> Proc.Parallel.run |> ignore - - let runOrDefault args = - try - match args with - | [| "-t"; target |] - | [| target |] - -> Target.runOrDefaultWithArguments target - | _ -> Target.runOrDefaultWithArguments "Run" - 0 - with e -> - printfn "%A" e - 1 diff --git a/build/Targets.fs b/build/Targets.fs deleted file mode 100644 index a997082..0000000 --- a/build/Targets.fs +++ /dev/null @@ -1,413 +0,0 @@ -namespace ProjectBuild - -module internal Targets = - open System - open System.IO - - open Fake.Core - open Fake.DotNet - open Fake.IO - open Fake.IO.FileSystemOperators - open Fake.IO.Globbing.Operators - open Fake.Core.TargetOperators - - open Utils - open Github.Types - - // -------------------------------------------------------------------------------------------------------- - // 2. Targets for FAKE - // -------------------------------------------------------------------------------------------------------- - - [] - module SafeStackTargets = - open SafeBuildHelpers - - let init safe = - Target.create "SafeClean" (fun _ -> - Shell.cleanDir safe.DeployPath - run dotnet [ "fable"; "clean"; "--yes" ] safe.ClientPath // Delete *.fs.js files created by Fable - ) - - Target.create "InstallClient" (fun _ -> - run npm [ "--version" ] "." - run npm [ "install" ] "." - ) - - Target.create "Bundle" (fun _ -> - [ - "server", dotnet [ "publish"; "-c"; "Release"; "-o"; safe.DeployPath ] safe.ServerPath - "client", dotnet [ "fable"; "-o"; "output"; "-s"; "--run"; "npx"; "vite"; "build" ] safe.ClientPath - ] - |> runParallel - ) - - Target.create "Run" (fun _ -> - run dotnet [ "build" ] safe.SharedPath - [ - "server", dotnet [ "watch"; "run" ] safe.ServerPath - "client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] safe.ClientPath - ] - |> runParallel - ) - - Target.create "RunMirrord" (fun _ -> - run dotnet [ "build" ] safe.SharedPath - Environment.setEnvironVar "RUN_IN" "mirrord" - [ - "server", createProcess "mirrord" [ "exec"; "--config-file"; "../../.mirrord/mirrord.json"; "--"; "dotnet"; "watch"; "run" ] safe.ServerPath - "client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] safe.ClientPath - ] - |> runParallel - ) - - Target.create "WatchTests" (fun _ -> - run dotnet [ "build" ] safe.SharedTestsPath - - [ - "server", dotnet [ "watch"; "run" ] safe.ServerTestsPath - "client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] safe.ClientTestsPath - ] - |> runParallel - ) - - Target.create "Tests" (fun _ -> - run dotnet [ "build" ] safe.SharedTestsPath - - [ - "server", dotnet [ "run" ] safe.ServerTestsPath - //"client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] safe.ClientTestsPath - ] - |> runParallel - ) - - [ - "SafeClean" - ==> "Clean" - - "SafeClean" - ==> "AssemblyInfo" - ==> "InstallClient" - ==> "Build" - - "Tests" - ==> "Bundle" - - "Build" - ==> "Lint" - ==> "Tests" <=> "WatchTests" - - "Build" - ==> "Run" <=> "RunMirrord" - ] - - let init (definition: ProjectDefinition) = - Target.initEnvironment () - - Target.create "Info" (fun _ -> - let separator sign = Trace.traceFAKE "%s" (String.replicate 69 sign) - - Trace.traceHeader "Project info" - Trace.tracefn "Project: %s" definition.Project.Name - Trace.tracefn "Summary: %s" definition.Project.Summary - Trace.tracefn "Type: %s" definition.Specs.Type - - separator "-" - - Trace.tracefn "Git.branch: %s" (definition.Project.Git |> Option.map (fun git -> git.Branch) |> Option.defaultValue "unknown") - Trace.tracefn "Git.commit: %s" (definition.Project.Git |> Option.map (fun git -> git.Commit) |> Option.defaultValue "unknown") - Trace.tracefn "Git.repository: %s" (definition.Project.Git |> Option.bind (fun git -> git.Repository) |> Option.defaultValue "unknown") - - separator "-" - - Trace.tracefn "BuildNumber: %s" ("BUILD_NUMBER" |> envVar |> Option.defaultValue "-") - - match definition with - | { Specs = SAFEStackApplication { TemplateVersion = templateVersion } } -> - Trace.tracefn "SafeTemplateVersion: %s" templateVersion - | _ -> () - - separator "=" - ) - - Target.create "Clean" <| skipOn "no-clean" (fun _ -> - !! "./**/bin/Release" - ++ "./**/bin/Debug" - ++ "./**/obj" - ++ "./**/.ionide" - -- "./bin/console" - -- "./build/**" - |> Shell.cleanDirs - ) - - Target.create "AssemblyInfo" (fun _ -> - let getAssemblyInfoAttributes projectName = - let now = DateTime.Now - - let release = - definition.ChangeLog - |> Option.bind (fun changeLog -> - try ReleaseNotes.parse (System.IO.File.ReadAllLines changeLog |> Seq.filter ((<>) "## Unreleased")) |> Some - with _ -> None - ) - - let gitValue fallbackEnvironmentVariableNames initialValue = - initialValue - |> String.replace "NoBranch" "" - |> stringToOption - |> Option.bindNone (fun _ -> fallbackEnvironmentVariableNames |> List.tryPick envVar) - |> Option.defaultValue "unknown" - - [ - AssemblyInfo.Title projectName - AssemblyInfo.Product definition.Project.Name - AssemblyInfo.Description definition.Project.Summary - - match release with - | Some release -> - AssemblyInfo.Version release.AssemblyVersion - AssemblyInfo.FileVersion release.AssemblyVersion - | _ -> - AssemblyInfo.Version "1.0" - AssemblyInfo.FileVersion "1.0" - - AssemblyInfo.InternalsVisibleTo "tests" - - match definition.Project.Git with - | None -> - AssemblyInfo.Metadata("gitbranch", null |> gitValue [ "GIT_BRANCH"; "branch" ]) - AssemblyInfo.Metadata("gitcommit", null |> gitValue [ "GIT_COMMIT"; "commit" ]) - | Some git -> - AssemblyInfo.Metadata("gitbranch", git.Branch |> gitValue [ "GIT_BRANCH"; "branch" ]) - AssemblyInfo.Metadata("gitcommit", git.Commit |> gitValue [ "GIT_COMMIT"; "commit" ]) - - AssemblyInfo.Metadata("createdAt", now.ToString("yyyy-MM-dd HH:mm:ss")) - AssemblyInfo.Metadata("buildNumber", "BUILD_NUMBER" |> envVar |> Option.defaultValue "-") - - match definition with - | { Specs = SAFEStackApplication { TemplateVersion = templateVersion } } -> - AssemblyInfo.Metadata("SafeTemplateVersion", templateVersion) - | _ -> () - ] - - let getProjectDetails (projectPath: string) = - let projectName = IO.Path.GetFileNameWithoutExtension(projectPath) - ( - projectPath, - projectName, - IO.Path.GetDirectoryName(projectPath), - (getAssemblyInfoAttributes projectName) - ) - - definition.Sources.All - |> Seq.map getProjectDetails - |> Seq.iter (fun (_, _, folderName, attributes) -> - AssemblyInfoFile.createFSharp (folderName "AssemblyInfo.fs") attributes - ) - ) - - Target.create "Build" (fun _ -> - definition.Sources.All - |> Seq.iter (Path.getDirectory >> Dotnet.runOrFail "build") - ) - - Target.create "Lint" <| skipOn "no-lint" (fun _ -> - definition.Sources.All - ++ "build/build.fsproj" - |> Seq.iter (fun fsproj -> - match Dotnet.runInRoot (sprintf "fsharplint lint %s" fsproj) with - | Ok () -> Trace.tracefn "Lint %s is Ok" fsproj - | Error e -> raise e - ) - ) - - if not definition.Specs.IsSAFEStack then - Target.create "Tests" (fun _ -> - if definition.Sources.Tests |> Seq.isEmpty - then Trace.tracefn "There are no tests yet." - else Dotnet.runOrFail "run" "tests" - ) - - let zipRelease releaseDir runtimeIds = - if releaseDir "zipCompiled" |> File.exists - then - let zipReleaseProcess = createProcess (releaseDir "zipCompiled") - - Trace.tracefn "\nZipping released files in %s ..." releaseDir - run zipReleaseProcess "" "." - |> Trace.tracefn "Zip result:\n%A\n" - - Trace.tracefn "\nZip compiled files" - runtimeIds - |> List.iter (RuntimeId.value >> fun runtimeId -> - Trace.tracefn " -> zipping %s ..." runtimeId - let zipFile = sprintf "%s.zip" runtimeId - IO.File.Delete zipFile - Zip.zip releaseDir (releaseDir zipFile) !!(releaseDir runtimeId "*") - ) - - Target.create "Release" (fun _ -> - match definition with - | { Specs = Library { ReleaseDir = releaseDir; NugetApi = nugetApi } } -> - match "src" definition.Project.Name with - | releaseSource when releaseSource |> Directory.Exists -> - Dotnet.runOrFail "pack" releaseSource - | _ -> - Dotnet.runInRootOrFail "pack" - - Directory.ensure releaseDir - - !! "**/bin/**/*.nupkg" - |> Seq.iter (Shell.moveFile releaseDir) - - | { Specs = ConsoleApplication { RuntimeIds = runtimeIds; ReleaseSource = releaseSource; ReleaseDir = releaseDir } } -> - let releaseDir = Path.getFullName releaseDir - - Trace.tracefn "\nClean previous releases" - runtimeIds - |> Seq.collect (RuntimeId.value >> fun runtimeId -> - Trace.tracefn " - %s" runtimeId - !! (releaseDir runtimeId) - ) - |> Shell.cleanDirs - - Trace.tracefn "\nClean previous zipped releases" - !! (releaseDir "*.zip") - ++ (releaseDir "*.tar.gz") - |> Seq.map (tee (Trace.tracefn " - %s")) - |> Seq.iter File.delete - - Trace.tracefn "\nPublish current release" - - seq { - let project = releaseSource - yield! runtimeIds |> List.collect (RuntimeId.value >> fun runtimeId -> [project, runtimeId]) - } - |> Seq.iter (fun (project, runtimeId) -> - sprintf "publish -c Release /p:PublishSingleFile=true -o %s/%s --self-contained -r %s %s" releaseDir runtimeId runtimeId project - |> Dotnet.runInRootOrFail - ) - - runtimeIds |> zipRelease releaseDir - - | { Specs = Executable { ReleaseDir = releaseDir } } -> - releaseDir - |> sprintf "publish -c Release -o %s" - |> Dotnet.runInRootOrFail - - | { Specs = SAFEStackApplication _ } -> failwithf "For releasing SAFE-Stack Application, use \"bundle\" target instead." - ) - - Target.create "ZipRelease" (fun _ -> - match definition with - | { Specs = ConsoleApplication { RuntimeIds = runtimeIds; ReleaseDir = releaseDir } } -> - runtimeIds |> zipRelease releaseDir - | _ -> () - ) - - Target.create "Publish" (fun _ -> - match definition with - | { Specs = Library { NugetApi = NugetApi.NotUsed } } -> Trace.traceHeader "NugetApi is not used" - - | { Specs = Library { ReleaseDir = releaseDir; NugetApi = NugetApi.Organization organization; NugetCustomServerRepository = nugetServer } } -> - Trace.traceHeader "Pushing to organization nuget server" - - envVar "PRIVATE_FEED_PASS" - |> Option.requireSome "Environment variable PRIVATE_FEED_PASS is not set." - |> Nuget.push releaseDir (Some organization) - - match envVar "NUGET_SERVER_TOKEN", envVar "NUGET_SERVER_REPOSITORY" |> Option.orElse nugetServer with - | Some token, Some repository -> - Trace.tracefn "Trigger: Update %s readme" repository - - Github.triggerAction { - EventType = "update-readme" - CurrentProject = definition.Project.Name - Token = token - Organization = envVar "NUGET_SERVER_ORGANIZATION" |> Option.defaultValue organization - Repository = repository - } - |> Async.RunSynchronously - - | _ -> () - - | { Specs = Library { ReleaseDir = releaseDir; NugetApi = NugetApi.AskForKey; Organization = organization }} -> - Trace.traceHeader "Pushing to public nuget server" - - match UserInput.getUserInput "Are you sure - is it tagged yet? [y|n]: " with - | "y" | "yes" -> - match UserInput.getUserPassword "Nuget ApiKey: " with - | null | "" -> failwithf "You have to provide an api key for nuget." - | apiKey -> Nuget.push releaseDir organization apiKey - | _ -> () - - | { Specs = Library { ReleaseDir = releaseDir; NugetApi = NugetApi.KeyInEnvironment name; Organization = organization }} -> - Trace.traceHeader "Pushing to nuget server" - - envVar name - |> Option.iter (Nuget.push releaseDir organization) - - | _ -> () - ) - - Target.create "Watch" (fun _ -> - Dotnet.runInRootOrFail "watch run" - ) - - Target.create "WatchMirrord" (fun _ -> - Environment.setEnvironVar "RUN_IN" "mirrord" - run (createProcess "mirrord") "exec --config-file .mirrord/mirrord.json -- dotnet watch run" "." - ) - - Target.create "Run" (fun _ -> - Dotnet.runInRootOrFail "run" - ) - - Target.create "RunMirrord" (fun _ -> - Environment.setEnvironVar "RUN_IN" "mirrord" - run (createProcess "mirrord") "exec --config-file .mirrord/mirrord.json -- dotnet run" "." - ) - - // -------------------------------------------------------------------------------------------------------- - // 3. FAKE targets hierarchy - // -------------------------------------------------------------------------------------------------------- - - match definition with - | { Specs = Library _ } -> - [ - "Clean" - ==> "AssemblyInfo" - ==> "Build" - ==> "Lint" - ==> "Tests" - ==> "Release" - ==> "Publish" - ] - - | { Specs = ConsoleApplication _ } -> - [ - "Clean" - ==> "AssemblyInfo" - ==> "Build" - ==> "Lint" - ==> "Tests" - ==> "Release" - ==> "ZipRelease" - - "Build" - ==> "Watch" <=> "WatchMirrord" <=> "Run" <=> "RunMirrord" - ] - - | { Specs = Executable _ } -> - [ - "Clean" - ==> "AssemblyInfo" - ==> "Build" - ==> "Lint" - ==> "Tests" - ==> "Release" <=> "Watch" <=> "WatchMirrord" <=> "Run" <=> "RunMirrord" - ] - - | { Specs = SAFEStackApplication safe } -> - SafeStackTargets.init safe - - |> ignore diff --git a/build/Utils.fs b/build/Utils.fs deleted file mode 100644 index 1047ee7..0000000 --- a/build/Utils.fs +++ /dev/null @@ -1,430 +0,0 @@ -namespace ProjectBuild - -module internal Utils = - open System - open System.IO - - open Fake.Core - open Fake.DotNet - open Fake.IO - open Fake.IO.FileSystemOperators - open Fake.IO.Globbing.Operators - open Fake.Core.TargetOperators - open Fake.Tools.Git - - [] - module Args = - let init args = - args - |> Array.toList - |> Context.FakeExecutionContext.Create false "build.fsx" - |> Context.RuntimeContext.Fake - |> Context.setExecutionContext - - let run args = - match args with - | [| "-t"; target |] -> Target.runOrDefault target - | [| target |] -> Target.runOrDefaultWithArguments target - | _ -> Target.runOrDefaultWithArguments "Build" - - 0 // return an integer exit code - - let tee f a = - f a - a - - let skipOn option action p = - if p.Context.Arguments |> Seq.contains option - then Trace.tracefn "Skipped ..." - else action p - - let createProcess exe arg dir = - CreateProcess.fromRawCommandLine exe arg - |> CreateProcess.withWorkingDirectory dir - |> CreateProcess.ensureExitCode - - let run proc arg dir = - proc arg dir - |> Proc.run - |> ignore - - let orFail = function - | Error e -> raise e - | Ok ok -> ok - - let stringToOption = function - | null | "" -> None - | string -> Some string - - let envVar name = - if Environment.hasEnvironVar(name) - then Environment.environVar(name) |> Some - else None - - [] - module Option = - let mapNone f = function - | Some v -> v - | None -> f None - - let bindNone f = function - | Some v -> Some v - | None -> f None - - let requireSome error = function - | Some v -> v - | None -> failwith error - - [] - module Dotnet = - let dotnet = createProcess "dotnet" - - let run command dir = try run dotnet command dir |> Ok with e -> Error e - let runInRoot command = run command "." - let runOrFail command dir = run command dir |> orFail - let runInRootOrFail command = run command "." |> orFail - - [] - module Nuget = - let push releaseDir organization token = - let sourceName = - organization - |> Option.map (fun organization -> - let sourceName = "github" - - Trace.tracefn "[Nuget] Add organization %A as a source" organization - sprintf "nuget add source --username %s --password %s --store-password-in-clear-text --name %s \"https://nuget.pkg.github.com/%s/index.json\"" - organization token sourceName organization - |> Dotnet.runInRootOrFail - - sourceName - ) - - Trace.tracefn "[Nuget] Push packages" - sprintf "nuget push %s --source=%s --api-key=%s --skip-duplicate" - (releaseDir "*.nupkg") - (sourceName |> Option.defaultValue "https://api.nuget.org/v3/index.json") - token - |> Dotnet.runInRootOrFail - - [] - module ProjectDefinition = - type IProjectSources = - abstract member Sources: IGlobbingPattern - abstract member Tests: IGlobbingPattern - abstract member All: IGlobbingPattern - - type ProjectDefinition = - { - Project: ProjectMeta - Specs: ProjectSpec - } - - with - member this.Sources = - match this with - | { Specs = Library app } -> app :> IProjectSources - | { Specs = Executable app } -> app :> IProjectSources - | { Specs = ConsoleApplication app } -> app :> IProjectSources - | { Specs = SAFEStackApplication app } -> app :> IProjectSources - - member this.ChangeLog = - match this with - | { Specs = Library { Changelog = changeLog } } -> Some changeLog - | { Specs = Executable { Changelog = changeLog } } - | { Specs = ConsoleApplication { Changelog = changeLog } } - | { Specs = SAFEStackApplication { Changelog = changeLog } } -> changeLog - - and ProjectMeta = { - Name: string - Summary: string - Git: Git option - } - - and Git = { - Commit: string - Branch: string - Repository: string option - } - - and ProjectSpec = - | Library of LibrarySpec - | Executable of ExecutableSpec - | ConsoleApplication of ConsoleApplicationSpec - | SAFEStackApplication of SAFEStackApplicationSpec - - with - member this.Type = - match this with - | Library _ -> "Library" - | Executable _ -> "Executable" - | ConsoleApplication _ -> "Console Application" - | SAFEStackApplication _ -> "SAFE-Stack Application" - - member this.IsSAFEStack = - match this with - | SAFEStackApplication _ -> true - | _ -> false - - and LibrarySpec = - { - Changelog: string - ReleaseDir: string - LibrarySources: IGlobbingPattern - TestsSources: IGlobbingPattern - AllSources: IGlobbingPattern - /// Organization (it is used for a custom github nuget source) - Organization: string option - /// Configuration for nuget api, to push packages into - NugetApi: NugetApi - /// Repository for custom nuget server, it will be triggered for a readme update - NugetCustomServerRepository: string option - } - - interface IProjectSources with - member this.Sources = this.LibrarySources - member this.Tests = this.TestsSources - member this.All = this.AllSources - - and [] NugetApi = - | NotUsed - | AskForKey - | Organization of name: string - | KeyInEnvironment of string - - and ExecutableSpec = - { - Changelog: string option - ReleaseDir: string - ApplicationSources: IGlobbingPattern - TestsSources: IGlobbingPattern - AllSources: IGlobbingPattern - } - - interface IProjectSources with - member this.Sources = this.ApplicationSources - member this.Tests = this.TestsSources - member this.All = this.AllSources - - and ConsoleApplicationSpec = - { - Changelog: string option - ReleaseDir: string - RuntimeIds: RuntimeId list - ReleaseSource: string - ApplicationSources: IGlobbingPattern - TestsSources: IGlobbingPattern - AllSources: IGlobbingPattern - } - - interface IProjectSources with - member this.Sources = this.ApplicationSources - member this.Tests = this.TestsSources - member this.All = this.AllSources - - and SAFEStackApplicationSpec = - { - Changelog: string option - TemplateVersion: string - - SharedPath: string - ServerPath: string - ClientPath: string - - DeployPath: string - - SharedTestsPath: string - ServerTestsPath: string - ClientTestsPath: string - - ReleaseSources: IGlobbingPattern - TestsSources: IGlobbingPattern - AllSources: IGlobbingPattern - } - - interface IProjectSources with - member this.Sources = this.ReleaseSources - member this.Tests = this.TestsSources - member this.All = this.AllSources - - and RuntimeId = - | OSX - | Windows - | Linux - | ArmLinux - | AlpineLinux - | RaspberryPiHassioAddon - | Other of string - - [] - module Git = - let init () = - Some { - Commit = Information.getCurrentSHA1(".") - Branch = Information.getBranchName(".") - Repository = None - } - - [] - module Spec = - let defaultLibrary: ProjectSpec = - let sources = - !! "./*.fsproj" - ++ "src/*.fsproj" - ++ "src/**/*.fsproj" - - Library { - Changelog = "CHANGELOG.md" - ReleaseDir = "release" - LibrarySources = sources - TestsSources = !! "tests/*.fsproj" - AllSources = - sources - ++ "tests/*.fsproj" - ++ "build/*.fsproj" - Organization = None - NugetApi = NugetApi.NotUsed - NugetCustomServerRepository = None - } - - let defaultExecutable: ProjectSpec = - let release = - !! "./*.fsproj" - ++ "src/**/*.fsproj" - - Executable { - Changelog = if File.Exists "CHANGELOG.md" then Some "CHANGELOG.md" else None - ReleaseDir = "/app" - - ApplicationSources = release - TestsSources = !! "tests/**/*.fsproj" - AllSources = - release - ++ "tests/**/*.fsproj" - ++ "build/*.fsproj" - } - - let defaultConsoleApplication runtimeIds: ProjectSpec = - let sources = - !! "./*.fsproj" - ++ "src/*.fsproj" - ++ "src/**/*.fsproj" - - ConsoleApplication { - Changelog = if File.Exists "CHANGELOG.md" then Some "CHANGELOG.md" else None - ReleaseDir = "./dist" - RuntimeIds = runtimeIds - - ApplicationSources = sources - ReleaseSource = sources |> Seq.head - TestsSources = !! "tests/*.fsproj" - AllSources = - sources - ++ "tests/*.fsproj" - ++ "build/*.fsproj" - } - - let defaultSAFEStackApplication templateVersion: ProjectSpec = - let release = !! "src/**/*.fsproj" - - SAFEStackApplication { - Changelog = if File.Exists "CHANGELOG.md" then Some "CHANGELOG.md" else None - TemplateVersion = templateVersion - - SharedPath = Path.getFullName ("src" "Shared") - ServerPath = Path.getFullName ("src" "Server") - ClientPath = Path.getFullName ("src" "Client") - - DeployPath = Path.getFullName "deploy" - - SharedTestsPath = Path.getFullName ("tests" "Shared") - ServerTestsPath = Path.getFullName ("tests" "Server") - ClientTestsPath = Path.getFullName ("tests" "Client") - - ReleaseSources = release - TestsSources = !! "tests/**/*.fsproj" - AllSources = release ++ "tests/**/*.fsproj" - } - - let mapLibrary f = function - | Library spec -> f spec |> Library - | spec -> spec - - let mapExecutable f = function - | Executable spec -> f spec |> Executable - | spec -> spec - - let mapConsoleApplication f = function - | ConsoleApplication spec -> f spec |> ConsoleApplication - | spec -> spec - - let mapSAFEStackApplication f = function - | SAFEStackApplication spec -> f spec |> SAFEStackApplication - | spec -> spec - - [] - module RuntimeId = - /// Runtime IDs: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#macos-rids - let value = function - | OSX -> "osx-x64" - | Windows -> "win-x64" - | Linux -> "linux-x64" - | ArmLinux -> "linux-arm64" - | AlpineLinux -> "linux-musl-x64" - | RaspberryPiHassioAddon -> "alpine.3.16-arm64" - | Other other -> other - - [] - module Http = - open System.Net.Http - open System.Net.Http.Headers - - let post (currentProject: string) token (url: string) (data: string) = async { - use client = new HttpClient() - - let requestHeaders = client.DefaultRequestHeaders - requestHeaders.Authorization <- new AuthenticationHeaderValue("Bearer", token) - requestHeaders.Add("User-Agent", sprintf "Fake.Build/%s" currentProject) - - use request = new StringContent(data, Text.Encoding.UTF8) - request.Headers.ContentType <- new MediaTypeHeaderValue("application/json") - - let! response = client.PostAsync(url, request) |> Async.AwaitTask - response.EnsureSuccessStatusCode() |> ignore - - let headers = - response.Headers :> seq>> - |> Seq.append ( - response.Content.Headers :> seq>> - ) - |> Seq.map (fun kv -> kv.Key, kv.Value |> Seq.toList) - |> Map.ofSeq - - use! stream = response.Content.ReadAsStreamAsync() |> Async.AwaitTask - use reader = new StreamReader(stream) - - return headers, reader.ReadToEnd() - } - - [] - module Github = - [] - module Types = - type TriggerAction = { - CurrentProject: string - Token: string - Organization: string - Repository: string - EventType: string - } - - let triggerAction { CurrentProject = current; Token = token; Organization = org; Repository = repo; EventType = event } = async { - let url = - $"https://api.github.com/repos/{org}/{repo}/dispatches" - |> tee (Trace.tracefn "Github.Trigger<%s>: %s" event) - - let data = sprintf @"{""event_type"":""%s"",""client_payload"":{""from"": ""%s""}}" event current - let! _ = Http.post current token url data - - return () - } diff --git a/build/build.fsproj b/build/build.fsproj index 1d5a065..909c8f9 100644 --- a/build/build.fsproj +++ b/build/build.fsproj @@ -8,10 +8,7 @@ - - - diff --git a/build/paket.references b/build/paket.references index d771935..d497b97 100644 --- a/build/paket.references +++ b/build/paket.references @@ -1,9 +1,2 @@ group Build - Fake.DotNet.Cli - Fake.IO.FileSystem - Fake.IO.Zip - Fake.Core.Target - Fake.Core.UserInput - Fake.DotNet.AssemblyInfoFile - Fake.Core.ReleaseNotes - Fake.Tools.Git + Alma.Build diff --git a/dist/zipCompiled b/dist/zipCompiled index 48b8975..21816b8 100755 --- a/dist/zipCompiled +++ b/dist/zipCompiled @@ -3,11 +3,11 @@ DIR="dist" echo "Remove previous ..." -rm -rf "$DIR/*.7z" +rm -f "$DIR"/*.7z echo "Zipping all compiled files ..." -7z a -t7z -- "$DIR/osx-x64.7z" "$DIR/osx-x64" +7z a -t7z -- "$DIR/osx-arm64.7z" "$DIR/osx-arm64" 7z a -t7z -- "$DIR/linux-x64.7z" "$DIR/linux-x64" 7z a -t7z -- "$DIR/win-x64.7z" "$DIR/win-x64" diff --git a/fsharplint.json b/fsharplint.json index e0e6bd8..4c26569 100644 --- a/fsharplint.json +++ b/fsharplint.json @@ -493,4 +493,4 @@ "Array.append a (Array.append b c) ===> Array.concat [|a; b; c|]" ] } -} \ No newline at end of file +} diff --git a/paket.dependencies b/paket.dependencies index f3376f0..b89731a 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -20,11 +20,5 @@ group Tests group Build storage none source https://api.nuget.org/v3/index.json - nuget Fake.DotNet.Cli - nuget Fake.IO.FileSystem - nuget Fake.IO.Zip - nuget Fake.Core.Target - nuget Fake.Core.UserInput - nuget Fake.DotNet.AssemblyInfoFile - nuget Fake.Core.ReleaseNotes - nuget Fake.Tools.Git + source ~/.nuget/local + nuget Alma.Build ~> 3.0 diff --git a/paket.lock b/paket.lock index 8e8c1db..8560fdc 100644 --- a/paket.lock +++ b/paket.lock @@ -263,21 +263,33 @@ GROUP Build STORAGE: NONE NUGET remote: https://api.nuget.org/v3/index.json - BlackFox.VsWhere (1.1) - restriction: >= netstandard2.0 - FSharp.Core (>= 4.0.0.1) - restriction: >= net45 + Alma.Build (3.0) + Fake.Core.ReleaseNotes (>= 6.1.4) - restriction: >= net10.0 + Fake.Core.Target (>= 6.1.4) - restriction: >= net10.0 + Fake.Core.UserInput (>= 6.1.4) - restriction: >= net10.0 + Fake.DotNet.AssemblyInfoFile (>= 6.1.4) - restriction: >= net10.0 + Fake.DotNet.Cli (>= 6.1.4) - restriction: >= net10.0 + Fake.IO.FileSystem (>= 6.1.4) - restriction: >= net10.0 + Fake.IO.Zip (>= 6.1.4) - restriction: >= net10.0 + Fake.Tools.Git (>= 6.1.4) - restriction: >= net10.0 + FSharp.Core (>= 10.1.401 < 11.0) - restriction: >= net10.0 + Microsoft.Build.Framework (>= 18.9.6 < 18.10) - restriction: >= net10.0 + Microsoft.Build.Utilities.Core (>= 18.9.6 < 18.10) - restriction: >= net10.0 + Microsoft.NET.StringTools (>= 18.9.6 < 18.10) - restriction: >= net10.0 + BlackFox.VsWhere (1.1) - restriction: >= net10.0 FSharp.Core (>= 4.2.3) - restriction: && (< net45) (>= netstandard2.0) Microsoft.Win32.Registry (>= 4.7) - restriction: && (< net45) (>= netstandard2.0) - Fake.Core.CommandLineParsing (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.CommandLineParsing (6.1.4) - restriction: >= net10.0 FParsec (>= 1.1.1) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.Context (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.Context (6.1.4) - restriction: >= net10.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.Environment (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.Environment (6.1.4) - restriction: >= net10.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.FakeVar (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.FakeVar (6.1.4) - restriction: >= net10.0 Fake.Core.Context (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.Process (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.Process (6.1.4) - restriction: >= net10.0 Fake.Core.Environment (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.FakeVar (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.String (>= 6.1.4) - restriction: >= netstandard2.0 @@ -285,15 +297,15 @@ NUGET Fake.IO.FileSystem (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 System.Collections.Immutable (>= 8.0) - restriction: >= netstandard2.0 - Fake.Core.ReleaseNotes (6.1.4) + Fake.Core.ReleaseNotes (6.1.4) - restriction: >= net10.0 Fake.Core.SemVer (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.String (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.SemVer (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.SemVer (6.1.4) - restriction: >= net10.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.String (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.String (6.1.4) - restriction: >= net10.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.Target (6.1.4) + Fake.Core.Target (6.1.4) - restriction: >= net10.0 Fake.Core.CommandLineParsing (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.Context (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.Environment (>= 6.1.4) - restriction: >= netstandard2.0 @@ -303,25 +315,25 @@ NUGET Fake.Core.Trace (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Control.Reactive (>= 5.0.2) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.Tasks (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.Tasks (6.1.4) - restriction: >= net10.0 Fake.Core.Trace (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.Trace (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.Trace (6.1.4) - restriction: >= net10.0 Fake.Core.Environment (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.FakeVar (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.UserInput (6.1.4) + Fake.Core.UserInput (6.1.4) - restriction: >= net10.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Core.Xml (6.1.4) - restriction: >= netstandard2.0 + Fake.Core.Xml (6.1.4) - restriction: >= net10.0 Fake.Core.String (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.DotNet.AssemblyInfoFile (6.1.4) + Fake.DotNet.AssemblyInfoFile (6.1.4) - restriction: >= net10.0 Fake.Core.Environment (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.String (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.Trace (>= 6.1.4) - restriction: >= netstandard2.0 Fake.IO.FileSystem (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.DotNet.Cli (6.1.4) + Fake.DotNet.Cli (6.1.4) - restriction: >= net10.0 Fake.Core.Environment (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.Process (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.String (>= 6.1.4) - restriction: >= netstandard2.0 @@ -331,7 +343,7 @@ NUGET Fake.IO.FileSystem (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 Mono.Posix.NETStandard (>= 1.0) - restriction: >= netstandard2.0 - Fake.DotNet.MSBuild (6.1.4) - restriction: >= netstandard2.0 + Fake.DotNet.MSBuild (6.1.4) - restriction: >= net10.0 BlackFox.VsWhere (>= 1.1) - restriction: >= netstandard2.0 Fake.Core.Environment (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.Process (>= 6.1.4) - restriction: >= netstandard2.0 @@ -340,7 +352,7 @@ NUGET Fake.IO.FileSystem (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 MSBuild.StructuredLogger (>= 2.1.815) - restriction: >= netstandard2.0 - Fake.DotNet.NuGet (6.1.4) - restriction: >= netstandard2.0 + Fake.DotNet.NuGet (6.1.4) - restriction: >= net10.0 Fake.Core.Environment (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.Process (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.SemVer (>= 6.1.4) - restriction: >= netstandard2.0 @@ -353,18 +365,18 @@ NUGET FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 Newtonsoft.Json (>= 13.0.3) - restriction: >= netstandard2.0 NuGet.Protocol (>= 6.12.4) - restriction: >= netstandard2.0 - Fake.IO.FileSystem (6.1.4) + Fake.IO.FileSystem (6.1.4) - restriction: >= net10.0 Fake.Core.String (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.Trace (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.IO.Zip (6.1.4) + Fake.IO.Zip (6.1.4) - restriction: >= net10.0 Fake.Core.String (>= 6.1.4) - restriction: >= netstandard2.0 Fake.IO.FileSystem (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Net.Http (6.1.4) - restriction: >= netstandard2.0 + Fake.Net.Http (6.1.4) - restriction: >= net10.0 Fake.Core.Trace (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - Fake.Tools.Git (6.1.4) + Fake.Tools.Git (6.1.4) - restriction: >= net10.0 Fake.Core.Environment (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.Process (>= 6.1.4) - restriction: >= netstandard2.0 Fake.Core.SemVer (>= 6.1.4) - restriction: >= netstandard2.0 @@ -372,122 +384,52 @@ NUGET Fake.Core.Trace (>= 6.1.4) - restriction: >= netstandard2.0 Fake.IO.FileSystem (>= 6.1.4) - restriction: >= netstandard2.0 FSharp.Core (>= 8.0.400) - restriction: >= netstandard2.0 - FParsec (1.1.1) - restriction: >= netstandard2.0 + FParsec (1.1.1) - restriction: >= net10.0 FSharp.Core (>= 4.3.4) - restriction: || (>= net45) (>= netstandard2.0) - System.ValueTuple (>= 4.4) - restriction: >= net45 - FSharp.Control.Reactive (6.1.2) - restriction: >= netstandard2.0 + FSharp.Control.Reactive (6.1.2) - restriction: >= net10.0 FSharp.Core (>= 6.0.7) - restriction: >= netstandard2.0 System.Reactive (>= 6.0.1) - restriction: >= netstandard2.0 - FSharp.Core (10.0.100) - restriction: >= netstandard2.0 - Microsoft.Bcl.AsyncInterfaces (10.0) - restriction: >= net472 - System.Threading.Tasks.Extensions (>= 4.6.3) - restriction: || (>= net462) (&& (>= netstandard2.0) (< netstandard2.1)) - Microsoft.Bcl.Cryptography (10.0) - restriction: || (&& (< net10.0) (>= net9.0)) (&& (>= net462) (>= net8.0)) (&& (>= net8.0) (< net9.0)) (&& (>= net8.0) (< netstandard2.1)) - System.Formats.Asn1 (>= 10.0) - restriction: || (>= net462) (&& (>= net8.0) (< net9.0)) (&& (< net8.0) (>= netstandard2.1)) (&& (>= netstandard2.0) (< netstandard2.1)) - Microsoft.Build.Framework (18.0.2) - restriction: >= netstandard2.0 - System.Collections.Immutable (>= 9.0) - restriction: >= net472 - System.Diagnostics.DiagnosticSource (>= 9.0) - restriction: >= net472 - System.Memory (>= 4.6) - restriction: >= net472 - System.Runtime.CompilerServices.Unsafe (>= 6.1) - restriction: >= net472 - System.Text.Json (>= 9.0) - restriction: >= net472 - System.Threading.Tasks.Extensions (>= 4.6) - restriction: >= net472 - Microsoft.Build.Utilities.Core (18.0.2) - restriction: >= netstandard2.0 - Microsoft.Build.Framework (>= 18.0.2) - restriction: >= netstandard2.0 - Microsoft.IO.Redist (>= 6.1) - restriction: >= net472 - Microsoft.NET.StringTools (>= 18.0.2) - restriction: || (>= net10.0) (>= net472) - System.Collections.Immutable (>= 9.0) - restriction: >= net472 - System.Configuration.ConfigurationManager (>= 9.0) - restriction: || (>= net10.0) (>= net472) - System.Diagnostics.DiagnosticSource (>= 9.0) - restriction: >= net472 - System.Diagnostics.EventLog (>= 9.0) - restriction: >= net10.0 - System.Memory (>= 4.6) - restriction: >= net472 - System.Runtime.CompilerServices.Unsafe (>= 6.1) - restriction: >= net472 - System.Security.Cryptography.ProtectedData (>= 9.0.6) - restriction: >= net10.0 - System.Text.Json (>= 9.0) - restriction: >= net472 - System.Threading.Tasks.Extensions (>= 4.6) - restriction: >= net472 - Microsoft.IO.Redist (6.1.3) - restriction: >= net472 - System.Buffers (>= 4.6.1) - restriction: >= net472 - System.Memory (>= 4.6.3) - restriction: >= net472 - Microsoft.NET.StringTools (18.0.2) - restriction: || (>= net10.0) (>= net472) - System.Memory (>= 4.6) - restriction: || (&& (< net10.0) (>= netstandard2.0)) (>= net472) - System.Runtime.CompilerServices.Unsafe (>= 6.1) - restriction: || (&& (< net10.0) (>= netstandard2.0)) (>= net472) - Microsoft.NETCore.Platforms (7.0.4) - restriction: || (&& (>= monoandroid) (>= netcoreapp2.0) (< netstandard1.3)) (&& (>= monoandroid) (>= netcoreapp2.1) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (>= monotouch) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netcoreapp2.1)) (&& (>= net461) (>= netcoreapp2.0)) (&& (>= net461) (>= netcoreapp2.1)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinios)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinmac)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarintvos)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinwatchos)) (&& (>= netcoreapp2.0) (>= uap10.1)) (&& (< netcoreapp2.0) (>= netcoreapp2.1)) (&& (>= netcoreapp2.1) (< netcoreapp3.0)) (&& (>= netcoreapp2.1) (>= uap10.1)) - Microsoft.Win32.Registry (5.0) - restriction: && (< net45) (>= netstandard2.0) - System.Buffers (>= 4.5.1) - restriction: || (&& (>= monoandroid) (< netstandard1.3)) (>= monotouch) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0)) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos) - System.Memory (>= 4.5.4) - restriction: || (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= uap10.1) + FSharp.Core (10.1.401) - restriction: >= net10.0 + Microsoft.Build.Framework (18.9.6) - restriction: >= net10.0 + Microsoft.NET.StringTools (>= 18.9.6) - restriction: >= netstandard2.0 + Microsoft.Build.Utilities.Core (18.9.6) - restriction: >= net10.0 + Microsoft.Build.Framework (>= 18.9.6) - restriction: >= netstandard2.0 + System.Configuration.ConfigurationManager (>= 10.0.8) - restriction: || (>= net10.0) (>= net472) + System.Diagnostics.EventLog (>= 10.0.8) - restriction: >= net10.0 + System.Security.Cryptography.ProtectedData (>= 10.0.8) - restriction: >= net10.0 + Microsoft.NET.StringTools (18.9.6) - restriction: >= net10.0 + Microsoft.Win32.Registry (5.0) - restriction: >= net10.0 System.Security.AccessControl (>= 5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0)) (>= monotouch) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (>= netcoreapp2.1) (>= uap10.1) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos) System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0)) (>= monotouch) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (>= netcoreapp2.1) (>= uap10.1) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos) - Mono.Posix.NETStandard (1.0) - restriction: >= netstandard2.0 - MSBuild.StructuredLogger (2.3.109) - restriction: >= netstandard2.0 + Mono.Posix.NETStandard (1.0) - restriction: >= net10.0 + MSBuild.StructuredLogger (2.3.109) - restriction: >= net10.0 Microsoft.Build.Framework (>= 17.5) - restriction: >= netstandard2.0 Microsoft.Build.Utilities.Core (>= 17.5) - restriction: >= netstandard2.0 - System.Collections.Immutable (>= 8.0) - restriction: && (< net8.0) (>= netstandard2.0) - System.Memory (>= 4.6) - restriction: && (< net8.0) (>= netstandard2.0) - System.Runtime.CompilerServices.Unsafe (>= 6.1) - restriction: && (< net8.0) (>= netstandard2.0) - Newtonsoft.Json (13.0.4) - restriction: >= netstandard2.0 - NuGet.Common (7.0.1) - restriction: || (>= net472) (>= net8.0) + Newtonsoft.Json (13.0.4) - restriction: >= net10.0 + NuGet.Common (7.0.1) - restriction: >= net10.0 NuGet.Frameworks (>= 7.0.1) - restriction: || (>= net472) (>= net8.0) - System.Collections.Immutable (>= 8.0) - restriction: >= net472 - NuGet.Configuration (7.0.1) - restriction: || (>= net472) (>= net8.0) + NuGet.Configuration (7.0.1) - restriction: >= net10.0 NuGet.Common (>= 7.0.1) - restriction: || (>= net472) (>= net8.0) System.Security.Cryptography.ProtectedData (>= 9.0.6) - restriction: >= net8.0 - NuGet.Frameworks (7.0.1) - restriction: || (>= net472) (>= net8.0) - NuGet.Packaging (7.0.1) - restriction: || (>= net472) (>= net8.0) + NuGet.Frameworks (7.0.1) - restriction: >= net10.0 + NuGet.Packaging (7.0.1) - restriction: >= net10.0 Newtonsoft.Json (>= 13.0.3) - restriction: || (>= net472) (>= net8.0) NuGet.Configuration (>= 7.0.1) - restriction: || (>= net472) (>= net8.0) NuGet.Versioning (>= 7.0.1) - restriction: || (>= net472) (>= net8.0) System.Security.Cryptography.Pkcs (>= 9.0.6) - restriction: >= net8.0 - System.Text.Json (>= 8.0.5) - restriction: >= net472 - NuGet.Protocol (7.0.1) - restriction: >= netstandard2.0 + NuGet.Protocol (7.0.1) - restriction: >= net10.0 NuGet.Packaging (>= 7.0.1) - restriction: || (>= net472) (>= net8.0) - System.Text.Json (>= 8.0.5) - restriction: >= net472 - NuGet.Versioning (7.0.1) - restriction: || (>= net472) (>= net8.0) - System.Buffers (4.6.1) - restriction: || (&& (>= monoandroid) (< netstandard1.3) (>= netstandard2.0)) (&& (>= monotouch) (>= netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (&& (>= net462) (>= netstandard2.0)) (>= net472) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) (&& (>= netstandard2.0) (>= xamarintvos)) (&& (>= netstandard2.0) (>= xamarinwatchos)) (>= xamarinios) (>= xamarinmac) - System.Collections.Immutable (10.0) - restriction: >= netstandard2.0 - System.Memory (>= 4.6.3) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Runtime.CompilerServices.Unsafe (>= 6.1.2) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Configuration.ConfigurationManager (10.0) - restriction: || (>= net10.0) (>= net472) - System.Diagnostics.EventLog (>= 10.0) - restriction: >= net8.0 - System.Security.Cryptography.ProtectedData (>= 10.0) - restriction: || (&& (< net462) (>= netstandard2.0)) (>= net8.0) - System.Diagnostics.DiagnosticSource (10.0) - restriction: >= net472 - System.Memory (>= 4.6.3) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Runtime.CompilerServices.Unsafe (>= 6.1.2) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Diagnostics.EventLog (10.0) - restriction: || (>= net10.0) (&& (>= net472) (>= net8.0)) - System.Formats.Asn1 (10.0) - restriction: || (&& (< net10.0) (>= net9.0)) (&& (>= net462) (>= net8.0)) (&& (>= net462) (>= net9.0)) (&& (>= net8.0) (< net9.0)) (&& (>= net8.0) (< netstandard2.1)) (&& (< net8.0) (>= net9.0)) (&& (>= net9.0) (< netstandard2.1)) - System.IO.Pipelines (10.0) - restriction: >= net472 - System.Buffers (>= 4.6.1) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Memory (>= 4.6.3) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Threading.Tasks.Extensions (>= 4.6.3) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Memory (4.6.3) - restriction: || (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= net462) (>= netstandard2.0)) (>= net472) (&& (< net8.0) (>= netstandard2.0)) (&& (>= netstandard2.0) (>= uap10.1)) - System.Buffers (>= 4.6.1) - restriction: || (>= net462) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) - System.Numerics.Vectors (>= 4.6.1) - restriction: || (>= net462) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) - System.Runtime.CompilerServices.Unsafe (>= 6.1.2) - restriction: || (>= net462) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) - System.Numerics.Vectors (4.6.1) - restriction: || (&& (>= net462) (>= netstandard2.0)) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) - System.Reactive (6.1) - restriction: >= netstandard2.0 - System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (>= net472) (&& (< net6.0) (>= netstandard2.0)) (>= uap10.1) - System.Runtime.CompilerServices.Unsafe (6.1.2) - restriction: || (&& (>= net462) (>= netstandard2.0)) (>= net472) (&& (< net8.0) (>= netstandard2.0)) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) - System.Security.AccessControl (6.0.1) - restriction: || (&& (>= monoandroid) (< netstandard1.3) (>= netstandard2.0)) (&& (< monoandroid) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netstandard2.0)) (&& (< net45) (>= net461) (>= netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (>= netcoreapp2.1) (&& (>= netstandard2.0) (>= uap10.1)) (&& (>= netstandard2.0) (>= xamarintvos)) (&& (>= netstandard2.0) (>= xamarinwatchos)) (>= xamarinios) (>= xamarinmac) - System.Security.Principal.Windows (>= 5.0) - restriction: || (>= net461) (&& (< net6.0) (>= netstandard2.0)) - System.Security.Cryptography.Pkcs (10.0) - restriction: >= net8.0 - Microsoft.Bcl.Cryptography (>= 10.0) - restriction: || (&& (< net10.0) (>= net9.0)) (>= net462) (&& (>= net8.0) (< net9.0)) (&& (< net8.0) (>= netstandard2.1)) (&& (>= netstandard2.0) (< netstandard2.1)) - System.Formats.Asn1 (>= 10.0) - restriction: || (&& (< net10.0) (>= net9.0)) (&& (< net462) (>= netstandard2.0) (< netstandard2.1)) (&& (>= net8.0) (< net9.0)) (&& (< net8.0) (>= netstandard2.1)) - System.Security.Cryptography.ProtectedData (10.0) - restriction: || (&& (< net462) (>= net472)) (>= net8.0) - System.Security.Principal.Windows (5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3) (>= netstandard2.0)) (&& (< monoandroid) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netstandard2.0)) (&& (< net45) (>= net461) (>= netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (&& (>= net461) (>= netcoreapp2.0)) (>= netcoreapp2.1) (&& (>= netstandard2.0) (>= uap10.1)) (&& (>= netstandard2.0) (>= xamarintvos)) (&& (>= netstandard2.0) (>= xamarinwatchos)) (>= xamarinios) (>= xamarinmac) - Microsoft.NETCore.Platforms (>= 5.0) - restriction: || (&& (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (>= netcoreapp2.1) (< netcoreapp3.0)) - System.Text.Encodings.Web (10.0) - restriction: >= net472 - System.Buffers (>= 4.6.1) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Memory (>= 4.6.3) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Runtime.CompilerServices.Unsafe (>= 6.1.2) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Text.Json (10.0) - restriction: >= net472 - Microsoft.Bcl.AsyncInterfaces (>= 10.0) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Buffers (>= 4.6.1) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.IO.Pipelines (>= 10.0) - restriction: || (&& (< net10.0) (>= net9.0)) (>= net462) (&& (>= net8.0) (< net9.0)) (&& (< net8.0) (>= netstandard2.0)) - System.Memory (>= 4.6.3) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Runtime.CompilerServices.Unsafe (>= 6.1.2) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.Text.Encodings.Web (>= 10.0) - restriction: || (&& (< net10.0) (>= net9.0)) (>= net462) (&& (>= net8.0) (< net9.0)) (&& (< net8.0) (>= netstandard2.0)) - System.Threading.Tasks.Extensions (>= 4.6.3) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0)) - System.ValueTuple (>= 4.6.1) - restriction: >= net462 - System.Threading.Tasks.Extensions (4.6.3) - restriction: || (>= net472) (&& (< net6.0) (>= netstandard2.0)) (&& (>= netstandard2.0) (>= uap10.1)) - System.Runtime.CompilerServices.Unsafe (>= 6.1.2) - restriction: || (>= net462) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) - System.ValueTuple (4.6.1) - restriction: || (&& (>= net45) (>= netstandard2.0)) (>= net472) + NuGet.Versioning (7.0.1) - restriction: >= net10.0 + System.Collections.Immutable (10.0) - restriction: >= net10.0 + System.Configuration.ConfigurationManager (10.0.12) - restriction: >= net10.0 + System.Diagnostics.EventLog (>= 10.0.12) - restriction: >= net8.0 + System.Security.Cryptography.ProtectedData (>= 10.0.12) - restriction: || (&& (< net462) (>= netstandard2.0)) (>= net8.0) + System.Diagnostics.EventLog (10.0.12) - restriction: >= net10.0 + System.Reactive (6.1) - restriction: >= net10.0 + System.Security.AccessControl (6.0.1) - restriction: >= net10.0 + System.Security.Cryptography.Pkcs (10.0) - restriction: >= net10.0 + System.Security.Cryptography.ProtectedData (10.0.12) - restriction: >= net10.0 + System.Security.Principal.Windows (5.0) - restriction: >= net10.0 GROUP Tests STORAGE: NONE diff --git a/src/Puml/Generator.fs b/src/Puml/Generator.fs index 8a87a8f..5a8b220 100644 --- a/src/Puml/Generator.fs +++ b/src/Puml/Generator.fs @@ -84,8 +84,9 @@ module Generate = [] module private Part = - [] + // fsharplint:disable FL0085 let rec generate mainActor indentation: Generate = fun output -> + // fsharplint:enable let currentIndentation = indent indentation let deeper = indentation + indentSize @@ -426,13 +427,9 @@ module Generate = | AsciiUnicode -> "ascii_Unicode" | LaTeX -> "laTeX" - let private bundledRendererSettings () = - let jarPath = Path.Combine(AppContext.BaseDirectory, "plantuml", "plantuml.jar") - - { PlantUmlJar = PlantUmlJar.create jarPath } - let image imageFormat (Puml puml) = asyncResult { - let settings = bundledRendererSettings () + let! executable = NativeRuntime.bundled () |> Result.mapError RenderError.format + let settings: RendererSettings = { PlantUmlExecutable = executable } let! renderer = Renderer.create settings |> Result.mapError RenderError.format let! image = Renderer.render renderer (imageFormat |> ImageFormat.renderFormat) puml diff --git a/src/Puml/Renderer.fs b/src/Puml/Renderer.fs index c5cfed1..cd9ef59 100644 --- a/src/Puml/Renderer.fs +++ b/src/Puml/Renderer.fs @@ -3,37 +3,30 @@ namespace Tuc.Puml open System open System.Diagnostics open System.IO +open System.IO.Compression +open System.Runtime.InteropServices +open System.Security.Cryptography open System.Text open System.Threading open System.Threading.Tasks open Feather.ErrorHandling -type JavaExecutable = private JavaExecutable of string - -type PlantUmlJar = private PlantUmlJar of string - -type private AvailablePlantUmlJar = private AvailablePlantUmlJar of PlantUmlJar +type PlantUmlExecutable = private PlantUmlExecutable of string type RendererSettings = { - PlantUmlJar: PlantUmlJar + PlantUmlExecutable: PlantUmlExecutable } type Renderer = private { - JavaExecutable: JavaExecutable - PlantUmlJar: AvailablePlantUmlJar + PlantUmlExecutable: PlantUmlExecutable } -/// Executable invocation the process protocol runs; the testable boundary beneath PlantUML rendering. +/// Executable invocation the process protocol runs. type internal RenderCommand = { - Executable: JavaExecutable + Executable: PlantUmlExecutable Arguments: string list } -type internal JavaEnvironment = { - JavaHome: string option - Path: string option -} - [] type RenderFormat = | Png @@ -50,37 +43,20 @@ type RenderFormat = [] type RenderError = - | JavaNotFound - | JarNotFound of PlantUmlJar + | ExecutableNotFound of PlantUmlExecutable + | UnsupportedRuntime of runtimeId: string + | RuntimeArchiveNotFound of path: string + | RuntimeExtractionFailed of message: string | StartFailed of message: string | RenderingFailed of exitCode: int * message: string | CommunicationFailed of message: string | Cancelled [] -module JavaExecutable = - let value (JavaExecutable path) = path +module PlantUmlExecutable = + let value (PlantUmlExecutable path) = path - let create path = - if File.Exists path then - Ok (JavaExecutable path) - else - Error RenderError.JavaNotFound - -[] -module PlantUmlJar = - let value (PlantUmlJar path) = path - - let create path = PlantUmlJar path - -module private AvailablePlantUmlJar = - let value (AvailablePlantUmlJar jar) = jar |> PlantUmlJar.value - - let create jar = - if jar |> PlantUmlJar.value |> File.Exists then - Ok (AvailablePlantUmlJar jar) - else - Error (RenderError.JarNotFound jar) + let create path = PlantUmlExecutable path [] module RenderFormat = @@ -100,189 +76,172 @@ module RenderFormat = [] module RenderError = let format = function - | RenderError.JavaNotFound -> "PlantUML local rendering requires Java on PATH or JAVA_HOME." - | RenderError.JarNotFound jar -> sprintf "PlantUML JAR is missing at %s." (PlantUmlJar.value jar) + | RenderError.ExecutableNotFound executable -> sprintf "PlantUML native executable is missing at %s." (PlantUmlExecutable.value executable) + | RenderError.UnsupportedRuntime runtimeId -> sprintf "PlantUML native runtime is unsupported on %s." runtimeId + | RenderError.RuntimeArchiveNotFound path -> sprintf "PlantUML native runtime archive is missing at %s." path + | RenderError.RuntimeExtractionFailed message -> message | RenderError.StartFailed message -> message | RenderError.RenderingFailed (exitCode, message) -> sprintf "PlantUML exited with code %d: %s" exitCode message | RenderError.CommunicationFailed message -> message | RenderError.Cancelled -> "PlantUML rendering was cancelled." +[] +module NativeRuntime = + [] + type private Platform = + | Linux + | Windows + | MacOS + | Unsupported + + let private extractionLock = obj () + + let private currentPlatform () = + if OperatingSystem.IsLinux() then Platform.Linux + elif OperatingSystem.IsWindows() then Platform.Windows + elif OperatingSystem.IsMacOS() then Platform.MacOS + else Platform.Unsupported + + let private currentRuntimeId () = + match currentPlatform (), RuntimeInformation.OSArchitecture with + | Platform.Linux, Architecture.X64 -> Some "linux-x64" + | Platform.Windows, Architecture.X64 -> Some "win-x64" + | Platform.MacOS, Architecture.Arm64 -> Some "osx-arm64" + | _ -> None + + let private executableName () = if OperatingSystem.IsWindows() then "plantuml.exe" else "plantuml" + + let private extract archivePath = + use archive = File.OpenRead archivePath + let cacheKey = archive |> SHA256.HashData |> Convert.ToHexString |> fun hash -> hash.ToLowerInvariant() + let destination = Path.Combine(Path.GetTempPath(), "tuc-console", "plantuml", cacheKey) + let executable = Path.Combine(destination, executableName ()) + + try + if File.Exists executable |> not then + let temporary = destination + ".tmp-" + Guid.NewGuid().ToString "N" + Directory.CreateDirectory temporary |> ignore + + try + ZipFile.ExtractToDirectory(archivePath, temporary) + + if OperatingSystem.IsWindows() |> not then + File.SetUnixFileMode(Path.Combine(temporary, executableName ()), UnixFileMode.UserRead ||| UnixFileMode.UserWrite ||| UnixFileMode.UserExecute ||| UnixFileMode.GroupRead ||| UnixFileMode.GroupExecute ||| UnixFileMode.OtherRead ||| UnixFileMode.OtherExecute) + + lock extractionLock (fun () -> + if File.Exists executable |> not then + if Directory.Exists destination then Directory.Delete(destination, true) + Directory.CreateDirectory(Path.GetDirectoryName destination) |> ignore + Directory.Move(temporary, destination) + ) + finally + if Directory.Exists temporary then Directory.Delete(temporary, true) + + Ok (PlantUmlExecutable.create executable) + with error -> + Error (RenderError.RuntimeExtractionFailed error.Message) + + let bundled () = + match currentRuntimeId () with + | None -> Error (RenderError.UnsupportedRuntime RuntimeInformation.RuntimeIdentifier) + | Some runtimeId -> + let archivePath = + Path.Combine(AppContext.BaseDirectory, "plantuml", "native", runtimeId, "plantuml.zip") + + if File.Exists archivePath |> not then Error (RenderError.RuntimeArchiveNotFound archivePath) + else extract archivePath + [] module Renderer = let internal plantUmlCommand (renderer: Renderer) (format: RenderFormat): RenderCommand = { - Executable = renderer.JavaExecutable - Arguments = [ - "-Dfile.encoding=UTF-8" - "-jar" - renderer.PlantUmlJar |> AvailablePlantUmlJar.value - format |> RenderFormat.toCliSwitch - "-pipe" - "-charset" - "UTF-8" - ] + Executable = renderer.PlantUmlExecutable + Arguments = [ format |> RenderFormat.toCliSwitch; "-pipe"; "-charset"; "UTF-8" ] } let private startInfo (command: RenderCommand) = - let startInfo = ProcessStartInfo(JavaExecutable.value command.Executable) + let startInfo = ProcessStartInfo(PlantUmlExecutable.value command.Executable) startInfo.UseShellExecute <- false startInfo.RedirectStandardInput <- true startInfo.RedirectStandardOutput <- true startInfo.RedirectStandardError <- true startInfo.StandardInputEncoding <- UTF8Encoding false startInfo.StandardErrorEncoding <- UTF8Encoding false - - command.Arguments - |> List.iter startInfo.ArgumentList.Add - + command.Arguments |> List.iter startInfo.ArgumentList.Add startInfo - let private communicationError (error: exn) = - error.Message - |> RenderError.CommunicationFailed + let private communicationError (error: exn) = error.Message |> RenderError.CommunicationFailed let private startProcess (command: RenderCommand): Result = - try - Process.Start(startInfo command) - |> Ok - with error -> - Error (RenderError.StartFailed error.Message) + try Process.Start(startInfo command) |> Ok + with error -> Error (RenderError.StartFailed error.Message) let private terminateProcessTree (childProcess: Process) = - try - if not childProcess.HasExited then - childProcess.Kill true - with _ -> - () - - let internal createWith (findJava: unit -> Result) (settings: RendererSettings): Result = - settings.PlantUmlJar - |> AvailablePlantUmlJar.create - |> Result.bind (fun jar -> - findJava () - |> Result.map (fun java -> - { - JavaExecutable = java - PlantUmlJar = jar - } - ) - ) - - let internal discoverJavaWith executable (environment: JavaEnvironment) = - let javaHome = - environment.JavaHome - |> Option.map (fun home -> Path.Combine(home, "bin", executable)) - |> Option.bind (JavaExecutable.create >> Result.toOption) - - let fromPath = - environment.Path - |> Option.bind (fun path -> - path.Split Path.PathSeparator - |> Array.tryPick (fun directory -> - Path.Combine(directory, executable) - |> JavaExecutable.create - |> Result.toOption - ) - ) - - match javaHome |> Option.orElse fromPath with - | Some executable -> Ok executable - | None -> Error RenderError.JavaNotFound - - let private environmentVariable variable = - Environment.GetEnvironmentVariable variable - |> Option.ofObj + try if not childProcess.HasExited then childProcess.Kill true with _ -> () - let discoverJava () = - let executable = if OperatingSystem.IsWindows() then "java.exe" else "java" - - { - JavaHome = environmentVariable "JAVA_HOME" - Path = environmentVariable "PATH" - } - |> discoverJavaWith executable - - let create = createWith discoverJava + let create (settings: RendererSettings) = + if settings.PlantUmlExecutable |> PlantUmlExecutable.value |> File.Exists then + Ok { PlantUmlExecutable = settings.PlantUmlExecutable } + else + Error (RenderError.ExecutableNotFound settings.PlantUmlExecutable) let private writeSource (standardInput: StreamWriter) (source: string): AsyncResult = async { try do! standardInput.WriteAsync source |> Async.AwaitTask standardInput.Close() return Ok () - with error -> - return Error (communicationError error) + with error -> return Error (communicationError error) } - let private liftCommunication (task: Task): AsyncResult = - task |> AsyncResult.ofEmptyTaskCatch communicationError + let private liftCommunication (task: Task): AsyncResult = task |> AsyncResult.ofEmptyTaskCatch communicationError let private terminateOnError (childProcess: Process) = function | Error _ -> terminateProcessTree childProcess | Ok _ -> () - // Every step is total, so the flow always reaches the drains and disposal never races a live read. let private runWithCancellation (cancellationToken: CancellationToken) (command: RenderCommand) (source: string): AsyncResult = async { match startProcess command with | Error error -> return Error error | Ok childProcess -> - // Register owned resources, make cancellation kill the process tree use childProcess = childProcess use _ = cancellationToken.Register(fun () -> terminateProcessTree childProcess) use standardInput = childProcess.StandardInput use stdout = new MemoryStream() - - // Start draining both output pipes let stdoutRead = childProcess.StandardOutput.BaseStream.CopyToAsync stdout |> liftCommunication let stderrRead = childProcess.StandardError.ReadToEndAsync() |> AsyncResult.ofTaskCatch communicationError - - // Failures don't short-circuit here to prevent resource leaks, but they do kill the process tree to let the drains complete in the next stage let! sourceWritten = writeSource standardInput source - sourceWritten |> terminateOnError childProcess let! exited = liftCommunication (childProcess.WaitForExitAsync()) exited |> terminateOnError childProcess - - // The process has terminated, wait for both output drains to complete let! stdoutDrained = stdoutRead let! stderrDrained = stderrRead - // Check cancellation, then the protocol results, then the exit code return if cancellationToken.IsCancellationRequested then Error RenderError.Cancelled else result { - do! sourceWritten do! exited do! stdoutDrained let! stderr = stderrDrained return! match childProcess.ExitCode with - | 0 -> Ok (stdout.ToArray()) + | 0 -> + result { + do! sourceWritten + return stdout.ToArray() + } | exitCode -> Error (RenderError.RenderingFailed (exitCode, stderr)) } } - // Shields the operation from the caller's cancellation: aborting it mid-flight would abandon - // process cleanup, so it always runs to completion and reports cancellation as a typed result - // instead of an exception. let private withTypedCancellation operation = async { return! Async.FromContinuations(fun (complete, fail, _) -> - Async.StartWithContinuations( - operation, - complete, - fail, - (fun _ -> complete (Error RenderError.Cancelled)), - cancellationToken = CancellationToken.None - ) + Async.StartWithContinuations(operation, complete, fail, (fun _ -> complete (Error RenderError.Cancelled)), cancellationToken = CancellationToken.None) ) } let internal runCommand (command: RenderCommand) (source: string): AsyncResult = async { let! cancellationToken = Async.CancellationToken - - return! - runWithCancellation cancellationToken command source - |> withTypedCancellation + return! runWithCancellation cancellationToken command source |> withTypedCancellation } - let render (renderer: Renderer) (format: RenderFormat) (source: string) = - runCommand (plantUmlCommand renderer format) source + let render (renderer: Renderer) (format: RenderFormat) (source: string) = runCommand (plantUmlCommand renderer format) source diff --git a/tests/RendererTests.fs b/tests/RendererTests.fs index b63bd34..6d3222c 100644 --- a/tests/RendererTests.fs +++ b/tests/RendererTests.fs @@ -4,439 +4,125 @@ open System open System.Diagnostics open System.IO open System.Text -open System.Threading open Expecto open Tuc.Console.Tests.Fixture open Tuc.Puml [] -module private BoundaryFixture = - let path name = Path.Combine(Path.GetTempPath(), sprintf "tuc-renderer-%s-%s" (Guid.NewGuid().ToString "N") name) - - let resultOrFail = function - | Ok value -> value - | Error error -> failtestf "Fixture setup should succeed: %A" error +module private Fixture = + let executable = Path.Combine(AppContext.BaseDirectory, "fixture" + if OperatingSystem.IsWindows() then ".exe" else "") - let file name = - let path = path name + let executablePath name = + let path = Path.Combine(Path.GetTempPath(), sprintf "tuc-renderer-%s-%s" (Guid.NewGuid().ToString "N") name) File.WriteAllText(path, "") path -[] -module private RendererProcessFixture = - let executable = Path.Combine(AppContext.BaseDirectory, "fixture" + if OperatingSystem.IsWindows() then ".exe" else "") - let source = "source" - let private fileWaitAttempts = 100 - - let createRenderCommand (mode: FixtureMode) = { - Executable = JavaExecutable.create executable |> BoundaryFixture.resultOrFail - Arguments = mode |> FixtureMode.serialize - } - - let start (mode: FixtureMode) = - let startInfo = ProcessStartInfo(executable, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true) - mode |> FixtureMode.serialize |> List.iter startInfo.ArgumentList.Add - - Process.Start startInfo - - let run (mode: FixtureMode) = async { - use childProcess = start mode - let stdout = childProcess.StandardOutput.ReadToEndAsync() - let stderr = childProcess.StandardError.ReadToEndAsync() - do! childProcess.WaitForExitAsync() |> Async.AwaitTask - let! stdout = stdout |> Async.AwaitTask - let! stderr = stderr |> Async.AwaitTask - - return childProcess.ExitCode, stdout, stderr - } + let resultOrFail = function + | Ok value -> value + | Error error -> failtestf "Fixture setup should succeed: %A" error - [] - let rec private waitForFileWithAttempts attempts path = async { - if File.Exists path then - return () - elif attempts = 0 then - failtestf "Fixture did not write its process record: %s" path - else - do! Async.Sleep 10 - return! waitForFileWithAttempts (attempts - 1) path + let command mode = { + Executable = PlantUmlExecutable.create executable + Arguments = FixtureMode.serialize mode } - let waitForFile path = - waitForFileWithAttempts fileWaitAttempts path - - let isAlive processId = - try - use childProcess = Process.GetProcessById processId - not childProcess.HasExited - with :? ArgumentException -> - false - -[] -module private LocalPlantUml = - let jarPath = Path.Combine(AppContext.BaseDirectory, "plantuml", "plantuml.jar") - - let createRenderer jarPath = - { PlantUmlJar = PlantUmlJar.create jarPath } - |> Renderer.create - |> BoundaryFixture.resultOrFail - -// Test that the process fixture behaves correctly under all configurations -// so the tests using it can rely on its behavior -[] -let processFixtureTests = - testList "PlantUML process fixture" [ - testCaseAsync "should emit success output when invoked with a success configuration" <| async { - let! exitCode, stdout, stderr = RendererProcessFixture.run FixtureMode.Success - - Expect.equal exitCode FixtureMode.successExitCode "Successful fixture should exit successfully" - Expect.equal stdout FixtureMode.successOutput "Successful fixture should emit deterministic output" - Expect.equal stderr "" "Successful fixture should not emit errors" - } - - testCaseAsync "should emit stderr and a nonzero exit code when configured to fail" <| async { - let! exitCode, stdout, stderr = RendererProcessFixture.run FixtureMode.Nonzero - - Expect.equal exitCode FixtureMode.failureExitCode "Failing fixture should expose its configured exit code" - Expect.equal stdout "" "Failing fixture should not emit standard output" - Expect.equal stderr FixtureMode.failureOutput "Failing fixture should emit deterministic errors" - } - - testCaseAsync "should emit large standard output and standard error without blocking" <| async { - let! exitCode, stdout, stderr = RendererProcessFixture.run FixtureMode.HighOutput - - Expect.equal exitCode 0 "High-output fixture should exit successfully" - Expect.equal stdout.Length FixtureMode.highOutputLength "High-output fixture should emit one mebibyte to standard output" - Expect.equal stderr.Length FixtureMode.highOutputLength "High-output fixture should emit one mebibyte to standard error" - } - - testCaseAsync "should terminate its process tree when the fixture parent is killed" <| async { - let processRecordPath = BoundaryFixture.path "processes" - let fixtureProcess = RendererProcessFixture.start (FixtureMode.Cancellable processRecordPath) - - try - do! RendererProcessFixture.waitForFile processRecordPath - let processIds = File.ReadAllLines(processRecordPath) |> Array.map Int32.Parse - - fixtureProcess.Kill true - do! fixtureProcess.WaitForExitAsync() |> Async.AwaitTask - do! Async.Sleep 10 - - processIds - |> Array.iter (fun processId -> - Expect.isFalse (RendererProcessFixture.isAlive processId) (sprintf "Fixture process %d should be terminated" processId) - ) - finally - fixtureProcess.Dispose() - File.Delete processRecordPath - } - ] + let nativeRenderer () = + let executable = NativeRuntime.bundled () |> resultOrFail + let settings: RendererSettings = { PlantUmlExecutable = executable } + settings |> Renderer.create |> resultOrFail [] -let processProtocolTests = +let protocolTests = testList "PlantUML process protocol" [ - testCaseAsync "should return exact UTF-8 source bytes when the fixture echoes standard input" <| async { - let source = "@startuml\nAlice -> Bob: caf\u00e9\n@enduml\n" + testCaseAsync "should return UTF-8 input bytes when fixture echoes standard input" <| async { + let source = "@startuml\nAlice -> Bob: cafe\n@enduml\n" - let! result = Renderer.runCommand (RendererProcessFixture.createRenderCommand FixtureMode.Echo) source + let! result = Renderer.runCommand (Fixture.command FixtureMode.Echo) source - Expect.equal result (Ok (Encoding.UTF8.GetBytes source)) "Renderer should return the fixture's exact standard output bytes" + Expect.equal result (Ok (Encoding.UTF8.GetBytes source)) "Renderer should preserve standard output bytes" } - testCaseAsync "should return the exit code and standard error when rendering fails" <| async { - let! result = Renderer.runCommand (RendererProcessFixture.createRenderCommand FixtureMode.Nonzero) RendererProcessFixture.source + testCaseAsync "should return RenderingFailed error when fixture exits nonzero" <| async { + let! result = Renderer.runCommand (Fixture.command FixtureMode.Nonzero) "source" - Expect.equal result (Error (RenderError.RenderingFailed (FixtureMode.failureExitCode, FixtureMode.failureOutput))) "Renderer should return typed process failures" + Expect.equal result (Error (RenderError.RenderingFailed (FixtureMode.failureExitCode, FixtureMode.failureOutput))) "Renderer should preserve exit code and standard error" } - testCaseAsync "should return StartFailed when Java cannot be started" <| async { - let javaPath = BoundaryFixture.file "not-an-executable" - let command: RenderCommand = { Executable = JavaExecutable.create javaPath |> BoundaryFixture.resultOrFail; Arguments = [] } + testCaseAsync "should return StartFailed error when executable cannot start" <| async { + let path = Fixture.executablePath "not-executable" + let command: RenderCommand = { Executable = PlantUmlExecutable.create path; Arguments = [] } try - let! result = Renderer.runCommand command RendererProcessFixture.source + let! result = Renderer.runCommand command "source" match result with | Error (RenderError.StartFailed _) -> () | _ -> failtestf "Renderer should return StartFailed, got %A" result finally - File.Delete javaPath + File.Delete path } - testCaseAsync "should complete when fixture emits large standard output and standard error" <| async { - let! result = Renderer.runCommand (RendererProcessFixture.createRenderCommand FixtureMode.HighOutput) RendererProcessFixture.source + testCaseAsync "should drain both streams when fixture emits high output" <| async { + let! result = Renderer.runCommand (Fixture.command FixtureMode.HighOutput) "source" match result with - | Ok output -> Expect.equal output.Length FixtureMode.highOutputLength "Renderer should drain the fixture's large standard output" - | Error error -> failtestf "Renderer should not block on high output: %A" error + | Ok output -> Expect.equal output.Length FixtureMode.highOutputLength "Renderer should drain the complete standard output" + | Error error -> failtestf "Renderer should not block, got %A" error } ] [] -let cancellationTests = - testList "PlantUML cancellation" [ - testCaseAsync "should kill the fixture process tree and return Cancelled" <| async { - let processRecordPath = BoundaryFixture.path "renderer-processes" - let command = RendererProcessFixture.createRenderCommand (FixtureMode.Cancellable processRecordPath) - use cancellation = new CancellationTokenSource() - let rendering = Async.StartAsTask(Renderer.runCommand command RendererProcessFixture.source, cancellationToken = cancellation.Token) +let rendererTests = + testList "PlantUML native renderer" [ + testCase "should return ExecutableNotFound error when executable path is absent" <| fun _ -> + let executable = PlantUmlExecutable.create (Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString "N")) - try - do! RendererProcessFixture.waitForFile processRecordPath - cancellation.Cancel() - let! result = rendering |> Async.AwaitTask - let processIds = File.ReadAllLines(processRecordPath) |> Array.map Int32.Parse - - Expect.equal result (Error RenderError.Cancelled) "Cancellation should be typed" - processIds - |> Array.iter (fun processId -> - Expect.isFalse (RendererProcessFixture.isAlive processId) (sprintf "Renderer fixture process %d should be terminated" processId) - ) - finally - if File.Exists processRecordPath then - File.ReadAllLines(processRecordPath) - |> Array.map Int32.Parse - |> Array.iter (fun processId -> - try - use fixtureProcess = Process.GetProcessById processId - - if not fixtureProcess.HasExited then - fixtureProcess.Kill true - with :? ArgumentException -> - () - ) - - File.Delete processRecordPath - } - ] + let result = Renderer.create { PlantUmlExecutable = executable } -[] -let adapterTests = - testList "Generate.image adapter" [ - testCaseAsync "should return SVG bytes through the application image adapter" <| async { - let! result = Generate.image Generate.ImageFormat.Svg (Puml "@startuml\nAlice -> Bob: adapter\n@enduml") + Expect.equal result (Error (RenderError.ExecutableNotFound executable)) "Renderer should validate native executable path" - match result with - | Ok image -> - image - |> PumlImage.value - |> Encoding.UTF8.GetString - |> fun svg -> Expect.stringContains svg "adapter" "Adapter should preserve rendered SVG output" - | Error error -> failtestf "Generate.image should render through the local adapter: %s" error - } - ] + testCase "should construct pipe command when rendering SVG" <| fun _ -> + let executable = PlantUmlExecutable.create Fixture.executable + let renderer = Renderer.create { PlantUmlExecutable = executable } |> Fixture.resultOrFail -[] -let localIntegrationTests = - testList "PlantUML local integration" [ - testCaseAsync "should render with explicit settings using the bundled JAR" <| async { - let renderer = LocalPlantUml.createRenderer LocalPlantUml.jarPath + let command = Renderer.plantUmlCommand renderer RenderFormat.Svg + + Expect.equal (PlantUmlExecutable.value command.Executable) Fixture.executable "Command should start native executable" + Expect.equal command.Arguments [ "-tsvg"; "-pipe"; "-charset"; "UTF-8" ] "Command should use native pipe protocol" - let! result = Renderer.render renderer RenderFormat.Svg "@startuml\nAlice -> Bob: explicit\n@enduml" + testCaseAsync "should render SVG when bundled native runtime is extracted" <| async { + let renderer = Fixture.nativeRenderer () + + let! result = Renderer.render renderer RenderFormat.Svg "@startuml\nAlice -> Bob: native SVG\n@enduml" match result with - | Ok image -> - image - |> Encoding.UTF8.GetString - |> fun svg -> Expect.stringContains svg "explicit" "Explicit renderer settings should render SVG" - | Error error -> failtestf "Explicit renderer settings should render: %A" error + | Ok image -> image |> Encoding.UTF8.GetString |> fun svg -> Expect.stringContains svg "native SVG" "Native renderer should generate SVG" + | Error error -> failtestf "Native SVG rendering should succeed, got %A" error } - testCaseAsync "should render when the JAR path contains spaces" <| async { - let directory = BoundaryFixture.path "jar directory" - Directory.CreateDirectory directory |> ignore - let jarPath = Path.Combine(directory, "plantuml jar.jar") - File.Copy(LocalPlantUml.jarPath, jarPath) - let renderer = LocalPlantUml.createRenderer jarPath + testCaseAsync "should render PNG when bundled native runtime is extracted" <| async { + let renderer = Fixture.nativeRenderer () - try - let! result = Renderer.render renderer RenderFormat.Svg "@startuml\nAlice -> Bob: spaces\n@enduml" + let! result = Renderer.render renderer RenderFormat.Png "@startuml\nAlice -> Bob: native PNG\n@enduml" - match result with - | Ok image -> - image - |> Encoding.UTF8.GetString - |> fun svg -> Expect.stringContains svg "spaces" "ArgumentList should preserve spaced JAR paths" - | Error error -> failtestf "Renderer should support spaced JAR paths: %A" error - finally - Directory.Delete(directory, true) + match result with + | Ok image -> Expect.sequenceStarts image [| 137uy; 80uy; 78uy; 71uy |] "Native renderer should generate PNG signature" + | Error error -> failtestf "Native PNG rendering should succeed, got %A" error } - testCaseAsync "should complete ten concurrent renders with explicit settings" <| async { - let renderer = LocalPlantUml.createRenderer LocalPlantUml.jarPath + testCaseAsync "should complete concurrent renders when one extracted runtime is shared" <| async { + let renderer = Fixture.nativeRenderer () let source = "@startuml\nAlice -> Bob: concurrent\n@enduml" - let! results = - [ 1..10 ] - |> List.map (fun _ -> Renderer.render renderer RenderFormat.Svg source) - |> Async.Parallel + let! results = [ 1..10 ] |> List.map (fun _ -> Renderer.render renderer RenderFormat.Svg source) |> Async.Parallel results |> Array.iter (function | Ok _ -> () - | Error error -> failtestf "Concurrent explicit renders should succeed: %A" error + | Error error -> failtestf "Concurrent native render should succeed, got %A" error ) } ] [] -let tests = - testList "PlantUML renderer" [ - testList "boundaries" [ - testCase "should prefer JAVA_HOME candidate when both candidates exist" <| fun _ -> - let javaHome = BoundaryFixture.path "java-home" - let javaHomeBin = Path.Combine(javaHome, "bin") - Directory.CreateDirectory(javaHomeBin) |> ignore - - let javaHomeCandidate = Path.Combine(javaHomeBin, "java") - let pathCandidate = BoundaryFixture.file "java-path" - File.WriteAllText(javaHomeCandidate, "") - - try - let result = Renderer.discoverJavaWith "java" { JavaHome = Some javaHome; Path = Some (Path.GetDirectoryName pathCandidate) } - - Expect.equal result (Ok (JavaExecutable.create javaHomeCandidate |> BoundaryFixture.resultOrFail)) "JAVA_HOME candidate should win" - finally - Directory.Delete(javaHome, true) - File.Delete(pathCandidate) - - testCase "should fall back to first PATH candidate when JAVA_HOME candidate is missing" <| fun _ -> - let pathDirectory = BoundaryFixture.path "path" - Directory.CreateDirectory(pathDirectory) |> ignore - let pathCandidate = Path.Combine(pathDirectory, "java") - File.WriteAllText(pathCandidate, "") - - try - let result = Renderer.discoverJavaWith "java" { JavaHome = Some (BoundaryFixture.path "missing-java-home"); Path = Some pathDirectory } - - Expect.equal result (Ok (JavaExecutable.create pathCandidate |> BoundaryFixture.resultOrFail)) "PATH candidate should be used" - finally - Directory.Delete(pathDirectory, true) - - testCase "should return JavaNotFound when no candidate exists" <| fun _ -> - let result = Renderer.discoverJavaWith "java" { JavaHome = None; Path = Some (BoundaryFixture.path "missing-path") } - - Expect.equal result (Error RenderError.JavaNotFound) "Missing candidates should return a typed error" - - testCase "should discover Java when constructing a renderer" <| fun _ -> - let jarPath = BoundaryFixture.file "plantuml.jar" - let javaPath = BoundaryFixture.file "java" - let settings: RendererSettings = { PlantUmlJar = PlantUmlJar.create jarPath } - let java = JavaExecutable.create javaPath |> BoundaryFixture.resultOrFail - - try - let result = Renderer.createWith (fun () -> Ok java) settings - - Expect.isOk result "Renderer construction should discover Java" - finally - File.Delete jarPath - File.Delete javaPath - - testCase "should return JarNotFound error when the configured JAR is absent" <| fun _ -> - let jarPath = BoundaryFixture.path "missing-plantuml.jar" - let javaPath = BoundaryFixture.file "java" - let settings: RendererSettings = { PlantUmlJar = PlantUmlJar.create jarPath } - let java = JavaExecutable.create javaPath |> BoundaryFixture.resultOrFail - - try - let result = Renderer.createWith (fun () -> Ok java) settings - - Expect.equal result (Error (RenderError.JarNotFound (PlantUmlJar.create jarPath))) "Renderer construction should validate the configured JAR" - finally - File.Delete javaPath - - testCase "should construct the official PlantUML pipe command" <| fun _ -> - let jarPath = BoundaryFixture.file "plantuml.jar" - let javaPath = BoundaryFixture.file "java" - let settings: RendererSettings = { PlantUmlJar = PlantUmlJar.create jarPath } - - try - let renderer = Renderer.createWith (fun () -> JavaExecutable.create javaPath) settings |> BoundaryFixture.resultOrFail - let command = Renderer.plantUmlCommand renderer RenderFormat.Svg - - Expect.equal (JavaExecutable.value command.Executable) javaPath "Command should run the resolved Java" - Expect.equal command.Arguments [ "-Dfile.encoding=UTF-8"; "-jar"; jarPath; "-tsvg"; "-pipe"; "-charset"; "UTF-8" ] "Command should follow the official pipe protocol" - finally - File.Delete jarPath - File.Delete javaPath - - testCase "should map each format to its PlantUML command switch" <| fun _ -> - let switches = - [ - RenderFormat.Png, "-tpng" - RenderFormat.Svg, "-tsvg" - RenderFormat.Eps, "-teps" - RenderFormat.Pdf, "-tpdf" - RenderFormat.Vdx, "-tvdx" - RenderFormat.Xmi, "-txmi" - RenderFormat.Scxml, "-tscxml" - RenderFormat.Html, "-thtml" - RenderFormat.Ascii, "-ttxt" - RenderFormat.AsciiUnicode, "-tutxt" - RenderFormat.LaTeX, "-tlatex" - ] - - switches - |> List.iter (fun (format, expected) -> - Expect.equal (RenderFormat.toCliSwitch format) expected (sprintf "%A should have its official switch" format) - ) - - testCase "should format each renderer error stably" <| fun _ -> - let jarPath = BoundaryFixture.file "missing.jar" - let jar = PlantUmlJar.create jarPath - - try - [ - RenderError.JavaNotFound, "PlantUML local rendering requires Java on PATH or JAVA_HOME." - RenderError.JarNotFound jar, sprintf "PlantUML JAR is missing at %s." jarPath - RenderError.StartFailed "Cannot start Java.", "Cannot start Java." - RenderError.RenderingFailed (2, "PlantUML error."), "PlantUML exited with code 2: PlantUML error." - RenderError.CommunicationFailed "Pipe failed.", "Pipe failed." - RenderError.Cancelled, "PlantUML rendering was cancelled." - ] - |> List.iter (fun (error, expected) -> - Expect.equal (RenderError.format error) expected (sprintf "%A should format stably" error) - ) - finally - File.Delete jarPath - ] - - testCaseAsync "should render included local file when PlantUML is bundled" <| async { - let includedFilePath = Path.Combine(Path.GetTempPath(), sprintf "tuc-plantuml-%s.iuml" (Guid.NewGuid().ToString "N")) - - File.WriteAllText(includedFilePath, "title Local renderer fixture") - - try - let diagram = Puml (sprintf "@startuml\n!include %s\nAlice -> Bob: hello\n@enduml" includedFilePath) - let! result = Generate.image Generate.ImageFormat.Svg diagram - - match result with - | Ok image -> - let svg = image |> PumlImage.value |> Encoding.UTF8.GetString - Expect.stringContains svg "Local renderer fixture" "SVG should render the local include" - | Error error -> - failtestf "Local PlantUML rendering should succeed: %s" error - finally - File.Delete includedFilePath - } - - testCaseAsync "should identify bundled PlantUML version when rendering SVG" <| async { - let manifestPath = Path.Combine(AppContext.BaseDirectory, "plantuml", "manifest.txt") - let version = - File.ReadLines manifestPath - |> Seq.tryPick (fun line -> - if line.StartsWith "version=" then Some(line.Substring "version=".Length) else None - ) - |> Option.defaultWith (fun () -> failtestf "Bundled PlantUML manifest does not contain a version: %s" manifestPath) - let diagram = Puml "@startuml\nAlice -> Bob: hello\n@enduml" - - let! result = Generate.image Generate.ImageFormat.Svg diagram - - match result with - | Ok image -> - let svg = image |> PumlImage.value |> Encoding.UTF8.GetString - Expect.stringContains svg (sprintf "" version) "SVG should identify the bundled PlantUML version" - | Error error -> - failtestf "Bundled PlantUML rendering should succeed: %s" error - } - - ] +let tests = testList "PlantUML renderer" [ protocolTests; rendererTests ] diff --git a/tests/fixture/fixture.fsproj b/tests/fixture/fixture.fsproj index 6f0a366..9079e17 100644 --- a/tests/fixture/fixture.fsproj +++ b/tests/fixture/fixture.fsproj @@ -1,12 +1,13 @@ + Exe net10.0 false - - + + \ No newline at end of file diff --git a/tests/tests.fsproj b/tests/tests.fsproj index eb9fd74..d804ed2 100644 --- a/tests/tests.fsproj +++ b/tests/tests.fsproj @@ -16,12 +16,5 @@ - - - plantuml/manifest.txt - PreserveNewest - - - diff --git a/tools/plantuml/licenses/COPYING b/tools/plantuml/licenses/COPYING new file mode 100644 index 0000000..f6cdd22 --- /dev/null +++ b/tools/plantuml/licenses/COPYING @@ -0,0 +1,232 @@ +GNU GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS + +0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on the Program. + +To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. + +A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. + + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. +A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. + +14. Revised Versions of this License. +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/tools/plantuml/licenses/NOTICE b/tools/plantuml/licenses/NOTICE new file mode 100644 index 0000000..564592d --- /dev/null +++ b/tools/plantuml/licenses/NOTICE @@ -0,0 +1,12 @@ +PlantUML +Copyright 2009-2026 PlantUML contributors. + +This distribution embeds an unmodified official PlantUML native runtime archive. +The archive is licensed under the GNU General Public License, version 3. + +The distribution includes this notice, the complete GPLv3 text, and corresponding-source +information under licenses/PlantUML/. + +Upstream project: https://github.com/plantuml/plantuml +Pinned release: v1.2026.8 +Release page: https://github.com/plantuml/plantuml/releases/tag/v1.2026.8 diff --git a/tools/plantuml/manifest.txt b/tools/plantuml/manifest.txt index 810ca57..c6f6c20 100644 --- a/tools/plantuml/manifest.txt +++ b/tools/plantuml/manifest.txt @@ -1,4 +1,21 @@ -version=1.2026.7 -url=https://github.com/plantuml/plantuml/releases/download/v1.2026.7/plantuml-mit-1.2026.7.jar -sha256=249ae0234a03acf999c3845eb683b495415b512bbfc7e7a4a173528c0892ec2e -license=MIT +version=1.2026.8 +license=GPL-3.0-only +release=https://github.com/plantuml/plantuml/releases/tag/v1.2026.8 +license-text=tools/plantuml/licenses/COPYING +notice=tools/plantuml/licenses/NOTICE +source-provenance=tools/plantuml/source-provenance.txt + +rid.linux-x64.archive=native-plantuml-linux-amd64-1.2026.8.zip +rid.linux-x64.url=https://github.com/plantuml/plantuml/releases/download/v1.2026.8/native-plantuml-linux-amd64-1.2026.8.zip +rid.linux-x64.sha256=38be3f8051a52f64e81e33bfb96ff7e49e176c91d41074f6225800923a7524a2 +rid.linux-x64.executable=plantuml + +rid.win-x64.archive=native-plantuml-windows-amd64-1.2026.8.zip +rid.win-x64.url=https://github.com/plantuml/plantuml/releases/download/v1.2026.8/native-plantuml-windows-amd64-1.2026.8.zip +rid.win-x64.sha256=75c62a594d7db35fec5b4e745b9a6cf1a82acbc2dae9d99b4d5ab4b2ee6518d6 +rid.win-x64.executable=plantuml.exe + +rid.osx-arm64.archive=native-plantuml-macos-arm64-1.2026.8.zip +rid.osx-arm64.url=https://github.com/plantuml/plantuml/releases/download/v1.2026.8/native-plantuml-macos-arm64-1.2026.8.zip +rid.osx-arm64.sha256=6797141f947a40469dedbfcb46e66b8c8440b6d21f6b2bdde79edfe4591631ac +rid.osx-arm64.executable=plantuml diff --git a/tools/plantuml/source-provenance.txt b/tools/plantuml/source-provenance.txt new file mode 100644 index 0000000..761b197 --- /dev/null +++ b/tools/plantuml/source-provenance.txt @@ -0,0 +1,9 @@ +component=PlantUML native runtime +version=1.2026.8 +license=GPL-3.0-only +source_repository=https://github.com/plantuml/plantuml +source_release=https://github.com/plantuml/plantuml/tree/v1.2026.8 +source_archive=https://github.com/plantuml/plantuml/archive/refs/tags/v1.2026.8.tar.gz +release=https://github.com/plantuml/plantuml/releases/tag/v1.2026.8 +license_text=tools/plantuml/licenses/COPYING +notice=tools/plantuml/licenses/NOTICE diff --git a/tools/plantuml/update.sh b/tools/plantuml/update.sh index 0a66dce..31bb142 100755 --- a/tools/plantuml/update.sh +++ b/tools/plantuml/update.sh @@ -1,20 +1,21 @@ #!/usr/bin/env bash -set -eu -set -o pipefail +set -euo pipefail script_directory="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" readonly script_directory repository_root="$(cd -- "$script_directory/../.." && pwd)" readonly repository_root readonly manifest_path="$repository_root/tools/plantuml/manifest.txt" -readonly jar_path="$repository_root/tools/plantuml/plantuml.jar" +readonly provenance_path="$repository_root/tools/plantuml/source-provenance.txt" +readonly license_path="$repository_root/tools/plantuml/licenses/COPYING" +readonly notice_path="$repository_root/tools/plantuml/licenses/NOTICE" readonly releases_url="https://github.com/plantuml/plantuml/releases" readonly releases_api_url="https://api.github.com/repos/plantuml/plantuml/releases" usage() { printf 'Usage: %s [VERSION]\n' "${0##*/}" - printf 'Download a PlantUML MIT JAR and update %s.\n' "$manifest_path" + printf 'Update PlantUML native archive metadata, GPLv3 text, notice, and source provenance.\n' } resolve_version() { @@ -22,25 +23,12 @@ resolve_version() { | sed -n 's|.*/tag/v\([0-9][0-9.]*\)$|\1|p' } -release_checksum() { - local version="$1" - local asset_name="plantuml-mit-$version.jar" - - curl --fail --silent --show-error --location "$releases_api_url/tags/v$version" \ - | jq --raw-output --arg asset_name "$asset_name" ' - .assets[] - | select(.name == $asset_name) - | .digest // empty - ' \ - | sed -n 's/^sha256://p' -} - -sha256() { - if command -v sha256sum >/dev/null 2>&1; then - sha256sum "$1" | awk '{print $1}' - else - shasum -a 256 "$1" | awk '{print $1}' - fi +asset_name() { + case "$1" in + linux-x64) printf 'native-plantuml-linux-amd64-%s.zip' "$2" ;; + win-x64) printf 'native-plantuml-windows-amd64-%s.zip' "$2" ;; + osx-arm64) printf 'native-plantuml-macos-arm64-%s.zip' "$2" ;; + esac } if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then @@ -48,10 +36,12 @@ if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then exit 0 fi -if ! command -v jq >/dev/null 2>&1; then - printf 'PlantUML updater requires jq.\n' >&2 - exit 1 -fi +for command in curl jq; do + if ! command -v "$command" >/dev/null 2>&1; then + printf 'PlantUML updater requires %s.\n' "$command" >&2 + exit 1 + fi +done version="${1:-$(resolve_version)}" @@ -60,47 +50,83 @@ if [[ ! "$version" =~ ^[0-9]+(\.[0-9]+)+$ ]]; then exit 1 fi -url="$releases_url/download/v$version/plantuml-mit-$version.jar" -checksum="$(release_checksum "$version")" - -if [[ ! "$checksum" =~ ^[a-f0-9]{64}$ ]]; then - printf 'Could not resolve an SHA-256 checksum for PlantUML %s.\n' "$version" >&2 - exit 1 -fi - -current_version="$(sed -n 's/^version=//p' "$manifest_path" 2>/dev/null || true)" -current_checksum="$(sed -n 's/^sha256=//p' "$manifest_path" 2>/dev/null || true)" - -if [[ "$current_version" == "$version" && "$current_checksum" == "$checksum" ]]; then - printf 'PlantUML %s is already current (%s)\n' "$version" "$checksum" - exit 0 -fi - -temporary_jar="$(mktemp)" -temporary_manifest="$(mktemp)" +release_json="$(mktemp)" cleanup() { - rm -f "$temporary_jar" "$temporary_manifest" + rm -f "$release_json" } trap cleanup EXIT -curl --fail --silent --show-error --location --output "$temporary_jar" "$url" -downloaded_checksum="$(sha256 "$temporary_jar")" +curl --fail --silent --show-error --location "$releases_api_url/tags/v$version" --output "$release_json" -if [[ "$downloaded_checksum" != "$checksum" ]]; then - printf 'Downloaded PlantUML SHA-256 mismatch: expected %s, got %s.\n' "$checksum" "$downloaded_checksum" >&2 - exit 1 -fi +asset_metadata() { + jq --raw-output --arg name "$1" ' + .assets[] + | select(.name == $name) + | [.name, .browser_download_url, (.digest // "" | sub("^sha256:"; ""))] + | @tsv + ' "$release_json" +} -cat > "$temporary_manifest" <&2 + exit 1 + fi -printf 'Pinned PlantUML %s (%s)\n' "$version" "$checksum" + executable="plantuml" + [[ "$rid" == "win-x64" ]] && executable="plantuml.exe" + assets+=("$rid|$name|$url|$checksum|$executable") +done + +mkdir -p "$(dirname "$license_path")" +curl --fail --silent --show-error --location "https://raw.githubusercontent.com/plantuml/plantuml/v$version/LICENSE" --output "$license_path" + +{ + printf 'version=%s\n' "$version" + printf 'license=GPL-3.0-only\n' + printf 'release=%s/tag/v%s\n' "$releases_url" "$version" + printf 'license-text=tools/plantuml/licenses/COPYING\n' + printf 'notice=tools/plantuml/licenses/NOTICE\n' + printf 'source-provenance=tools/plantuml/source-provenance.txt\n\n' + + for index in "${!assets[@]}"; do + [[ "$index" -gt 0 ]] && printf '\n' + asset="${assets[$index]}" + IFS='|' read -r rid name url checksum executable <<< "$asset" + printf 'rid.%s.archive=%s\n' "$rid" "$name" + printf 'rid.%s.url=%s\n' "$rid" "$url" + printf 'rid.%s.sha256=%s\n' "$rid" "$checksum" + printf 'rid.%s.executable=%s\n' "$rid" "$executable" + done +} > "$manifest_path" + +{ + printf 'component=PlantUML native runtime\n' + printf 'version=%s\n' "$version" + printf 'license=GPL-3.0-only\n' + printf 'source_repository=https://github.com/plantuml/plantuml\n' + printf 'source_release=https://github.com/plantuml/plantuml/tree/v%s\n' "$version" + printf 'source_archive=https://github.com/plantuml/plantuml/archive/refs/tags/v%s.tar.gz\n' "$version" + printf 'release=%s/tag/v%s\n' "$releases_url" "$version" + printf 'license_text=tools/plantuml/licenses/COPYING\n' + printf 'notice=tools/plantuml/licenses/NOTICE\n' +} > "$provenance_path" + +{ + printf 'PlantUML\n' + printf 'Copyright 2009-2026 PlantUML contributors.\n\n' + printf 'This distribution embeds an unmodified official PlantUML native runtime archive.\n' + printf 'The archive is licensed under the GNU General Public License, version 3.\n\n' + printf 'The distribution includes this notice, the complete GPLv3 text, and corresponding-source\n' + printf 'information under licenses/PlantUML/.\n\n' + printf 'Upstream project: https://github.com/plantuml/plantuml\n' + printf 'Pinned release: v%s\n' "$version" + printf 'Release page: %s/tag/v%s\n' "$releases_url" "$version" +} > "$notice_path" + +printf 'Pinned PlantUML native archives for %s.\n' "$version"