Merge pull request #45 from invenia/cdg/drop-ahe

Drop AutoHashEquals dependency, other minor updates
This commit is contained in:
Chris de Graaf 2018-12-20 15:03:36 -06:00 committed by GitHub
commit a9cb7df047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 60 additions and 71 deletions

View File

@ -1,8 +1,3 @@
[[AutoHashEquals]]
git-tree-sha1 = "45bb6705d93be619b81451bb2006b7ee5d4e4453"
uuid = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
version = "0.2.0"
[[Base64]] [[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

View File

@ -4,7 +4,6 @@ authors = ["Chris de Graaf <chrisadegraaf@gmail.com>"]
version = "0.4.1" version = "0.4.1"
[deps] [deps]
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"

View File

@ -1,4 +1,3 @@
julia 0.7 julia 0.7
AutoHashEquals
Mustache Mustache
URIParser URIParser

View File

@ -1,6 +1,5 @@
module PkgTemplates module PkgTemplates
using AutoHashEquals
using Dates using Dates
using InteractiveUtils using InteractiveUtils
using LibGit2 using LibGit2

View File

@ -21,7 +21,7 @@ Generic plugins are plugins that add any number of patterns to the generated pac
# Example # Example
```julia ```julia
@auto_hash_equals struct MyPlugin <: GenericPlugin struct MyPlugin <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{AbstractString}
src::Union{AbstractString, Nothing} src::Union{AbstractString, Nothing}
dest::AbstractString dest::AbstractString
@ -69,19 +69,19 @@ abstract type GenericPlugin <: Plugin end
function Base.show(io::IO, p::GenericPlugin) function Base.show(io::IO, p::GenericPlugin)
spc = " " spc = " "
println(io, "$(nameof(typeof(p))):") println(io, nameof(typeof(p)), ":")
cfg = if p.src === nothing cfg = if p.src === nothing
"None" "None"
else else
dirname(p.src) == DEFAULTS_DIR ? "Default" : p.src dirname(p.src) == DEFAULTS_DIR ? "Default" : p.src
end end
println(io, "$spc→ Config file: $cfg") println(io, spc, " Config file: ", cfg)
n = length(p.gitignore) n = length(p.gitignore)
s = n == 1 ? "" : "s" s = n == 1 ? "" : "s"
print(io, "$spc→ $n gitignore entrie$s") print(io, spc, " $n gitignore entrie$s")
n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))") n > 0 && print(io, ": ", join(map(repr, p.gitignore), ", "))
end end
""" """
@ -96,7 +96,7 @@ signature.
# Example # Example
```julia ```julia
@auto_hash_equals struct MyPlugin <: CustomPlugin struct MyPlugin <: CustomPlugin
gitignore::Vector{AbstractString} gitignore::Vector{AbstractString}
lucky::Bool lucky::Bool
@ -152,10 +152,10 @@ A `Badge` contains the data necessary to generate a Markdown badge.
* `image::AbstractString`: URL to the image to display. * `image::AbstractString`: URL to the image to display.
* `link::AbstractString`: URL to go to upon clicking the badge. * `link::AbstractString`: URL to go to upon clicking the badge.
""" """
@auto_hash_equals struct Badge struct Badge
hover::AbstractString hover::String
image::AbstractString image::String
link::AbstractString link::String
end end
""" """
@ -230,7 +230,7 @@ function interactive(T::Type{<:GenericPlugin}; file::Union{AbstractString, Nothi
if default_config_file == nothing if default_config_file == nothing
print("[None]: ") print("[None]: ")
else else
print("[$(replace(default_config_file, homedir() => "~"))]: ") print("[", replace(default_config_file, homedir() => "~"), "]: ")
end end
config_file = readline() config_file = readline()

View File

@ -8,10 +8,10 @@ generated repositories, and an appropriate badge to the README.
* `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.appveyor.yml`. * `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.appveyor.yml`.
If `nothing` is supplied, no file will be generated. If `nothing` is supplied, no file will be generated.
""" """
@auto_hash_equals struct AppVeyor <: GenericPlugin struct AppVeyor <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{String}
src::Union{AbstractString, Nothing} src::Union{String, Nothing}
dest::AbstractString dest::String
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}

View File

@ -9,10 +9,10 @@ to generated repositories, and an appropriate badge to the README. Also updates
* `config_file::Union{AbstractString, Nothing}=nothing`: Path to a custom `.codecov.yml`. * `config_file::Union{AbstractString, Nothing}=nothing`: Path to a custom `.codecov.yml`.
If left unset, no file will be generated. If left unset, no file will be generated.
""" """
@auto_hash_equals struct Codecov <: GenericPlugin struct Codecov <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{String}
src::Union{AbstractString, Nothing} src::Union{String, Nothing}
dest::AbstractString dest::String
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}

View File

