Package Generation

Package Generation

Creating new packages with PkgTemplates revolves around creating a new Template, then calling generate on it.

Template

Template(; kwargs...) -> Template

Records common information used to generate a package. If you don't wish to manually create a template, you can use interactive_template instead.

Keyword Arguments

  • 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. If neither is set, an ArgumentError is thrown. This is case-sensitive for some plugins, so take care to enter it correctly.

  • host::AbstractString="github.com": URL to the code hosting service where your package will reside. Note that while hosts other than GitHub won't cause errors, they are not officially supported and they will cause certain plugins will produce incorrect output. For example, AppVeyor's badge image will point to a GitHub-specific URL, regardless of the value of host.

  • license::AbstractString="MIT": Name of the package license. If an empty string is given, no license is created. available_licenses can be used to list all available licenses, and show_license can be used to print out a particular license's text.

  • authors::Union{AbstractString, Vector{<:AbstractString}}="": Names that appear on the license. Supply a string for one author or an array for multiple. Similarly to user, it will try to take the value of a supplied git config's "user.name" key, then the global git config's value, if it is left unset.

  • 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. Relative paths are converted to absolute ones at template creation time.

  • julia_version::VersionNumber=VERSION: Minimum allowed Julia version.

  • requirements::Vector{<:AbstractString}=String[]: Package requirements. If there are duplicate requirements with different versions, i.e. ["PkgTemplates", "PkgTemplates 0.1"], an ArgumentError is thrown. Each entry in this array will be copied into the REQUIRE file of packages generated with this template.

  • gitconfig::Dict=Dict(): Git configuration options.

  • plugins::Vector{<:Plugin}=Plugin[]: A list of Plugins that the package will include.

source
interactive_template(; fast::Bool=false) -> Template

Interactively create a Template. If fast is set, defaults will be assumed for all values except username and plugins.

source

generate

PkgTemplates.generateFunction.
generate(
    pkg_name::AbstractString,
    t::Template;
    force::Bool=false,
    ssh::Bool=false,
) -> Void

Generate a package named pkg_name from template.

Keyword Arguments

  • force::Bool=false: Whether or not to overwrite old packages with the same name.

  • ssh::Bool=false: Whether or not to use SSH for the remote.

  • backup_dir::AbstractString="": Directory in which to store the generated package if t.dir is not a valid directory. If left unset, a temporary directory will be created.

Notes

The package is generated entirely in a temporary directory and only moved into 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 (this is especially helpful when force=true).

source
generate_interactive(
    pkg_name::AbstractString;
    force::Bool=false,
    ssh::Bool=false,
    backup_dir::AbstractString="",
    fast::Bool=false,
) -> Void

Interactively create a template, and then generate a package with it. Arguments and keywords are used in the same way as in generate and interactive_template.

source

Helper Functions

gen_entrypoint

gen_entrypoint(
    dir::AbstractString,
    pkg_name::AbstractString,
    template::Template,
) -> Vector{String}

Create the module entrypoint in the temp package directory.

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.

  • template::Template: The template whose entrypoint we are generating.

Returns an array of generated file/directory names.

source

gen_tests

gen_tests(
    dir::AbstractString,
    pkg_name::AbstractString,
    template::Template,
) -> Vector{String}

Create the test directory and entrypoint in the temp package directory.

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.

  • template::Template: The template whose tests we are generating.

Returns an array of generated file/directory names.

source

gen_require

gen_require(
    dir::AbstractString,
    pkg_name::AbstractString,
    template::Template,
) -> Vector{String}

Create the REQUIRE file in the temp package directory.

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.

  • template::Template: The template whose REQUIRE we are generating.

Returns an array of generated file/directory names.

source

gen_readme

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.

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.

  • template::Template: The template whose README we are generating.

Returns an array of generated file/directory names.

source

gen_gitignore

gen_gitignore(
    dir::AbstractString,
    pkg_name::AbstractString,
    template::Template,
) -> Vector{String}

Create a .gitignore in the temp package directory.

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.

  • template::Template: The template whose .gitignore we are generating.

Returns an array of generated file/directory names.

source

gen_license

gen_license(
    dir::AbstractString,
    pkg_name::AbstractString,
    template::Template,
) -> Vector{String}

Create a license in the temp package directory.

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.

  • template::Template: The template whose LICENSE we are generating.

Returns an array of generated file/directory names.

source