Make Pkg.develop optional (close #78)

This commit is contained in:
Chris de Graaf 2019-06-17 10:22:00 -05:00
parent 77387b267b
commit f129e741b2
6 changed files with 28 additions and 10 deletions

View File

@ -82,9 +82,9 @@ version = "1.0.0"
[[Tables]]
deps = ["IteratorInterfaceExtensions", "LinearAlgebra", "Requires", "TableTraits", "Test"]
git-tree-sha1 = "9e748316f5aa7b7753c90de612ef98fe8b0ea297"
git-tree-sha1 = "351a4b894122e1553c6ed05fda54086ab036adef"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "0.2.1"
version = "0.2.5"
[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]

View File

@ -1,7 +1,7 @@
name = "PkgTemplates"
uuid = "14b8a8f1-9102-5b29-a752-f990bacb7fe1"
authors = ["Chris de Graaf <chrisadegraaf@gmail.com>"]
version = "0.6.0"
version = "0.6.1"
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

View File

@ -85,8 +85,10 @@ function generate(
end
end
if t.dev
# Add the new package to the current environment.
Pkg.develop(PackageSpec(path=pkg_dir))
end
@info "New package is at $pkg_dir"
catch e

View File

@ -25,6 +25,7 @@ create a template, you can use [`interactive_template`](@ref) instead.
package will go. Relative paths are converted to absolute ones at template creation time.
* `julia_version::VersionNumber=$(default_version())`: Minimum allowed Julia version.
* `ssh::Bool=false`: Whether or not to use SSH for the git remote. If `false` HTTPS will be used.
* `dev::Bool=true`: Whether or not to `Pkg.develop` generated packages.
* `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.
"""
@ -36,6 +37,7 @@ struct Template
dir::String
julia_version::VersionNumber
ssh::Bool
dev::Bool
manifest::Bool
plugins::Dict{DataType, <:Plugin}
@ -47,6 +49,7 @@ struct Template
dir::AbstractString=Pkg.devdir(),
julia_version::VersionNumber=default_version(),
ssh::Bool=false,
dev::Bool=true,
manifest::Bool=false,
plugins::Vector{<:Plugin}=Plugin[],
git::Bool=true,
@ -87,7 +90,7 @@ struct Template
@warn "Plugin list contained duplicates, only the last of each type was kept"
end
new(user, host, license, authors, dir, julia_version, ssh, manifest, plugin_dict)
new(user, host, license, authors, dir, julia_version, ssh, dev, manifest, plugin_dict)
end
end
@ -109,6 +112,7 @@ function Base.show(io::IO, t::Template)
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, "→ SSH remote: ", t.ssh ? "Yes" : "No")
println(io, spc, "→ Add packages to main environment: ", t.dev ? "Yes" : "No")
println(io, spc, "→ Commit Manifest.toml: ", t.manifest ? "Yes" : "No")
print(io, spc, "→ Plugins:")
@ -208,6 +212,13 @@ function interactive_template(; git::Bool=true, fast::Bool=false)
uppercase(readline()) in ["Y", "YES", "T", "TRUE"]
end
kwargs[:dev] = if fast
true
else
print("Add packages to main environment? [yes]: ")
uppercase(readline()) in ["", "Y", "YES", "T", "TRUE"]
end
kwargs[:manifest] = if fast
false
else

View File

@ -1,6 +1,6 @@
@testset "Interactive mode" begin
@testset "Template creation" begin
write(stdin.buffer, "$me\n\n\r\n\n\n\nd")
write(stdin.buffer, "$me\n\n\r\n\n\n\n\nd")
t = interactive_template()
@test t.user == me
@test t.host == "github.com"
@ -9,6 +9,8 @@
@test t.dir == default_dir
@test t.julia_version == VERSION
@test !t.ssh
@test t.dev
@test !t.manifest
@test isempty(t.plugins)
if isempty(LibGit2.getconfig("github.user", ""))
@ -17,7 +19,7 @@
end
down = '\x1b' * "[B" # Down array key.
write(stdin.buffer, "$me\ngitlab.com\n$down\r$me\n$test_file\n0.5\nyes\nyes\n$down\r$down\rd\n\n")
write(stdin.buffer, "$me\ngitlab.com\n$down\r$me\n$test_file\n0.5\nyes\nno\nyes\n$down\r$down\rd\n\n")
t = interactive_template()
@test t.user == me
@test t.host == "gitlab.com"
@ -27,6 +29,7 @@
@test t.dir == abspath(test_file)
@test t.julia_version == v"0.5.0"
@test t.ssh
@test !t.dev
@test t.manifest
# Like above, not sure which plugins this will generate.
@test length(t.plugins) == 2
@ -45,7 +48,7 @@
println()
# Host and SSH aren't prompted for when git is disabled.
write(stdin.buffer, "$me\n\n\r\n\n\nd")
write(stdin.buffer, "$me\n\n\r\n\n\n\nd")
t = interactive_template(; git=false)
@test t.host == "github.com"
@test !t.ssh
@ -53,7 +56,7 @@
end
@testset "Package generation" begin
write(stdin.buffer, "$me\n\n\r\n\n\n\n\n\n\nd")
write(stdin.buffer, "$me\n\n\r\n\n\n\n\n\n\n\nd")
generate_interactive(test_pkg; gitconfig=gitconfig)
@test isdir(joinpath(default_dir, test_pkg))
rm(joinpath(default_dir, test_pkg); force=true, recursive=true)

View File

@ -120,6 +120,7 @@ end
Package directory: $pkg_dir
Minimum Julia version: v$ver
SSH remote: No
Add packages to main environment: Yes
Commit Manifest.toml: No
Plugins: None
"""
@ -145,6 +146,7 @@ end
Package directory: $pkg_dir
Minimum Julia version: v$ver
SSH remote: Yes
Add packages to main environment: Yes
Commit Manifest.toml: Yes
Plugins:
Codecov: