# This file is a part of Julia. License is MIT: https://julialang.org/license

using Artifacts: with_artifacts_directory
# using Pkg.Artifacts: ensure_all_artifacts_installed
using Pkg.Artifacts: load_artifacts_toml, ensure_artifact_installed
let
    tempdir = joinpath(@__DIR__, "artifacts")
    toml = joinpath(@__DIR__, "Artifacts.toml")
    unused = Base.BinaryPlatforms.Platform(string(Sys.ARCH), "linux")
    with_artifacts_directory(tempdir) do
        # ensure_all_artifacts_installed(toml; include_lazy=false)
        dict = load_artifacts_toml(toml)
        for (name, meta) in dict
            if meta isa Array
                for meta in meta
                    get(meta, "lazy", false) && continue
                    ensure_artifact_installed(name, meta, toml; platform=unused)
                end
            else; meta::Dict
                get(meta, "lazy", false) && continue
                ensure_artifact_installed(name, meta, toml; platform=unused)
            end
        end
    end
end
