Add version option to ProjectFile plugin to set initial version

This commit is contained in:
Chris de Graaf 2019-11-04 15:58:32 +07:00
parent aaa1f5280c
commit 6bb3c2c669
No known key found for this signature in database
GPG Key ID: 150FFDD9B0073C7B
4 changed files with 13 additions and 6 deletions

View File

@ -1,19 +1,24 @@
"""
ProjectFile()
ProjectFile(; version=v"0.1.0")
Creates a `Project.toml`.
## Keyword Arguments
- `version::VersionNumber`: The initial version of created packages.
"""
struct ProjectFile <: Plugin end
@with_kw_noshow struct ProjectFile <: Plugin
version::VersionNumber = v"0.1.0"
end
# Other plugins like Tests will modify this file.
priority(::ProjectFile, ::typeof(hook)) = typemax(Int) - 5
function hook(::ProjectFile, t::Template, pkg_dir::AbstractString)
function hook(p::ProjectFile, t::Template, pkg_dir::AbstractString)
toml = Dict(
"name" => basename(pkg_dir),
"uuid" => string(uuid4()),
"authors" => t.authors,
"version" => "0.1.0",
"version" => string(p.version),
"compat" => Dict("julia" => compat_version(t.julia)),
)
open(io -> TOML.print(io, toml), joinpath(pkg_dir, "Project.toml"), "w")

View File

@ -1,7 +1,7 @@
name = "WackyOptions"
uuid = "5b7e9947-ddc0-4b3f-9b55-0d8042f74170"
authors = ["tester"]
version = "0.1.0"
version = "1.0.0"
[compat]
julia = "1.2"

View File

@ -43,6 +43,7 @@ end
Git(; ignore=["a", "b", "c"], manifest=true),
GitLabCI(; coverage=false, extra_versions=[v"0.6"]),
License(; name="ISC"),
ProjectFile(; version=v"1"),
Readme(; inline_badges=true),
Tests(; project=true),
TravisCI(;

View File

@ -38,7 +38,8 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses")
License:
path: "$(joinpath(LICENSES_DIR, "MIT"))"
destination: "LICENSE"
ProjectFile
ProjectFile:
version: v"0.1.0"
Readme:
file: "$(joinpath(TEMPLATES_DIR, "README.md"))"
destination: "README.md"