@ -9,10 +9,10 @@ file to generated repositories, and an appropriate badge to the README. Also upd
* `config_file::Union{AbstractString, Nothing}=nothing`: Path to a custom `.coveralls.yml`. * `config_file::Union{AbstractString, Nothing}=nothing`: Path to a custom `.coveralls.yml`.
If left unset, no file will be generated. If left unset, no file will be generated.
""" """
@auto_hash_equals struct Coveralls <: GenericPlugin struct Coveralls <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{String}
src::Union{AbstractString, Nothing} src::Union{String, Nothing}
dest::AbstractString dest::String
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}

View File

@ -109,19 +109,19 @@ end
function Base.show(io::IO, p::Documenter) function Base.show(io::IO, p::Documenter)
spc = " " spc = " "
println(io, "$(nameof(typeof(p))):") println(io, nameof(typeof(p)), ":")
n = length(p.assets) n = length(p.assets)
s = n == 1 ? "" : "s" s = n == 1 ? "" : "s"
print(io, "$spc→ $n asset file$s") print(io, spc, " $n asset file$s")
if n == 0 if n == 0
println(io) println(io)
else else
println(io, ": $(join(map(a -> replace(a, homedir() => "~"), p.assets), ", "))") println(io, ": ", join(map(a -> replace(a, homedir() => "~"), p.assets), ", "))
end end
n = length(p.gitignore) n = length(p.gitignore)
s = n == 1 ? "" : "s" s = n == 1 ? "" : "s"
print(io, "$spc→ $n gitignore entrie$s") print(io, "$spc→ $n gitignore entrie$s")
n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))") n > 0 && print(io, ": ", join(map(repr, p.gitignore), ", "))
end end

View File

