2017-08-11 22:18:09 +00:00
|
|
|
"""
|
|
|
|
Template(; kwargs...) -> Template
|
|
|
|
|
|
|
|
Records common information used to generate a package.
|
|
|
|
|
|
|
|
# Keyword Arguments
|
|
|
|
* `remote_prefix::AbstractString`: The base url for the remote repository. e.g.
|
|
|
|
"https://github.com/username/". This will be used with the package name to set the url
|
|
|
|
for the remote repository, as well as to determine the account's username. Failing to
|
|
|
|
specify this will cause an error. This is case-sensitive for some plugins, so take care
|
|
|
|
to enter it correctly.
|
|
|
|
* `license::Union{AbstractString, Void}=nothing`: Name of the package licsense. If
|
|
|
|
no license is specified, no license is created. `show_license` can be used to list all
|
|
|
|
available licenses, or to print out a particular license's text.
|
|
|
|
* `authors::Union{AbstractString, Array}=LibGit2.getconfig("user.name", "")`: Names that
|
|
|
|
appear on the license. Supply a string for one author, and an array for multiple.
|
2017-08-14 18:13:14 +00:00
|
|
|
* `years::Union{Int, AbstractString}=string(Dates.year(Dates.today()))`: Copyright years
|
|
|
|
on the license. Can be supplied by a number, or a string such as "2016 - 2017".
|
|
|
|
* `path::AbstractString=Pkg.dir()`: Directory in which the package will go.
|
2017-08-11 22:18:09 +00:00
|
|
|
* `julia_version::VersionNumber=VERSION`: Minimum allowed Julia version.
|
|
|
|
* `git_config::Dict{String, String}=Dict{String, String}()`: Git configuration options.
|
|
|
|
* `plugins::Vector{Plugin}`: A list of `Plugin`s that the package will include.
|
|
|
|
"""
|
2017-08-14 18:12:37 +00:00
|
|
|
@auto_hash_equals struct Template
|
2017-08-11 22:18:09 +00:00
|
|
|
remote_prefix::AbstractString
|
|
|
|
license::Union{AbstractString, Void}
|
|
|
|
authors::Union{AbstractString, Array}
|
|
|
|
years::AbstractString
|
|
|
|
path::AbstractString
|
|
|
|
julia_version::VersionNumber
|
|
|
|
git_config::Dict{String, String}
|
|
|
|
plugins::Dict{DataType, Plugin}
|
|
|
|
|
|
|
|
function Template{P <: Plugin}(;
|
|
|
|
remote_prefix::AbstractString="",
|
|
|
|
license::Union{AbstractString, Void}=nothing,
|
|
|
|
authors::Union{AbstractString, Array}=LibGit2.getconfig("user.name", ""),
|
|
|
|
years::Union{Int, AbstractString}=string(Dates.year(Dates.today())),
|
2017-08-14 18:13:14 +00:00
|
|
|
path::AbstractString=Pkg.dir(),
|
2017-08-11 22:18:09 +00:00
|
|
|
julia_version::VersionNumber=VERSION,
|
|
|
|
git_config::Dict{String, String}=Dict{String, String}(),
|
|
|
|
plugins::Vector{P}=Vector{Plugin}(),
|
|
|
|
)
|
|
|
|
if isempty(remote_prefix)
|
|
|
|
throw(ArgumentError("Must specify remote_prefix::AbstractString"))
|
|
|
|
end
|
|
|
|
years = string(years)
|
2017-08-14 20:58:01 +00:00
|
|
|
|
|
|
|
# If an explicitly supplied git config contains a name and the author name was not
|
|
|
|
# explicitly supplied, then take the git config's name as the author name.
|
|
|
|
if haskey(git_config, "user.name") && authors == LibGit2.getconfig("user.name", "")
|
|
|
|
authors = get(git_config, "user.name", LibGit2.getconfig("user.name", ""))
|
|
|
|
elseif isa(authors, Array)
|
2017-08-11 22:18:09 +00:00
|
|
|
authors = join(authors, ", ")
|
|
|
|
end
|
|
|
|
if !endswith(remote_prefix, "/")
|
|
|
|
remote_prefix *= "/"
|
|
|
|
end
|
|
|
|
if license != nothing && !isfile(joinpath(LICENSE_DIR, license))
|
|
|
|
throw(ArgumentError("License '$license' is not available"))
|
|
|
|
end
|
|
|
|
|
2017-08-14 19:15:53 +00:00
|
|
|
|
|
|
|
plugin_dict = Dict{DataType, Plugin}(typeof(p) => p for p in plugins)
|
|
|
|
if (length(plugins) != length(plugin_dict))
|
|
|
|
warn("Plugin list contained duplicates, only the last of each type was kept")
|
|
|
|
end
|
2017-08-11 22:18:09 +00:00
|
|
|
|
|
|
|
new(
|
2017-08-14 19:15:53 +00:00
|
|
|
remote_prefix, license, authors, years, path,
|
|
|
|
julia_version, git_config, plugin_dict,
|
2017-08-11 22:18:09 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|