5 million review changes
This commit is contained in:
parent
86d2d5c0fb
commit
2af2407881
@ -34,4 +34,4 @@ test_script:
|
|||||||
- C:\projects\julia\bin\julia -e "Pkg.test(\"PkgTemplates\"; coverage=true)"
|
- C:\projects\julia\bin\julia -e "Pkg.test(\"PkgTemplates\"; coverage=true)"
|
||||||
|
|
||||||
after_test:
|
after_test:
|
||||||
- C:\projects\julia\bin\julia -e "cd(Pkg.dir(\"AppVeyorTesting\")); Pkg.add(\"Coverage\"); using Coverage; Codecov.submit(process_folder())"
|
- C:\projects\julia\bin\julia -e "cd(Pkg.dir(\"PkgTemplates\")); Pkg.add(\"Coverage\"); using Coverage; Codecov.submit(process_folder())"
|
||||||
|
@ -7,8 +7,6 @@ julia:
|
|||||||
- nightly
|
- nightly
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
before_script:
|
|
||||||
- cp docs/src/assets/invenia.css $HOME
|
|
||||||
script:
|
script:
|
||||||
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
|
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
|
||||||
- julia -e 'Pkg.clone(pwd()); Pkg.test("PkgTemplates"; coverage=true)'
|
- julia -e 'Pkg.clone(pwd()); Pkg.test("PkgTemplates"; coverage=true)'
|
||||||
|
14
README.md
14
README.md
@ -54,7 +54,7 @@ julia> t = Template(;
|
|||||||
dir=joinpath(homedir(), "code"),
|
dir=joinpath(homedir(), "code"),
|
||||||
julia_version=v"0.5.2",
|
julia_version=v"0.5.2",
|
||||||
requirements=["PkgTemplates"],
|
requirements=["PkgTemplates"],
|
||||||
git_config=Dict("diff.renames" => true),
|
gitconfig=Dict("diff.renames" => true),
|
||||||
plugins=[
|
plugins=[
|
||||||
TravisCI(),
|
TravisCI(),
|
||||||
CodeCov(; config_file=nothing),
|
CodeCov(; config_file=nothing),
|
||||||
@ -102,13 +102,13 @@ And if that's **still** too much work for you, you can call
|
|||||||
`interactive_template` with `fast=true` to use default values for everything
|
`interactive_template` with `fast=true` to use default values for everything
|
||||||
but username and plugin selection.
|
but username and plugin selection.
|
||||||
|
|
||||||
## Comparison to [PkgDev](https://github.com/JuliaLang/PkgDev.jl)
|
## Comparison to PkgDev
|
||||||
|
|
||||||
`PkgTemplates` is similar in functionality to `PkgDev`'s `generate` function.
|
`PkgTemplates` is similar in functionality to
|
||||||
However, `PkgTemplates` offers more customizability in templates and more
|
[`PkgDev`](https://github.com/JuliaLang/PkgDev.jl)'s `generate` function. However,
|
||||||
extensibility via plugins. For the package registration and release management
|
`PkgTemplates` offers more customizability in templates and more extensibility via plugins.
|
||||||
features that `PkgTemplates` doesn't include, you are encouraged to use
|
For the package registration and release management features that `PkgTemplates` doesn't
|
||||||
[AttoBot](https://github.com/apps/attobot) instead.
|
include, you are encouraged to use [AttoBot](https://github.com/apps/attobot) instead.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
@ -14,9 +14,7 @@ makedocs(;
|
|||||||
repo="https://github.com/christopher-dG/PkgTemplates.jl/blob/{commit}{path}#L{line}",
|
repo="https://github.com/christopher-dG/PkgTemplates.jl/blob/{commit}{path}#L{line}",
|
||||||
sitename="PkgTemplates.jl",
|
sitename="PkgTemplates.jl",
|
||||||
authors="Chris de Graaf, Invenia Technical Computing Corporation",
|
authors="Chris de Graaf, Invenia Technical Computing Corporation",
|
||||||
assets=[
|
assets=[],
|
||||||
"assets/invenia.css",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
deploydocs(;
|
deploydocs(;
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
/* Links */
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: #4595D1;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover, a:focus {
|
|
||||||
color: #194E82;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Navigation */
|
|
||||||
|
|
||||||
nav.toc ul a:hover,
|
|
||||||
nav.toc ul.internal a:hover {
|
|
||||||
color: #FFFFFF;
|
|
||||||
background-color: #4595D1;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav.toc ul .toctext {
|
|
||||||
color: #FFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav.toc {
|
|
||||||
box-shadow: none;
|
|
||||||
color: #FFFFFF;
|
|
||||||
background-color: #194E82;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav.toc li.current > .toctext {
|
|
||||||
color: #FFFFFF;
|
|
||||||
background-color: #4595D1;
|
|
||||||
border-top-width: 0px;
|
|
||||||
border-bottom-width: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav.toc ul.internal a {
|
|
||||||
color: #194E82;
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Text */
|
|
||||||
|
|
||||||
article#docs a.nav-anchor {
|
|
||||||
color: #194E82;
|
|
||||||
}
|
|
||||||
|
|
||||||
article#docs blockquote {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Code */
|
|
||||||
|
|
||||||
code .hljs-meta {
|
|
||||||
color: #4595D1;
|
|
||||||
}
|
|
||||||
|
|
||||||
code .hljs-keyword {
|
|
||||||
color: #194E82;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre, code {
|
|
||||||
font-family: "Liberation Mono", "Consolas", "DejaVu Sans Mono", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* mkdocs (old) */
|
|
||||||
|
|
||||||
/*.navbar-default {
|
|
||||||
background-color: #194E82;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-default .navbar-nav > .active > a,
|
|
||||||
.navbar-default .navbar-nav > .active > a:hover,
|
|
||||||
.navbar-default .navbar-nav > .active > a:focus {
|
|
||||||
background-color: #4595D1;
|
|
||||||
}*/
|
|
@ -40,7 +40,7 @@ t = Template(;
|
|||||||
dir=joinpath(homedir(), "code"),
|
dir=joinpath(homedir(), "code"),
|
||||||
julia_version=v"0.5.2",
|
julia_version=v"0.5.2",
|
||||||
requirements=["PkgTemplates"],
|
requirements=["PkgTemplates"],
|
||||||
git_config=Dict("diff.renames" => true),
|
gitconfig=Dict("diff.renames" => true),
|
||||||
plugins=[
|
plugins=[
|
||||||
TravisCI(),
|
TravisCI(),
|
||||||
CodeCov(; config_file=nothing),
|
CodeCov(; config_file=nothing),
|
||||||
|
@ -8,6 +8,12 @@ CurrentModule = PkgTemplates
|
|||||||
are available for use with `PkgTemplates`, but if you see that one is missing,
|
are available for use with `PkgTemplates`, but if you see that one is missing,
|
||||||
don't hesitate to open an issue or PR.
|
don't hesitate to open an issue or PR.
|
||||||
|
|
||||||
|
## `available_licenses`
|
||||||
|
|
||||||
|
```@docs
|
||||||
|
available_licenses
|
||||||
|
```
|
||||||
|
|
||||||
## `show_license`
|
## `show_license`
|
||||||
|
|
||||||
```@docs
|
```@docs
|
||||||
|
@ -5,12 +5,12 @@ using Mustache
|
|||||||
using TerminalMenus
|
using TerminalMenus
|
||||||
using URIParser
|
using URIParser
|
||||||
|
|
||||||
export generate, interactive_template, show_license, Template, GitHubPages, AppVeyor,
|
export generate, interactive_template, show_license, available_licenses, Template,
|
||||||
TravisCI, CodeCov, Coveralls
|
GitHubPages, AppVeyor, TravisCI, CodeCov, Coveralls
|
||||||
|
|
||||||
abstract type Plugin end
|
abstract type Plugin end
|
||||||
|
|
||||||
include("license.jl")
|
include("licenses.jl")
|
||||||
include("template.jl")
|
include("template.jl")
|
||||||
include("generate.jl")
|
include("generate.jl")
|
||||||
include("plugin.jl")
|
include("plugin.jl")
|
||||||
@ -22,17 +22,6 @@ include(joinpath("plugins", "travisci.jl"))
|
|||||||
include(joinpath("plugins", "githubpages.jl"))
|
include(joinpath("plugins", "githubpages.jl"))
|
||||||
|
|
||||||
const DEFAULTS_DIR = normpath(joinpath(@__DIR__, "..", "defaults"))
|
const DEFAULTS_DIR = normpath(joinpath(@__DIR__, "..", "defaults"))
|
||||||
const LICENSE_DIR = normpath(joinpath(@__DIR__, "..", "licenses"))
|
|
||||||
const LICENSES = Dict(
|
|
||||||
"MIT" => "MIT \"Expat\" License",
|
|
||||||
"BSD" => "Simplified \"2-clause\" BSD License",
|
|
||||||
"ASL" => "Apache License, Version 2.0",
|
|
||||||
"MPL" => "Mozilla Public License, Version 2.0",
|
|
||||||
"GPL-2.0+" => "GNU Public License, Version 2.0+",
|
|
||||||
"GPL-3.0+" => "GNU Public License, Version 3.0+",
|
|
||||||
"LGPL-2.1+" => "Lesser GNU Public License, Version 2.1+",
|
|
||||||
"LGPL-3.0+" => "Lesser GNU Public License, Version 3.0+"
|
|
||||||
)
|
|
||||||
const BADGE_ORDER = [GitHubPages, TravisCI, AppVeyor, CodeCov, Coveralls]
|
const BADGE_ORDER = [GitHubPages, TravisCI, AppVeyor, CodeCov, Coveralls]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
124
src/generate.jl
124
src/generate.jl
@ -13,8 +13,8 @@ Generate a package names `pkg_name` from `template`.
|
|||||||
* `ssh::Bool=false`: Whether or not to use SSH for the remote.
|
* `ssh::Bool=false`: Whether or not to use SSH for the remote.
|
||||||
|
|
||||||
# Notes
|
# Notes
|
||||||
The package is generated entirely in a temporary directory (`t.temp_dir`), and only moved
|
The package is generated entirely in a temporary directory and only moved into
|
||||||
into `joinpath(t.dir, pkg_name)` at the very end. In the case of an error, the temporary
|
`joinpath(t.dir, pkg_name)` at the very end. In the case of an error, the temporary
|
||||||
directory will contain leftovers, but the destination directory will remain untouched
|
directory will contain leftovers, but the destination directory will remain untouched
|
||||||
(this is especially helpful when `force=true`).
|
(this is especially helpful when `force=true`).
|
||||||
"""
|
"""
|
||||||
@ -23,10 +23,22 @@ function generate(
|
|||||||
t::Template;
|
t::Template;
|
||||||
force::Bool=false,
|
force::Bool=false,
|
||||||
ssh::Bool=false,
|
ssh::Bool=false,
|
||||||
|
)
|
||||||
|
mktempdir() do temp_dir
|
||||||
|
generate(pkg_name, t, temp_dir; force=force, ssh=ssh)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function generate(
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
t::Template,
|
||||||
|
dir::AbstractString;
|
||||||
|
force::Bool=false,
|
||||||
|
ssh::Bool=false,
|
||||||
)
|
)
|
||||||
pkg_name = Pkg.splitjl(pkg_name)
|
pkg_name = Pkg.splitjl(pkg_name)
|
||||||
pkg_dir = joinpath(t.dir, pkg_name)
|
pkg_dir = joinpath(t.dir, pkg_name)
|
||||||
temp_pkg_dir = joinpath(t.temp_dir, pkg_name)
|
temp_pkg_dir = joinpath(dir, pkg_name)
|
||||||
|
|
||||||
if !force && ispath(pkg_dir)
|
if !force && ispath(pkg_dir)
|
||||||
throw(ArgumentError(
|
throw(ArgumentError(
|
||||||
@ -38,8 +50,8 @@ function generate(
|
|||||||
repo = LibGit2.init(temp_pkg_dir)
|
repo = LibGit2.init(temp_pkg_dir)
|
||||||
info("Initialized git repo at $temp_pkg_dir")
|
info("Initialized git repo at $temp_pkg_dir")
|
||||||
cfg = LibGit2.GitConfig(repo)
|
cfg = LibGit2.GitConfig(repo)
|
||||||
!isempty(t.git_config) && info("Applying git configuration")
|
!isempty(t.gitconfig) && info("Applying git configuration")
|
||||||
for (key, val) in t.git_config
|
for (key, val) in t.gitconfig
|
||||||
LibGit2.set!(cfg, key, val)
|
LibGit2.set!(cfg, key, val)
|
||||||
end
|
end
|
||||||
LibGit2.commit(repo, "Empty initial commit")
|
LibGit2.commit(repo, "Empty initial commit")
|
||||||
@ -62,13 +74,13 @@ function generate(
|
|||||||
|
|
||||||
# Generate the files.
|
# Generate the files.
|
||||||
files = vcat(
|
files = vcat(
|
||||||
gen_entrypoint(pkg_name, t),
|
gen_entrypoint(dir, pkg_name, t),
|
||||||
gen_tests(pkg_name, t),
|
gen_tests(dir, pkg_name, t),
|
||||||
gen_require(temp_pkg_dir, t),
|
gen_require(dir, pkg_name, t),
|
||||||
gen_readme(pkg_name, t),
|
gen_readme(dir, pkg_name, t),
|
||||||
gen_gitignore(pkg_name, t),
|
gen_gitignore(dir, pkg_name, t),
|
||||||
gen_license(pkg_name, t),
|
gen_license(dir, pkg_name, t),
|
||||||
vcat(collect(gen_plugin(plugin, t, pkg_name) for plugin in values(t.plugins))...),
|
vcat([gen_plugin(plugin, t, dir, pkg_name) for plugin in values(t.plugins)]...),
|
||||||
)
|
)
|
||||||
|
|
||||||
LibGit2.add!(repo, files...)
|
LibGit2.add!(repo, files...)
|
||||||
@ -78,7 +90,7 @@ function generate(
|
|||||||
multiple_branches = length(collect(LibGit2.GitBranchIter(repo))) > 1
|
multiple_branches = length(collect(LibGit2.GitBranchIter(repo))) > 1
|
||||||
info("Moving temporary package directory into $(t.dir)/")
|
info("Moving temporary package directory into $(t.dir)/")
|
||||||
mv(temp_pkg_dir, pkg_dir; remove_destination=force)
|
mv(temp_pkg_dir, pkg_dir; remove_destination=force)
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
info("Finished")
|
info("Finished")
|
||||||
if multiple_branches
|
if multiple_branches
|
||||||
warn("Remember to push all created branches to your remote: git push --all")
|
warn("Remember to push all created branches to your remote: git push --all")
|
||||||
@ -86,17 +98,23 @@ function generate(
|
|||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_entrypoint(pkg_name::AbstractString, template::Template) -> Vector{String}
|
gen_entrypoint(
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
template::Template,
|
||||||
|
) -> Vector{String}
|
||||||
|
|
||||||
Create the module entrypoint in the temp package directory.
|
Create the module entrypoint in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
* `dir::AbstractString`: The directory in which the files will be generated. Note that
|
||||||
|
this will be joined to `pkg_name`.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `template::Template`: The template whose entrypoint we are generating.
|
* `template::Template`: The template whose entrypoint we are generating.
|
||||||
|
|
||||||
Returns an array of generated file/directory names.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_entrypoint(pkg_name::AbstractString, template::Template)
|
function gen_entrypoint(dir::AbstractString, pkg_name::AbstractString, template::Template)
|
||||||
text = """
|
text = """
|
||||||
module $pkg_name
|
module $pkg_name
|
||||||
|
|
||||||
@ -105,22 +123,28 @@ function gen_entrypoint(pkg_name::AbstractString, template::Template)
|
|||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
|
|
||||||
gen_file(joinpath(template.temp_dir, pkg_name, "src", "$pkg_name.jl"), text)
|
gen_file(joinpath(dir, pkg_name, "src", "$pkg_name.jl"), text)
|
||||||
return ["src/"]
|
return ["src/"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_tests(pkg_name::AbstractString, template::Template) -> Vector{String}
|
gen_tests(
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
template::Template,
|
||||||
|
) -> Vector{String}
|
||||||
|
|
||||||
Create the test directory and entrypoint in the temp package directory.
|
Create the test directory and entrypoint in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
* `dir::AbstractString`: The directory in which the files will be generated. Note that
|
||||||
|
this will be joined to `pkg_name`.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `template::Template`: The template whose tests we are generating.
|
* `template::Template`: The template whose tests we are generating.
|
||||||
|
|
||||||
Returns an array of generated file/directory names.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_tests(pkg_name::AbstractString, template::Template)
|
function gen_tests(dir::AbstractString, pkg_name::AbstractString, template::Template)
|
||||||
text = """
|
text = """
|
||||||
using $pkg_name
|
using $pkg_name
|
||||||
using Base.Test
|
using Base.Test
|
||||||
@ -129,44 +153,55 @@ function gen_tests(pkg_name::AbstractString, template::Template)
|
|||||||
@test 1 == 2
|
@test 1 == 2
|
||||||
"""
|
"""
|
||||||
|
|
||||||
gen_file(joinpath(template.temp_dir, pkg_name, "test", "runtests.jl"), text)
|
gen_file(joinpath(dir, pkg_name, "test", "runtests.jl"), text)
|
||||||
return ["test/"]
|
return ["test/"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_require(pkg_name::AbstractString, template::Template) -> Vector{String}
|
gen_require(
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
template::Template,
|
||||||
|
) -> Vector{String}
|
||||||
|
|
||||||
Create the `REQUIRE` file in the temp package directory.
|
Create the `REQUIRE` file in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
* `dir::AbstractString`: The directory in which the files will be generated. Note that
|
||||||
|
this will be joined to `pkg_name`.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `template::Template`: The template whose REQUIRE we are generating.
|
* `template::Template`: The template whose REQUIRE we are generating.
|
||||||
|
|
||||||
Returns an array of generated file/directory names.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_require(pkg_name::AbstractString, template::Template)
|
function gen_require(dir::AbstractString, pkg_name::AbstractString, template::Template)
|
||||||
text = "julia $(version_floor(template.julia_version))\n"
|
text = "julia $(version_floor(template.julia_version))\n"
|
||||||
text *= join(template.requirements, "\n")
|
text *= join(template.requirements, "\n")
|
||||||
|
|
||||||
gen_file(joinpath(template.temp_dir, pkg_name, "REQUIRE"), text)
|
gen_file(joinpath(dir, pkg_name, "REQUIRE"), text)
|
||||||
return ["REQUIRE"]
|
return ["REQUIRE"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_readme(pkg_name::AbstractString, template::Template) -> Vector{String}
|
gen_readme(
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
template::Template,
|
||||||
|
) -> Vector{String}
|
||||||
|
|
||||||
Create a README in the temp package directory with badges for each enabled plugin.
|
Create a README in the temp package directory with badges for each enabled plugin.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
* `dir::AbstractString`: The directory in which the files will be generated. Note that
|
||||||
|
this will be joined to `pkg_name`.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `template::Template`: The template whose README we are generating.
|
* `template::Template`: The template whose README we are generating.
|
||||||
|
|
||||||
Returns an array of generated file/directory names.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_readme(pkg_name::AbstractString, template::Template)
|
function gen_readme(dir::AbstractString, pkg_name::AbstractString, template::Template)
|
||||||
text = "# $pkg_name\n"
|
text = "# $pkg_name\n"
|
||||||
remaining = copy(collect(keys(template.plugins)))
|
done = []
|
||||||
|
|
||||||
# Generate the ordered badges first, then add any remaining ones to the right.
|
# Generate the ordered badges first, then add any remaining ones to the right.
|
||||||
for plugin_type in BADGE_ORDER
|
for plugin_type in BADGE_ORDER
|
||||||
if haskey(template.plugins, plugin_type)
|
if haskey(template.plugins, plugin_type)
|
||||||
@ -175,10 +210,10 @@ function gen_readme(pkg_name::AbstractString, template::Template)
|
|||||||
badges(template.plugins[plugin_type], template.user, pkg_name),
|
badges(template.plugins[plugin_type], template.user, pkg_name),
|
||||||
"\n",
|
"\n",
|
||||||
)
|
)
|
||||||
deleteat!(remaining, find(p -> p == plugin_type, remaining)[1])
|
push!(done, plugin_type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for plugin_type in remaining
|
for plugin_type in setdiff(keys(template.plugins), done)
|
||||||
text *= "\n"
|
text *= "\n"
|
||||||
text *= join(
|
text *= join(
|
||||||
badges(template.plugins[plugin_type], template.user, pkg_name),
|
badges(template.plugins[plugin_type], template.user, pkg_name),
|
||||||
@ -186,56 +221,67 @@ function gen_readme(pkg_name::AbstractString, template::Template)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
gen_file(joinpath(template.temp_dir, pkg_name, "README.md"), text)
|
gen_file(joinpath(dir, pkg_name, "README.md"), text)
|
||||||
return ["README.md"]
|
return ["README.md"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_gitignore(pkg_name::AbstractString, template::Template) -> Vector{String}
|
gen_gitignore(
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
template::Template,
|
||||||
|
) -> Vector{String}
|
||||||
|
|
||||||
Create a `.gitignore` in the temp package directory.
|
Create a `.gitignore` in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
* `dir::AbstractString`: The directory in which the files will be generated. Note that
|
||||||
|
this will be joined to `pkg_name`.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `template::Template`: The template whose .gitignore we are generating.
|
* `template::Template`: The template whose .gitignore we are generating.
|
||||||
|
|
||||||
Returns an array of generated file/directory names.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_gitignore(pkg_name::AbstractString, template::Template)
|
function gen_gitignore(dir::AbstractString, pkg_name::AbstractString, template::Template)
|
||||||
text = ".DS_Store\n"
|
seen = [".DS_Store"]
|
||||||
seen = []
|
|
||||||
patterns = vcat([plugin.gitignore for plugin in values(template.plugins)]...)
|
patterns = vcat([plugin.gitignore for plugin in values(template.plugins)]...)
|
||||||
for pattern in patterns
|
for pattern in patterns
|
||||||
if !in(pattern, seen)
|
if !in(pattern, seen)
|
||||||
text *= "$pattern\n"
|
|
||||||
push!(seen, pattern)
|
push!(seen, pattern)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
text = join(seen, "\n")
|
||||||
|
|
||||||
gen_file(joinpath(template.temp_dir, pkg_name, ".gitignore"), text)
|
gen_file(joinpath(dir, pkg_name, ".gitignore"), text)
|
||||||
return [".gitignore"]
|
return [".gitignore"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_license(pkg_name::AbstractString, template::Template) -> Vector{String}
|
gen_license(
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
template::Template,
|
||||||
|
) -> Vector{String}
|
||||||
|
|
||||||
Create a license in the temp package directory.
|
Create a license in the temp package directory.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
* `dir::AbstractString`: The directory in which the files will be generated. Note that
|
||||||
|
this will be joined to `pkg_name`.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
* `template::Template`: The template whose LICENSE we are generating.
|
* `template::Template`: The template whose LICENSE we are generating.
|
||||||
|
|
||||||
Returns an array of generated file/directory names.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
function gen_license(pkg_name::AbstractString, template::Template)
|
function gen_license(dir::AbstractString, pkg_name::AbstractString, template::Template)
|
||||||
if template.license == nothing
|
if isempty(template.license)
|
||||||
return String[]
|
return String[]
|
||||||
end
|
end
|
||||||
|
|
||||||
text = "Copyright (c) $(template.years) $(template.authors)\n"
|
text = "Copyright (c) $(template.years) $(template.authors)\n"
|
||||||
text *= read_license(template.license)
|
text *= read_license(template.license)
|
||||||
|
|
||||||
gen_file(joinpath(template.temp_dir, pkg_name, "LICENSE"), text)
|
gen_file(joinpath(dir, pkg_name, "LICENSE"), text)
|
||||||
return ["LICENSE"]
|
return ["LICENSE"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
"""
|
|
||||||
show_license([license::AbstractString]; io=STDOUT) -> Void
|
|
||||||
|
|
||||||
Show all available license names, or prints the text of `license`.
|
|
||||||
"""
|
|
||||||
show_license(; io=STDOUT) = println(io, join(["$k: $v" for (k, v) in LICENSES], "\n"))
|
|
||||||
show_license(license::AbstractString; io=STDOUT) = println(io, read_license(license))
|
|
||||||
|
|
||||||
"""
|
|
||||||
read_license(licence::AbstractString) -> String
|
|
||||||
|
|
||||||
Returns the contents of `license`. Errors if it is not found. Use [`show_license`](@ref) to
|
|
||||||
view available licenses.
|
|
||||||
"""
|
|
||||||
function read_license(license::AbstractString)
|
|
||||||
path = joinpath(LICENSE_DIR, license)
|
|
||||||
if isfile(path)
|
|
||||||
return string(readchomp(path))
|
|
||||||
else
|
|
||||||
throw(ArgumentError("License '$license' is not available"))
|
|
||||||
end
|
|
||||||
end
|
|
42
src/licenses.jl
Normal file
42
src/licenses.jl
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
const LICENSE_DIR = normpath(joinpath(@__DIR__, "..", "licenses"))
|
||||||
|
const LICENSES = Dict(
|
||||||
|
"MIT" => "MIT \"Expat\" License",
|
||||||
|
"BSD" => "Simplified \"2-clause\" BSD License",
|
||||||
|
"ASL" => "Apache License, Version 2.0",
|
||||||
|
"MPL" => "Mozilla Public License, Version 2.0",
|
||||||
|
"GPL-2.0+" => "GNU Public License, Version 2.0+",
|
||||||
|
"GPL-3.0+" => "GNU Public License, Version 3.0+",
|
||||||
|
"LGPL-2.1+" => "Lesser GNU Public License, Version 2.1+",
|
||||||
|
"LGPL-3.0+" => "Lesser GNU Public License, Version 3.0+"
|
||||||
|
)
|
||||||
|
|
||||||
|
"""
|
||||||
|
available_licenses([io]) -> Void
|
||||||
|
|
||||||
|
Print the names of all available licenses.
|
||||||
|
"""
|
||||||
|
available_licenses(io::IO) = println(io, join(["$k: $v" for (k, v) in LICENSES], "\n"))
|
||||||
|
available_licenses() = available_licenses(STDOUT)
|
||||||
|
|
||||||
|
"""
|
||||||
|
show_license([io::IO], license::AbstractString) -> Void
|
||||||
|
|
||||||
|
Print the text of `license`.
|
||||||
|
"""
|
||||||
|
show_license(io::IO, license::AbstractString) = println(io, read_license(license))
|
||||||
|
show_license(license::AbstractString) = show_license(STDOUT, license)
|
||||||
|
|
||||||
|
"""
|
||||||
|
read_license(licence::AbstractString) -> String
|
||||||
|
|
||||||
|
Returns the contents of `license`. Errors if it is not found. Use [`show_license`](@ref) to
|
||||||
|
view available licenses.
|
||||||
|
"""
|
||||||
|
function read_license(license::AbstractString)
|
||||||
|
path = joinpath(LICENSE_DIR, license)
|
||||||
|
if isfile(path)
|
||||||
|
return string(readchomp(path))
|
||||||
|
else
|
||||||
|
throw(ArgumentError("License '$license' is not available"))
|
||||||
|
end
|
||||||
|
end
|
@ -49,7 +49,7 @@ Generic plugins are plugins that add any number of patterns to the generated pac
|
|||||||
"https://myplugin.com/{{USER}}/{{PKGNAME}}.jl",
|
"https://myplugin.com/{{USER}}/{{PKGNAME}}.jl",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
Dict{String, Any}("YEAR" => Dates.year(now()),
|
Dict{String, Any}("YEAR" => Dates.year(Dates.today())),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -59,9 +59,9 @@ interactive(plugin_type::Type{MyPlugin}) = interactive(plugin_type; file="my-plu
|
|||||||
|
|
||||||
The above plugin ignores files ending with `.mgp`, copies `defaults/my-plugin.toml` by
|
The above plugin ignores files ending with `.mgp`, copies `defaults/my-plugin.toml` by
|
||||||
default, and creates a badge that links to the project on its own site, using the default
|
default, and creates a badge that links to the project on its own site, using the default
|
||||||
substitutions with one addition: `{{YEAR}} => Dates.year(now()`. Since the default config
|
substitutions with one addition: `{{YEAR}} => Dates.year(Dates.today())`. Since the default
|
||||||
template file doesn't follow the generic naming convention, we added another `interactive`
|
config template file doesn't follow the generic naming convention, we added another
|
||||||
method to correct the assumed filename.
|
`interactive` method to correct the assumed filename.
|
||||||
"""
|
"""
|
||||||
abstract type GenericPlugin <: Plugin end
|
abstract type GenericPlugin <: Plugin end
|
||||||
|
|
||||||
@ -86,14 +86,15 @@ pattern. They can implement [`gen_plugin`](@ref), [`badges`](@ref), and
|
|||||||
function gen_plugin(
|
function gen_plugin(
|
||||||
plugin::MyPlugin,
|
plugin::MyPlugin,
|
||||||
template::Template,
|
template::Template,
|
||||||
|
dir::AbstractString,
|
||||||
pkg_name::AbstractString
|
pkg_name::AbstractString
|
||||||
)
|
)
|
||||||
if plugin.lucky
|
if plugin.lucky
|
||||||
text = substitute(
|
text = substitute(
|
||||||
"You got lucky with {{PKGNAME}}, {{USER}}!"),
|
"You got lucky with {{PKGNAME}}, {{USER}}!",
|
||||||
template,
|
template,
|
||||||
)
|
)
|
||||||
gen_file(joinpath(template.temp_dir, ".myplugin.yml"), text)
|
gen_file(joinpath(dir, ".myplugin.yml"), text)
|
||||||
else
|
else
|
||||||
println("Maybe next time.")
|
println("Maybe next time.")
|
||||||
end
|
end
|
||||||
@ -149,9 +150,6 @@ A `Badge` contains the data necessary to generate a Markdown badge.
|
|||||||
hover::AbstractString
|
hover::AbstractString
|
||||||
image::AbstractString
|
image::AbstractString
|
||||||
link::AbstractString
|
link::AbstractString
|
||||||
function Badge(hover::AbstractString, image::AbstractString, link::AbstractString)
|
|
||||||
new(hover, image, link)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -162,20 +160,39 @@ Return `badge`'s data formatted as a Markdown string.
|
|||||||
format(b::Badge) = "[)]($(b.link))"
|
format(b::Badge) = "[)]($(b.link))"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gen_plugin(plugin::Plugin, template::Template, pkg_name::AbstractString) -> Vector{String}
|
gen_plugin(
|
||||||
|
plugin::Plugin,
|
||||||
|
template::Template,
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString
|
||||||
|
) -> Vector{String}
|
||||||
|
|
||||||
Generate any files associated with a plugin.
|
Generate any files associated with a plugin.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
* `plugin::Plugin`: Plugin whose files are being generated.
|
* `plugin::Plugin`: Plugin whose files are being generated.
|
||||||
* `template::Template`: Template configuration.
|
* `template::Template`: Template configuration.
|
||||||
|
* `dir::AbstractString`: The directory in which the files will be generated. Note that
|
||||||
|
this will be joined to `pkg_name`.
|
||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
|
|
||||||
Returns an array of generated file/directory names.
|
Returns an array of generated file/directory names.
|
||||||
"""
|
"""
|
||||||
gen_plugin(plugin::Plugin, template::Template, pkg_name::AbstractString) = String[]
|
function gen_plugin(
|
||||||
|
plugin::Plugin,
|
||||||
|
template::Template,
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
)
|
||||||
|
return String[]
|
||||||
|
end
|
||||||
|
|
||||||
function gen_plugin(plugin::GenericPlugin, template::Template, pkg_name::AbstractString)
|
function gen_plugin(
|
||||||
|
plugin::GenericPlugin,
|
||||||
|
template::Template,
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
)
|
||||||
src = try
|
src = try
|
||||||
get(plugin.src)
|
get(plugin.src)
|
||||||
catch
|
catch
|
||||||
@ -186,7 +203,7 @@ function gen_plugin(plugin::GenericPlugin, template::Template, pkg_name::Abstrac
|
|||||||
template;
|
template;
|
||||||
view=merge(Dict("PKGNAME" => pkg_name), plugin.view),
|
view=merge(Dict("PKGNAME" => pkg_name), plugin.view),
|
||||||
)
|
)
|
||||||
gen_file(joinpath(template.temp_dir, pkg_name, plugin.dest), text)
|
gen_file(joinpath(dir, pkg_name, plugin.dest), text)
|
||||||
return [plugin.dest]
|
return [plugin.dest]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -214,16 +231,16 @@ end
|
|||||||
interactive(
|
interactive(
|
||||||
plugin_type::Type{P <: Plugin};
|
plugin_type::Type{P <: Plugin};
|
||||||
file::Union{AbstractString, Void}="",
|
file::Union{AbstractString, Void}="",
|
||||||
) -> Union{Plugin, Void}
|
) -> Plugin
|
||||||
|
|
||||||
Interactively create a plugin of type `plugin_type`, where `file` is the plugin type's
|
Interactively create a plugin of type `plugin_type`, where `file` is the plugin type's
|
||||||
default config template with a non-standard name (for `MyPlugin`, this is anything but
|
default config template with a non-standard name (for `MyPlugin`, this is anything but
|
||||||
"myplugin.yml").
|
"myplugin.yml").
|
||||||
"""
|
"""
|
||||||
function interactive(
|
function interactive(
|
||||||
plugin_type::Type{P};
|
plugin_type::Type{<:GenericPlugin};
|
||||||
file::Union{AbstractString, Void}="",
|
file::Union{AbstractString, Void}="",
|
||||||
) where P <: GenericPlugin
|
)
|
||||||
plugin_name = String(split(string(plugin_type), ".")[end])
|
plugin_name = String(split(string(plugin_type), ".")[end])
|
||||||
# By default, we expect the default plugin file template for a plugin called
|
# By default, we expect the default plugin file template for a plugin called
|
||||||
# "MyPlugin" to be called "myplugin.yml".
|
# "MyPlugin" to be called "myplugin.yml".
|
||||||
|
@ -4,12 +4,17 @@ generation via [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl).
|
|||||||
"""
|
"""
|
||||||
abstract type Documenter <: CustomPlugin end
|
abstract type Documenter <: CustomPlugin end
|
||||||
|
|
||||||
function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractString)
|
function gen_plugin(
|
||||||
|
plugin::Documenter,
|
||||||
|
template::Template,
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
)
|
||||||
if Pkg.installed("Documenter") == nothing
|
if Pkg.installed("Documenter") == nothing
|
||||||
info("Adding Documenter.jl")
|
info("Adding Documenter.jl")
|
||||||
Pkg.add("Documenter")
|
Pkg.add("Documenter")
|
||||||
end
|
end
|
||||||
path = joinpath(template.temp_dir, pkg_name)
|
path = joinpath(dir, pkg_name)
|
||||||
docs_dir = joinpath(path, "docs", "src")
|
docs_dir = joinpath(path, "docs", "src")
|
||||||
mkpath(docs_dir)
|
mkpath(docs_dir)
|
||||||
if !isempty(plugin.assets)
|
if !isempty(plugin.assets)
|
||||||
@ -52,7 +57,7 @@ function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractSt
|
|||||||
open(joinpath(docs_dir, "index.md"), "w") do fp
|
open(joinpath(docs_dir, "index.md"), "w") do fp
|
||||||
write(fp, "# $pkg_name")
|
write(fp, "# $pkg_name")
|
||||||
end
|
end
|
||||||
readme_path = joinpath(template.temp_dir, pkg_name, "README.md")
|
readme_path = joinpath(dir, pkg_name, "README.md")
|
||||||
if isfile(readme_path)
|
if isfile(readme_path)
|
||||||
cp(readme_path, joinpath(docs_dir, "index.md"), remove_destination=true)
|
cp(readme_path, joinpath(docs_dir, "index.md"), remove_destination=true)
|
||||||
end
|
end
|
||||||
|
@ -38,13 +38,18 @@ function badges(_::GitHubPages, user::AbstractString, pkg_name::AbstractString)
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
function gen_plugin(plugin::GitHubPages, template::Template, pkg_name::AbstractString)
|
function gen_plugin(
|
||||||
|
plugin::GitHubPages,
|
||||||
|
template::Template,
|
||||||
|
dir::AbstractString,
|
||||||
|
pkg_name::AbstractString,
|
||||||
|
)
|
||||||
invoke(
|
invoke(
|
||||||
gen_plugin, Tuple{Documenter, Template, AbstractString},
|
gen_plugin, Tuple{Documenter, Template, AbstractString, AbstractString},
|
||||||
plugin, template, pkg_name
|
plugin, template, dir, pkg_name,
|
||||||
)
|
)
|
||||||
if haskey(template.plugins, TravisCI)
|
if haskey(template.plugins, TravisCI)
|
||||||
docs_src = joinpath(template.temp_dir, pkg_name, "docs", "src")
|
docs_src = joinpath(dir, pkg_name, "docs", "src")
|
||||||
open(joinpath(dirname(docs_src), "make.jl"), "a") do file
|
open(joinpath(dirname(docs_src), "make.jl"), "a") do file
|
||||||
write(
|
write(
|
||||||
file,
|
file,
|
||||||
|
@ -5,7 +5,7 @@ Records common information used to generate a package. If you don't wish to manu
|
|||||||
create a template, you can use [`interactive_template`](@ref) instead.
|
create a template, you can use [`interactive_template`](@ref) instead.
|
||||||
|
|
||||||
# Keyword Arguments
|
# Keyword Arguments
|
||||||
* `user::AbstractString="")`: GitHub username. If left unset, it will try to take the
|
* `user::AbstractString=""`: GitHub username. If left unset, it will try to take the
|
||||||
value of a supplied git config's "github.user" key, then the global git config's
|
value of a supplied git config's "github.user" key, then the global git config's
|
||||||
value. If neither is set, an `ArgumentError` is thrown.
|
value. If neither is set, an `ArgumentError` is thrown.
|
||||||
**This is case-sensitive for some plugins, so take care to enter it correctly.**
|
**This is case-sensitive for some plugins, so take care to enter it correctly.**
|
||||||
@ -14,15 +14,16 @@ create a template, you can use [`interactive_template`](@ref) instead.
|
|||||||
officially supported and they will cause certain plugins will produce incorrect output.
|
officially supported and they will cause certain plugins will produce incorrect output.
|
||||||
For example, [`AppVeyor`](@ref)'s badge image will point to a GitHub-specific URL,
|
For example, [`AppVeyor`](@ref)'s badge image will point to a GitHub-specific URL,
|
||||||
regardless of the value of `host`.
|
regardless of the value of `host`.
|
||||||
* `license::Union{AbstractString, Void}="MIT"`: Name of the package license. If
|
* `license::AbstractString="MIT"`: Name of the package license. If an empty string is
|
||||||
no license is specified, no license is created. [`show_license`](@ref) can be used to
|
given, no license is created. [`available_licenses`](@ref) can be used to list all
|
||||||
list all available licenses, or to print out a particular license's text.
|
available licenses, and [`show_license`](@ref) can be used to print out a particular
|
||||||
* `authors::Union{AbstractString, Array}=""`: Names that appear on the license. Supply a
|
license's text.
|
||||||
string for one author, and an array for multiple. Similarly to `user`, it will try to
|
* `authors::Union{AbstractString, Vector{<:AbstractString}}=""`: Names that appear on the
|
||||||
take the value of a supplied git config's "user.name" key, then the global git config's
|
license. Supply a string for one author, and an array for multiple. Similarly to `user`,
|
||||||
value, if it is left unset
|
it will try to take the value of a supplied git config's "user.name" key, then the global
|
||||||
* `years::Union{Int, AbstractString}=Dates.year(now())`: Copyright years on the license.
|
git config's value, if it is left unset.
|
||||||
Can be supplied by a number, or a string such as "2016 - 2017".
|
* `years::Union{Integer, AbstractString}=Dates.year(Dates.today())`: Copyright years on the
|
||||||
|
license. Can be supplied by a number, or a string such as "2016 - 2017".
|
||||||
* `dir::AbstractString=Pkg.dir()`: Directory in which the package will go.
|
* `dir::AbstractString=Pkg.dir()`: Directory in which the package will go.
|
||||||
* `julia_version::VersionNumber=VERSION`: Minimum allowed Julia version.
|
* `julia_version::VersionNumber=VERSION`: Minimum allowed Julia version.
|
||||||
* `requirements::Vector{String}=String[]`: Package requirements. If there are duplicate
|
* `requirements::Vector{String}=String[]`: Package requirements. If there are duplicate
|
||||||
@ -30,49 +31,37 @@ create a template, you can use [`interactive_template`](@ref) instead.
|
|||||||
an `ArgumentError` is thrown.
|
an `ArgumentError` is thrown.
|
||||||
Each entry in this array will be copied into the `REQUIRE` file of packages generated
|
Each entry in this array will be copied into the `REQUIRE` file of packages generated
|
||||||
with this template.
|
with this template.
|
||||||
* `git_config::Dict{String, String}=Dict{String, String}()`: Git configuration options.
|
* `gitconfig::Dict{String, String}=Dict{String, String}()`: Git configuration options.
|
||||||
* `plugins::Plugin[]`: A list of `Plugin`s that the package will include.
|
* `plugins::Plugin[]`: A list of `Plugin`s that the package will include.
|
||||||
|
|
||||||
# Notes
|
|
||||||
When you create a `Template`, a temporary directory is created with
|
|
||||||
`mktempdir()`. This directory will be removed after you call [`generate`](@ref).
|
|
||||||
Creating multiple packages in succession with the same instance of a template will still
|
|
||||||
work, but there is a miniscule chance of another process sharing the temporary directory,
|
|
||||||
which could result in the created package repository containing untracked files that
|
|
||||||
don't belong.
|
|
||||||
"""
|
"""
|
||||||
@auto_hash_equals struct Template
|
@auto_hash_equals struct Template
|
||||||
user::AbstractString
|
user::AbstractString
|
||||||
host::AbstractString
|
host::AbstractString
|
||||||
license::Union{AbstractString, Void}
|
license::AbstractString
|
||||||
authors::Union{AbstractString, Array}
|
authors::AbstractString
|
||||||
years::AbstractString
|
years::AbstractString
|
||||||
dir::AbstractString
|
dir::AbstractString
|
||||||
temp_dir::AbstractString
|
|
||||||
julia_version::VersionNumber
|
julia_version::VersionNumber
|
||||||
requirements::Vector{AbstractString}
|
requirements::Vector{AbstractString}
|
||||||
git_config::Dict
|
gitconfig::Dict
|
||||||
plugins::Dict{DataType, Plugin}
|
plugins::Dict{DataType, Plugin}
|
||||||
|
|
||||||
function Template(;
|
function Template(;
|
||||||
user::AbstractString="",
|
user::AbstractString="",
|
||||||
host::AbstractString="https://github.com",
|
host::AbstractString="https://github.com",
|
||||||
license::Union{AbstractString, Void}="MIT",
|
license::Union{AbstractString, Void}="MIT",
|
||||||
authors::Union{AbstractString, Array}="",
|
authors::Union{AbstractString, Vector{<:AbstractString}}="",
|
||||||
years::Union{Int, AbstractString}=Dates.year(now()),
|
years::Union{Integer, AbstractString}=Dates.year(Dates.today()),
|
||||||
dir::AbstractString=Pkg.dir(),
|
dir::AbstractString=Pkg.dir(),
|
||||||
julia_version::VersionNumber=VERSION,
|
julia_version::VersionNumber=VERSION,
|
||||||
requirements::Vector{String}=String[],
|
requirements::Vector{<:AbstractString}=String[],
|
||||||
git_config::Dict=Dict(),
|
gitconfig::Dict=Dict(),
|
||||||
plugins::Vector{P}=Plugin[],
|
plugins::Vector{<:Plugin}=Plugin[],
|
||||||
) where P <: Plugin
|
)
|
||||||
# If no username was set, look for one in a supplied git config,
|
# If no username was set, look for one in a supplied git config,
|
||||||
# and then in the global git config.
|
# and then in the global git config.
|
||||||
if isempty(user)
|
if isempty(user)
|
||||||
user = get(
|
user = get(gitconfig, "github.user", LibGit2.getconfig("github.user", ""))
|
||||||
git_config, "github.user",
|
|
||||||
LibGit2.getconfig("github.user", ""),
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
if isempty(user)
|
if isempty(user)
|
||||||
throw(ArgumentError("No GitHub username found, set one with user=username"))
|
throw(ArgumentError("No GitHub username found, set one with user=username"))
|
||||||
@ -80,22 +69,20 @@ don't belong.
|
|||||||
|
|
||||||
host = URI(startswith(host, "https://") ? host : "https://$host").host
|
host = URI(startswith(host, "https://") ? host : "https://$host").host
|
||||||
|
|
||||||
if license != nothing && !isfile(joinpath(LICENSE_DIR, license))
|
if !isempty(license) && !isfile(joinpath(LICENSE_DIR, license))
|
||||||
throw(ArgumentError("License '$license' is not available"))
|
throw(ArgumentError("License '$license' is not available"))
|
||||||
end
|
end
|
||||||
|
|
||||||
# If no author was set, look for one in the supplied git config,
|
# If no author was set, look for one in the supplied git config,
|
||||||
# and then in the global git config.
|
# and then in the global git config.
|
||||||
if isempty(authors)
|
if isempty(authors)
|
||||||
authors = get(git_config, "user.name", LibGit2.getconfig("user.name", ""))
|
authors = get(gitconfig, "user.name", LibGit2.getconfig("user.name", ""))
|
||||||
elseif isa(authors, Array)
|
elseif isa(authors, Vector)
|
||||||
authors = join(authors, ", ")
|
authors = join(authors, ", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
years = string(years)
|
years = string(years)
|
||||||
|
|
||||||
temp_dir = mktempdir()
|
|
||||||
|
|
||||||
requirements_dedup = collect(Set(requirements))
|
requirements_dedup = collect(Set(requirements))
|
||||||
diff = length(requirements) - length(requirements_dedup)
|
diff = length(requirements) - length(requirements_dedup)
|
||||||
names = [tokens[1] for tokens in split.(requirements_dedup)]
|
names = [tokens[1] for tokens in split.(requirements_dedup)]
|
||||||
@ -113,8 +100,8 @@ don't belong.
|
|||||||
end
|
end
|
||||||
|
|
||||||
new(
|
new(
|
||||||
user, host, license, authors, years, dir, temp_dir,
|
user, host, license, authors, years, dir, julia_version,
|
||||||
julia_version, requirements_dedup, git_config, plugin_dict
|
requirements_dedup, gitconfig, plugin_dict,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -157,10 +144,10 @@ function interactive_template(; fast::Bool=false)
|
|||||||
else
|
else
|
||||||
println("Select a license:")
|
println("Select a license:")
|
||||||
io = IOBuffer()
|
io = IOBuffer()
|
||||||
show_license(; io=io)
|
available_licenses(io)
|
||||||
licenses = [nothing => nothing, collect(LICENSES)...]
|
licenses = ["" => "", collect(LICENSES)...]
|
||||||
menu = RadioMenu(["None", split(String(take!(io)), "\n")...])
|
menu = RadioMenu(["None", split(String(take!(io)), "\n")...])
|
||||||
# If the user breaks out of the menu with C-c, the result is -1, the absolute
|
# If the user breaks out of the menu with Ctrl-c, the result is -1, the absolute
|
||||||
# value of which correponds to no license.
|
# value of which correponds to no license.
|
||||||
licenses[abs(request(menu))].first
|
licenses[abs(request(menu))].first
|
||||||
end
|
end
|
||||||
@ -176,9 +163,9 @@ function interactive_template(; fast::Bool=false)
|
|||||||
end
|
end
|
||||||
|
|
||||||
kwargs[:years] = if fast
|
kwargs[:years] = if fast
|
||||||
Dates.year(now())
|
Dates.year(Dates.today())
|
||||||
else
|
else
|
||||||
default_years = Dates.year(now())
|
default_years = Dates.year(Dates.today())
|
||||||
print("Enter the copyright year(s) [$default_years]: ")
|
print("Enter the copyright year(s) [$default_years]: ")
|
||||||
years = readline()
|
years = readline()
|
||||||
isempty(years) ? default_years : years
|
isempty(years) ? default_years : years
|
||||||
@ -209,20 +196,20 @@ function interactive_template(; fast::Bool=false)
|
|||||||
String.(split(readline()))
|
String.(split(readline()))
|
||||||
end
|
end
|
||||||
|
|
||||||
kwargs[:git_config] = if fast
|
kwargs[:gitconfig] = if fast
|
||||||
Dict()
|
Dict()
|
||||||
else
|
else
|
||||||
git_config = Dict()
|
gitconfig = Dict()
|
||||||
print("Enter any Git key-value pairs (one at a time, separated by spaces) [None]: ")
|
print("Enter any Git key-value pairs (one at a time, separated by spaces) [None]: ")
|
||||||
while true
|
while true
|
||||||
tokens = split(readline())
|
tokens = split(readline())
|
||||||
isempty(tokens) && break
|
isempty(tokens) && break
|
||||||
if haskey(git_config, tokens[1])
|
if haskey(gitconfig, tokens[1])
|
||||||
warn("Duplicate key '$(tokens[1])': Replacing old value '$(tokens[2])'")
|
warn("Duplicate key '$(tokens[1])': Replacing old value '$(tokens[2])'")
|
||||||
end
|
end
|
||||||
git_config[tokens[1]] = tokens[2]
|
gitconfig[tokens[1]] = tokens[2]
|
||||||
end
|
end
|
||||||
git_config
|
gitconfig
|
||||||
end
|
end
|
||||||
|
|
||||||
println("Select plugins:")
|
println("Select plugins:")
|
||||||
@ -243,4 +230,4 @@ end
|
|||||||
|
|
||||||
Get all concrete subtypes of `t`.
|
Get all concrete subtypes of `t`.
|
||||||
"""
|
"""
|
||||||
leaves(t::Type) = isleaftype(t) ? t : vcat(leaves.(subtypes(t))...)
|
leaves(t::Type)::Vector{DataType} = isleaftype(t) ? [t] : vcat(leaves.(subtypes(t))...)
|
||||||
|
156
test/tests.jl
156
test/tests.jl
@ -12,7 +12,7 @@ struct Bar <: CustomPlugin end
|
|||||||
struct Baz <: Plugin end
|
struct Baz <: Plugin end
|
||||||
|
|
||||||
const me = "christopher-dG"
|
const me = "christopher-dG"
|
||||||
const git_config = Dict(
|
const gitconfig = Dict(
|
||||||
"user.name" => "Tester McTestFace",
|
"user.name" => "Tester McTestFace",
|
||||||
"user.email" => "email@web.site",
|
"user.email" => "email@web.site",
|
||||||
"github.user" => "TesterMcTestFace",
|
"github.user" => "TesterMcTestFace",
|
||||||
@ -20,12 +20,12 @@ const git_config = Dict(
|
|||||||
const test_pkg = "TestPkg"
|
const test_pkg = "TestPkg"
|
||||||
const fake_path = bin(hash("/this/file/does/not/exist"))
|
const fake_path = bin(hash("/this/file/does/not/exist"))
|
||||||
const test_file = tempname()
|
const test_file = tempname()
|
||||||
template_text = """
|
const template_text = """
|
||||||
PKGNAME: {{PKGNAME}}
|
PKGNAME: {{PKGNAME}}
|
||||||
VERSION: {{VERSION}}}
|
VERSION: {{VERSION}}}
|
||||||
{{#DOCUMENTER}}Documenter{{/DOCUMENTER}}
|
{{#DOCUMENTER}}Documenter{{/DOCUMENTER}}
|
||||||
{{#CODECOV}}CodeCov{{/CODECOV}}
|
{{#CODECOV}}CodeCov{{/CODECOV}}
|
||||||
{{#CODECOV}}Coveralls{{/CODECOV}}
|
{{#COVERALLS}}Coveralls{{/COVERALLS}}
|
||||||
{{#AFTER}}After{{/AFTER}}
|
{{#AFTER}}After{{/AFTER}}
|
||||||
{{#OTHER}}Other{{/OTHER}}
|
{{#OTHER}}Other{{/OTHER}}
|
||||||
"""
|
"""
|
||||||
@ -33,77 +33,61 @@ write(test_file, template_text)
|
|||||||
|
|
||||||
@testset "Template creation" begin
|
@testset "Template creation" begin
|
||||||
t = Template(; user=me)
|
t = Template(; user=me)
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.user == me
|
@test t.user == me
|
||||||
@test t.license == "MIT"
|
@test t.license == "MIT"
|
||||||
@test t.years == string(Dates.year(Dates.today()))
|
@test t.years == string(Dates.year(Dates.today()))
|
||||||
@test t.authors == LibGit2.getconfig("user.name", "")
|
@test t.authors == LibGit2.getconfig("user.name", "")
|
||||||
@test t.dir == Pkg.dir()
|
@test t.dir == Pkg.dir()
|
||||||
@test t.julia_version == VERSION
|
@test t.julia_version == VERSION
|
||||||
@test isempty(t.git_config)
|
@test isempty(t.gitconfig)
|
||||||
@test isempty(t.plugins)
|
@test isempty(t.plugins)
|
||||||
|
|
||||||
t = Template(; user=me, license=nothing)
|
t = Template(; user=me, license="")
|
||||||
rm(t.temp_dir; recursive=true)
|
@test t.license == ""
|
||||||
@test t.license == nothing
|
|
||||||
|
|
||||||
t = Template(; user=me, license="MPL")
|
t = Template(; user=me, license="MPL")
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.license == "MPL"
|
@test t.license == "MPL"
|
||||||
|
|
||||||
t = Template(; user=me, years=2014)
|
t = Template(; user=me, years=2014)
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.years == "2014"
|
@test t.years == "2014"
|
||||||
t = Template(user=me, years="2014-2015")
|
t = Template(user=me, years="2014-2015")
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.years == "2014-2015"
|
@test t.years == "2014-2015"
|
||||||
|
|
||||||
t = Template(; user=me, authors="Some Guy")
|
t = Template(; user=me, authors="Some Guy")
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.authors == "Some Guy"
|
@test t.authors == "Some Guy"
|
||||||
|
|
||||||
t = Template(; user=me, authors=["Guy", "Gal"])
|
t = Template(; user=me, authors=["Guy", "Gal"])
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.authors == "Guy, Gal"
|
@test t.authors == "Guy, Gal"
|
||||||
|
|
||||||
t = Template(; user=me, dir=test_file)
|
t = Template(; user=me, dir=test_file)
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.dir == test_file
|
@test t.dir == test_file
|
||||||
|
|
||||||
t = Template(; user=me, julia_version=v"0.1.2")
|
t = Template(; user=me, julia_version=v"0.1.2")
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.julia_version == v"0.1.2"
|
@test t.julia_version == v"0.1.2"
|
||||||
|
|
||||||
t = Template(; user=me, requirements=["$test_pkg 0.1"])
|
t = Template(; user=me, requirements=["$test_pkg 0.1"])
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.requirements == ["$test_pkg 0.1"]
|
@test t.requirements == ["$test_pkg 0.1"]
|
||||||
@test_warn r".+" t = Template(; user=me, requirements=[test_pkg, test_pkg])
|
@test_warn r".+" t = Template(; user=me, requirements=[test_pkg, test_pkg])
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.requirements == [test_pkg]
|
@test t.requirements == [test_pkg]
|
||||||
@test_throws ArgumentError t = Template(;
|
@test_throws ArgumentError t = Template(;
|
||||||
user=me,
|
user=me,
|
||||||
requirements=[test_pkg, "$test_pkg 0.1"]
|
requirements=[test_pkg, "$test_pkg 0.1"]
|
||||||
)
|
)
|
||||||
rm(t.temp_dir; force=true, recursive=true)
|
|
||||||
|
|
||||||
t = Template(; user=me, git_config=git_config)
|
t = Template(; user=me, gitconfig=gitconfig)
|
||||||
rm(t.temp_dir; recursive=true)
|
@test t.gitconfig == gitconfig
|
||||||
@test t.git_config == git_config
|
|
||||||
|
|
||||||
t = Template(; user=me, git_config=git_config)
|
t = Template(; user=me, gitconfig=gitconfig)
|
||||||
rm(t.temp_dir; recursive=true)
|
@test t.authors == gitconfig["user.name"]
|
||||||
@test t.authors == git_config["user.name"]
|
|
||||||
|
|
||||||
t = Template(; git_config=git_config)
|
t = Template(; gitconfig=gitconfig)
|
||||||
rm(t.temp_dir; recursive=true)
|
@test t.user == gitconfig["github.user"]
|
||||||
@test t.user == git_config["github.user"]
|
@test t.authors == gitconfig["user.name"]
|
||||||
@test t.authors == git_config["user.name"]
|
|
||||||
|
|
||||||
t = Template(;
|
t = Template(;
|
||||||
user=me,
|
user=me,
|
||||||
plugins = [GitHubPages(), TravisCI(), AppVeyor(), CodeCov(), Coveralls()],
|
plugins = [GitHubPages(), TravisCI(), AppVeyor(), CodeCov(), Coveralls()],
|
||||||
)
|
)
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test Set(keys(t.plugins)) == Set(
|
@test Set(keys(t.plugins)) == Set(
|
||||||
[GitHubPages, TravisCI, AppVeyor, CodeCov, Coveralls]
|
[GitHubPages, TravisCI, AppVeyor, CodeCov, Coveralls]
|
||||||
)
|
)
|
||||||
@ -115,7 +99,6 @@ write(test_file, template_text)
|
|||||||
user=me,
|
user=me,
|
||||||
plugins=[TravisCI(), TravisCI()],
|
plugins=[TravisCI(), TravisCI()],
|
||||||
)
|
)
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
|
|
||||||
if isempty(LibGit2.getconfig("github.user", ""))
|
if isempty(LibGit2.getconfig("github.user", ""))
|
||||||
@test_throws ArgumentError t = Template()
|
@test_throws ArgumentError t = Template()
|
||||||
@ -123,9 +106,7 @@ write(test_file, template_text)
|
|||||||
t = Template()
|
t = Template()
|
||||||
@test t.user == LibGit2.getconfig("github.user", "")
|
@test t.user == LibGit2.getconfig("github.user", "")
|
||||||
end
|
end
|
||||||
rm(t.temp_dir; force=true, recursive=true)
|
|
||||||
@test_throws ArgumentError t = Template(; user=me, license="FakeLicense")
|
@test_throws ArgumentError t = Template(; user=me, license="FakeLicense")
|
||||||
rm(t.temp_dir; force=true, recursive=true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Interactive template creation" begin
|
@testset "Interactive template creation" begin
|
||||||
@ -133,52 +114,49 @@ end
|
|||||||
in_read, in_write = redirect_stdin()
|
in_read, in_write = redirect_stdin()
|
||||||
write(in_write, "$me\n\n\r\n\n\n\n\n\nd")
|
write(in_write, "$me\n\n\r\n\n\n\n\n\nd")
|
||||||
t = interactive_template()
|
t = interactive_template()
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.user == me
|
@test t.user == me
|
||||||
@test t.host == "github.com"
|
@test t.host == "github.com"
|
||||||
@test t.license == nothing
|
@test isempty(t.license)
|
||||||
@test t.authors == LibGit2.getconfig("user.name", "")
|
@test t.authors == LibGit2.getconfig("user.name", "")
|
||||||
@test t.years == string(Dates.year(now()))
|
@test t.years == string(Dates.year(Dates.today()))
|
||||||
@test t.dir == Pkg.dir()
|
@test t.dir == Pkg.dir()
|
||||||
@test t.julia_version == VERSION
|
@test t.julia_version == VERSION
|
||||||
@test isempty(t.requirements)
|
@test isempty(t.requirements)
|
||||||
@test isempty(t.git_config)
|
@test isempty(t.gitconfig)
|
||||||
@test isempty(t.plugins)
|
@test isempty(t.plugins)
|
||||||
|
|
||||||
if isempty(LibGit2.getconfig("github.user", ""))
|
if isempty(LibGit2.getconfig("github.user", ""))
|
||||||
write(in_write, "\n")
|
write(in_write, "\n")
|
||||||
@test_throws ArgumentError t = interactive_template()
|
@test_throws ArgumentError t = interactive_template()
|
||||||
rm(t.temp_dir; force=true, recursive=true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
write(in_write, "$me\ngitlab.com\n$('\x1b')[B\r$me\n2016\n$test_file\n0.5\nX Y\nA B\n\n$('\x1b')[B\r$('\x1b')[B\rd\n\n")
|
write(in_write, "$me\ngitlab.com\n$('\x1b')[B\r$me\n2016\n$test_file\n0.5\nX Y\nA B\n\n$('\x1b')[B\r$('\x1b')[B\rd\n\n")
|
||||||
t = interactive_template()
|
t = interactive_template()
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.user == me
|
@test t.user == me
|
||||||
@test t.host == "gitlab.com"
|
@test t.host == "gitlab.com"
|
||||||
# Not sure if the order the licenses are displayed is consistent.
|
# Not sure if the order the licenses are displayed is consistent.
|
||||||
@test t.license != nothing
|
@test !isempty(t.license)
|
||||||
@test t.authors == me
|
@test t.authors == me
|
||||||
@test t.years == "2016"
|
@test t.years == "2016"
|
||||||
@test t.dir == test_file
|
@test t.dir == test_file
|
||||||
@test t.julia_version == v"0.5.0"
|
@test t.julia_version == v"0.5.0"
|
||||||
@test Set(t.requirements) == Set(["X", "Y"])
|
@test Set(t.requirements) == Set(["X", "Y"])
|
||||||
@test t.git_config == Dict("A" => "B")
|
@test t.gitconfig == Dict("A" => "B")
|
||||||
# Like above, not sure which plugins this will generate.
|
# Like above, not sure which plugins this will generate.
|
||||||
@test length(t.plugins) == 2
|
@test length(t.plugins) == 2
|
||||||
|
|
||||||
write(in_write, "$me\nd")
|
write(in_write, "$me\nd")
|
||||||
t = interactive_template(; fast=true)
|
t = interactive_template(; fast=true)
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
@test t.user == me
|
@test t.user == me
|
||||||
@test t.host == "github.com"
|
@test t.host == "github.com"
|
||||||
@test t.license == "MIT"
|
@test t.license == "MIT"
|
||||||
@test t.authors == LibGit2.getconfig("user.name", "")
|
@test t.authors == LibGit2.getconfig("user.name", "")
|
||||||
@test t.years == string(Dates.year(now()))
|
# I guess this could technically break if it runs on New Year's Eve...
|
||||||
|
@test t.years == string(Dates.year(Dates.today()))
|
||||||
@test t.dir == Pkg.dir()
|
@test t.dir == Pkg.dir()
|
||||||
@test t.julia_version == VERSION
|
@test t.julia_version == VERSION
|
||||||
@test isempty(t.requirements)
|
@test isempty(t.requirements)
|
||||||
@test isempty(t.git_config)
|
@test isempty(t.gitconfig)
|
||||||
@test isempty(t.plugins)
|
@test isempty(t.plugins)
|
||||||
|
|
||||||
redirect_stdin(old_stdin)
|
redirect_stdin(old_stdin)
|
||||||
@ -199,7 +177,7 @@ end
|
|||||||
]
|
]
|
||||||
@test isempty(p.view)
|
@test isempty(p.view)
|
||||||
p = AppVeyor(; config_file=nothing)
|
p = AppVeyor(; config_file=nothing)
|
||||||
@test_throws NullException get(p.src)
|
@test isnull(p.src)
|
||||||
p = AppVeyor(; config_file=test_file)
|
p = AppVeyor(; config_file=test_file)
|
||||||
@test get(p.src) == test_file
|
@test get(p.src) == test_file
|
||||||
@test_throws ArgumentError p = AppVeyor(; config_file=fake_path)
|
@test_throws ArgumentError p = AppVeyor(; config_file=fake_path)
|
||||||
@ -217,7 +195,7 @@ end
|
|||||||
]
|
]
|
||||||
@test isempty(p.view)
|
@test isempty(p.view)
|
||||||
p = TravisCI(; config_file=nothing)
|
p = TravisCI(; config_file=nothing)
|
||||||
@test_throws NullException get(p.src)
|
@test isnull(p.src)
|
||||||
p = TravisCI(; config_file=test_file)
|
p = TravisCI(; config_file=test_file)
|
||||||
@test get(p.src) == test_file
|
@test get(p.src) == test_file
|
||||||
@test_throws ArgumentError p = TravisCI(; config_file=fake_path)
|
@test_throws ArgumentError p = TravisCI(; config_file=fake_path)
|
||||||
@ -235,14 +213,14 @@ end
|
|||||||
]
|
]
|
||||||
@test isempty(p.view)
|
@test isempty(p.view)
|
||||||
p = CodeCov(; config_file=nothing)
|
p = CodeCov(; config_file=nothing)
|
||||||
@test_throws NullException get(p.src)
|
@test isnull(p.src)
|
||||||
p = CodeCov(; config_file=test_file)
|
p = CodeCov(; config_file=test_file)
|
||||||
@test get(p.src) == test_file
|
@test get(p.src) == test_file
|
||||||
@test_throws ArgumentError p = CodeCov(; config_file=fake_path)
|
@test_throws ArgumentError p = CodeCov(; config_file=fake_path)
|
||||||
|
|
||||||
p = Coveralls()
|
p = Coveralls()
|
||||||
@test p.gitignore == ["*.jl.cov", "*.jl.*.cov", "*.jl.mem"]
|
@test p.gitignore == ["*.jl.cov", "*.jl.*.cov", "*.jl.mem"]
|
||||||
@test_throws NullException get(p.src)
|
@test isnull(p.src)
|
||||||
@test p.dest == ".coveralls.yml"
|
@test p.dest == ".coveralls.yml"
|
||||||
@test p.badges == [
|
@test p.badges == [
|
||||||
Badge(
|
Badge(
|
||||||
@ -253,7 +231,7 @@ end
|
|||||||
]
|
]
|
||||||
@test isempty(p.view)
|
@test isempty(p.view)
|
||||||
p = Coveralls(; config_file=nothing)
|
p = Coveralls(; config_file=nothing)
|
||||||
@test_throws NullException get(p.src)
|
@test isnull(p.src)
|
||||||
p = Coveralls(; config_file=test_file)
|
p = Coveralls(; config_file=test_file)
|
||||||
@test get(p.src) == test_file
|
@test get(p.src) == test_file
|
||||||
@test_throws ArgumentError p = Coveralls(; config_file=fake_path)
|
@test_throws ArgumentError p = Coveralls(; config_file=fake_path)
|
||||||
@ -267,7 +245,7 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
@testset "Badge generation" begin
|
@testset "Badge generation" begin
|
||||||
user = git_config["github.user"]
|
user = gitconfig["github.user"]
|
||||||
|
|
||||||
badge = Badge("A", "B", "C")
|
badge = Badge("A", "B", "C")
|
||||||
@test badge.hover == "A"
|
@test badge.hover == "A"
|
||||||
@ -304,10 +282,11 @@ end
|
|||||||
user=me,
|
user=me,
|
||||||
license="MPL",
|
license="MPL",
|
||||||
requirements=[test_pkg],
|
requirements=[test_pkg],
|
||||||
git_config=git_config,
|
gitconfig=gitconfig,
|
||||||
plugins=[Coveralls(), TravisCI(), CodeCov(), GitHubPages(), AppVeyor()],
|
plugins=[Coveralls(), TravisCI(), CodeCov(), GitHubPages(), AppVeyor()],
|
||||||
)
|
)
|
||||||
pkg_dir = joinpath(t.temp_dir, test_pkg)
|
temp_dir = mktempdir()
|
||||||
|
pkg_dir = joinpath(temp_dir, test_pkg)
|
||||||
|
|
||||||
temp_file = tempname()
|
temp_file = tempname()
|
||||||
gen_file(temp_file, "Hello, world")
|
gen_file(temp_file, "Hello, world")
|
||||||
@ -315,7 +294,7 @@ end
|
|||||||
@test readstring(temp_file) == "Hello, world\n"
|
@test readstring(temp_file) == "Hello, world\n"
|
||||||
rm(temp_file)
|
rm(temp_file)
|
||||||
|
|
||||||
@test gen_readme(test_pkg, t) == ["README.md"]
|
@test gen_readme(temp_dir, test_pkg, t) == ["README.md"]
|
||||||
@test isfile(joinpath(pkg_dir, "README.md"))
|
@test isfile(joinpath(pkg_dir, "README.md"))
|
||||||
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
||||||
rm(joinpath(pkg_dir, "README.md"))
|
rm(joinpath(pkg_dir, "README.md"))
|
||||||
@ -331,12 +310,12 @@ end
|
|||||||
search(readme, "coveralls").start
|
search(readme, "coveralls").start
|
||||||
# Plugins with badges but not in BADGE_ORDER should appear at the far right side.
|
# Plugins with badges but not in BADGE_ORDER should appear at the far right side.
|
||||||
t.plugins[Foo] = Foo()
|
t.plugins[Foo] = Foo()
|
||||||
gen_readme(test_pkg, t)
|
gen_readme(temp_dir, test_pkg, t)
|
||||||
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
||||||
rm(joinpath(pkg_dir, "README.md"))
|
rm(joinpath(pkg_dir, "README.md"))
|
||||||
@test search(readme, "coveralls").start < search(readme, "baz").start
|
@test search(readme, "coveralls").start < search(readme, "baz").start
|
||||||
|
|
||||||
@test gen_gitignore(test_pkg, t) == [".gitignore"]
|
@test gen_gitignore(temp_dir, test_pkg, t) == [".gitignore"]
|
||||||
@test isfile(joinpath(pkg_dir, ".gitignore"))
|
@test isfile(joinpath(pkg_dir, ".gitignore"))
|
||||||
gitignore = readstring(joinpath(pkg_dir, ".gitignore"))
|
gitignore = readstring(joinpath(pkg_dir, ".gitignore"))
|
||||||
rm(joinpath(pkg_dir, ".gitignore"))
|
rm(joinpath(pkg_dir, ".gitignore"))
|
||||||
@ -347,7 +326,7 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@test gen_license(test_pkg, t) == ["LICENSE"]
|
@test gen_license(temp_dir, test_pkg, t) == ["LICENSE"]
|
||||||
@test isfile(joinpath(pkg_dir, "LICENSE"))
|
@test isfile(joinpath(pkg_dir, "LICENSE"))
|
||||||
license = readchomp(joinpath(pkg_dir, "LICENSE"))
|
license = readchomp(joinpath(pkg_dir, "LICENSE"))
|
||||||
rm(joinpath(pkg_dir, "LICENSE"))
|
rm(joinpath(pkg_dir, "LICENSE"))
|
||||||
@ -355,20 +334,20 @@ end
|
|||||||
@test contains(license, t.years)
|
@test contains(license, t.years)
|
||||||
@test contains(license, read_license(t.license))
|
@test contains(license, read_license(t.license))
|
||||||
|
|
||||||
@test gen_entrypoint(test_pkg, t) == ["src/"]
|
@test gen_entrypoint(temp_dir, test_pkg, t) == ["src/"]
|
||||||
@test isdir(joinpath(pkg_dir, "src"))
|
@test isdir(joinpath(pkg_dir, "src"))
|
||||||
@test isfile(joinpath(pkg_dir, "src", "$test_pkg.jl"))
|
@test isfile(joinpath(pkg_dir, "src", "$test_pkg.jl"))
|
||||||
entrypoint = readchomp(joinpath(pkg_dir, "src", "$test_pkg.jl"))
|
entrypoint = readchomp(joinpath(pkg_dir, "src", "$test_pkg.jl"))
|
||||||
rm(joinpath(pkg_dir, "src"); recursive=true)
|
rm(joinpath(pkg_dir, "src"); recursive=true)
|
||||||
@test contains(entrypoint, "module $test_pkg")
|
@test contains(entrypoint, "module $test_pkg")
|
||||||
|
|
||||||
@test gen_require(test_pkg, t) == ["REQUIRE"]
|
@test gen_require(temp_dir, test_pkg, t) == ["REQUIRE"]
|
||||||
@test isfile(joinpath(pkg_dir, "REQUIRE"))
|
@test isfile(joinpath(pkg_dir, "REQUIRE"))
|
||||||
vf = version_floor(t.julia_version)
|
vf = version_floor(t.julia_version)
|
||||||
@test readchomp(joinpath(pkg_dir, "REQUIRE")) == "julia $vf\n$test_pkg"
|
@test readchomp(joinpath(pkg_dir, "REQUIRE")) == "julia $vf\n$test_pkg"
|
||||||
rm(joinpath(pkg_dir, "REQUIRE"))
|
rm(joinpath(pkg_dir, "REQUIRE"))
|
||||||
|
|
||||||
@test gen_tests(test_pkg, t) == ["test/"]
|
@test gen_tests(temp_dir, test_pkg, t) == ["test/"]
|
||||||
@test isdir(joinpath(pkg_dir, "test"))
|
@test isdir(joinpath(pkg_dir, "test"))
|
||||||
@test isfile(joinpath(pkg_dir, "test", "runtests.jl"))
|
@test isfile(joinpath(pkg_dir, "test", "runtests.jl"))
|
||||||
runtests = readchomp(joinpath(pkg_dir, "test", "runtests.jl"))
|
runtests = readchomp(joinpath(pkg_dir, "test", "runtests.jl"))
|
||||||
@ -376,11 +355,11 @@ end
|
|||||||
@test contains(runtests, "using $test_pkg")
|
@test contains(runtests, "using $test_pkg")
|
||||||
@test contains(runtests, "using Base.Test")
|
@test contains(runtests, "using Base.Test")
|
||||||
|
|
||||||
rm(t.temp_dir; recursive=true)
|
rm(dirname(pkg_dir); recursive=true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Package generation" begin
|
@testset "Package generation" begin
|
||||||
t = Template(; user=me)
|
t = Template(; user=me, gitconfig=gitconfig)
|
||||||
generate(test_pkg, t)
|
generate(test_pkg, t)
|
||||||
@test isfile(Pkg.dir(test_pkg, "LICENSE"))
|
@test isfile(Pkg.dir(test_pkg, "LICENSE"))
|
||||||
@test isfile(Pkg.dir(test_pkg, "README.md"))
|
@test isfile(Pkg.dir(test_pkg, "README.md"))
|
||||||
@ -393,7 +372,7 @@ end
|
|||||||
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
||||||
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
||||||
@test LibGit2.getconfig(repo, "user.name", "") == LibGit2.getconfig("user.name", "")
|
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
|
||||||
@test LibGit2.url(remote) == "https://github.com/$me/$test_pkg.jl"
|
@test LibGit2.url(remote) == "https://github.com/$me/$test_pkg.jl"
|
||||||
@test in("master", branches)
|
@test in("master", branches)
|
||||||
@test !in("gh-pages", branches)
|
@test !in("gh-pages", branches)
|
||||||
@ -406,7 +385,7 @@ end
|
|||||||
@test LibGit2.url(remote) == "git@github.com:$me/$test_pkg.jl.git"
|
@test LibGit2.url(remote) == "git@github.com:$me/$test_pkg.jl.git"
|
||||||
rm(Pkg.dir(test_pkg); recursive=true)
|
rm(Pkg.dir(test_pkg); recursive=true)
|
||||||
|
|
||||||
t = Template(; user=me, host="gitlab.com")
|
t = Template(; user=me, host="gitlab.com", gitconfig=gitconfig)
|
||||||
generate(test_pkg, t)
|
generate(test_pkg, t)
|
||||||
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
||||||
@ -414,18 +393,19 @@ end
|
|||||||
rm(Pkg.dir(test_pkg); recursive=true)
|
rm(Pkg.dir(test_pkg); recursive=true)
|
||||||
|
|
||||||
temp_dir = mktempdir()
|
temp_dir = mktempdir()
|
||||||
t = Template(; user=me, dir=temp_dir)
|
t = Template(; user=me, dir=temp_dir, gitconfig=gitconfig)
|
||||||
generate(test_pkg, t)
|
generate(test_pkg, t)
|
||||||
@test isdir(joinpath(temp_dir, test_pkg))
|
@test isdir(joinpath(temp_dir, test_pkg))
|
||||||
rm(temp_dir; recursive=true)
|
rm(temp_dir; recursive=true)
|
||||||
|
|
||||||
t = Template(;
|
t = Template(;
|
||||||
user=me,
|
user=me,
|
||||||
license=nothing,
|
license="",
|
||||||
git_config=git_config,
|
gitconfig=gitconfig,
|
||||||
plugins=[AppVeyor(), GitHubPages(), Coveralls(), CodeCov(), TravisCI()],
|
plugins=[AppVeyor(), GitHubPages(), Coveralls(), CodeCov(), TravisCI()],
|
||||||
)
|
)
|
||||||
generate(test_pkg, t)
|
generate(test_pkg, t)
|
||||||
|
@test isdir(joinpath(Pkg.dir(), test_pkg))
|
||||||
@test !isfile(Pkg.dir(test_pkg, "LICENSE"))
|
@test !isfile(Pkg.dir(test_pkg, "LICENSE"))
|
||||||
@test isfile(Pkg.dir(test_pkg, ".travis.yml"))
|
@test isfile(Pkg.dir(test_pkg, ".travis.yml"))
|
||||||
@test isfile(Pkg.dir(test_pkg, ".appveyor.yml"))
|
@test isfile(Pkg.dir(test_pkg, ".appveyor.yml"))
|
||||||
@ -435,7 +415,7 @@ end
|
|||||||
@test isdir(Pkg.dir(test_pkg, "docs", "src"))
|
@test isdir(Pkg.dir(test_pkg, "docs", "src"))
|
||||||
@test isfile(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
@test isfile(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
||||||
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
@test LibGit2.getconfig(repo, "user.name", "") == git_config["user.name"]
|
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
|
||||||
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
||||||
@test in("gh-pages", branches)
|
@test in("gh-pages", branches)
|
||||||
@test !LibGit2.isdirty(repo)
|
@test !LibGit2.isdirty(repo)
|
||||||
@ -447,7 +427,7 @@ end
|
|||||||
@test isfile(Pkg.dir(test_pkg, "README.md"))
|
@test isfile(Pkg.dir(test_pkg, "README.md"))
|
||||||
rm(Pkg.dir(test_pkg); recursive=true)
|
rm(Pkg.dir(test_pkg); recursive=true)
|
||||||
|
|
||||||
t = Template(; user=me, plugins=[GitHubPages()])
|
t = Template(; user=me, gitconfig=gitconfig, plugins=[GitHubPages()])
|
||||||
generate(test_pkg, t)
|
generate(test_pkg, t)
|
||||||
readme = readstring(Pkg.dir(test_pkg, "README.md"))
|
readme = readstring(Pkg.dir(test_pkg, "README.md"))
|
||||||
index = readstring(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
index = readstring(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
||||||
@ -457,10 +437,11 @@ end
|
|||||||
|
|
||||||
@testset "Plugin generation" begin
|
@testset "Plugin generation" begin
|
||||||
t = Template(; user=me)
|
t = Template(; user=me)
|
||||||
pkg_dir = joinpath(t.temp_dir, test_pkg)
|
temp_dir = mktempdir()
|
||||||
|
pkg_dir = joinpath(temp_dir, test_pkg)
|
||||||
|
|
||||||
p = TravisCI()
|
p = TravisCI()
|
||||||
@test gen_plugin(p, t, test_pkg) == [".travis.yml"]
|
@test gen_plugin(p, t, temp_dir, test_pkg) == [".travis.yml"]
|
||||||
@test isfile(joinpath(pkg_dir, ".travis.yml"))
|
@test isfile(joinpath(pkg_dir, ".travis.yml"))
|
||||||
travis = readstring(joinpath(pkg_dir, ".travis.yml"))
|
travis = readstring(joinpath(pkg_dir, ".travis.yml"))
|
||||||
@test !contains(travis, "after_success")
|
@test !contains(travis, "after_success")
|
||||||
@ -469,7 +450,7 @@ end
|
|||||||
@test !contains(travis, "Pkg.add(\"Documenter\")")
|
@test !contains(travis, "Pkg.add(\"Documenter\")")
|
||||||
rm(joinpath(pkg_dir, ".travis.yml"))
|
rm(joinpath(pkg_dir, ".travis.yml"))
|
||||||
t.plugins[CodeCov] = CodeCov()
|
t.plugins[CodeCov] = CodeCov()
|
||||||
gen_plugin(p, t, test_pkg)
|
gen_plugin(p, t, temp_dir, test_pkg)
|
||||||
delete!(t.plugins, CodeCov)
|
delete!(t.plugins, CodeCov)
|
||||||
travis = readstring(joinpath(pkg_dir, ".travis.yml"))
|
travis = readstring(joinpath(pkg_dir, ".travis.yml"))
|
||||||
@test contains(travis, "after_success")
|
@test contains(travis, "after_success")
|
||||||
@ -478,7 +459,7 @@ end
|
|||||||
@test !contains(travis, "Pkg.add(\"Documenter\")")
|
@test !contains(travis, "Pkg.add(\"Documenter\")")
|
||||||
rm(joinpath(pkg_dir, ".travis.yml"))
|
rm(joinpath(pkg_dir, ".travis.yml"))
|
||||||
t.plugins[Coveralls] = Coveralls()
|
t.plugins[Coveralls] = Coveralls()
|
||||||
gen_plugin(p, t, test_pkg)
|
gen_plugin(p, t, temp_dir, test_pkg)
|
||||||
delete!(t.plugins, Coveralls)
|
delete!(t.plugins, Coveralls)
|
||||||
travis = readstring(joinpath(pkg_dir, ".travis.yml"))
|
travis = readstring(joinpath(pkg_dir, ".travis.yml"))
|
||||||
@test contains(travis, "after_success")
|
@test contains(travis, "after_success")
|
||||||
@ -487,7 +468,7 @@ end
|
|||||||
@test !contains(travis, "Pkg.add(\"Documenter\")")
|
@test !contains(travis, "Pkg.add(\"Documenter\")")
|
||||||
rm(joinpath(pkg_dir, ".travis.yml"))
|
rm(joinpath(pkg_dir, ".travis.yml"))
|
||||||
t.plugins[GitHubPages] = GitHubPages()
|
t.plugins[GitHubPages] = GitHubPages()
|
||||||
gen_plugin(p, t, test_pkg)
|
gen_plugin(p, t, temp_dir, test_pkg)
|
||||||
delete!(t.plugins, GitHubPages)
|
delete!(t.plugins, GitHubPages)
|
||||||
travis = readstring(joinpath(pkg_dir, ".travis.yml"))
|
travis = readstring(joinpath(pkg_dir, ".travis.yml"))
|
||||||
@test contains(travis, "after_success")
|
@test contains(travis, "after_success")
|
||||||
@ -496,12 +477,12 @@ end
|
|||||||
@test !contains(travis, "Coveralls.submit")
|
@test !contains(travis, "Coveralls.submit")
|
||||||
rm(joinpath(pkg_dir, ".travis.yml"))
|
rm(joinpath(pkg_dir, ".travis.yml"))
|
||||||
p = TravisCI(; config_file=nothing)
|
p = TravisCI(; config_file=nothing)
|
||||||
@test isempty(gen_plugin(p, t, test_pkg))
|
@test isempty(gen_plugin(p, t, temp_dir, test_pkg))
|
||||||
@test !isfile(joinpath(pkg_dir, ".travis.yml"))
|
@test !isfile(joinpath(pkg_dir, ".travis.yml"))
|
||||||
@test_throws ArgumentError TravisCI(; config_file=fake_path)
|
@test_throws ArgumentError TravisCI(; config_file=fake_path)
|
||||||
|
|
||||||
p = AppVeyor()
|
p = AppVeyor()
|
||||||
@test gen_plugin(p, t, test_pkg) == [".appveyor.yml"]
|
@test gen_plugin(p, t, temp_dir, test_pkg) == [".appveyor.yml"]
|
||||||
@test isfile(joinpath(pkg_dir, ".appveyor.yml"))
|
@test isfile(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
appveyor = readstring(joinpath(pkg_dir, ".appveyor.yml"))
|
appveyor = readstring(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
@test !contains(appveyor, "coverage=true")
|
@test !contains(appveyor, "coverage=true")
|
||||||
@ -510,7 +491,7 @@ end
|
|||||||
@test !contains(appveyor, "Coveralls.submit")
|
@test !contains(appveyor, "Coveralls.submit")
|
||||||
rm(joinpath(pkg_dir, ".appveyor.yml"))
|
rm(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
t.plugins[CodeCov] = CodeCov()
|
t.plugins[CodeCov] = CodeCov()
|
||||||
gen_plugin(p, t, test_pkg)
|
gen_plugin(p, t, temp_dir, test_pkg)
|
||||||
delete!(t.plugins, CodeCov)
|
delete!(t.plugins, CodeCov)
|
||||||
appveyor = readstring(joinpath(pkg_dir, ".appveyor.yml"))
|
appveyor = readstring(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
@test contains(appveyor, "coverage=true")
|
@test contains(appveyor, "coverage=true")
|
||||||
@ -519,7 +500,7 @@ end
|
|||||||
@test !contains(appveyor, "Coveralls.submit")
|
@test !contains(appveyor, "Coveralls.submit")
|
||||||
rm(joinpath(pkg_dir, ".appveyor.yml"))
|
rm(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
t.plugins[Coveralls] = Coveralls()
|
t.plugins[Coveralls] = Coveralls()
|
||||||
gen_plugin(p, t, test_pkg)
|
gen_plugin(p, t, temp_dir, test_pkg)
|
||||||
delete!(t.plugins, Coveralls)
|
delete!(t.plugins, Coveralls)
|
||||||
appveyor = readstring(joinpath(pkg_dir, ".appveyor.yml"))
|
appveyor = readstring(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
@test contains(appveyor, "coverage=true")
|
@test contains(appveyor, "coverage=true")
|
||||||
@ -528,21 +509,21 @@ end
|
|||||||
@test !contains(appveyor, "Codecov.submit")
|
@test !contains(appveyor, "Codecov.submit")
|
||||||
rm(joinpath(pkg_dir, ".appveyor.yml"))
|
rm(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
p = AppVeyor(; config_file=nothing)
|
p = AppVeyor(; config_file=nothing)
|
||||||
@test isempty(gen_plugin(p, t, test_pkg))
|
@test isempty(gen_plugin(p, t, temp_dir, test_pkg))
|
||||||
@test !isfile(joinpath(pkg_dir, ".appveyor.yml"))
|
@test !isfile(joinpath(pkg_dir, ".appveyor.yml"))
|
||||||
@test_throws ArgumentError AppVeyor(; config_file=fake_path)
|
@test_throws ArgumentError AppVeyor(; config_file=fake_path)
|
||||||
|
|
||||||
p = CodeCov()
|
p = CodeCov()
|
||||||
@test gen_plugin(p, t, test_pkg) == [".codecov.yml"]
|
@test gen_plugin(p, t, temp_dir, test_pkg) == [".codecov.yml"]
|
||||||
@test isfile(joinpath(pkg_dir, ".codecov.yml"))
|
@test isfile(joinpath(pkg_dir, ".codecov.yml"))
|
||||||
rm(joinpath(pkg_dir, ".codecov.yml"))
|
rm(joinpath(pkg_dir, ".codecov.yml"))
|
||||||
p = CodeCov(; config_file=nothing)
|
p = CodeCov(; config_file=nothing)
|
||||||
@test isempty(gen_plugin(p, t, test_pkg))
|
@test isempty(gen_plugin(p, t, temp_dir, test_pkg))
|
||||||
@test !isfile(joinpath(pkg_dir, ".codecov.yml"))
|
@test !isfile(joinpath(pkg_dir, ".codecov.yml"))
|
||||||
@test_throws ArgumentError CodeCov(; config_file=fake_path)
|
@test_throws ArgumentError CodeCov(; config_file=fake_path)
|
||||||
|
|
||||||
p = GitHubPages()
|
p = GitHubPages()
|
||||||
@test gen_plugin(p, t, test_pkg) == ["docs/"]
|
@test gen_plugin(p, t, temp_dir, test_pkg) == ["docs/"]
|
||||||
@test isdir(joinpath(pkg_dir, "docs"))
|
@test isdir(joinpath(pkg_dir, "docs"))
|
||||||
@test isfile(joinpath(pkg_dir, "docs", "make.jl"))
|
@test isfile(joinpath(pkg_dir, "docs", "make.jl"))
|
||||||
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
||||||
@ -554,7 +535,7 @@ end
|
|||||||
@test index == "# $test_pkg"
|
@test index == "# $test_pkg"
|
||||||
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
||||||
p = GitHubPages(; assets=[test_file])
|
p = GitHubPages(; assets=[test_file])
|
||||||
@test gen_plugin(p, t, test_pkg) == ["docs/"]
|
@test gen_plugin(p, t, temp_dir, test_pkg) == ["docs/"]
|
||||||
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
||||||
@test contains(
|
@test contains(
|
||||||
make,
|
make,
|
||||||
@ -567,18 +548,18 @@ end
|
|||||||
@test isfile(joinpath(pkg_dir, "docs", "src", "assets", basename(test_file)))
|
@test isfile(joinpath(pkg_dir, "docs", "src", "assets", basename(test_file)))
|
||||||
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
||||||
t.plugins[TravisCI] = TravisCI()
|
t.plugins[TravisCI] = TravisCI()
|
||||||
@test gen_plugin(p, t, test_pkg) == ["docs/"]
|
@test gen_plugin(p, t, temp_dir, test_pkg) == ["docs/"]
|
||||||
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
make = readchomp(joinpath(pkg_dir, "docs", "make.jl"))
|
||||||
@test contains(make, "deploydocs")
|
@test contains(make, "deploydocs")
|
||||||
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
rm(joinpath(pkg_dir, "docs"); recursive=true)
|
||||||
@test_throws ArgumentError GitHubPages(; assets=[fake_path])
|
@test_throws ArgumentError GitHubPages(; assets=[fake_path])
|
||||||
|
|
||||||
p = Bar()
|
p = Bar()
|
||||||
@test isempty(gen_plugin(p, t, test_pkg))
|
@test isempty(gen_plugin(p, t, temp_dir, test_pkg))
|
||||||
p = Baz()
|
p = Baz()
|
||||||
@test isempty(gen_plugin(p, t, test_pkg))
|
@test isempty(gen_plugin(p, t, temp_dir, test_pkg))
|
||||||
|
|
||||||
rm(t.temp_dir; recursive=true)
|
rm(dirname(pkg_dir); recursive=true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Version floor" begin
|
@testset "Version floor" begin
|
||||||
@ -604,7 +585,6 @@ end
|
|||||||
@test contains(text, "Other")
|
@test contains(text, "Other")
|
||||||
|
|
||||||
t = Template(; user=me)
|
t = Template(; user=me)
|
||||||
rm(t.temp_dir; recursive=true)
|
|
||||||
view["OTHER"] = false
|
view["OTHER"] = false
|
||||||
|
|
||||||
text = substitute(template_text, t; view=view)
|
text = substitute(template_text, t; view=view)
|
||||||
@ -626,7 +606,7 @@ end
|
|||||||
@test contains(text, "After")
|
@test contains(text, "After")
|
||||||
empty!(t.plugins)
|
empty!(t.plugins)
|
||||||
|
|
||||||
t.plugins[CodeCov] = Coveralls()
|
t.plugins[Coveralls] = Coveralls()
|
||||||
text = substitute(template_text, t; view=view)
|
text = substitute(template_text, t; view=view)
|
||||||
@test contains(text, "Coveralls")
|
@test contains(text, "Coveralls")
|
||||||
@test contains(text, "After")
|
@test contains(text, "After")
|
||||||
@ -640,7 +620,7 @@ end
|
|||||||
@testset "License display" begin
|
@testset "License display" begin
|
||||||
old_stdout = STDOUT
|
old_stdout = STDOUT
|
||||||
out_read, out_write = redirect_stdout()
|
out_read, out_write = redirect_stdout()
|
||||||
show_license()
|
available_licenses()
|
||||||
licenses = join(Char(c) for c in readavailable(out_read))
|
licenses = join(Char(c) for c in readavailable(out_read))
|
||||||
show_license("MIT")
|
show_license("MIT")
|
||||||
mit = join(Char(c) for c in readavailable(out_read))
|
mit = join(Char(c) for c in readavailable(out_read))
|
||||||
|
Loading…
Reference in New Issue
Block a user