@ -13,9 +13,9 @@ adds appropriate badges to the README, and updates the `.gitignore` accordingly.
configuration (see configuration (see
[here](https://juliadocs.github.io/Documenter.jl/stable/man/hosting/#SSH-Deploy-Keys-1)). [here](https://juliadocs.github.io/Documenter.jl/stable/man/hosting/#SSH-Deploy-Keys-1)).
""" """
@auto_hash_equals struct GitHubPages <: Documenter struct GitHubPages <: Documenter
gitignore::Vector{AbstractString} gitignore::Vector{String}
assets::Vector{AbstractString} assets::Vector{String}
function GitHubPages(; assets::Vector{<:AbstractString}=String[]) function GitHubPages(; assets::Vector{<:AbstractString}=String[])
for file in assets for file in assets

View File

@ -10,10 +10,10 @@ generated repositories, and appropriate badge(s) to the README.
* `coverage::Bool=true`: Whether or not GitLab CI's built-in code coverage analysis should * `coverage::Bool=true`: Whether or not GitLab CI's built-in code coverage analysis should
be enabled. be enabled.
""" """
@auto_hash_equals struct GitLabCI <: GenericPlugin struct GitLabCI <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{String}
src::Union{AbstractString, Nothing} src::Union{String, Nothing}
dest::AbstractString dest::String
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}
@ -61,7 +61,7 @@ function interactive(::Type{GitLabCI})
default_config_file = joinpath(DEFAULTS_DIR, "gitlab-ci.yml") default_config_file = joinpath(DEFAULTS_DIR, "gitlab-ci.yml")
print("$name: Enter the config template filename (\"None\" for no file) ") print("$name: Enter the config template filename (\"None\" for no file) ")
print("[$default_config_file]: ") print("[", replace(default_config_file, homedir() => "~"), "]: ")
config_file = readline() config_file = readline()
kwargs[:config_file] = if uppercase(config_file) == "NONE" kwargs[:config_file] = if uppercase(config_file) == "NONE"
nothing nothing

View File

@ -8,10 +8,10 @@ generated repositories, and an appropriate badge to the README.
* `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.travis.yml`. * `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.travis.yml`.
If `nothing` is supplied, no file will be generated. If `nothing` is supplied, no file will be generated.
""" """
@auto_hash_equals struct TravisCI <: GenericPlugin struct TravisCI <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{String}
src::Union{AbstractString, Nothing} src::Union{String, Nothing}
dest::AbstractString dest::String
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}

View File

@ -26,16 +26,16 @@ create a template, you can use [`interactive_template`](@ref) instead.
* `manifest::Bool=false`: Whether or not to commit the `Manifest.toml`. * `manifest::Bool=false`: Whether or not to commit the `Manifest.toml`.
* `plugins::Vector{<:Plugin}=Plugin[]`: A list of `Plugin`s that the package will include. * `plugins::Vector{<:Plugin}=Plugin[]`: A list of `Plugin`s that the package will include.
""" """
@auto_hash_equals struct Template struct Template
user::AbstractString user::String
host::AbstractString host::String
license::AbstractString license::String
authors::AbstractString authors::String
dir::AbstractString dir::String
julia_version::VersionNumber julia_version::VersionNumber
ssh::Bool ssh::Bool
manifest::Bool manifest::Bool
plugins::Dict{DataType, Plugin} plugins::Dict{DataType, <:Plugin}
function Template(; function Template(;
user::AbstractString="", user::AbstractString="",
@ -88,26 +88,26 @@ create a template, you can use [`interactive_template`](@ref) instead.
end end
function Base.show(io::IO, t::Template) function Base.show(io::IO, t::Template)
maybe(s::AbstractString) = isempty(string(s)) ? "None" : string(s) maybe(s::String) = isempty(s) ? "None" : s
spc = " " spc = " "
println(io, "Template:") println(io, "Template:")
println(io, "$spc→ User: $(maybe(t.user))") println(io, spc, "→ User: ", maybe(t.user))
println(io, "$spc→ Host: $(maybe(t.host))") println(io, spc, "→ Host: ", maybe(t.host))
print(io, "$spc→ License: ") print(io, spc, " License: ")
if isempty(t.license) if isempty(t.license)
println(io, "None") println(io, "None")
else else
println(io, "$(t.license) ($(t.authors) $(year(today())))") println(io, t.license, " ($(t.authors) ", year(today()), ")")
end end
println(io, "$spc→ Package directory: $(replace(maybe(t.dir), homedir() => "~"))") println(io, spc, "→ Package directory: ", replace(maybe(t.dir), homedir() => "~"))
println(io, "$spc→ Minimum Julia version: v$(version_floor(t.julia_version))") println(io, spc, "→ Minimum Julia version: v", version_floor(t.julia_version))
println(io, "$spc→ SSH remote: $(t.ssh ? "Yes" : "No")") println(io, spc, "→ SSH remote: ", t.ssh ? "Yes" : "No")
println(io, "$spc→ Commit Manifest.toml: $(t.manifest ? "Yes" : "No")") println(io, spc, "→ Commit Manifest.toml: ", t.manifest ? "Yes" : "No")
print(io, "$spc→ Plugins:") print(io, spc, " Plugins:")
if isempty(t.plugins) if isempty(t.plugins)
print(io, " None") print(io, " None")
else else
@ -115,7 +115,7 @@ function Base.show(io::IO, t::Template)
println(io) println(io)
buf = IOBuffer() buf = IOBuffer()
show(buf, plugin) show(buf, plugin)
print(io, "$(spc^2)") print(io, spc^2, "")
print(io, join(split(String(take!(buf)), "\n"), "\n$(spc^2)")) print(io, join(split(String(take!(buf)), "\n"), "\n$(spc^2)"))
end end
end end
@ -135,7 +135,7 @@ function interactive_template(; git::Bool=true, fast::Bool=false)
kwargs = Dict{Symbol, Any}() kwargs = Dict{Symbol, Any}()
default_user = LibGit2.getconfig("github.user", "") default_user = LibGit2.getconfig("github.user", "")
print("Username [$(isempty(default_user) ? "REQUIRED" : default_user)]: ") print("Username [", isempty(default_user) ? "REQUIRED" : default_user, "]: ")
user = readline() user = readline()
kwargs[:user] = if !isempty(user) kwargs[:user] = if !isempty(user)
user user
@ -192,7 +192,7 @@ function interactive_template(; git::Bool=true, fast::Bool=false)
VERSION VERSION
else else
default_julia_version = VERSION default_julia_version = VERSION
print("Mminimum Julia version [$(version_floor(default_julia_version))]: ") print("Minimum Julia version [", version_floor(default_julia_version), "]: ")
julia_version = readline() julia_version = readline()
isempty(julia_version) ? default_julia_version : VersionNumber(julia_version) isempty(julia_version) ? default_julia_version : VersionNumber(julia_version)
end end

View File

@ -85,12 +85,9 @@ write(test_file, template_text)
user=me, user=me,
plugins = [GitHubPages(), TravisCI(), AppVeyor(), Codecov(), Coveralls()], plugins = [GitHubPages(), TravisCI(), AppVeyor(), Codecov(), Coveralls()],
) )
@test Set(keys(t.plugins)) == Set( @test Set(keys(t.plugins)) == Set(map(typeof, values(t.plugins))) == Set(
[GitHubPages, TravisCI, AppVeyor, Codecov, Coveralls] [GitHubPages, TravisCI, AppVeyor, Codecov, Coveralls]
) )
@test Set(values(t.plugins)) == Set(
[GitHubPages(), TravisCI(), AppVeyor(), Codecov(), Coveralls()]
)
# Duplicate plugins should warn. # Duplicate plugins should warn.
@test_logs (:warn, r"duplicates") match_mode=:any t = Template(; @test_logs (:warn, r"duplicates") match_mode=:any t = Template(;