Merge pull request #61 from invenia/cdg/plugins

Package overhaul
This commit is contained in:
Chris de Graaf 2019-11-10 12:58:53 +08:00 committed by GitHub
commit 055f37d720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
165 changed files with 5411 additions and 4075 deletions

View File

@ -1 +0,0 @@
comment: false

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
* eol=lf

8
.gitignore vendored
View File

@ -1,6 +1,4 @@
.DS_Store
*.jl.cov
*.jl.*.cov
*.jl.mem
/docs/build/
/docs/site/
*.jl.*.cov
*.jl.cov
*.jl.mem

View File

@ -1,25 +1,40 @@
language: julia
notifications:
email: false
os:
- linux
- osx
- windows
julia:
- 1.0
- 1.1
- 1.2
- 1.3
- nightly
before_script:
- git config --global user.name Tester
- git config --global user.email te@st.er
matrix:
allow_failures:
- julia: nightly
fast_finish: true
notifications:
email: false
after_success: julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
jobs:
allow_failures:
- julia: 1.3
- julia: nightly
include:
- arch: x86
julia: 1.0
- stage: Documentation
julia: 1.1
script: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
julia: 1.0
script:
- git config --global user.name name
- git config --global user.email email
- git config --global github.user username
- julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(; path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
after_success: skip
after_success: julia -e '
using Pkg;
Pkg.add("Coverage");
using Coverage;
Codecov.submit(process_folder());'

View File

@ -1,3 +1,5 @@
MIT License
Copyright (c) 2017-2019 Chris de Graaf, Invenia Technical Computing Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy

View File

@ -3,6 +3,16 @@
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[DataAPI]]
git-tree-sha1 = "674b67f344687a88310213ddfa8a2b3c76cc4252"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.1.0"
[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"
[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
@ -39,9 +49,21 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[Mustache]]
deps = ["Printf", "Tables"]
git-tree-sha1 = "d27b8b8b99c052ea1fdd40c678bfb2dfaec4e96e"
git-tree-sha1 = "f39de3a12232eb47bd0629b3a661054287780276"
uuid = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70"
version = "0.5.12"
version = "0.5.13"
[[OrderedCollections]]
deps = ["Random", "Serialization", "Test"]
git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.1.0"
[[Parameters]]
deps = ["OrderedCollections"]
git-tree-sha1 = "b62b2558efb1eef1fa44e4be5ff58a515c287e38"
uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a"
version = "0.12.0"
[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
@ -59,12 +81,6 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[Requires]]
deps = ["Test"]
git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "0.5.2"
[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
@ -81,21 +97,15 @@ uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.0"
[[Tables]]
deps = ["IteratorInterfaceExtensions", "LinearAlgebra", "Requires", "TableTraits", "Test"]
git-tree-sha1 = "351a4b894122e1553c6ed05fda54086ab036adef"
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "aaed7b3b00248ff6a794375ad6adf30f30ca5591"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "0.2.5"
version = "0.2.11"
[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[URIParser]]
deps = ["Test", "Unicode"]
git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69"
uuid = "30578b45-9adc-5946-b283-645ec420af67"
version = "0.4.0"
[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

View File

@ -1,22 +1,26 @@
name = "PkgTemplates"
uuid = "14b8a8f1-9102-5b29-a752-f990bacb7fe1"
authors = ["Chris de Graaf <chrisadegraaf@gmail.com>"]
version = "0.6.3"
authors = ["Chris de Graaf", "Invenia Technical Computing Corporation"]
version = "0.7.0"
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
Mustache = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
URIParser = "30578b45-9adc-5946-b283-645ec420af67"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[compat]
Mustache = ">= 0.5.13"
julia = "1"
[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
SimpleMock = "a896ed2c-15a5-4479-b61d-a0e88e2a1d25"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]
test = ["Suppressor", "Random", "ReferenceTests", "SimpleMock", "Test"]

153
README.md
View File

@ -1,147 +1,56 @@
# PkgTemplates
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://invenia.github.io/PkgTemplates.jl/stable)
[![Latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://invenia.github.io/PkgTemplates.jl/latest)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://invenia.github.io/PkgTemplates.jl/dev)
[![Build Status](https://travis-ci.org/invenia/PkgTemplates.jl.svg?branch=master)](https://travis-ci.org/invenia/PkgTemplates.jl)
[![Build Status](https://ci.appveyor.com/api/projects/status/r24xamruqlm88uti/branch/master?svg=true)](https://ci.appveyor.com/project/christopher-dG/pkgtemplates-jl/branch/master)
[![Codecov](https://codecov.io/gh/invenia/PkgTemplates.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/invenia/PkgTemplates.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
**PkgTemplates is a Julia package for creating new Julia packages in an easy,
repeatable, and customizable way.**
**PkgTemplates creates new Julia packages in an easy, repeatable, and customizable way.**
## Installation
```julia
pkg> add PkgTemplates
Install with Pkg, just like any other registered Julia package:
```jl
pkg> add PkgTemplates # Press ']' to enter te Pkg REPL mode.
```
## Plugins
`PkgTemplates` is based on plugins which handle the setup of individual package components.
The available plugins are:
* Continuous Integration (CI)
* [Travis CI](https://travis-ci.com) (Linux, MacOS)
* [AppVeyor](https://appveyor.com) (Windows)
* [GitLabCI](https://gitlab.com) (Linux)
* [CirrusCI](https://cirrus-ci.org) (FreeBSD)
* Code Coverage
* [Codecov](https://codecov.io)
* [Coveralls](https://coveralls.io)
* Documentation
* [GitHubPages](https://pages.github.com)
* Citation
## Usage
Assuming you have the relatively standard Git options `user.name`, `user.email` and `github.user` set up globally with `git config --global`, the simplest template requires no arguments:
Creating a `Template` is as simple as:
```julia
julia> using PkgTemplates
julia> t = Template()
Template:
→ User: christopher-dG
→ Host: github.com
→ License: MIT (Chris de Graaf 2018)
→ Package directory: ~/.julia/dev
→ Minimum Julia version: v1.0
→ SSH remote: No
→ Commit Manifest.toml: No
→ Plugins: None
julia> generate("MyPkg", t)
julia> run(`git -C $(joinpath(t.dir, "MyPkg")) ls-files`);
.gitignore
LICENSE
Manifest.toml
Project.toml
README.md
REQUIRE
src/MyPkg.jl
test/runtests.jl
```jl
using PkgTemplates
t = Template()
```
However, we can also configure a number of keyword arguments to `Template`:
The no-keywords constructor assumes the existence of some preexisting Git configuration (set with `git config --global`):
```julia
julia> t = Template(;
user="myusername",
license="ISC",
authors=["Chris de Graaf", "Invenia Technical Computing Corporation"],
dir="~/code",
julia_version=v"0.7",
plugins=[
TravisCI(),
Codecov(),
Coveralls(),
AppVeyor(),
GitHubPages(),
CirrusCI(),
],
)
Template:
→ User: myusername
→ Host: github.com
→ License: ISC (Chris de Graaf, Invenia Technical Computing Corporation 2018)
→ Package directory: ~/code
→ Minimum Julia version: v0.7
→ SSH remote: No
→ Commit Manifest.toml: No
→ Plugins:
• AppVeyor:
→ Config file: Default
→ 0 gitignore entries
• Codecov:
→ Config file: None
→ 3 gitignore entries: "*.jl.cov", "*.jl.*.cov", "*.jl.mem"
• Coveralls:
→ Config file: None
→ 3 gitignore entries: "*.jl.cov", "*.jl.*.cov", "*.jl.mem"
• GitHubPages:
→ 0 asset files
→ 2 gitignore entries: "/docs/build/", "/docs/site/"
• TravisCI:
→ Config file: Default
→ 0 gitignore entries
- `user.name`: Your real name, e.g. John Smith.
- `user.email`: Your email address, eg. john.smith@acme.corp.
- `github.user`: Your GitHub username: e.g. john-smith.
julia> generate(t, "MyPkg2")
Once you have a `Template`, use it to generate a package:
julia> run(`git -C $(joinpath(t.dir, "MyPkg2")) ls-files`);
.appveyor.yml
.gitignore
.travis.yml
LICENSE
Project.toml
README.md
REQUIRE
docs/Manifest.toml
docs/Project.toml
docs/make.jl
docs/src/index.md
src/MyPkg2.jl
test/runtests.jl
```jl
t("MyPkg")
```
Information on each keyword as well as plugin types can be found in the
[documentation](https://invenia.github.io/PkgTemplates.jl/stable).
However, it's probably desirable to customize the template to your liking with various options and plugins:
If that looks like a lot of work, you can also create templates interactively
with `interactive_template`:
```jl
t = Template(;
dir="~/code",
plugins=[
Git(; manifest=true, ssh=true),
Codecov(),
TravisCI(; x86=true),
Documenter{TravisCI}(),
],
)
```
[![asciicast](https://asciinema.org/a/31bZqW9u8h5RHpd7gtsemioRV.png)](https://asciinema.org/a/31bZqW9u8h5RHpd7gtsemioRV)
---
And if that's **still** too much work for you, you can call
`interactive_template` with `fast=true` to use default values for everything
but username and plugin selection.
You can also use `generate_interactive` to interactively generate a template and then
immediately use it to create a new package.
## Contributing
It's extremely easy to extend `PkgTemplates` with new plugins. To get started,
check out the
[plugin development guide](https://invenia.github.io/PkgTemplates.jl/stable/pages/plugin_development.html).
For a much more detailled overview, please see the documentation.

View File

@ -1,3 +0,0 @@
julia 0.7
Mustache
URIParser

View File

@ -1,29 +0,0 @@
---
kind: pipeline
name: linux - arm - Julia {{VERSION}}
platform:
os: linux
arch: arm
steps:
- name: build
image: julia:{{VERSION}}
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"
---
kind: pipeline
name: linux - arm64 - Julia {{VERSION}}
platform:
os: linux
arch: arm64
steps:
- name: build
image: julia:{{VERSION}}
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"
...

View File

@ -1,26 +0,0 @@
Julia {{VERSION}}:
image: julia:{{VERSION}}
script: julia --project='@.' -e 'using Pkg; Pkg.build(); Pkg.test({{#GITLABCOVERAGE}}; coverage=true{{/GITLABCOVERAGE}})'
{{#GITLABCOVERAGE}}
coverage: /Test Coverage (\d+\.\d+%)/
after_script:
- julia -e 'using Printf; using Pkg; Pkg.add("Coverage"); using Coverage; c, t = get_summary(process_folder()); @printf "Test Coverage %.2f%%\n" 100c/t'
{{/GITLABCOVERAGE}}
{{#DOCUMENTER}}
pages:
image: julia:{{VERSION}}
stage: deploy
script:
- julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
- mkdir -p public
- mv docs/build public/dev
artifacts:
paths:
- public
only:
- master
{{/DOCUMENTER}}

View File

@ -1,35 +0,0 @@
# Documentation: http://docs.travis-ci.com/user/languages/julia/
language: julia
os:
- linux
- osx
julia:
- {{VERSION}}
- nightly
matrix:
allow_failures:
- julia: nightly
fast_finish: true
notifications:
email: false
{{#COVERAGE}}
after_success:
{{#CODECOV}}
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
{{/CODECOV}}
{{#COVERALLS}}
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
{{/COVERALLS}}
{{/COVERAGE}}
{{#DOCUMENTER}}
jobs:
include:
- stage: Documentation
julia: {{VERSION}}
script: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
after_success: skip
{{/DOCUMENTER}}

View File

@ -1,3 +1,5 @@
# This file is machine-generated - editing it directly is not advised
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@ -6,35 +8,34 @@ deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[Distributed]]
deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
git-tree-sha1 = "1df01539a1c952cef21f2d2d1c092c2bcf0177d7"
git-tree-sha1 = "88bb0edb352b16608036faadcc071adda068582a"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.6.0"
version = "0.8.1"
[[Documenter]]
deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "LibGit2", "Logging", "Markdown", "Pkg", "REPL", "Random", "Test", "Unicode"]
git-tree-sha1 = "a6db1c69925cdc53aafb38caec4446be26e0c617"
deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "d45c163c7a3ae293c15361acc52882c0f853f97c"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.21.0"
version = "0.23.4"
[[InteractiveUtils]]
deps = ["LinearAlgebra", "Markdown"]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.0"
[[LibGit2]]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
@ -42,6 +43,15 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "ef0af6c8601db18c282d092ccbd2f01f3f0cd70b"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "0.3.7"
[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
@ -72,7 +82,7 @@ deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[UUIDs]]
deps = ["Random"]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[[Unicode]]

View File

@ -1,20 +1,22 @@
using Documenter, PkgTemplates
using Documenter: Documenter, makedocs, deploydocs
using PkgTemplates: PkgTemplates
makedocs(;
modules=[PkgTemplates],
format=Documenter.HTML(),
pages=[
"Home" => "index.md",
"Package Generation" => "pages/package_generation.md",
"Plugins" => "pages/plugins.md",
"Plugin Development" => "pages/plugin_development.md",
"Licenses" => "pages/licenses.md",
"Index" => "pages/index.md",
],
authors="Chris de Graaf, Invenia Technical Computing Corporation",
repo="https://github.com/invenia/PkgTemplates.jl/blob/{commit}{path}#L{line}",
sitename="PkgTemplates.jl",
authors="Chris de Graaf, Invenia Technical Computing Corporation",
assets=[],
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://invenia.github.io/PkgTemplates.jl",
assets=String[],
),
pages=[
"Home" => "index.md",
"User Guide" => "user.md",
"Developer Guide" => "developer.md",
"Migrating To PkgTemplates 0.7+" => "migrating.md",
],
)
deploydocs(;

344
docs/src/developer.md Normal file
View File

@ -0,0 +1,344 @@
```@meta
CurrentModule = PkgTemplates
```
# PkgTemplates Developer Guide
```@contents
Pages = ["developer.md"]
```
PkgTemplates can be easily extended by adding new [`Plugin`](@ref)s.
There are two types of plugins: [`Plugin`](@ref) and [`BasicPlugin`](@ref).
```@docs
Plugin
BasicPlugin
```
## Template + Package Creation Pipeline
The [`Template`](@ref) constructor basically does this:
```
- extract values from keyword arguments
- create a Template from the values
- for each plugin:
- validate plugin against the template
```
The plugin validation step uses the [`validate`](@ref) function.
It lets us catch mistakes before we try to generate packages.
```@docs
validate
```
The package generation process looks like this:
```
- create empty directory for the package
- for each plugin, ordered by priority:
- run plugin prehook
- for each plugin, ordered by priority:
- run plugin hook
- for each plugin, ordered by priority:
- run plugin posthook
```
As you can tell, plugins play a central role in setting up a package.
The three main entrypoints for plugins to do work are the [`prehook`](@ref), the [`hook`](@ref), and the [`posthook`](@ref).
As the names might imply, they basically mean "before the main stage", "the main stage", and "after the main stage", respectively.
Each stage is basically identical, since the functions take the exact same arguments.
However, the multiple stages allow us to depend on artifacts of the previous stages.
For example, the [`Git`](@ref) plugin uses [`posthook`](@ref) to commit all generated files, but it wouldn't make sense to do that before the files are generated.
But what about dependencies within the same stage?
In this case, we have [`priority`](@ref) to define which plugins go when.
The [`Git`](@ref) plugin also uses this function to lower its posthook's priority, so that even if other plugins generate files in their posthooks, they still get committed (provided that those plugins didn't set an even lower priority).
```@docs
prehook
hook
posthook
priority
```
## `Plugin` Walkthrough
Concrete types that subtype [`Plugin`](@ref) directly are free to do almost anything.
To understand how they're implemented, let's look at simplified versions of two plugins: [`Documenter`](@ref) to explore templating, and [`Git`](@ref) to further clarify the multi-stage pipeline.
### Example: `Documenter`
```julia
@with_kw_noshow struct Documenter <: Plugin
make_jl::String = default_file("docs", "make.jl") <- "Path to make.jl template"
index_md::String = default_file("docs", "src", "index.md") <- "Path to index.md template"
end
gitignore(::Documenter) = ["/docs/build/"]
badges(::Documenter) = [
Badge(
"Stable",
"https://img.shields.io/badge/docs-stable-blue.svg",
"https://{{{USER}}}.github.io/{{{PKG}}}.jl/stable",
),
Badge(
"Dev",
"https://img.shields.io/badge/docs-dev-blue.svg",
"https://{{{USER}}}.github.io/{{{PKG}}}.jl/dev",
),
]
view(p::Documenter, t::Template, pkg::AbstractString) = Dict(
"AUTHORS" => join(t.authors, ", "),
"PKG" => pkg,
"REPO" => "$(t.host)/$(t.user)/$pkg.jl",
"USER" => t.user,
)
function hook(p::Documenter, t::Template, pkg_dir::AbstractString)
pkg = basename(pkg_dir)
docs_dir = joinpath(pkg_dir, "docs")
make = render_file(p.make_jl, combined_view(p, t, pkg), tags(p))
gen_file(joinpath(docs_dir, "make.jl"), make)
index = render_file(p.index_md, combined_view(p, t, pkg), tags(p))
gen_file(joinpath(docs_dir, "src", "index.md"), index)
# What this function does is not relevant here.
create_documentation_project()
end
```
The `@with_kw_noshow` macro defines keyword constructors for us.
Inside of our struct definition, we're using [`default_file`](@ref) to refer to files in this repository.
```@docs
default_file
```
The first method we implement for `Documenter` is [`gitignore`](@ref), so that packages created with this plugin ignore documentation build artifacts.
```@docs
gitignore
```
Second, we implement [`badges`](@ref) to add a couple of badges to new packages' README files.
```@docs
badges
Badge
```
These two functions, [`gitignore`](@ref) and [`badges`](@ref), are currently the only "special" functions for cross-plugin interactions.
In other cases, you can still access the [`Template`](@ref)'s plugins to depend on the presence/properties of other plugins, although that's less powerful.
Third, we implement [`view`](@ref), which is used to fill placeholders in badges and rendered files.
```@docs
view
```
Finally, we implement [`hook`](@ref), which is the real workhorse for the plugin.
Inside of this function, we generate a couple of files with the help of a few more text templating functions.
```@docs
render_file
render_text
gen_file
combined_view
tags
```
For more information on text templating, see the [`BasicPlugin` Walkthrough](@ref) and the section on [Custom Template Files](@ref).
### Example: `Git`
```julia
struct Git <: Plugin end
priority(::Git, ::typeof(posthook)) = 5
function validate(::Git, ::Template)
foreach(("user.name", "user.email")) do k
if isempty(LibGit2.getconfig(k, ""))
throw(ArgumentError("Git: Global Git config is missing required value '$k'"))
end
end
end
function prehook(::Git, t::Template, pkg_dir::AbstractString)
LibGit2.with(LibGit2.init(pkg_dir)) do repo
LibGit2.commit(repo, "Initial commit")
pkg = basename(pkg_dir)
url = "https://$(t.host)/$(t.user)/$pkg.jl"
close(GitRemote(repo, "origin", url))
end
end
function hook(::Git, t::Template, pkg_dir::AbstractString)
ignore = mapreduce(gitignore, append!, t.plugins)
unique!(sort!(ignore))
gen_file(joinpath(pkg_dir, ".gitignore"), join(ignore, "\n"))
end
function posthook(::Git, ::Template, pkg_dir::AbstractString)
LibGit2.with(GitRepo(pkg_dir)) do repo
LibGit2.add!(repo, ".")
LibGit2.commit(repo, "Files generated by PkgTemplates")
end
end
```
Validation and all three hooks are implemented:
- [`validate`](@ref) makes sure that all required Git configuration is present.
- [`prehook`](@ref) creates the Git repository for the package.
- [`hook`](@ref) generates the `.gitignore` file, using the special [`gitignore`](@ref) function.
- [`posthook`](@ref) adds and commits all the generated files.
As previously mentioned, we use [`priority`](@ref) to make sure that we wait until all other plugins are finished their work before committing files.
Hopefully, this demonstrates the level of control you have over the package generation process when developing plugins, and when it makes sense to exercise that power!
## `BasicPlugin` Walkthrough
Most of the time, you don't really need all of the control that we showed off above.
Plugins that subtype [`BasicPlugin`](@ref) perform a much more limited task.
In general, they just generate one templated file.
To illustrate, let's look at the [`Citation`](@ref) plugin, which creates a `CITATION.bib` file.
```julia
@with_kw_noshow struct Citation <: BasicPlugin
file::String = default_file("CITATION.bib")
end
source(p::Citation) = p.file
destination(::Citation) = "CITATION.bib"
tags(::Citation) = "<<", ">>"
view(::Citation, t::Template, pkg::AbstractString) = Dict(
"AUTHORS" => join(t.authors, ", "),
"MONTH" => month(today()),
"PKG" => pkg,
"URL" => "https://$(t.host)/$(t.user)/$pkg.jl",
"YEAR" => year(today()),
)
```
Similar to the `Documenter` example above, we're defining a keyword constructor, and assigning a default template file from this repository.
This plugin adds nothing to `.gitignore`, and it doesn't add any badges, so implementations for [`gitignore`](@ref) and [`badges`](@ref) are omitted.
First, we implement [`source`](@ref) and [`destination`](@ref) to define where the template file comes from, and where it goes.
These functions are specific to [`BasicPlugin`](@ref)s, and have no effect on regular [`Plugin`](@ref)s by default.
```@docs
source
destination
```
Next, we implement [`tags`](@ref).
We briefly saw this function earlier, but in this case it's necessary to change its behaviour from the default.
To see why, it might help to see the template file in its entirety:
```
@misc{<<&PKG>>.jl,
author = {<<&AUTHORS>>},
title = {<<&PKG>>.jl},
url = {<<&URL>>},
version = {v0.1.0},
year = {<<&YEAR>>},
month = {<<&MONTH>>}
}
```
Because the file contains its own `{}` delimiters, we need to use different ones for templating to work properly.
Finally, we implement [`view`](@ref) to fill in the placeholders that we saw in the template file.
## Doing Extra Work With `BasicPlugin`s
Notice that we didn't have to implement [`hook`](@ref) for our plugin.
It's implemented for all [`BasicPlugin`](@ref)s, like so:
```julia
function render_plugin(p::BasicPlugin, t::Template, pkg::AbstractString)
return render_file(source(p), combined_view(p, t, pkg), tags(p))
end
function hook(p::BasicPlugin, t::Template, pkg_dir::AbstractString)
source(p) === nothing && return
pkg = basename(pkg_dir)
path = joinpath(pkg_dir, destination(p))
text = render_plugin(p, t, pkg)
gen_file(path, text)
end
```
But what if we want to do a little more than just generate one file?
A good example of this is the [`Tests`](@ref) plugin.
It creates `runtests.jl`, but it also modifies the `Project.toml` to include the `Test` dependency.
Of course, we could use a normal [`Plugin`](@ref), but it turns out there's a way to avoid that while still getting the extra capbilities that we want.
The plugin implements its own `hook`, but uses `invoke` to avoid duplicating the file creation code:
```julia
@with_kw_noshow struct Tests <: BasicPlugin
file::String = default_file("runtests.jl")
end
source(p::Tests) = p.file
destination(::Tests) = joinpath("test", "runtests.jl")
view(::Tests, ::Template, pkg::AbstractString) = Dict("PKG" => pkg)
function hook(p::Tests, t::Template, pkg_dir::AbstractString)
# Do the normal BasicPlugin behaviour to create the test script.
invoke(hook, Tuple{BasicPlugin, Template, AbstractString}, p, t, pkg_dir)
# Do some other work.
add_test_dependency()
end
```
There is also a default [`validate`](@ref) implementation for [`BasicPlugin`](@ref)s, which checks that the plugin's [`source`](@ref) file exists, and throws an `ArgumentError` otherwise.
If you want to extend the validation but keep the file existence check, use the `invoke` method as described above.
For more examples, see the plugins in the [Continuous Integration (CI)](@ref) and [Code Coverage](@ref) sections.
## Miscellaneous Tips
### Writing Template Files
For an overview of writing template files for Mustache.jl, see [Custom Template Files](@ref) in the user guide.
### Predicates
There are a few predicate functions for plugins that are occasionally used to answer questions like "does this `Template` have any code coverage plugins?".
If you're implementing a plugin that fits into one of the following categories, it would be wise to implement the corresponding predicate function to return `true` for instances of your type.
```@docs
needs_username
is_ci
is_coverage
```
### Formatting Version Numbers
When writing configuration files for CI services, working with version numbers is often needed.
There are a few convenience functions that can be used to make this a little bit easier.
```@docs
compat_version
format_version
collect_versions
```

View File

@ -1,107 +1,20 @@
```@meta
CurrentModule = PkgTemplates
```
# PkgTemplates
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://invenia.github.io/PkgTemplates.jl/stable)
[![Latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://invenia.github.io/PkgTemplates.jl/latest)
[![Build Status](https://travis-ci.org/invenia/PkgTemplates.jl.svg?branch=master)](https://travis-ci.org/invenia/PkgTemplates.jl)
[![Build Status](https://ci.appveyor.com/api/projects/status/r24xamruqlm88uti/branch/master?svg=true)](https://ci.appveyor.com/project/christopher-dG/pkgtemplates-jl/branch/master)
[![Codecov](https://codecov.io/gh/invenia/PkgTemplates.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/invenia/PkgTemplates.jl)
**PkgTemplates creates new Julia packages in an easy, repeatable, and customizable way.**
**PkgTemplates is a Julia package for creating new Julia packages in an easy,
repeatable, and customizable way.**
## Documentation
## Installation
If you're looking to **create new packages**, see the [User Guide](user.md).
```julia
pkg> add PkgTemplates
If you want to **create new plugins**, see the [Developer Guide](developer.md).
if you're trying to **migrate from an older version of PkgTemplates**, see [Migrating To PkgTemplates 0.7+](migrating.md).
## Index
```@index
```
## Plugins
`PkgTemplates` is based on plugins which handle the setup of individual package components.
The available plugins are:
* Continuous Integration (CI)
* [Travis CI](https://travis-ci.com) (Linux, MacOS)
* [AppVeyor](https://appveyor.com) (Windows)
* [GitLabCI](https://gitlab.com) (Linux)
* [CirrusCI](https://cirrus-ci.org) (FreeBSD)
* Code Coverage
* [Codecov](https://codecov.io)
* [Coveralls](https://coveralls.io)
* Documentation
* [GitHubPages](https://pages.github.com)
* Citation
## Usage
```@setup usage
using LibGit2: getconfig
isempty(getconfig("user.name", "")) && run(`git config --global user.name "Travis"`)
isempty(getconfig("user.email", "")) && run(`git config --global user.email "travis@c.i"`)
isempty(getconfig("github.user", "")) && run(`git config --global github.user "travis"`)
using Pkg
Pkg.activate(mktempdir())
# This code gets run in docs/build/, so this path evaluates to the repo root.
Pkg.add(PackageSpec(path=dirname(dirname(pwd()))))
```
Assuming you have the relatively standard Git options `user.name`, `user.email` and `github.user` set up globally with `git config --global`, the simplest template requires no arguments:
```@repl usage
using PkgTemplates
t = Template()
generate("MyPkg", t)
run(`git -C $(joinpath(t.dir, "MyPkg")) ls-files`);
```
However, we can also configure a number of keyword arguments to
[`Template`](@ref):
```@repl usage
using PkgTemplates
t = Template(;
user="myusername",
license="MIT",
authors=["Chris de Graaf", "Invenia Technical Computing Corporation"],
dir="~/code",
julia_version=v"0.7",
ssh=true,
plugins=[
TravisCI(),
Codecov(),
Coveralls(),
AppVeyor(),
GitHubPages(),
CirrusCI(),
],
)
generate("MyPkg2", t)
run(`git -C $(joinpath(t.dir, "MyPkg2")) ls-files`);
```
If that looks like a lot of work, you can also create templates interactively
with [`interactive_template`](@ref):
[![asciicast](https://asciinema.org/a/31bZqW9u8h5RHpd7gtsemioRV.png)](https://asciinema.org/a/31bZqW9u8h5RHpd7gtsemioRV)
And if that's **still** too much work for you, you can call
`interactive_template` with `fast=true` to use default values for everything
but username and plugin selection.
You can also use [`generate_interactive`](@ref) to interactively generate a template and then
immediately use it to create a new package.
## Comparison to PkgDev
`PkgTemplates` is similar in functionality to
[`PkgDev`](https://github.com/JuliaLang/PkgDev.jl)'s `generate` function. However,
`PkgTemplates` offers more customizability in templates and more extensibility via plugins.
For the package registration and release management features that `PkgTemplates` doesn't
include, you are encouraged to use [AttoBot](https://github.com/apps/attobot) instead.
## Contributing
It's extremely easy to extend `PkgTemplates` with new plugins. To get started,
check out the
[plugin development guide](https://invenia.github.io/PkgTemplates.jl/stable/pages/plugin_development.html).

61
docs/src/migrating.md Normal file
View File

@ -0,0 +1,61 @@
```@meta
CurrentModule = PkgTemplates
```
# Migrating To PkgTemplates 0.7+
PkgTemplates 0.7 is a ground-up rewrite of the package with similar functionality but with updated APIs and internals.
Here is a summary of things that existed in older versions but have been moved elsewhere or removed.
However, it might be easier to just read the [User Guide](user.md).
## Template keywords
The recurring theme is "everything is a plugin now".
| Old | New |
| :------------------: | :-------------------------------: |
| `license="ISC"` | `plugins=[License(; name="ISC")]` |
| `develop=true` * | `plugins=[Develop()]` |
| `git=false` | `disable_defaults=[Git]` |
| `julia_version=v"1"` | `julia=v"1"` |
| `ssh=true` | `plugins=[Git(; ssh=true)]` |
| `manifest=true` | `plugins=[Git(; manifest=true)]` |
\* `develop=true` was the default setting, but it is no longer the default in PkgTemplates 0.7+.
## Plugins
Aside from renamings, basically every plugin has had their constructors reworked.
So if you are using anything non-default, you should consult the new docstring.
| Old | New |
| :-----------: | :--------------------: |
| `GitHubPages` | `Documenter{TravisCI}` |
| `GitLabPages` | `Documenter{GitLabCI}` |
## Package Generation
One less name to remember!
| Old | New |
| :-----------------------------------------: | :---------------------------------: |
| `generate(::Template, pkg::AbstractString)` | `(::Template)(pkg::AbstractString)` |
## Interactive Templates
Currently not implemented, but will be in the future.
## Other Functions
Two less names to remember!
Although it's unlikely that anyone used these.
| Old | New |
| :------------------: | :--------------------------------------------------------------------------------------------------: |
| `available_licenses` | [View licenses on GitHub](https://github.com/invenia/PkgTemplates.jl/tree/master/templates/licenses) |
| `show_license` | [View licenses on GitHub](https://github.com/invenia/PkgTemplates.jl/tree/master/templates/licenses) |
## Custom Plugins
In addition to the changes in usage, custom plugins from older versions of PkgTemplates will not work in 0.7+.
See the [Developer Guide](developer.md) for more information on the new extension API.

View File

@ -1,4 +0,0 @@
# Index
```@index
```

View File

@ -1,20 +0,0 @@
```@meta
CurrentModule = PkgTemplates
```
# Licenses
[Many open-source licenses](https://github.com/christopher-dG/PkgTemplates.jl/tree/master/licenses)
are available for use with `PkgTemplates`, but if you see that one is missing,
don't hesitate to open an issue or PR.
```@docs
available_licenses
show_license
```
### Helper Functions
```@docs
read_license
```

View File

@ -1,31 +0,0 @@
```@meta
CurrentModule = PkgTemplates
```
# Package Generation
Creating new packages with `PkgTemplates` revolves around creating a new
[`Template`](@ref), then calling [`generate`](@ref) on it.
## `Template`
```@docs
Template
interactive_template
```
## `generate`
```@docs
generate
generate_interactive
```
### Helper Functions
```@docs
gen_tests
gen_readme
gen_gitignore
gen_license
```

View File

@ -1,75 +0,0 @@
```@meta
CurrentModule = PkgTemplates
```
# Plugin Development
The best and easiest way to contribute to `PkgTemplates` is to write new
plugins.
```@docs
Plugin
```
## Generic Plugins
```@docs
GenericPlugin
```
## Custom Plugins
```@docs
CustomPlugin
```
### `CustomPlugin` Required Methods
#### `gen_plugin`
```@docs
gen_plugin
interactive
```
**Note**: [`interactive`](@ref) is not strictly required, however without it,
your custom plugin will not be available when creating templates with
[`interactive_template`](@ref).
#### `badges`
```@docs
badges
```
## Helper Types/Functions
#### `gen_file`
```@docs
gen_file
```
#### `substitute`
```@docs
substitute
```
#### `Badge`
```@docs
Badge
```
#### `format`
```@docs
format
```
#### `version_floor`
```@docs
version_floor
```

View File

@ -1,33 +0,0 @@
```@meta
CurrentModule = PkgTemplates
```
# Plugins
Plugins are the secret sauce behind `PkgTemplates`'s customization and extension. This page
describes plugins that already exist; for information on writing your own plugins, see
[Plugin Development](@ref).
## Continuous Integration (CI)
```@docs
TravisCI
AppVeyor
GitLabCI
CirrusCI
```
## Code Coverage
```@docs
Codecov
Coveralls
```
## Documentation
```@docs
Documenter
GitHubPages
GitLabPages
```

276
docs/src/user.md Normal file
View File

@ -0,0 +1,276 @@
```@meta
CurrentModule = PkgTemplates
```
# PkgTemplates User Guide
```@contents
Pages = ["user.md"]
```
Using PkgTemplates is straightforward.
Just create a [`Template`](@ref), and call it on a package name to generate that package:
```julia
using PkgTemplates
t = Template()
t("MyPkg")
```
## Template
```@docs
Template
```
## Plugins
Plugins add functionality to `Template`s.
There are a number of plugins available to automate common boilerplate tasks.
### Default Plugins
These plugins are included by default.
They can be overridden by supplying another value via the `plugins` keyword, or disabled by supplying the type via the `disable_defaults` keyword.
```@docs
ProjectFile
SrcDir
Tests
Readme
License
Git
```
### Continuous Integration (CI)
These plugins will create the configuration files of common CI services for you.
```@docs
AppVeyor
CirrusCI
DroneCI
GitHubActions
GitLabCI
TravisCI
```
### Code Coverage
These plugins will enable code coverage reporting from CI.
```@docs
Codecov
Coveralls
```
### Documentation
```@docs
Documenter
```
### Miscellaneous
```@docs
Develop
Citation
```
## A More Complicated Example
Here are a few example templates that use the options and plugins explained above.
This one includes plugins suitable for a project hosted on GitHub, and some other customizations:
```julia
Template(;
user="my-username",
dir="~/code",
authors="Acme Corp",
julia=v"1.1",
plugins=[
License(; name="MPL"),
Git(; manifest=true, ssh=true),
GitHubActions(; x86=true),
Codecov(),
Documenter{GitHubActions}(),
Develop(),
],
)
```
Here's one that works well for projects hosted on GitLab:
```julia
Template(;
user="my-username",
host="gitlab.com",
plugins=[
GitLabCI(),
Documenter{GitLabCI}(),
],
)
```
## Custom Template Files
!!! note "Templates vs Templating"
This documentation refers plenty to [`Template`](@ref)s, the package's main type, but it also refers to "template files" and "text templating", which are plaintext files with placeholders to be filled with data, and the technique of filling those placeholders with data, respectively.
These concepts should be familiar if you've used [Jinja](https://palletsprojects.com/p/jinja) or [Mustache](https://mustache.github.io) (Mustache is the particular flavour used by PkgTemplates, via [Mustache.jl](https://github.com/jverzani/Mustache.jl)).
Please keep the difference between these two things in mind!
Many plugins support a `file` argument or similar, which sets the path to the template file to be used for generating files.
Each plugin has a sensible default that should make sense for most people, but you might have a specialized workflow that requires a totally different template file.
If that's the case, a basic understanding of [Mustache](https://mustache.github.io)'s syntax is required.
Here's an example template file:
```
Hello, {{{name}}}.
{{#weather}}
It's {{{weather}}} outside.
{{/weather}}
{{^weather}}
I don't know what the weather outside is.
{{/weather}}
{{#has_things}}
I have the following things:
{{/has_things}}
{{#things}}
- Here's a thing: {{{.}}}
{{/things}}
{{#people}}
- {{{name}}} is {{{mood}}}
{{/people}}
```
In the first section, `name` is a key, and its value replaces `{{{name}}}`.
In the second section, `weather`'s value may or may not exist.
If it does exist, then "It's $weather outside" is printed.
Otherwise, "I don't know what the weather outside is" is printed.
Mustache uses a notion of "truthiness" similar to Python or JavaScript, where values of `nothing`, `false`, or empty collections are all considered to not exist.
In the third section, `has_things`' value is printed if it's truthy.
Then, if the `things` list is truthy (i.e. not empty), its values are each printed on their own line.
The reason that we have two separate keys is that `{{#things}}` iterates over the whole `things` list, even when there are no `{{{.}}}` placeholders, which would duplicate "I have the following things:" `n` times.
The fourth section iterates over the `people` list, but instead of using the `{{{.}}}` placeholder, we have `name` and `mood`, which are keys or fields of the list elements.
Most types are supported here, including `Dict`s and structs.
`NamedTuple`s require you to use `{{{:name}}}` instead of the normal `{{{name}}}`, though.
You might notice that some curlies are in groups of two (`{{key}}`), and some are in groups of three (`{{{key}}}`).
Whenever we want to subtitute in a value, using the triple curlies disables HTML escaping, which we rarely want for the types of files we're creating.
If you do want escaping, just use the double curlies.
And if you're using different delimiters, for example `<<foo>>`, use `<<&foo>>` to disable escaping.
Assuming the following view:
```julia
struct Person; name::String; mood::String; end
things = ["a", "b", "c"]
view = Dict(
"name" => "Chris",
"weather" => "sunny",
"has_things" => !isempty(things),
"things" => things,
"people" => [Person("John", "happy"), Person("Jane", "sad")],
)
```
Our example template would produce this:
```
Hello, Chris.
It's sunny outside.
I have the following things:
- Here's a thing: a
- Here's a thing: b
- Here's a thing: c
- John is happy
- Jane is sad
```
## Extending Existing Plugins
Most of the existing plugins generate a file from a template file.
If you want to use custom template files, you may run into situations where the data passed into the templating engine is not sufficient.
In this case, you can look into implementing [`user_view`](@ref) to supply whatever data is necessary for your use case.
```@docs
user_view
```
For example, suppose you were using the [`Readme`](@ref) plugin with a custom template file that looked like this:
```md
# {{PKG}}
Created on *{{TODAY}}*.
```
The [`view`](@ref) function supplies a value for `PKG`, but it does not supply a value for `TODAY`.
Rather than override [`view`](@ref), we can implement this function to get both the default values and whatever else we need to add.
```julia
user_view(::Readme, ::Template, ::AbstractString) = Dict("TODAY" => today())
```
## Saving Templates
One of the main reasons for PkgTemplates' existence is for new packages to be consistent.
This means using the same template more than once, so we want a way to save a template to be used later.
Here's my recommendation for loading a template whenever it's needed:
```julia
function template()
@eval using PkgTemplates
Template(; #= ... =#)
end
```
Add this to your `startup.jl`, and you can create your template from anywhere, without incurring any startup cost.
Another strategy is to write the string representation of the template to a Julia file:
```julia
const t = Template(; #= ... =#)
open("template.jl", "w") do io
println(io, "using PkgTemplates")
sprint(show, io, t)
end
```
Then the template is just an `include` away:
```julia
const t = include("template.jl")
```
The only disadvantage to this approach is that the saved template is much less human-readable than code you wrote yourself.
One more method of saving templates is to simply use the Serialization package in the standard library:
```julia
const t = Template(; #= ... =#)
using Serialization
open(io -> serialize(io, t), "template.bin", "w")
```
Then simply `deserialize` to load:
```julia
using Serialization
const t = open(deserialize, "template.bin")
```
This approach has the same disadvantage as the previous one, and the serialization format is not guaranteed to be stable across Julia versions.

View File

@ -1,12 +0,0 @@
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,191 +0,0 @@
EUROPEAN UNION PUBLIC LICENCE v. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the EUPL) applies to the Work (as defined below) which is provided under the
terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following
notice immediately following the copyright notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1.Definitions
In this Licence, the following terms have the following meaning:
The Licence:this Licence.
The Original Work:the work or software distributed or communicated by the Licensor under this Licence, available
as Source Code and also as Executable Code as the case may be.
Derivative Works:the works or software that could be created by the Licensee, based upon the Original Work or
modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work
required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in
the country mentioned in Article 15.
The Work:the Original Work or its Derivative Works.
The Source Code:the human-readable form of the Work which is the most convenient for people to study and
modify.
The Executable Code:any code which has generally been compiled and which is meant to be interpreted by
a computer as a program.
The Licensor:the natural or legal person that distributes or communicates the Work under the Licence.
Contributor(s):any natural or legal person who modifies the Work under the Licence, or otherwise contributes to
the creation of a Derivative Work.
The Licensee or You:any natural or legal person who makes any usage of the Work under the terms of the
Licence.
Distribution or Communication:any act of selling, giving, lending, renting, distributing, communicating,
transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential
functionalities at the disposal of any other natural or legal person.
2.Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for
the duration of copyright vested in the Original Work:
— use the Work in any circumstance and for all usage,
— reproduce the Work,
— modify the Work, and make Derivative Works based upon the Work,
— communicate to the public, including the right to make available or display the Work or copies thereof to the public
and perform publicly, as the case may be, the Work,
— distribute the Work or copies thereof,
— lend and rent the Work or copies thereof,
— sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the
applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed
by law in order to make effective the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the
extent necessary to make use of the rights granted on the Work under this Licence.
3.Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as
Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with
each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to
the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to
distribute or communicate the Work.
4.Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the
exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations
thereto.
5.Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those
obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to
the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the
Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work
to carry prominent notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this
Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless
the Original Work is expressly distributed only under this version of the Licence — for example by communicating
EUPL v. 1.2 only. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the
Work or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both
the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done
under the terms of this Compatible Licence. For the sake of this clause, Compatible Licence refers to the licences listed
in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with
his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide
a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available
for as long as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names
of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6.Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or
licensed to him/her and that he/she has the power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or
licensed to him/her and that he/she has the power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions
to the Work, under the terms of this Licence.
7.Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work
and may therefore contain defects or bugs inherent to this type of development.
For the above reason, the Work is provided under the Licence on an as is basis and without warranties of any kind
concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or
errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this
Licence.
This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work.
8.Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be
liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the
Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss
of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However,
the Licensor will be liable under statutory product liability laws as far such laws apply to the Work.
9.Additional agreements
While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services
consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole
responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by
the fact You have accepted any warranty or additional liability.
10.Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon I agree placed under the bottom of a window
displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms
and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You
by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution
or Communication by You of the Work or copies thereof.
11.Information to the public
In case of any Distribution or Communication of the Work by means of electronic communication by You (for example,
by offering to download the Work from a remote location) the distribution channel or media (for example, a website)
must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence
and the way it may be accessible, concluded, stored and reproduced by the Licensee.
12.Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms
of the Licence.
Such a termination will not terminate the licences of any person who has received the Work from the Licensee under
the Licence, provided such persons remain in full compliance with the Licence.
13.Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the
Work.
If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or
enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid
and enforceable.
The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of
the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence.
New versions of the Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take
advantage of the linguistic version of their choice.
14.Jurisdiction
Without prejudice to specific agreement between parties,
— any litigation resulting from the interpretation of this License, arising between the European Union institutions,
bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice
of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union,
— any litigation arising between other parties and resulting from the interpretation of this License, will be subject to
the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business.
15.Applicable Law
Without prejudice to specific agreement between parties,
— this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat,
resides or has his registered office,
— this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside
a European Union Member State.
Appendix
Compatible Licences according to Article 5 EUPL are:
— GNU General Public License (GPL) v. 2, v. 3
— GNU Affero General Public License (AGPL) v. 3
— Open Software License (OSL) v. 2.1, v. 3.0
— Eclipse Public License (EPL) v. 1.0
— CeCILL v. 2.0, v. 2.1
— Mozilla Public Licence (MPL) v. 2
— GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
— Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software
— European Union Public Licence (EUPL) v. 1.1, v. 1.2
— Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+).
The European Commission may update this Appendix to later versions of the above licences without producing
a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the
covered Source Code from exclusive appropriation.
All other changes or additions to this Appendix require the production of a new EUPL version.

View File

@ -1,182 +0,0 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
END OF TERMS AND CONDITIONS

View File

@ -1,363 +0,0 @@
Mozilla Public License, version 2.0
1. Definitions
1.1. "Contributor"
means each individual or legal entity that creates, contributes to the
creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used by a
Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached the
notice in Exhibit A, the Executable Form of such Source Code Form, and
Modifications of such Source Code Form, in each case including portions
thereof.
1.5. "Incompatible With Secondary Licenses"
means
a. that the initial Contributor has attached the notice described in
Exhibit B to the Covered Software; or
b. that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the terms of
a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in a
separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible, whether
at the time of the initial grant or subsequently, any and all of the
rights conveyed by this License.
1.10. "Modifications"
means any of the following:
a. any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered Software; or
b. any new file in Source Code Form that contains any Covered Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the License,
by the making, using, selling, offering for sale, having made, import,
or transfer of either its Contributions or its Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU Lesser
General Public License, Version 2.1, the GNU Affero General Public
License, Version 3.0, or any later versions of those licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that controls, is
controlled by, or is under common control with You. For purposes of this
definition, "control" means (a) the power, direct or indirect, to cause
the direction or management of such entity, whether by contract or
otherwise, or (b) ownership of more than fifty percent (50%) of the
outstanding shares or beneficial ownership of such entity.
2. License Grants and Conditions
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
a. under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
b. under Patent Claims of such Contributor to make, use, sell, offer for
sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
a. for any code that a Contributor has removed from Covered Software; or
b. for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
c. under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights to
grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
Section 2.1.
3. Responsibilities
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
a. such Covered Software must also be made available in Source Code Form,
as described in Section 3.1, and You must inform recipients of the
Executable Form how they can obtain a copy of such Source Code Form by
reasonable means in a timely manner, at a charge no more than the cost
of distribution to the recipient; and
b. You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter the
recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty, or
limitations of liability) contained within the Source Code Form of the
Covered Software, except that You may alter any license notices to the
extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
If it is impossible for You to comply with any of the terms of this License
with respect to some or all of the Covered Software due to statute,
judicial order, or regulation then You must: (a) comply with the terms of
this License to the maximum extent possible; and (b) describe the
limitations and the code they affect. Such description must be placed in a
text file included with all distributions of the Covered Software under
this License. Except to the extent prohibited by statute or regulation,
such description must be sufficiently detailed for a recipient of ordinary
skill to be able to understand it.
5. Termination
5.1. The rights granted under this License will terminate automatically if You
fail to comply with any of its terms. However, if You become compliant,
then the rights granted under this License from a particular Contributor
are reinstated (a) provisionally, unless and until such Contributor
explicitly and finally terminates Your grants, and (b) on an ongoing
basis, if such Contributor fails to notify You of the non-compliance by
some reasonable means prior to 60 days after You have come back into
compliance. Moreover, Your grants from a particular Contributor are
reinstated on an ongoing basis if such Contributor notifies You of the
non-compliance by some reasonable means, this is the first time You have
received notice of non-compliance with this License from such
Contributor, and You become compliant prior to 30 days after Your receipt
of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
license agreements (excluding distributors and resellers) which have been
validly granted by You or Your distributors under this License prior to
termination shall survive termination.
6. Disclaimer of Warranty
Covered Software is provided under this License on an "as is" basis,
without warranty of any kind, either expressed, implied, or statutory,
including, without limitation, warranties that the Covered Software is free
of defects, merchantable, fit for a particular purpose or non-infringing.
The entire risk as to the quality and performance of the Covered Software
is with You. Should any Covered Software prove defective in any respect,
You (not any Contributor) assume the cost of any necessary servicing,
repair, or correction. This disclaimer of warranty constitutes an essential
part of this License. No use of any Covered Software is authorized under
this License except under this disclaimer.
7. Limitation of Liability
Under no circumstances and under no legal theory, whether tort (including
negligence), contract, or otherwise, shall any Contributor, or anyone who
distributes Covered Software as permitted above, be liable to You for any
direct, indirect, special, incidental, or consequential damages of any
character including, without limitation, damages for lost profits, loss of
goodwill, work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses, even if such party shall have been
informed of the possibility of such damages. This limitation of liability
shall not apply to liability for death or personal injury resulting from
such party's negligence to the extent applicable law prohibits such
limitation. Some jurisdictions do not allow the exclusion or limitation of
incidental or consequential damages, so this exclusion and limitation may
not apply to You.
8. Litigation
Any litigation relating to this License may be brought only in the courts
of a jurisdiction where the defendant maintains its principal place of
business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions. Nothing
in this Section shall prevent a party's ability to bring cross-claims or
counter-claims.
9. Miscellaneous
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides that
the language of a contract shall be construed against the drafter shall not
be used to construe this License against a Contributor.
10. Versions of the License
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses If You choose to distribute Source Code Form that is
Incompatible With Secondary Licenses under the terms of this version of
the License, the notice described in Exhibit B of this License must be
attached.
Exhibit A - Source Code Form License Notice
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular file,
then You may include the notice in a location (such as a LICENSE file in a
relevant directory) where a recipient would be likely to look for such a
notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
This Source Code Form is "Incompatible
With Secondary Licenses", as defined by
the Mozilla Public License, v. 2.0.

View File

@ -1,57 +1,57 @@
module PkgTemplates
using Dates
using InteractiveUtils
using LibGit2
using Mustache
using Pkg
using REPL.TerminalMenus
using URIParser
using Base: active_project
using Base.Filesystem: contractuser
using Dates: month, today, year
using LibGit2: LibGit2, GitRemote, GitRepo
using Pkg: Pkg, TOML, PackageSpec
using UUIDs: uuid4
using Mustache: render
using Parameters: @with_kw_noshow
export
# Template/package generation.
Template,
generate,
interactive_template,
generate_interactive,
# Licenses.
show_license,
available_licenses,
# Plugins.
GitHubPages,
GitLabPages,
AppVeyor,
TravisCI,
GitLabCI,
CirrusCI,
Citation,
DroneCI,
Codecov,
Coveralls,
Citation
Develop,
Documenter,
Git,
GitHubActions,
GitLabCI,
License,
ProjectFile,
Readme,
SrcDir,
Tests,
TravisCI
"""
A plugin to be added to a [`Template`](@ref), which adds some functionality or integration.
New plugins should almost always extend [`GenericPlugin`](@ref) or [`CustomPlugin`](@ref).
Plugins are PkgTemplates' source of customization and extensibility.
Add plugins to your [`Template`](@ref)s to enable extra pieces of repository setup.
When implementing a new plugin, subtype this type to have full control over its behaviour.
"""
abstract type Plugin end
include("licenses.jl")
include("template.jl")
include("generate.jl")
include("plugin.jl")
include(joinpath("plugins", "documenter.jl"))
include(joinpath("plugins", "coveralls.jl"))
include(joinpath("plugins", "appveyor.jl"))
include(joinpath("plugins", "codecov.jl"))
include(joinpath("plugins", "travisci.jl"))
include(joinpath("plugins", "gitlabci.jl"))
include(joinpath("plugins", "cirrusci.jl"))
include(joinpath("plugins", "droneci.jl"))
include(joinpath("plugins", "githubpages.jl"))
include(joinpath("plugins", "gitlabpages.jl"))
include(joinpath("plugins", "citation.jl"))
include("show.jl")
const DEFAULTS_DIR = normpath(joinpath(@__DIR__, "..", "defaults"))
const BADGE_ORDER = [GitHubPages, GitLabPages, TravisCI, AppVeyor, GitLabCI, Codecov, Coveralls]
# Run some function with a project activated at the given path.
function with_project(f::Function, path::AbstractString)
proj = active_project()
try
Pkg.activate(path)
f()
finally
proj === nothing ? Pkg.activate() : Pkg.activate(proj)
end
end
end

View File

@ -1,359 +0,0 @@
"""
generate(pkg::AbstractString, t::Template) -> Nothing
generate(t::Template, pkg::AbstractString) -> Nothing
Generate a package named `pkg` from `t`. If `git` is `false`, no Git repository is created.
"""
function generate(
pkg::AbstractString,
t::Template;
git::Bool=true,
gitconfig::Union{GitConfig, Nothing}=nothing,
)
pkg = splitjl(pkg)
pkg_dir = joinpath(t.dir, pkg)
ispath(pkg_dir) && throw(ArgumentError("$pkg_dir already exists"))
try
# Create the directory with some boilerplate inside.
Pkg.generate(pkg_dir)
# Add a [compat] section for Julia.
open(joinpath(pkg_dir, "Project.toml"), "a") do io
println(io, "\n[compat]\njulia = $(repr_version(t.julia_version))")
end
# Replace the authors field with the template's authors.
if !isempty(t.authors)
path = joinpath(pkg_dir, "Project.toml")
project = read(path, String)
authors = string("[", join(map(repr strip, split(t.authors, ",")), ", "), "]")
write(path, replace(project, r"authors = .*" => "authors = $authors"))
end
if git
# Initialize the repo.
repo = LibGit2.init(pkg_dir)
@info "Initialized Git repo at $pkg_dir"
if gitconfig !== nothing
# Configure the repo.
repoconfig = GitConfig(repo)
for c in LibGit2.GitConfigIter(gitconfig)
LibGit2.set!(repoconfig, unsafe_string(c.name), unsafe_string(c.value))
end
end
# Commit and set the remote.
LibGit2.commit(repo, "Initial commit")
rmt = if t.ssh
"git@$(t.host):$(t.user)/$pkg.jl.git"
else
"https://$(t.host)/$(t.user)/$pkg.jl"
end
# We need to set the remote in a strange way, see #8.
close(LibGit2.GitRemote(repo, "origin", rmt))
@info "Set remote origin to $rmt"
# Create the gh-pages branch if necessary.
if haskey(t.plugins, GitHubPages)
LibGit2.branch!(repo, "gh-pages")
LibGit2.commit(repo, "Initial commit")
@info "Created empty gh-pages branch"
LibGit2.branch!(repo, "master")
end
end
# Generate the files.
files = vcat(
"src/", "Project.toml", # Created by Pkg.generate.
gen_tests(pkg_dir, t),
gen_readme(pkg_dir, t),
gen_license(pkg_dir, t),
vcat(map(p -> gen_plugin(p, t, pkg), values(t.plugins))...),
)
if git
append!(files, gen_gitignore(pkg_dir, t))
LibGit2.add!(repo, files...)
LibGit2.commit(repo, "Files generated by PkgTemplates")
@info "Committed $(length(files)) files/directories: $(join(files, ", "))"
if length(collect(LibGit2.GitBranchIter(repo))) > 1
@info "Remember to push all created branches to your remote: git push --all"
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
rm(pkg_dir; recursive=true)
rethrow(e)
end
end
function generate(
t::Template,
pkg::AbstractString;
git::Bool=true,
gitconfig::Union{GitConfig, Nothing}=nothing,
)
generate(pkg, t; git=git, gitconfig=gitconfig)
end
"""
generate_interactive(pkg::AbstractString; fast::Bool=false, git::Bool=true) -> Template
Interactively create a template, and then generate a package with it. Arguments and
keywords are used in the same way as in [`generate`](@ref) and
[`interactive_template`](@ref).
"""
function generate_interactive(
pkg::AbstractString;
fast::Bool=false,
git::Bool=true,
gitconfig::Union{GitConfig, Nothing}=nothing,
)
t = interactive_template(; git=git, fast=fast)
generate(pkg, t; git=git, gitconfig=gitconfig)
return t
end
"""
gen_tests(pkg_dir::AbstractString, t::Template) -> Vector{String}
Create the test entrypoint in `pkg_dir`.
# Arguments
* `pkg_dir::AbstractString`: The package directory in which the files will be generated
* `t::Template`: The template whose tests we are generating.
Returns an array of generated file/directory names.
"""
function gen_tests(pkg_dir::AbstractString, t::Template)
# TODO: Silence Pkg for this section? Adding and removing Test creates a lot of noise.
proj = Base.current_project()
try
Pkg.activate(pkg_dir)
Pkg.add("Test")
# Move the Test dependency into the [extras] section.
toml = read(joinpath(pkg_dir, "Project.toml"), String)
lines = split(toml, "\n")
idx = findfirst(l -> startswith(l, "Test = "), lines)
testdep = lines[idx]
deleteat!(lines, idx)
toml = join(lines, "\n") * """
[extras]
$testdep
[targets]
test = ["Test"]
"""
gen_file(joinpath(pkg_dir, "Project.toml"), toml)
Pkg.update() # Regenerate Manifest.toml (this cleans up Project.toml too).
finally
proj === nothing ? Pkg.activate() : Pkg.activate(proj)
end
pkg = basename(pkg_dir)
text = """
using $pkg
using Test
@testset "$pkg.jl" begin
# Write your own tests here.
end
"""
gen_file(joinpath(pkg_dir, "test", "runtests.jl"), text)
return ["test/"]
end
"""
gen_readme(pkg_dir::AbstractString, t::Template) -> Vector{String}
Create a README in `pkg_dir` with badges for each enabled plugin.
# Arguments
* `pkg_dir::AbstractString`: The directory in which the files will be generated.
* `t::Template`: The template whose README we are generating.
Returns an array of generated file/directory names.
"""
function gen_readme(pkg_dir::AbstractString, t::Template)
pkg = basename(pkg_dir)
text = "# $pkg\n"
done = []
# Generate the ordered badges first, then add any remaining ones to the right.
for plugin_type in BADGE_ORDER
if haskey(t.plugins, plugin_type)
text *= "\n"
text *= join(
badges(t.plugins[plugin_type], t.user, pkg),
"\n",
)
push!(done, plugin_type)
end
end
for plugin_type in setdiff(keys(t.plugins), done)
text *= "\n"
text *= join(
badges(t.plugins[plugin_type], t.user, pkg),
"\n",
)
end
if haskey(t.plugins, Citation) && t.plugins[Citation].readme_section
text *= "\n## Citing\n\nSee `CITATION.bib` for the relevant reference(s).\n"
end
gen_file(joinpath(pkg_dir, "README.md"), text)
return ["README.md"]
end
"""
gen_gitignore(pkg_dir::AbstractString, t::Template) -> Vector{String}
Create a `.gitignore` in `pkg_dir`.
# Arguments
* `pkg_dir::AbstractString`: The directory in which the files will be generated.
* `t::Template`: The template whose .gitignore we are generating.
Returns an array of generated file/directory names.
"""
function gen_gitignore(pkg_dir::AbstractString, t::Template)
pkg = basename(pkg_dir)
init = [".DS_Store", "/dev/"]
entries = mapfoldl(p -> p.gitignore, append!, values(t.plugins); init=init)
if !t.manifest && !in("Manifest.toml", entries)
push!(entries, "/Manifest.toml") # Only ignore manifests at the repo root.
end
unique!(sort!(entries))
text = join(entries, "\n")
gen_file(joinpath(pkg_dir, ".gitignore"), text)
files = [".gitignore"]
t.manifest && push!(files, "Manifest.toml")
return files
end
"""
gen_license(pkg_dir::AbstractString, t::Template) -> Vector{String}
Create a license in `pkg_dir`.
# Arguments
* `pkg_dir::AbstractString`: The directory in which the files will be generated.
* `t::Template`: The template whose LICENSE we are generating.
Returns an array of generated file/directory names.
"""
function gen_license(pkg_dir::AbstractString, t::Template)
if isempty(t.license)
return String[]
end
text = "Copyright (c) $(year(today())) $(t.authors)\n"
text *= read_license(t.license)
gen_file(joinpath(pkg_dir, "LICENSE"), text)
return ["LICENSE"]
end
"""
gen_file(file::AbstractString, text::AbstractString) -> Int
Create a new file containing some given text. Always ends the file with a newline.
# Arguments
* `file::AbstractString`: Path to the file to be created.
* `text::AbstractString`: Text to write to the file.
Returns the number of bytes written to the file.
"""
function gen_file(file::AbstractString, text::AbstractString)
mkpath(dirname(file))
if !endswith(text , "\n")
text *= "\n"
end
return write(file, text)
end
"""
version_floor(v::VersionNumber=VERSION) -> String
Format the given Julia version.
# Keyword arguments
* `v::VersionNumber=VERSION`: Version to floor.
Returns "major.minor" for the most recent release version relative to v. For prereleases
with v.minor == v.patch == 0, returns "major.minor-".
"""
function version_floor(v::VersionNumber=VERSION)
return if isempty(v.prerelease) || v.patch > 0
"$(v.major).$(v.minor)"
else
"$(v.major).$(v.minor)-"
end
end
"""
substitute(template::AbstractString, view::Dict{String, Any}) -> String
substitute(
template::AbstractString,
pkg_template::Template;
view::Dict{String, Any}=Dict{String, Any}(),
) -> String
Replace placeholders in `template` with values in `view` via
[`Mustache`](https://github.com/jverzani/Mustache.jl). `template` is not modified.
If `pkg_template` is supplied, some default replacements are also performed.
For information on how to structure `template`, see "Defining Template Files" section in
[Custom Plugins](@ref).
**Note**: Conditionals in `template` without a corresponding key in `view` won't error,
but will simply be evaluated as false.
"""
substitute(template::AbstractString, view::Dict{String, Any}) = render(template, view)
function substitute(
template::AbstractString,
pkg_template::Template;
view::Dict{String, Any}=Dict{String, Any}(),
)
# Don't use version_floor here because we don't want the trailing '-' on prereleases.
v = pkg_template.julia_version
d = Dict{String, Any}(
"USER" => pkg_template.user,
"VERSION" => "$(v.major).$(v.minor)",
"DOCUMENTER" => any(map(p -> isa(p, Documenter), values(pkg_template.plugins))),
"CODECOV" => haskey(pkg_template.plugins, Codecov),
"COVERALLS" => haskey(pkg_template.plugins, Coveralls),
)
# d["AFTER"] is true whenever something needs to occur in a CI "after_script".
d["AFTER"] = d["DOCUMENTER"] || d["CODECOV"] || d["COVERALLS"]
# d["COVERAGE"] is true whenever a coverage plugin is enabled.
# TODO: This doesn't handle user-defined coverage plugins.
# Maybe we need an abstract CoveragePlugin <: GenericPlugin?
d["COVERAGE"] = d["CODECOV"] || d["COVERALLS"]
return substitute(template, merge(d, view))
end
splitjl(pkg::AbstractString) = endswith(pkg, ".jl") ? pkg[1:end-3] : pkg
# Format a version in a way suitable for a Project.toml file.
function repr_version(v::VersionNumber)
s = string(v.major)
v.minor == 0 || (s *= ".$(v.minor)")
v.patch == 0 || (s *= ".$(v.patch)")
return repr(s)
end

View File

@ -1,45 +0,0 @@
const LICENSE_DIR = normpath(joinpath(@__DIR__, "..", "licenses"))
const LICENSES = Dict(
"MIT" => "MIT \"Expat\" License",
"BSD2" => "Simplified \"2-clause\" BSD License",
"BSD3" => "Modified \"3-clause\" BSD License",
"ISC" => "Internet Systems Consortium 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+",
"EUPL-1.2+" => "European Union Public Licence, Version 1.2+",
)
"""
available_licenses([io::IO]) -> Nothing
Print the names of all available licenses.
"""
available_licenses(io::IO) = print(io, join(("$k: $v" for (k, v) in LICENSES), "\n"))
available_licenses() = available_licenses(stdout)
"""
show_license([io::IO], license::AbstractString) -> Nothing
Print the text of `license`. Errors if the license is not found.
"""
show_license(io::IO, license::AbstractString) = print(io, read_license(license))
show_license(license::AbstractString) = show_license(stdout, license)
"""
read_license(license::AbstractString) -> String
Returns the contents of `license`. Errors if the license is not found. Use
[`available_licenses`](@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

View File

@ -1,156 +1,131 @@
const TEMPLATES_DIR = normpath(joinpath(@__DIR__, "..", "templates"))
const DEFAULT_PRIORITY = 1000
"""
Generic plugins are plugins that add any number of patterns to the generated package's
`.gitignore`, and have at most one associated file to generate.
# Attributes
* `gitignore::Vector{AbstractString}`: Array of patterns to be added to the `.gitignore` of
generated packages that use this plugin.
* `src::Union{AbstractString, Nothing}`: Path to the file that will be copied into the generated
package repository. If set to `nothing`, no file will be generated. When this defaults
to an empty string, there should be a default file in `defaults` that will be copied.
That file's name is usually the same as the plugin's name, except in all lowercase and
with the `.yml` extension. If this is not the case, an `interactive` method needs to be
implemented to call `interactive(; file="file.ext")`.
* `dest::AbstractString`: Path to the generated file, relative to the root of the generated
package repository.
* `badges::Vector{Badge}`: Array of [`Badge`](@ref)s containing information used to
create Markdown-formatted badges from the plugin. Entries will be run through
[`substitute`](@ref), so they may contain placeholder values.
* `view::Dict{String, Any}`: Additional substitutions to make in both the plugin's badges
and its associated file. See [`substitute`](@ref) for details.
# Example
```julia
struct MyPlugin <: GenericPlugin
gitignore::Vector{AbstractString}
src::Union{AbstractString, Nothing}
dest::AbstractString
badges::Vector{Badge}
view::Dict{String, Any}
function MyPlugin(; config_file::Union{AbstractString, Nothing}="")
if config_file != nothing
config_file = if isempty(config_file)
joinpath(DEFAULTS_DIR, "my-plugin.toml")
elseif isfile(config_file)
abspath(config_file)
else
throw(ArgumentError(
"File \$(abspath(config_file)) does not exist"
))
end
end
new(
["*.mgp"],
config_file,
".my-plugin.toml",
[
Badge(
"My Plugin",
"https://myplugin.com/badge-{{YEAR}}.png",
"https://myplugin.com/{{USER}}/{{PKGNAME}}.jl",
),
],
Dict{String, Any}("YEAR" => year(today())),
)
end
end
interactive(::Type{MyPlugin}) = interactive(MyPlugin; file="my-plugin.toml")
```
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
substitutions with one addition: `{{YEAR}} => year(today())`. Since the default config
template file doesn't follow the generic naming convention, we added another `interactive`
method to correct the assumed filename.
A simple plugin that, in general, creates a single file.
"""
abstract type GenericPlugin <: Plugin end
abstract type BasicPlugin <: Plugin end
function Base.show(io::IO, p::GenericPlugin)
spc = " "
println(io, nameof(typeof(p)), ":")
"""
default_file(paths::AbstractString...) -> String
cfg = if p.src === nothing
"None"
else
dirname(p.src) == DEFAULTS_DIR ? "Default" : p.src
end
println(io, spc, "→ Config file: ", cfg)
Return a path relative to the default template file directory
(`$(contractuser(TEMPLATES_DIR))`).
"""
default_file(paths::AbstractString...) = joinpath(TEMPLATES_DIR, paths...)
n = length(p.gitignore)
s = n == 1 ? "" : "s"
print(io, spc, "$n gitignore entrie$s")
n > 0 && print(io, ": ", join(map(repr, p.gitignore), ", "))
"""
view(::Plugin, ::Template, pkg::AbstractString) -> Dict{String, Any}
Return the view to be passed to the text templating engine for this plugin.
`pkg` is the name of the package being generated.
For [`BasicPlugin`](@ref)s, this is used for both the plugin badges
(see [`badges`](@ref)) and the template file (see [`source`](@ref)).
For other [`Plugin`](@ref)s, it is used only for badges,
but you can always call it yourself as part of your [`hook`](@ref) implementation.
By default, an empty `Dict` is returned.
"""
view(::Plugin, ::Template, ::AbstractString) = Dict{String, Any}()
"""
user_view(::Plugin, ::Template, pkg::AbstractString) -> Dict{String, Any}
The same as [`view`](@ref), but for use by package *users* for extension.
Values returned by this function will override those from [`view`](@ref)
when the keys are the same.
"""
user_view(::Plugin, ::Template, ::AbstractString) = Dict{String, Any}()
"""
combined_view(::Plugin, ::Template, pkg::AbstractString) -> Dict{String, Any}
This function combines [`view`](@ref) and [`user_view`](@ref) for use in text templating.
If you're doing manual file creation or text templating (i.e. writing [`Plugin`](@ref)s
that are not [`BasicPlugin`](@ref)s), then you should use this function
rather than either of the former two.
!!! note
Do not implement this function yourself!
If you're implementing a plugin, you should implement [`view`](@ref).
If you're customizing a plugin as a user, you should implement [`user_view`](@ref).
"""
function combined_view(p::Plugin, t::Template, pkg::AbstractString)
return merge(view(p, t, pkg), user_view(p, t, pkg))
end
"""
Custom plugins are plugins whose behaviour does not follow the [`GenericPlugin`](@ref)
pattern. They can implement [`gen_plugin`](@ref), [`badges`](@ref), and
[`interactive`](@ref) in any way they choose, as long as they conform to the usual type
signature.
tags(::Plugin) -> Tuple{String, String}
# Attributes
* `gitignore::Vector{AbstractString}`: Array of patterns to be added to the `.gitignore` of
generated packages that use this plugin.
Return the delimiters used for text templating.
See the [`Citation`](@ref) plugin for a rare case where changing the tags is necessary.
# Example
```julia
struct MyPlugin <: CustomPlugin
gitignore::Vector{AbstractString}
lucky::Bool
MyPlugin() = new([], rand() > 0.8)
function gen_plugin(p::MyPlugin, t::Template, pkg_name::AbstractString)
return if p.lucky
text = substitute("You got lucky with {{PKGNAME}}, {{USER}}!", t)
gen_file(joinpath(t.dir, pkg_name, ".myplugin.yml"), text)
[".myplugin.yml"]
else
println("Maybe next time.")
String[]
end
end
function badges(p::MyPlugin, user::AbstractString, pkg_name::AbstractString)
return if p.lucky
[
format(Badge(
"You got lucky!",
"https://myplugin.com/badge.png",
"https://myplugin.com/\$user/\$pkg_name.jl",
)),
]
else
String[]
end
end
end
interactive(:Type{MyPlugin}) = MyPlugin()
```
This plugin doesn't do much, but it demonstrates how [`gen_plugin`](@ref), [`badges`](@ref)
and [`interactive`](@ref) can be implemented using [`substitute`](@ref),
[`gen_file`](@ref), [`Badge`](@ref), and [`format`](@ref).
# Defining Template Files
Often, the contents of the config file that your plugin generates depends on variables like
the package name, the user's username, etc. Template files (which are stored in `defaults`)
can use [here](https://github.com/jverzani/Mustache.jl)'s syntax to define replacements.
By default, the tags are `"{{"` and `"}}"`.
"""
abstract type CustomPlugin <: Plugin end
tags(::Plugin) = "{{", "}}"
"""
Badge(hover::AbstractString, image::AbstractString, link::AbstractString) -> Badge
priority(::Plugin, ::Union{typeof(prehook), typeof(hook), typeof(posthook)}) -> Int
A `Badge` contains the data necessary to generate a Markdown badge.
Determines the order in which plugins are processed (higher goes first).
The default priority (`DEFAULT_PRIORITY`), is `$DEFAULT_PRIORITY`.
# Arguments
* `hover::AbstractString`: Text to appear when the mouse is hovered over the badge.
* `image::AbstractString`: URL to the image to display.
* `link::AbstractString`: URL to go to upon clicking the badge.
You can implement this function per-stage (by using `::typeof(hook)`, for example),
or for all stages by simply using `::Function`.
"""
priority(::Plugin, ::Function) = DEFAULT_PRIORITY
"""
gitignore(::Plugin) -> Vector{String}
Return patterns that should be added to `.gitignore`.
These are used by the [`Git`](@ref) plugin.
By default, an empty list is returned.
"""
gitignore(::Plugin) = String[]
"""
badges(::Plugin) -> Union{Badge, Vector{Badge}}
Return a list of [`Badge`](@ref)s, or just one, to be added to `README.md`.
These are used by the [`Readme`](@ref) plugin to add badges to the README.
By default, an empty list is returned.
"""
badges(::Plugin) = Badge[]
"""
source(::BasicPlugin) -> Union{String, Nothing}
Return the path to a plugin's template file, or `nothing` to indicate no file.
By default, `nothing` is returned.
"""
source(::BasicPlugin) = nothing
"""
destination(::BasicPlugin) -> String
Return the destination, relative to the package root, of a plugin's configuration file.
This function **must** be implemented.
"""
function destination end
"""
Badge(hover::AbstractString, image::AbstractString, link::AbstractString)
Container for Markdown badge data.
Each argument can contain placeholders,
which will be filled in with values from [`combined_view`](@ref).
## Arguments
- `hover::AbstractString`: Text to appear when the mouse is hovered over the badge.
- `image::AbstractString`: URL to the image to display.
- `link::AbstractString`: URL to go to upon clicking the badge.
"""
struct Badge
hover::String
@ -158,89 +133,132 @@ struct Badge
link::String
end
"""
format(b::Badge) -> String
Base.string(b::Badge) = "[![$(b.hover)]($(b.image))]($(b.link))"
Return `badge`'s data formatted as a Markdown string.
"""
format(b::Badge) = "[![$(b.hover)]($(b.image))]($(b.link))"
"""
gen_plugin(p::Plugin, t::Template, pkg_name::AbstractString) -> Vector{String}
Generate any files associated with a plugin.
# Arguments
* `p::Plugin`: Plugin whose files are being generated.
* `t::Template`: Template configuration.
* `pkg_name::AbstractString`: Name of the package.
Returns an array of generated file/directory names.
"""
gen_plugin(::Plugin, ::Template, ::AbstractString) = String[]
function gen_plugin(p::GenericPlugin, t::Template, pkg_name::AbstractString)
if p.src === nothing
return String[]
end
text = substitute(
read(p.src, String),
t;
view=merge(Dict("PKGNAME" => pkg_name), p.view),
)
gen_file(joinpath(t.dir, pkg_name, p.dest), text)
return [p.dest]
# Format a plugin's badges as a list of strings, with all substitutions applied.
function badges(p::Plugin, t::Template, pkg::AbstractString)
bs = badges(p)
bs isa Vector || (bs = [bs])
return map(b -> render_text(string(b), combined_view(p, t, pkg)), bs)
end
"""
badges(p::Plugin, user::AbstractString, pkg_name::AbstractString) -> Vector{String}
validate(::Plugin, ::Template)
Generate Markdown badges for the plugin.
Perform any required validation for a [`Plugin`](@ref).
# Arguments
* `p::Plugin`: Plugin whose badges we are generating.
* `user::AbstractString`: Username of the package creator.
* `pkg_name::AbstractString`: Name of the package.
Returns an array of Markdown badges.
It is preferred to do validation here instead of in [`prehook`](@ref),
because this function is called at [`Template`](@ref) construction time,
whereas the prehook is only run at package generation time.
"""
badges(::Plugin, ::AbstractString, ::AbstractString) = String[]
validate(::Plugin, ::Template) = nothing
function badges(p::GenericPlugin, user::AbstractString, pkg_name::AbstractString)
# Give higher priority to replacements defined in the plugin's view.
view = merge(Dict("USER" => user, "PKGNAME" => pkg_name), p.view)
return map(b -> substitute(format(b), view), p.badges)
"""
prehook(::Plugin, ::Template, pkg_dir::AbstractString)
Stage 1 of the package generation process (the "before" stage, in general).
At this point, `pkg_dir` is an empty directory that will eventually contain the package,
and neither the [`hook`](@ref)s nor the [`posthook`](@ref)s have run.
!!! note
`pkg_dir` only stays empty until the first plugin chooses to create a file.
See also: [`priority`](@ref).
"""
prehook(::Plugin, ::Template, ::AbstractString) = nothing
"""
hook(::Plugin, ::Template, pkg_dir::AbstractString)
Stage 2 of the package generation pipeline (the "main" stage, in general).
At this point, the [`prehook`](@ref)s have run, but not the [`posthook`](@ref)s.
`pkg_dir` is the directory in which the package is being generated
(so `basename(pkg_dir)` is the package name).
!!! note
You usually shouldn't implement this function for [`BasicPlugin`](@ref)s.
If you do, it should probably `invoke` the generic method
(otherwise, there's not much reason to subtype `BasicPlugin`).
"""
hook(::Plugin, ::Template, ::AbstractString) = nothing
"""
posthook(::Plugin, ::Template, pkg_dir::AbstractString)
Stage 3 of the package generation pipeline (the "after" stage, in general).
At this point, both the [`prehook`](@ref)s and [`hook`](@ref)s have run.
"""
posthook(::Plugin, ::Template, ::AbstractString) = nothing
function validate(p::T, ::Template) where T <: BasicPlugin
src = source(p)
src === nothing && return
isfile(src) || throw(ArgumentError("$(nameof(T)): The file $src does not exist"))
end
function hook(p::BasicPlugin, t::Template, pkg_dir::AbstractString)
source(p) === nothing && return
pkg = basename(pkg_dir)
path = joinpath(pkg_dir, destination(p))
text = render_plugin(p, t, pkg)
gen_file(path, text)
end
function render_plugin(p::BasicPlugin, t::Template, pkg::AbstractString)
return render_file(source(p), combined_view(p, t, pkg), tags(p))
end
"""
interactive(T::Type{<:Plugin}; file::Union{AbstractString, Nothing}="") -> Plugin
gen_file(file::AbstractString, text::AbstractString)
Interactively create a plugin of type `T`, where `file` is the plugin type's default
config template with a non-standard name (for `MyPlugin`, this is anything but
"myplugin.yml").
Create a new file containing some given text.
Trailing whitespace is removed, and the file will end with a newline.
"""
function interactive(T::Type{<:GenericPlugin}; file::Union{AbstractString, Nothing}="")
name = string(nameof(T))
# By default, we expect the default plugin file template for a plugin called
# "MyPlugin" to be called "myplugin.yml".
fn = file != nothing && isempty(file) ? "$(lowercase(name)).yml" : file
default_config_file = fn == nothing ? fn : joinpath(DEFAULTS_DIR, fn)
print("$name: Enter the config template filename (\"None\" for no file) ")
if default_config_file == nothing
print("[None]: ")
else
print("[", replace(default_config_file, homedir() => "~"), "]: ")
end
config_file = readline()
config_file = if uppercase(config_file) == "NONE"
nothing
elseif isempty(config_file)
default_config_file
else
config_file
end
return T(; config_file=config_file)
function gen_file(file::AbstractString, text::AbstractString)
mkpath(dirname(file))
text = strip(join(map(rstrip, split(text, "\n")), "\n")) * "\n"
write(file, text)
end
"""
render_file(file::AbstractString view::Dict{<:AbstractString}, tags) -> String
Render a template file with the data in `view`.
`tags` should be a tuple of two strings, which are the opening and closing delimiters,
or `nothing` to use the default delimiters.
"""
function render_file(file::AbstractString, view::Dict{<:AbstractString}, tags)
return render_text(read(file, String), view, tags)
end
"""
render_text(text::AbstractString, view::Dict{<:AbstractString}, tags=nothing) -> String
Render some text with the data in `view`.
`tags` should be a tuple of two strings, which are the opening and closing delimiters,
or `nothing` to use the default delimiters.
"""
function render_text(text::AbstractString, view::Dict{<:AbstractString}, tags=nothing)
return tags === nothing ? render(text, view) : render(text, view; tags=tags)
end
"""
needs_username(::Plugin) -> Bool
Determine whether or not a plugin needs a Git hosting service username to function correctly.
If you are implementing a plugin that uses the `user` field of a [`Template`](@ref),
you should implement this function and return `true`.
"""
needs_username(::Plugin) = false
include(joinpath("plugins", "project_file.jl"))
include(joinpath("plugins", "src_dir.jl"))
include(joinpath("plugins", "tests.jl"))
include(joinpath("plugins", "readme.jl"))
include(joinpath("plugins", "license.jl"))
include(joinpath("plugins", "git.jl"))
include(joinpath("plugins", "develop.jl"))
include(joinpath("plugins", "coverage.jl"))
include(joinpath("plugins", "ci.jl"))
include(joinpath("plugins", "citation.jl"))
include(joinpath("plugins", "documenter.jl"))

View File

@ -1,42 +0,0 @@
"""
AppVeyor(; config_file::Union{AbstractString, Nothing}="") -> AppVeyor
Add `AppVeyor` to a template's plugins to add a `.appveyor.yml` configuration file to
generated repositories, and an appropriate badge to the README.
# Keyword Arguments
* `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.appveyor.yml`.
If `nothing` is supplied, no file will be generated.
"""
struct AppVeyor <: GenericPlugin
gitignore::Vector{String}
src::Union{String, Nothing}
dest::String
badges::Vector{Badge}
view::Dict{String, Any}
function AppVeyor(; config_file::Union{AbstractString, Nothing}="")
if config_file != nothing
config_file = if isempty(config_file)
config_file = joinpath(DEFAULTS_DIR, "appveyor.yml")
elseif isfile(config_file)
abspath(config_file)
else
throw(ArgumentError("File $(abspath(config_file)) does not exist"))
end
end
new(
[],
config_file,
".appveyor.yml",
[
Badge(
"Build Status",
"https://ci.appveyor.com/api/projects/status/github/{{USER}}/{{PKGNAME}}.jl?svg=true",
"https://ci.appveyor.com/project/{{USER}}/{{PKGNAME}}-jl",
)
],
Dict{String, Any}(),
)
end
end

412
src/plugins/ci.jl Normal file
View File

@ -0,0 +1,412 @@
"""
format_version(v::Union{VersionNumber, AbstractString}) -> String
Strip everything but the major and minor release from a `VersionNumber`.
Strings are left in their original form.
"""
format_version(v::VersionNumber) = "$(v.major).$(v.minor)"
format_version(v::AbstractString) = string(v)
const ALLOWED_FAILURES = ["1.3", "nightly"] # TODO: Update this list with new RCs.
const DEFAULT_CI_VERSIONS = map(format_version, [default_version(), VERSION, "nightly"])
const DEFAULT_CI_VERSIONS_NO_NIGHTLY = map(format_version, [default_version(), VERSION])
const EXTRA_VERSIONS_DOC = "- `extra_versions::Vector`: Extra Julia versions to test, as strings or `VersionNumber`s."
"""
GitHubActions(;
file="$(contractuser(default_file("github", "workflows", "ci.yml")))",
destination="ci.yml",
linux=true,
osx=true,
windows=true,
x64=true,
x86=false,
coverage=true,
extra_versions=$DEFAULT_CI_VERSIONS_NO_NIGHTLY,
)
Integrates your packages with [GitHub Actions](https://github.com/features/actions).
## Keyword Arguments
- `file::AbstractString`: Template file for the workflow file.
- `destination::AbstractString`: Destination of the worflow file,
relative to `.github/workflows`.
- `linux::Bool`: Whether or not to run builds on Linux.
- `osx::Bool`: Whether or not to run builds on OSX (MacOS).
- `windows::Bool`: Whether or not to run builds on Windows.
- `x64::Bool`: Whether or not to run builds on 64-bit architecture.
- `x86::Bool`: Whether or not to run builds on 32-bit architecture.
- `coverage::Bool`: Whether or not to publish code coverage.
Another code coverage plugin such as [`Codecov`](@ref) must also be included.
$EXTRA_VERSIONS_DOC
!!! note
If using coverage plugins, don't forget to manually add your API tokens as secrets,
as described [here](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets#creating-encrypted-secrets).
!!! note
Nightly Julia is not supported.
"""
@with_kw_noshow struct GitHubActions <: BasicPlugin
file::String = default_file("github", "workflows", "ci.yml")
destination::String = "ci.yml"
linux::Bool = true
osx::Bool = true
windows::Bool = true
x64::Bool = true
x86::Bool = false
coverage::Bool = true
extra_versions::Vector = DEFAULT_CI_VERSIONS_NO_NIGHTLY
end
source(p::GitHubActions) = p.file
destination(p::GitHubActions) = joinpath(".github", "workflows", p.destination)
tags(::GitHubActions) = "<<", ">>"
badges(p::GitHubActions) = Badge(
"Build Status",
"https://github.com/{{{USER}}}/{{{PKG}}}.jl/actions",
"https://github.com/{{{USER}}}/{{{PKG}}}.jl/workflows/CI/badge.svg",
)
function view(p::GitHubActions, t::Template, pkg::AbstractString)
os = String[]
p.linux && push!(os, "ubuntu-latest")
p.osx && push!(os, "macOS-latest")
p.windows && push!(os, "windows-latest")
arch = filter(a -> getfield(p, Symbol(a)), ["x64", "x86"])
excludes = Dict{String, String}[]
p.osx && p.x86 && push!(excludes, Dict("E_OS" => "macOS-latest", "E_ARCH" => "x86"))
return Dict(
"ARCH" => arch,
"EXCLUDES" => excludes,
"HAS_CODECOV" => p.coverage && hasplugin(t, Codecov),
"HAS_COVERALLS" => p.coverage && hasplugin(t, Coveralls),
"HAS_DOCUMENTER" => hasplugin(t, Documenter{GitHubActions}),
"HAS_EXCLUDES" => !isempty(excludes),
"OS" => os,
"PKG" => pkg,
"USER" => t.user,
"VERSIONS" => collect_versions(t, p.extra_versions),
)
end
"""
TravisCI(;
file="$(contractuser(default_file("travis.yml")))",
linux=true,
osx=true,
windows=true,
x64=true,
x86=false,
arm64=false,
coverage=true,
extra_versions=$DEFAULT_CI_VERSIONS,
)
Integrates your packages with [Travis CI](https://travis-ci.com).
## Keyword Arguments
- `file::AbstractString`: Template file for `.travis.yml`.
- `linux::Bool`: Whether or not to run builds on Linux.
- `osx::Bool`: Whether or not to run builds on OSX (MacOS).
- `windows::Bool`: Whether or not to run builds on Windows.
- `x64::Bool`: Whether or not to run builds on 64-bit architecture.
- `x86::Bool`: Whether or not to run builds on 32-bit architecture.
- `arm64::Bool`: Whether or not to run builds on the ARM64 architecture.
- `coverage::Bool`: Whether or not to publish code coverage.
Another code coverage plugin such as [`Codecov`](@ref) must also be included.
$EXTRA_VERSIONS_DOC
"""
@with_kw_noshow struct TravisCI <: BasicPlugin
file::String = default_file("travis.yml")
linux::Bool = true
osx::Bool = true
windows::Bool = true
x64::Bool = true
x86::Bool = false
arm64::Bool = false
coverage::Bool = true
extra_versions::Vector = DEFAULT_CI_VERSIONS
end
source(p::TravisCI) = p.file
destination(::TravisCI) = ".travis.yml"
badges(::TravisCI) = Badge(
"Build Status",
"https://travis-ci.com/{{{USER}}}/{{{PKG}}}.jl.svg?branch=master",
"https://travis-ci.com/{{{USER}}}/{{{PKG}}}.jl",
)
function view(p::TravisCI, t::Template, pkg::AbstractString)
os = filter(o -> getfield(p, Symbol(o)), ["linux", "osx", "windows"])
arch = filter(a -> getfield(p, Symbol(a)), ["x64", "x86", "arm64"])
versions = collect_versions(t, p.extra_versions)
allow_failures = filter(in(versions), ALLOWED_FAILURES)
excludes = Dict{String, String}[]
p.x86 && p.osx && push!(excludes, Dict("E_OS" => "osx", "E_ARCH" => "x86"))
if p.arm64
p.osx && push!(excludes, Dict("E_OS" => "osx", "E_ARCH" => "arm64"))
p.windows && push!(excludes, Dict("E_OS" => "windows", "E_ARCH" => "arm64"))
"nightly" in versions && push!(excludes, Dict("E_JULIA" => "nightly", "E_ARCH" => "arm64"))
end
return Dict(
"ALLOW_FAILURES" => allow_failures,
"ARCH" => arch,
"EXCLUDES" => excludes,
"HAS_ALLOW_FAILURES" => !isempty(allow_failures),
"HAS_CODECOV" => hasplugin(t, Codecov),
"HAS_COVERAGE" => p.coverage && hasplugin(t, is_coverage),
"HAS_COVERALLS" => hasplugin(t, Coveralls),
"HAS_DOCUMENTER" => hasplugin(t, Documenter{TravisCI}),
"HAS_EXCLUDES" => !isempty(excludes),
"OS" => os,
"PKG" => pkg,
"USER" => t.user,
"VERSION" => format_version(t.julia),
"VERSIONS" => versions,
)
end
"""
AppVeyor(;
file="$(contractuser(default_file("appveyor.yml")))",
x86=false,
coverage=true,
extra_versions=$DEFAULT_CI_VERSIONS,
)
Integrates your packages with [AppVeyor](https://appveyor.com)
via [AppVeyor.jl](https://github.com/JuliaCI/Appveyor.jl).
## Keyword Arguments
- `file::AbstractString`: Template file for `.appveyor.yml`.
- `x86::Bool`: Whether or not to run builds on 32-bit systems,
in addition to the default 64-bit builds.
- `coverage::Bool`: Whether or not to publish code coverage.
[`Codecov`](@ref) must also be included.
$EXTRA_VERSIONS_DOC
"""
@with_kw_noshow struct AppVeyor <: BasicPlugin
file::String = default_file("appveyor.yml")
x86::Bool = false
coverage::Bool = true
extra_versions::Vector = DEFAULT_CI_VERSIONS
end
source(p::AppVeyor) = p.file
destination(::AppVeyor) = ".appveyor.yml"
badges(::AppVeyor) = Badge(
"Build Status",
"https://ci.appveyor.com/api/projects/status/github/{{{USER}}}/{{{PKG}}}.jl?svg=true",
"https://ci.appveyor.com/project/{{{USER}}}/{{{PKG}}}-jl",
)
function view(p::AppVeyor, t::Template, pkg::AbstractString)
platforms = ["x64"]
p.x86 && push!(platforms, "x86")
versions = collect_versions(t, p.extra_versions)
allow_failures = filter(in(versions), ALLOWED_FAILURES)
return Dict(
"ALLOW_FAILURES" => allow_failures,
"HAS_ALLOW_FAILURES" => !isempty(allow_failures),
"HAS_CODECOV" => p.coverage && hasplugin(t, Codecov),
"PKG" => pkg,
"PLATFORMS" => platforms,
"USER" => t.user,
"VERSIONS" => versions,
)
end
"""
CirrusCI(;
file="$(contractuser(default_file("cirrus.yml")))",
image="freebsd-12-0-release-amd64",
coverage=true,
extra_versions=$DEFAULT_CI_VERSIONS,
)
Integrates your packages with [Cirrus CI](https://cirrus-ci.org)
via [CirrusCI.jl](https://github.com/ararslan/CirrusCI.jl).
## Keyword Arguments
- `file::AbstractString`: Template file for `.cirrus.yml`.
- `image::AbstractString`: The FreeBSD image to be used.
- `coverage::Bool`: Whether or not to publish code coverage.
[`Codecov`](@ref) must also be included.
$EXTRA_VERSIONS_DOC
!!! note
Code coverage submission from Cirrus CI is not yet supported by
[Coverage.jl](https://github.com/JuliaCI/Coverage.jl).
"""
@with_kw_noshow struct CirrusCI <: BasicPlugin
file::String = default_file("cirrus.yml")
image::String = "freebsd-12-0-release-amd64"
coverage::Bool = true
extra_versions::Vector = DEFAULT_CI_VERSIONS
end
source(p::CirrusCI) = p.file
destination(::CirrusCI) = ".cirrus.yml"
badges(::CirrusCI) = Badge(
"Build Status",
"https://api.cirrus-ci.com/github/{{{USER}}}/{{{PKG}}}.jl.svg",
"https://cirrus-ci.com/github/{{{USER}}}/{{{PKG}}}.jl",
)
function view(p::CirrusCI, t::Template, pkg::AbstractString)
return Dict(
"HAS_CODECOV" => hasplugin(t, Codecov),
"HAS_COVERALLS" => hasplugin(t, Coveralls),
"HAS_COVERAGE" => p.coverage && hasplugin(t, is_coverage),
"IMAGE" => p.image,
"PKG" => pkg,
"USER" => t.user,
"VERSIONS" => collect_versions(t, p.extra_versions),
)
end
"""
GitLabCI(;
file="$(contractuser(default_file("gitlab-ci.yml")))",
coverage=true,
extra_versions=$DEFAULT_CI_VERSIONS_NO_NIGHTLY,
)
Integrates your packages with [GitLab CI](https://docs.gitlab.com/ce/ci).
## Keyword Arguments
- `file::AbstractString`: Template file for `.gitlab-ci.yml`.
- `coverage::Bool`: Whether or not to compute code coverage.
$EXTRA_VERSIONS_DOC
## GitLab Pages
Documentation can be generated by including a `Documenter{GitLabCI}` plugin.
See [`Documenter`](@ref) for more information.
!!! note
Nightly Julia is not supported.
"""
@with_kw_noshow struct GitLabCI <: BasicPlugin
file::String = default_file("gitlab-ci.yml")
coverage::Bool = true
# Nightly has no Docker image.
extra_versions::Vector = DEFAULT_CI_VERSIONS_NO_NIGHTLY
end
gitignore(p::GitLabCI) = p.coverage ? COVERAGE_GITIGNORE : String[]
source(p::GitLabCI) = p.file
destination(::GitLabCI) = ".gitlab-ci.yml"
function badges(p::GitLabCI)
ci = Badge(
"Build Status",
"https://gitlab.com/{{{USER}}}/{{{PKG}}}.jl/badges/master/build.svg",
"https://gitlab.com/{{{USER}}}/{{{PKG}}}.jl/pipelines",
)
cov = Badge(
"Coverage",
"https://gitlab.com/{{{USER}}}/{{{PKG}}}.jl/badges/master/coverage.svg",
"https://gitlab.com/{{{USER}}}/{{{PKG}}}.jl/commits/master",
)
return p.coverage ? [ci, cov] : [ci]
end
function view(p::GitLabCI, t::Template, pkg::AbstractString)
return Dict(
"HAS_COVERAGE" => p.coverage,
"HAS_DOCUMENTER" => hasplugin(t, Documenter{GitLabCI}),
"PKG" => pkg,
"USER" => t.user,
"VERSION" => format_version(t.julia),
"VERSIONS" => collect_versions(t, p.extra_versions),
)
end
"""
DroneCI(;
file="$(contractuser(default_file("drone.star")))",
amd64=true,
arm=false,
arm64=false,
extra_versions=$DEFAULT_CI_VERSIONS_NO_NIGHTLY,
)
Integrates your packages with [Drone CI](https://drone.io).
## Keyword Arguments
- `file::AbstractString`: Template file for `.drone.star`.
- `destination::AbstractString`: File destination, relative to the repository root.
For example, you might want to generate a `.drone.yml` instead of the default Starlark file.
- `amd64::Bool`: Whether or not to run builds on AMD64.
- `arm::Bool`: Whether or not to run builds on ARM (32-bit).
- `arm64::Bool`: Whether or not to run builds on ARM64.
$EXTRA_VERSIONS_DOC
!!! note
Nightly Julia is not supported.
"""
@with_kw_noshow struct DroneCI <: BasicPlugin
file::String = default_file("drone.star")
destination::String = ".drone.star"
amd64::Bool = true
arm::Bool = false
arm64::Bool = false
extra_versions::Vector = DEFAULT_CI_VERSIONS_NO_NIGHTLY
end
source(p::DroneCI) = p.file
destination(p::DroneCI) = p.destination
badges(::DroneCI) = Badge(
"Build Status",
"https://cloud.drone.io/api/badges/{{{USER}}}/{{{PKG}}}.jl/status.svg",
"https://cloud.drone.io/{{{USER}}}/{{{PKG}}}.jl",
)
function view(p::DroneCI, t::Template, pkg::AbstractString)
arches = String[]
p.amd64 && push!(arches, "amd64")
p.arm && push!(arches, "arm")
p.arm64 && push!(arches, "arm64")
return Dict(
"ARCHES" => join(map(repr, arches), ", "),
"PKG" => pkg,
"USER" => t.user,
"VERSIONS" => join(map(repr, collect_versions(t, p.extra_versions)), ", "),
)
end
"""
collect_versions(t::Template, versions::Vector) -> Vector{String}
Combine `t`'s Julia version with `versions`, and format them as `major.minor`.
This is useful for creating lists of versions to be included in CI configurations.
"""
function collect_versions(t::Template, versions::Vector)
vs = map(format_version, [t.julia, versions...])
return sort(unique(vs))
end
"""
is_ci(::Plugin) -> Bool
Determine whether or not a plugin is a CI plugin.
If you are adding a CI plugin, you should implement this function and return `true`.
"""
is_ci(::Plugin) = false
is_ci(::Union{AppVeyor, GitHubActions, TravisCI, CirrusCI, GitLabCI, DroneCI}) = true
needs_username(::Union{AppVeyor, GitHubActions, TravisCI, CirrusCI, GitLabCI, DroneCI}) = true

View File

@ -1,45 +0,0 @@
"""
CirrusCI(; config_file::Union{AbstractString, Nothing}="") -> CirrusCI
Add `CirrusCI` to a template's plugins to add a `.cirrus.yml` configuration file to
generated repositories, and an appropriate badge to the README. The default configuration
file supports only FreeBSD builds via [CirrusCI.jl](https://github.com/ararslan/CirrusCI.jl)
# Keyword Arguments
* `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.cirrus.yml`.
If `nothing` is supplied, no file will be generated.
"""
struct CirrusCI <: GenericPlugin
gitignore::Vector{String}
src::Union{String, Nothing}
dest::String
badges::Vector{Badge}
view::Dict{String, Any}
function CirrusCI(; config_file::Union{AbstractString, Nothing}="")
if config_file !== nothing
config_file = if isempty(config_file)
joinpath(DEFAULTS_DIR, "cirrus.yml")
elseif isfile(config_file)
abspath(config_file)
else
throw(ArgumentError("File $(abspath(config_file)) does not exist"))
end
end
return new(
[],
config_file,
".cirrus.yml",
[
Badge(
"Build Status",
"https://api.cirrus-ci.com/github/{{USER}}/{{PKGNAME}}.jl.svg",
"https://cirrus-ci.com/github/{{USER}}/{{PKGNAME}}.jl",
),
],
Dict{String, Any}(),
)
end
end
interactive(::Type{CirrusCI}) = interactive(CirrusCI; file="cirrus.yml")

View File

@ -1,50 +1,28 @@
"""
Citation(; readme_section::Bool=false)
Citation(; file="$(contractuser(default_file("CITATION.bib")))", readme=false)
Add `Citation` to a template's plugins to add a `CITATION.bib` file to
generated repositories, and an appropriate section in the README.
Creates a `CITATION.bib` file for citing package repositories.
# Keyword Arguments:
* `readme_section::Bool=false`: whether to add a section in the readme pointing to `CITATION.bib`.
## Keyword Arguments
- `file::AbstractString`: Template file for `CITATION.bib`.
- `readme::Bool`: Whether or not to include a section about citing in the README.
"""
struct Citation <: GenericPlugin
gitignore::Vector{AbstractString}
src::Union{String, Nothing}
dest::AbstractString
badges::Vector{Badge}
view::Dict{String, Any}
readme_section::Bool
function Citation(; readme_section::Bool=false)
new(
[],
nothing,
"CITATION.bib",
[],
Dict{String, Any}(),
readme_section,
)
end
@with_kw_noshow struct Citation <: BasicPlugin
file::String = default_file("CITATION.bib")
readme::Bool = false
end
function interactive(::Type{Citation})
print("Citation: Add a section to README.md mentioning CITATION.bib? [no]: ")
readme = uppercase(readline()) in ["Y", "YES", "TRUE"]
return Citation(; readme_section=readme)
end
tags(::Citation) = "<<", ">>"
source(p::Citation) = p.file
destination(::Citation) = "CITATION.bib"
function gen_plugin(p::Citation, t::Template, pkg_name::AbstractString)
pkg_dir = joinpath(t.dir, pkg_name)
text = """
@misc{$pkg_name.jl,
\tauthor = {$(t.authors)},
\ttitle = {{$(pkg_name).jl}},
\turl = {https://$(t.host)/$(t.user)/$(pkg_name).jl},
\tversion = {v0.1.0},
\tyear = {$(year(today()))},
\tmonth = {$(month(today()))}
}
"""
gen_file(joinpath(pkg_dir, "CITATION.bib"), text)
return ["CITATION.bib"]
end
view(::Citation, t::Template, pkg::AbstractString) = Dict(
"AUTHORS" => join(t.authors, ", "),
"MONTH" => month(today()),
"PKG" => pkg,
"URL" => "https://$(t.host)/$(t.user)/$pkg.jl",
"YEAR" => year(today()),
)
needs_username(::Citation) = true

View File

@ -1,44 +0,0 @@
"""
Codecov(; config_file::Union{AbstractString, Nothing}=nothing) -> Codecov
Add `Codecov` to a template's plugins to optionally add a `.codecov.yml` configuration file
to generated repositories, and an appropriate badge to the README. Also updates the
`.gitignore` accordingly.
# Keyword Arguments:
* `config_file::Union{AbstractString, Nothing}=nothing`: Path to a custom `.codecov.yml`.
If left unset, no file will be generated.
"""
struct Codecov <: GenericPlugin
gitignore::Vector{String}
src::Union{String, Nothing}
dest::String
badges::Vector{Badge}
view::Dict{String, Any}
function Codecov(; config_file::Union{AbstractString, Nothing}=nothing)
if config_file != nothing
config_file = if isfile(config_file)
abspath(config_file)
else
throw(ArgumentError("File $(abspath(config_file)) does not exist"))
end
end
new(
["*.jl.cov", "*.jl.*.cov", "*.jl.mem"],
config_file,
".codecov.yml",
[
Badge(
"Codecov",
"https://codecov.io/gh/{{USER}}/{{PKGNAME}}.jl/branch/master/graph/badge.svg",
"https://codecov.io/gh/{{USER}}/{{PKGNAME}}.jl",
),
],
Dict{String, Any}(),
)
end
end
Base.@deprecate_binding CodeCov Codecov
interactive(::Type{Codecov}) = interactive(Codecov; file=nothing)

58
src/plugins/coverage.jl Normal file
View File

@ -0,0 +1,58 @@
const COVERAGE_GITIGNORE = ["*.jl.cov", "*.jl.*.cov", "*.jl.mem"]
"""
Codecov(; file=nothing)
Sets up code coverage submission from CI to [Codecov](https://codecov.io).
## Keyword Arguments
- `file::Union{AbstractString, Nothing}`: Template file for `.codecov.yml`,
or `nothing` to create no file.
"""
@with_kw_noshow struct Codecov <: BasicPlugin
file::Union{String, Nothing} = nothing
end
source(p::Codecov) = p.file
destination(::Codecov) = ".codecov.yml"
badges(::Codecov) = Badge(
"Coverage",
"https://codecov.io/gh/{{{USER}}}/{{{PKG}}}.jl/branch/master/graph/badge.svg",
"https://codecov.io/gh/{{{USER}}}/{{{PKG}}}.jl",
)
"""
Coveralls(; file=nothing)
Sets up code coverage submission from CI to [Coveralls](https://coveralls.io).
## Keyword Arguments
- `file::Union{AbstractString, Nothing}`: Template file for `.coveralls.yml`,
or `nothing` to create no file.
"""
@with_kw_noshow struct Coveralls <: BasicPlugin
file::Union{String, Nothing} = nothing
end
source(p::Coveralls) = p.file
destination(::Coveralls) = ".coveralls.yml"
badges(::Coveralls) = Badge(
"Coverage",
"https://coveralls.io/repos/github/{{{USER}}}/{{{PKG}}}.jl/badge.svg?branch=master",
"https://coveralls.io/github/{{{USER}}}/{{{PKG}}}.jl?branch=master",
)
gitignore(::Union{Codecov, Coveralls}) = COVERAGE_GITIGNORE
"""
is_coverage(::Plugin) -> Bool
Determine whether or not a plugin is a coverage plugin.
If you are adding a coverage plugin, you should implement this function and return `true`.
"""
is_coverage(::Plugin) = false
is_coverage(::Union{Codecov, Coveralls}) = true
needs_username(::Union{Codecov, Coveralls}) = true

View File

@ -1,43 +0,0 @@
"""
Coveralls(; config_file::Union{AbstractString, Nothing}=nothing) -> Coveralls
Add `Coveralls` to a template's plugins to optionally add a `.coveralls.yml` configuration
file to generated repositories, and an appropriate badge to the README. Also updates the
`.gitignore` accordingly.
# Keyword Arguments:
* `config_file::Union{AbstractString, Nothing}=nothing`: Path to a custom `.coveralls.yml`.
If left unset, no file will be generated.
"""
struct Coveralls <: GenericPlugin
gitignore::Vector{String}
src::Union{String, Nothing}
dest::String
badges::Vector{Badge}
view::Dict{String, Any}
function Coveralls(; config_file::Union{AbstractString, Nothing}=nothing)
if config_file != nothing
config_file = if isfile(config_file)
abspath(config_file)
else
throw(ArgumentError("File $(abspath(config_file)) does not exist"))
end
end
new(
["*.jl.cov", "*.jl.*.cov", "*.jl.mem"],
config_file,
".coveralls.yml",
[
Badge(
"Coveralls",
"https://coveralls.io/repos/github/{{USER}}/{{PKGNAME}}.jl/badge.svg?branch=master",
"https://coveralls.io/github/{{USER}}/{{PKGNAME}}.jl?branch=master",
),
],
Dict{String, Any}(),
)
end
end
interactive(::Type{Coveralls}) = interactive(Coveralls; file=nothing)

13
src/plugins/develop.jl Normal file
View File

@ -0,0 +1,13 @@
"""
Develop()
Adds generated packages to the current environment by `dev`ing them.
See the Pkg documentation
[here](https://julialang.github.io/Pkg.jl/v1/managing-packages/#Developing-packages-1)
for more details.
"""
struct Develop <: Plugin end
function posthook(::Develop, ::Template, pkg_dir::AbstractString)
Pkg.develop(PackageSpec(; path=pkg_dir))
end

View File

@ -1,127 +1,138 @@
const DOCUMENTER_UUID = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
const STANDARD_KWS = [:modules, :format, :pages, :repo, :sitename, :authors, :assets]
const DOCUMENTER_DEP = PackageSpec(;
name="Documenter",
uuid="e30172f5-a6a5-5a46-863b-614d45cd2de4",
)
const DeployStyle = Union{TravisCI, GitHubActions, GitLabCI, Nothing}
const GitHubPagesStyle = Union{TravisCI, GitHubActions}
"""
Add a `Documenter` subtype to a template's plugins to add support for documentation
generation via [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl).
Documenter{T<:Union{TravisCI, GitLabCI, Nothing}}(;
make_jl="$(contractuser(default_file("docs", "make.jl")))",
index_md="$(contractuser(default_file("docs", "src", "index.md")))",
assets=String[],
canonical_url=make_canonical(T),
makedocs_kwargs=Dict{Symbol, Any}(),
)
By default, the plugin generates a minimal index.md and a make.jl file. The make.jl
file contains the Documenter.makedocs command with predefined values for `modules`,
`format`, `pages`, `repo`, `sitename`, and `authors`.
Sets up documentation generation via [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl).
Documentation deployment depends on `T`, where `T` is some supported CI plugin,
or `Nothing` to only support local documentation builds.
The subtype is expected to include the following fields:
* `assets::Vector{AbstractString}`, a list of filenames to be included as the `assets`
kwarg to `makedocs`
* `gitignore::Vector{AbstractString}`, a list of files to be added to the `.gitignore`
## Supported Type Parameters
- `GitHubActions`: Deploys documentation to [GitHub Pages](https://pages.github.com)
with the help of [`GitHubActions`](@ref).
- `TravisCI`: Deploys documentation to [GitHub Pages](https://pages.github.com)
with the help of [`TravisCI`](@ref).
- `GitLabCI`: Deploys documentation to [GitLab Pages](https://pages.gitlab.com)
with the help of [`GitLabCI`](@ref).
- `Nothing` (default): Does not set up documentation deployment.
It may optionally include the field `additional_kwargs::Union{AbstractDict, NamedTuple}`
to allow additional kwargs to be added to `makedocs`.
## Keyword Arguments
- `make_jl::AbstractString`: Template file for `make.jl`.
- `index_md::AbstractString`: Template file for `index.md`.
- `assets::Vector{<:AbstractString}`: Extra assets for the generated site.
- `canonical_url::Union{Function, Nothing}`: A function to generate the site's canonical URL.
The default value will compute GitHub Pages and GitLab Pages URLs
for [`TravisCI`](@ref) and [`GitLabCI`](@ref), respectively.
If set to `nothing`, no canonical URL is set.
- `makedocs_kwargs::Dict{Symbol}`: Extra keyword arguments to be inserted into `makedocs`.
!!! note
If deploying documentation with Travis CI, don't forget to complete
[the required configuration](https://juliadocs.github.io/Documenter.jl/stable/man/hosting/#SSH-Deploy-Keys-1).
"""
abstract type Documenter <: CustomPlugin end
struct Documenter{T<:DeployStyle} <: Plugin
assets::Vector{String}
makedocs_kwargs::Dict{Symbol}
canonical_url::Union{Function, Nothing}
make_jl::String
index_md::String
function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString)
path = joinpath(t.dir, pkg_name)
docs_dir = joinpath(path, "docs")
mkpath(docs_dir)
# Can't use @with_kw_noshow due to some weird precompilation issues.
function Documenter{T}(;
assets::Vector{<:AbstractString}=String[],
makedocs_kwargs::Dict{Symbol}=Dict{Symbol, Any}(),
canonical_url::Union{Function, Nothing}=make_canonical(T),
make_jl::AbstractString=default_file("docs", "make.jl"),
index_md::AbstractString=default_file("docs", "src", "index.md"),
) where T <: DeployStyle
return new(assets, makedocs_kwargs, canonical_url, make_jl, index_md)
end
end
Documenter(; kwargs...) = Documenter{Nothing}(; kwargs...)
gitignore(::Documenter) = ["/docs/build/"]
badges(::Documenter) = Badge[]
badges(::Documenter{<:GitHubPagesStyle}) = [
Badge(
"Stable",
"https://img.shields.io/badge/docs-stable-blue.svg",
"https://{{{USER}}}.github.io/{{{PKG}}}.jl/stable",
),
Badge(
"Dev",
"https://img.shields.io/badge/docs-dev-blue.svg",
"https://{{{USER}}}.github.io/{{{PKG}}}.jl/dev",
),
]
badges(::Documenter{GitLabCI}) = Badge(
"Dev",
"https://img.shields.io/badge/docs-dev-blue.svg",
"https://{{{USER}}}.gitlab.io/{{{PKG}}}.jl/dev",
)
view(p::Documenter, t::Template, pkg::AbstractString) = Dict(
"ASSETS" => map(basename, p.assets),
"AUTHORS" => join(t.authors, ", "),
"CANONICAL" => p.canonical_url === nothing ? nothing : p.canonical_url(t, pkg),
"HAS_ASSETS" => !isempty(p.assets),
"MAKEDOCS_KWARGS" => map(((k, v),) -> k => repr(v), collect(p.makedocs_kwargs)),
"PKG" => pkg,
"REPO" => "$(t.host)/$(t.user)/$pkg.jl",
"USER" => t.user,
)
function view(p::Documenter{<:GitHubPagesStyle}, t::Template, pkg::AbstractString)
base = invoke(view, Tuple{Documenter, Template, AbstractString}, p, t, pkg)
return merge(base, Dict("HAS_DEPLOY" => true))
end
validate(::Documenter{Nothing}, ::Template) = nothing
function validate(::Documenter{T}, t::Template) where T <: DeployStyle
if !hasplugin(t, T)
name = nameof(T)
s = "Documenter: The $name plugin must be included for docs deployment to be set up"
throw(ArgumentError(s))
end
end
function hook(p::Documenter, t::Template, pkg_dir::AbstractString)
pkg = basename(pkg_dir)
docs_dir = joinpath(pkg_dir, "docs")
# Generate files.
make = render_file(p.make_jl, combined_view(p, t, pkg), tags(p))
index = render_file(p.index_md, combined_view(p, t, pkg), tags(p))
gen_file(joinpath(docs_dir, "make.jl"), make)
gen_file(joinpath(docs_dir, "src", "index.md"), index)
# Copy over any assets.
assets_dir = joinpath(docs_dir, "src", "assets")
isempty(p.assets) || mkpath(assets_dir)
foreach(a -> cp(a, joinpath(assets_dir, basename(a))), p.assets)
# Create the documentation project.
proj = Base.current_project()
try
Pkg.activate(docs_dir)
Pkg.add(PackageSpec(; name="Documenter", uuid=DOCUMENTER_UUID))
finally
proj === nothing ? Pkg.activate() : Pkg.activate(proj)
end
tab = repeat(" ", 4)
assets_string = if !isempty(p.assets)
mkpath(joinpath(docs_dir, "src", "assets"))
for file in p.assets
cp(file, joinpath(docs_dir, "src", "assets", basename(file)))
end
# We want something that looks like the following:
# [
# assets/file1,
# assets/file2,
# ]
s = "[\n"
for asset in p.assets
s *= """$(tab^2)"assets/$(basename(asset))",\n"""
end
s *= "$tab]"
s
else
"String[]"
end
kwargs_string = if :additional_kwargs in fieldnames(typeof(p)) &&
fieldtype(typeof(p), :additional_kwargs) <: Union{AbstractDict, NamedTuple}
# We want something that looks like the following:
# key1="val1",
# key2="val2",
#
kws = [keys(p.additional_kwargs)...]
valid_keys = filter(k -> !in(Symbol(k), STANDARD_KWS), kws)
if length(p.additional_kwargs) > length(valid_keys)
invalid_keys = filter(k -> Symbol(k) in STANDARD_KWS, kws)
@warn string(
"Ignoring predefined Documenter kwargs ",
join(map(repr, invalid_keys), ", "),
" from additional kwargs"
)
end
join(map(k -> string(tab, k, "=", repr(p.additional_kwargs[k]), ",\n"), valid_keys))
else
""
end
make = """
using Documenter, $pkg_name
makedocs(;
modules=[$pkg_name],
format=Documenter.HTML(),
pages=[
"Home" => "index.md",
],
repo="https://$(t.host)/$(t.user)/$pkg_name.jl/blob/{commit}{path}#L{line}",
sitename="$pkg_name.jl",
authors="$(t.authors)",
assets=$assets_string,
$kwargs_string)
"""
docs = """
# $pkg_name.jl
```@index
```
```@autodocs
Modules = [$pkg_name]
```
"""
gen_file(joinpath(docs_dir, "make.jl"), make)
gen_file(joinpath(docs_dir, "src", "index.md"), docs)
with_project(() -> Pkg.add(DOCUMENTER_DEP), docs_dir)
end
function Base.show(io::IO, p::Documenter)
spc = " "
println(io, nameof(typeof(p)), ":")
github_pages_url(t::Template, pkg::AbstractString) = "https://$(t.user).github.io/$pkg.jl"
gitlab_pages_url(t::Template, pkg::AbstractString) = "https://$(t.user).gitlab.io/$pkg.jl"
n = length(p.assets)
s = n == 1 ? "" : "s"
print(io, spc, "$n asset file$s")
if n == 0
println(io)
else
println(io, ": ", join(map(a -> replace(a, homedir() => "~"), p.assets), ", "))
end
make_canonical(::Type{<:GitHubPagesStyle}) = github_pages_url
make_canonical(::Type{GitLabCI}) = gitlab_pages_url
make_canonical(::Type{Nothing}) = nothing
n = length(p.gitignore)
s = n == 1 ? "" : "s"
print(io, "$spc→ $n gitignore entrie$s")
n > 0 && print(io, ": ", join(map(repr, p.gitignore), ", "))
end
needs_username(::Documenter) = true

View File

@ -1,45 +0,0 @@
"""
DroneCI(; config_file::Union{AbstractString, Nothing}="") -> DroneCI
Add `DroneCI` to a template's plugins to add a `.drone.yml` configuration file to
generated repositories, and an appropriate badge to the README. The default configuration
file supports Linux on ARM32 and ARM64.
# Keyword Arguments
* `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.drone.yml`.
If `nothing` is supplied, no file will be generated.
"""
struct DroneCI <: GenericPlugin
gitignore::Vector{String}
src::Union{String, Nothing}
dest::String
badges::Vector{Badge}
view::Dict{String, Any}
function DroneCI(; config_file::Union{AbstractString, Nothing}="")
if config_file !== nothing
config_file = if isempty(config_file)
joinpath(DEFAULTS_DIR, "drone.yml")
elseif isfile(config_file)
abspath(config_file)
else
throw(ArgumentError("File $(abspath(config_file)) does not exist"))
end
end
return new(
[],
config_file,
".drone.yml",
[
Badge(
"Build Status",
"https://cloud.drone.io/api/badges/{{USER}}/{{PKGNAME}}.jl/status.svg",
"https://cloud.drone.io/{{USER}}/{{PKGNAME}}.jl",
),
],
Dict{String, Any}(),
)
end
end
interactive(::Type{DroneCI}) = interactive(DroneCI; file="drone.yml")

118
src/plugins/git.jl Normal file
View File

@ -0,0 +1,118 @@
"""
Git(; ignore=String[], ssh=false, manifest=false, gpgsign=false)
Creates a Git repository and a `.gitignore` file.
## Keyword Arguments
- `ignore::Vector{<:AbstractString}`: Patterns to add to the `.gitignore`.
See also: [`gitignore`](@ref).
- `ssh::Bool`: Whether or not to use SSH for the remote.
If left unset, HTTPS is used.
- `manifest::Bool`: Whether or not to commit `Manifest.toml`.
- `gpgsign::Bool`: Whether or not to sign commits with your GPG key.
This option requires that the Git CLI is installed,
and for you to have a GPG key associated with your committer identity.
"""
@with_kw_noshow struct Git <: Plugin
ignore::Vector{String} = String[]
ssh::Bool = false
manifest::Bool = false
gpgsign::Bool = false
end
# Try to make sure that no files are created after we commit.
priority(::Git, ::typeof(posthook)) = 5
Base.:(==)(a::Git, b::Git) = all(map(n -> getfield(a, n) == getfield(b, n), fieldnames(Git)))
function gitignore(p::Git)
ignore = copy(p.ignore)
p.manifest || push!(ignore, "Manifest.toml")
return ignore
end
function validate(p::Git, t::Template)
if p.gpgsign && !git_is_installed()
throw(ArgumentError("Git: gpgsign is set but the Git CLI is not installed"))
end
foreach(("user.name", "user.email")) do k
if isempty(LibGit2.getconfig(k, ""))
throw(ArgumentError("Git: Global Git config is missing required value '$k'"))
end
end
end
# Set up the Git repository.
function prehook(p::Git, t::Template, pkg_dir::AbstractString)
LibGit2.with(LibGit2.init(pkg_dir)) do repo
commit(p, repo, pkg_dir, "Initial commit")
pkg = basename(pkg_dir)
url = if p.ssh
"git@$(t.host):$(t.user)/$pkg.jl.git"
else
"https://$(t.host)/$(t.user)/$pkg.jl"
end
LibGit2.with(GitRemote(repo, "origin", url)) do remote
LibGit2.add_fetch!(repo, remote, "refs/heads/master")
LibGit2.add_push!(repo, remote, "refs/heads/master")
end
end
end
# Create the .gitignore.
function hook(p::Git, t::Template, pkg_dir::AbstractString)
ignore = mapreduce(gitignore, vcat, t.plugins)
# Only ignore manifests at the repo root.
p.manifest || "Manifest.toml" in ignore || push!(ignore, "/Manifest.toml")
unique!(sort!(ignore))
gen_file(joinpath(pkg_dir, ".gitignore"), join(ignore, "\n"))
end
# Commit the files.
function posthook(p::Git, ::Template, pkg_dir::AbstractString)
# Ensure that the manifest exists if it's going to be committed.
manifest = joinpath(pkg_dir, "Manifest.toml")
if p.manifest && !isfile(manifest)
touch(manifest)
with_project(Pkg.update, pkg_dir)
end
LibGit2.with(GitRepo(pkg_dir)) do repo
LibGit2.add!(repo, ".")
msg = "Files generated by PkgTemplates"
v = version_of("PkgTemplates")
v === nothing || (msg *= "\n\nPkgTemplates version: $v")
commit(p, repo, pkg_dir, msg)
end
end
function commit(p::Git, repo::GitRepo, pkg_dir::AbstractString, msg::AbstractString)
if p.gpgsign
run(pipeline(`git -C $pkg_dir commit -S --allow-empty -m $msg`; stdout=devnull))
else
LibGit2.commit(repo, msg)
end
end
needs_username(::Git) = true
function git_is_installed()
return try
run(pipeline(`git --version`; stdout=devnull))
true
catch
false
end
end
if isdefined(Pkg, :dependencies)
function version_of(pkg::AbstractString)
for p in values(Pkg.dependencies())
p.name == pkg && return p.version
end
return nothing
end
else
version_of(pkg::AbstractString) = get(Pkg.installed(), pkg, nothing)
end

View File

@ -1,69 +0,0 @@
"""
GitHubPages(; assets::Vector{<:AbstractString}=String[]) -> GitHubPages
Add `GitHubPages` to a template's plugins to add [`Documenter`](@ref) support via GitHub
Pages, including automatic uploading of documentation from [`TravisCI`](@ref). Also
adds appropriate badges to the README, and updates the `.gitignore` accordingly.
# Keyword Arguments
* `assets::Vector{<:AbstractString}=String[]`: Array of paths to Documenter asset files.
!!! note
If deploying documentation with Travis CI, don't forget to complete the required
configuration (see
[here](https://juliadocs.github.io/Documenter.jl/stable/man/hosting/#SSH-Deploy-Keys-1)).
"""
struct GitHubPages <: Documenter
gitignore::Vector{String}
assets::Vector{String}
function GitHubPages(; assets::Vector{<:AbstractString}=String[])
for file in assets
if !isfile(file)
throw(ArgumentError("Asset file $(abspath(file)) does not exist"))
end
end
# Windows Git recognizes these paths as well.
new(["/docs/build/", "/docs/site/"], abspath.(assets))
end
end
function badges(::GitHubPages, user::AbstractString, pkg_name::AbstractString)
return [
format(Badge(
"Stable",
"https://img.shields.io/badge/docs-stable-blue.svg",
"https://$user.github.io/$pkg_name.jl/stable"
)),
format(Badge(
"Dev",
"https://img.shields.io/badge/docs-dev-blue.svg",
"https://$user.github.io/$pkg_name.jl/dev"
)),
]
end
function gen_plugin(p::GitHubPages, t::Template, pkg_name::AbstractString)
invoke(gen_plugin, Tuple{Documenter, Template, AbstractString}, p, t, pkg_name)
if haskey(t.plugins, TravisCI)
docs_src = joinpath(t.dir, pkg_name, "docs", "src")
open(joinpath(dirname(docs_src), "make.jl"), "a") do file
write(
file,
"""
deploydocs(;
repo="$(t.host)/$(t.user)/$pkg_name.jl",
)
"""
)
end
end
return ["docs/"]
end
function interactive(::Type{GitHubPages})
print("GitHubPages: Enter any Documenter asset files (separated by spaces) []: ")
return GitHubPages(; assets=string.(split(readline())))
end

View File

@ -1,83 +0,0 @@
"""
GitLabCI(; config_file::Union{AbstractString, Nothing}="", coverage::Bool=true) -> GitLabCI
Add `GitLabCI` to a template's plugins to add a `.gitlab-ci.yml` configuration file to
generated repositories, and appropriate badge(s) to the README.
# Keyword Arguments:
* `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.gitlab-ci.yml`.
If `nothing` is supplied, no file will be generated.
* `coverage::Bool=true`: Whether or not GitLab CI's built-in code coverage analysis should
be enabled.
"""
struct GitLabCI <: GenericPlugin
gitignore::Vector{String}
src::Union{String, Nothing}
dest::String
badges::Vector{Badge}
view::Dict{String, Any}
function GitLabCI(; config_file::Union{AbstractString, Nothing}="", coverage::Bool=true)
if config_file != nothing
config_file = if isempty(config_file)
config_file = joinpath(DEFAULTS_DIR, "gitlab-ci.yml")
elseif isfile(config_file)
abspath(config_file)
else
throw(ArgumentError("File $(abspath(config_file)) does not exist"))
end
end
badges = [
Badge(
"Build Status",
"https://gitlab.com/{{USER}}/{{PKGNAME}}.jl/badges/master/build.svg",
"https://gitlab.com/{{USER}}/{{PKGNAME}}.jl/pipelines",
),
]
if coverage
push!(
badges,
Badge(
"Coverage",
"https://gitlab.com/{{USER}}/{{PKGNAME}}.jl/badges/master/coverage.svg",
"https://gitlab.com/{{USER}}/{{PKGNAME}}.jl/commits/master",
),
)
end
new(
coverage ? ["*.jl.cov", "*.jl.*.cov", "*.jl.mem"] : [],
config_file,
".gitlab-ci.yml",
badges,
Dict("GITLABCOVERAGE" => coverage),
)
end
end
function interactive(::Type{GitLabCI})
name = "GitLabCI"
kwargs = Dict{Symbol, Any}()
default_config_file = joinpath(DEFAULTS_DIR, "gitlab-ci.yml")
print("$name: Enter the config template filename (\"None\" for no file) ")
print("[", replace(default_config_file, homedir() => "~"), "]: ")
config_file = readline()
kwargs[:config_file] = if uppercase(config_file) == "NONE"
nothing
elseif isempty(config_file)
default_config_file
else
config_file
end
print("$name: Enable test coverage analysis? [yes]: ")
coverage = readline()
kwargs[:coverage] = if isempty(coverage)
true
else
!in(uppercase(coverage), ["N", "NO", "FALSE", "NONE"])
end
return GitLabCI(; kwargs...)
end

View File

@ -1,47 +0,0 @@
"""
GitLabPages(; assets::Vector{<:AbstractString}=String[]) -> GitLabPages
Add `GitLabPages` to a template's plugins to add [`Documenter`](@ref) support via GitLab
Pages, including automatic uploading of documentation from [`GitLabCI`](@ref). Also
adds appropriate badges to the README, and updates the `.gitignore` accordingly.
# Keyword Arguments
* `assets::Vector{<:AbstractString}=String[]`: Array of paths to Documenter asset files.
"""
struct GitLabPages <: Documenter
gitignore::Vector{String}
assets::Vector{String}
function GitLabPages(; assets::Vector{<:AbstractString}=String[])
for file in assets
if !isfile(file)
throw(ArgumentError("Asset file $(abspath(file)) does not exist"))
end
end
# Windows Git recognizes these paths as well.
new(["/docs/build/", "/docs/site/"], abspath.(assets))
end
end
function badges(::GitLabPages, user::AbstractString, pkg_name::AbstractString)
# We are only including a badge for `dev` documentation since versioned documentation
# is not supported in GitLab pages yet. See:
# https://github.com/invenia/PkgTemplates.jl/pull/54
return [
format(Badge(
"Dev",
"https://img.shields.io/badge/docs-dev-blue.svg",
"https://$user.gitlab.io/$pkg_name.jl/dev"
)),
]
end
function gen_plugin(p::GitLabPages, t::Template, pkg_name::AbstractString)
invoke(gen_plugin, Tuple{Documenter, Template, AbstractString}, p, t, pkg_name)
return ["docs/"]
end
function interactive(::Type{GitLabPages})
print("GitLabPages: Enter any Documenter asset files (separated by spaces) []: ")
return GitLabPages(; assets=string.(split(readline())))
end

37
src/plugins/license.jl Normal file
View File

@ -0,0 +1,37 @@
"""
License(; name="MIT", path=nothing, destination="LICENSE")
Creates a license file.
## Keyword Arguments
- `name::AbstractString`: Name of a license supported by PkgTemplates.
Available licenses can be seen
[here](https://github.com/invenia/PkgTemplates.jl/tree/master/templates/licenses).
- `path::Union{AbstractString, Nothing}`: Path to a custom license file.
This keyword takes priority over `name`.
- `destination::AbstractString`: File destination, relative to the repository root.
For example, `"LICENSE.md"` might be desired.
"""
struct License <: BasicPlugin
path::String
destination::String
end
function License(;
name::AbstractString="MIT",
path::Union{AbstractString, Nothing}=nothing,
destination::AbstractString="LICENSE",
)
if path === nothing
path = default_file("licenses", name)
isfile(path) || throw(ArgumentError("License '$(basename(path))' is not available"))
end
return License(path, destination)
end
source(p::License) = p.path
destination(p::License) = p.destination
view(::License, t::Template, ::AbstractString) = Dict(
"AUTHORS" => join(t.authors, ", "),
"YEAR" => year(today()),
)

View File

@ -0,0 +1,40 @@
"""
ProjectFile(; version=v"0.1.0")
Creates a `Project.toml`.
## Keyword Arguments
- `version::VersionNumber`: The initial version of created packages.
"""
@with_kw_noshow struct ProjectFile <: Plugin
version::VersionNumber = v"0.1.0"
end
# Other plugins like Tests will modify this file.
priority(::ProjectFile, ::typeof(hook)) = typemax(Int) - 5
function hook(p::ProjectFile, t::Template, pkg_dir::AbstractString)
toml = Dict(
"name" => basename(pkg_dir),
"uuid" => string(uuid4()),
"authors" => t.authors,
"version" => string(p.version),
"compat" => Dict("julia" => compat_version(t.julia)),
)
open(io -> TOML.print(io, toml), joinpath(pkg_dir, "Project.toml"), "w")
end
"""
compat_version(v::VersionNumber) -> String
Format a `VersionNumber` to exclude trailing zero components.
"""
function compat_version(v::VersionNumber)
return if v.patch == 0 && v.minor == 0
"$(v.major)"
elseif v.patch == 0
"$(v.major).$(v.minor)"
else
"$(v.major).$(v.minor).$(v.patch)"
end
end

59
src/plugins/readme.jl Normal file
View File

@ -0,0 +1,59 @@
"""
Readme(;
file="$(contractuser(default_file("README.md")))",
destination="README.md",
inline_badges=false,
)
Creates a `README` file that contains badges for other included plugins.
## Keyword Arguments
- `file::AbstractString`: Template file for the `README`.
- `destination::AbstractString`: File destination, relative to the repository root.
For example, values of `"README"` or `"README.rst"` might be desired.
- `inline_badges::Bool`: Whether or not to put the badges on the same line as the package name.
"""
@with_kw_noshow struct Readme <: BasicPlugin
file::String = default_file("README.md")
destination::String = "README.md"
inline_badges::Bool = false
end
source(p::Readme) = p.file
destination(p::Readme) = p.destination
function view(p::Readme, t::Template, pkg::AbstractString)
# Explicitly ordered badges go first.
strings = String[]
done = DataType[]
foreach(badge_order()) do T
if hasplugin(t, T)
append!(strings, badges(getplugin(t, T), t, pkg))
push!(done, T)
end
end
# And the rest go after, in no particular order.
foreach(setdiff(map(typeof, t.plugins), done)) do T
append!(strings, badges(getplugin(t, T), t, pkg))
end
return Dict(
"BADGES" => strings,
"HAS_CITATION" => hasplugin(t, Citation) && getplugin(t, Citation).readme,
"HAS_INLINE_BADGES" => !isempty(strings) && p.inline_badges,
"PKG" => pkg,
)
end
badge_order() = [
Documenter{GitLabCI},
Documenter{TravisCI},
GitHubActions,
GitLabCI,
TravisCI,
AppVeyor,
DroneCI,
CirrusCI,
Codecov,
Coveralls,
]

31
src/plugins/src_dir.jl Normal file
View File

@ -0,0 +1,31 @@
"""
SrcDir(; file="$(contractuser(default_file("src", "module.jl")))")
Creates a module entrypoint.
## Keyword Arguments
- `file::AbstractString`: Template file for `src/<module>.jl`.
"""
@with_kw_noshow mutable struct SrcDir <: BasicPlugin
file::String = default_file("src", "module.jl")
destination::String = ""
end
Base.:(==)(a::SrcDir, b::SrcDir) = a.file == b.file
# Don't display the destination field.
function Base.show(io::IO, ::MIME"text/plain", p::SrcDir)
indent = get(io, :indent, 0)
print(io, repeat(' ', indent), "SrcDir:")
print(io, "\n", repeat(' ', indent + 2), "file: ", show_field(p.file))
end
source(p::SrcDir) = p.file
destination(p::SrcDir) = p.destination
view(::SrcDir, ::Template, pkg::AbstractString) = Dict("PKG" => pkg)
# Update the destination now that we know the package name.
# Kind of hacky, but oh well.
function prehook(p::SrcDir, t::Template, pkg_dir::AbstractString)
p.destination = joinpath("src", basename(pkg_dir) * ".jl")
end

63
src/plugins/tests.jl Normal file
View File

@ -0,0 +1,63 @@
const TEST_UUID = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
const TEST_DEP = PackageSpec(; name="Test", uuid=TEST_UUID)
"""
Tests(; file="$(contractuser(default_file("test", "runtests.jl")))", project=false)
Sets up testing for packages.
## Keyword Arguments
- `file::AbstractString`: Template file for `runtests.jl`.
- `project::Bool`: Whether or not to create a new project for tests (`test/Project.toml`).
See [here](https://julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.2-and-above-1)
for more details.
!!! note
Managing test dependencies with `test/Project.toml` is only supported
in Julia 1.2 and later.
"""
@with_kw_noshow struct Tests <: BasicPlugin
file::String = default_file("test", "runtests.jl")
project::Bool = false
end
source(p::Tests) = p.file
destination(::Tests) = joinpath("test", "runtests.jl")
view(::Tests, ::Template, pkg::AbstractString) = Dict("PKG" => pkg)
function validate(p::Tests, t::Template)
invoke(validate, Tuple{BasicPlugin, Template}, p, t)
p.project && t.julia < v"1.2" && @warn string(
"Tests: The project option is set to create a project (supported in Julia 1.2 and later) ",
"but a Julia version older than 1.2 ($(t.julia)) is supported by the template",
)
end
function hook(p::Tests, t::Template, pkg_dir::AbstractString)
# Do the normal BasicPlugin behaviour to create the test script.
invoke(hook, Tuple{BasicPlugin, Template, AbstractString}, p, t, pkg_dir)
# Then set up the test depdendency in the chosen way.
f = p.project ? make_test_project : add_test_dependency
f(pkg_dir)
end
# Create a new test project.
function make_test_project(pkg_dir::AbstractString)
with_project(() -> Pkg.add(TEST_DEP), joinpath(pkg_dir, "test"))
end
# Add Test as a test-only dependency.
function add_test_dependency(pkg_dir::AbstractString)
# Add the dependency manually since there's no programmatic way to add to [extras].
path = joinpath(pkg_dir, "Project.toml")
toml = TOML.parsefile(path)
get!(toml, "extras", Dict())["Test"] = TEST_UUID
get!(toml, "targets", Dict())["test"] = ["Test"]
open(io -> TOML.print(io, toml), path, "w")
# Generate the manifest by updating the project.
# This also ensures that keys in Project.toml are sorted properly.
touch(joinpath(pkg_dir, "Manifest.toml")) # File must exist to be modified by Pkg.
with_project(Pkg.update, pkg_dir)
end

View File

@ -1,44 +0,0 @@
"""
TravisCI(; config_file::Union{AbstractString, Nothing}="") -> TravisCI
Add `TravisCI` to a template's plugins to add a `.travis.yml` configuration file to
generated repositories, and an appropriate badge to the README.
# Keyword Arguments:
* `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.travis.yml`.
If `nothing` is supplied, no file will be generated.
"""
struct TravisCI <: GenericPlugin
gitignore::Vector{String}
src::Union{String, Nothing}
dest::String
badges::Vector{Badge}
view::Dict{String, Any}
function TravisCI(; config_file::Union{AbstractString, Nothing}="")
if config_file != nothing
config_file = if isempty(config_file)
config_file = joinpath(DEFAULTS_DIR, "travis.yml")
elseif isfile(config_file)
abspath(config_file)
else
throw(ArgumentError("File $(abspath(config_file)) does not exist"))
end
end
new(
[],
config_file,
".travis.yml",
[
Badge(
"Build Status",
"https://travis-ci.com/{{USER}}/{{PKGNAME}}.jl.svg?branch=master",
"https://travis-ci.com/{{USER}}/{{PKGNAME}}.jl",
),
],
Dict{String, Any}(),
)
end
end
interactive(::Type{TravisCI}) = interactive(TravisCI; file="travis.yml")

33
src/show.jl Normal file
View File

@ -0,0 +1,33 @@
function Base.show(io::IO, m::MIME"text/plain", t::Template)
println(io, "Template:")
foreach(fieldnames(Template)) do n
n === :plugins || println(io, repeat(' ', 2), n, ": ", show_field(getfield(t, n)))
end
if isempty(t.plugins)
print(io, " plugins: None")
else
print(io, repeat(' ', 2), "plugins:")
foreach(sort(t.plugins; by=string)) do p
println(io)
show(IOContext(io, :indent => 4), m, p)
end
end
end
function Base.show(io::IO, ::MIME"text/plain", p::T) where T <: Plugin
indent = get(io, :indent, 0)
print(io, repeat(' ', indent), T)
ns = fieldnames(T)
isempty(ns) || print(io, ":")
foreach(ns) do n
println(io)
print(io, repeat(' ', indent + 2), n, ": ", show_field(getfield(p, n)))
end
end
show_field(x) = repr(x)
if Sys.iswindows()
show_field(x::AbstractString) = replace(repr(contractuser(x)), "\\\\" => "\\")
else
show_field(x::AbstractString) = repr(contractuser(x))
end

View File

@ -1,242 +1,145 @@
default_plugins() = [ProjectFile(), SrcDir(), Git(), License(), Readme(), Tests()]
default_user() = LibGit2.getconfig("github.user", "")
default_version() = VersionNumber(VERSION.major)
function default_authors()
name = LibGit2.getconfig("user.name", "")
isempty(name) && return ""
email = LibGit2.getconfig("user.email", "")
return isempty(email) ? name : "$name <$email>"
end
"""
Template(; kwargs...) -> Template
Template(; kwargs...)
Records common information used to generate a package. If you don't wish to manually
create a template, you can use [`interactive_template`](@ref) instead.
A configuration used to generate packages.
# Keyword Arguments
* `user::AbstractString=""`: GitHub (or other code hosting service) username. If left
unset, it will take the the global git config's value (`github.user`). If that is not
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.
* `license::AbstractString="MIT"`: Name of the package license. If an empty string is
given, no license is created. [`available_licenses`](@ref) can be used to list all
available licenses, and [`show_license`](@ref) 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 take the value of of the global git config's value if it is left unset.
* `dir::AbstractString=$(replace(Pkg.devdir(), homedir() => "~"))`: Directory in which the
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.
## Keyword Arguments
### User Options
- `user::AbstractString="$(default_user())"`: GitHub (or other code hosting service) username.
The default value comes from the global Git config (`github.user`).
If no value is obtained, many plugins that use this value will not work.
- `authors::Union{AbstractString, Vector{<:AbstractString}}="$(default_authors())"`: Package authors.
Like `user`, it takes its default value from the global Git config
(`user.name` and `user.email`).
### Package Options
- `dir::AbstractString="$(contractuser(Pkg.devdir()))"`: Directory to place packages in.
- `host::AbstractString="github.com"`: URL to the code hosting service where packages will reside.
- `julia::VersionNumber=$(repr(default_version()))`: Minimum allowed Julia version.
### Template Plugins
- `plugins::Vector{<:Plugin}=Plugin[]`: A list of [`Plugin`](@ref)s used by the template.
- `disable_defaults::Vector{DataType}=DataType[]`: Default plugins to disable.
The default plugins are [`ProjectFile`](@ref), [`SrcDir`](@ref), [`Tests`](@ref),
[`Readme`](@ref), [`License`](@ref), and [`Git`](@ref).
To override a default plugin instead of disabling it altogether, supply it via `plugins`.
---
To create a package from a `Template`, use the following syntax:
```julia
julia> t = Template();
julia> t("PkgName")
```
"""
struct Template
user::String
host::String
license::String
authors::String
authors::Vector{String}
dir::String
julia_version::VersionNumber
ssh::Bool
dev::Bool
manifest::Bool
plugins::Dict{DataType, <:Plugin}
function Template(;
user::AbstractString="",
host::AbstractString="https://github.com",
license::AbstractString="MIT",
authors::Union{AbstractString, Vector{<:AbstractString}}="",
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,
)
# Check for required Git options for package generation
# (you can't commit to a repository without them).
git && isempty(LibGit2.getconfig("user.name", "")) && missingopt("user.name")
git && isempty(LibGit2.getconfig("user.email", "")) && missingopt("user.email")
# If no username was set, look for one in the global git config.
# Note: This is one of a few GitHub specifics (maybe we could use the host value).
if isempty(user)
user = LibGit2.getconfig("github.user", "")
end
if isempty(user)
throw(ArgumentError("No GitHub username found, set one with user=username"))
end
host = URI(startswith(host, "https://") ? host : "https://$host").host
if !isempty(license) && !isfile(joinpath(LICENSE_DIR, license))
throw(ArgumentError("License '$license' is not available"))
end
# If no author was set, look for one in the global git config.
if isempty(authors)
authors = LibGit2.getconfig("user.name", "")
email = LibGit2.getconfig("user.email", "")
isempty(email) || (authors *= " <$email>")
elseif authors isa Vector
authors = join(authors, ", ")
end
dir = abspath(expanduser(dir))
plugin_dict = Dict{DataType, Plugin}(typeof(p) => p for p in plugins)
if (length(plugins) != length(plugin_dict))
@warn "Plugin list contained duplicates, only the last of each type was kept"
end
new(user, host, license, authors, dir, julia_version, ssh, dev, manifest, plugin_dict)
end
host::String
julia::VersionNumber
plugins::Vector{<:Plugin}
user::String
end
function Base.show(io::IO, t::Template)
maybe(s::String) = isempty(s) ? "None" : s
spc = " "
Template(; kwargs...) = Template(Val(false); kwargs...)
println(io, "Template:")
println(io, spc, "→ User: ", maybe(t.user))
println(io, spc, "→ Host: ", maybe(t.host))
# Non-interactive constructor.
function Template(::Val{false}; kwargs...)
kwargs = Dict(kwargs)
print(io, spc, "→ License: ")
if isempty(t.license)
println(io, "None")
else
println(io, t.license, " ($(t.authors) ", year(today()), ")")
end
user = getkw!(kwargs, :user)
dir = abspath(expanduser(getkw!(kwargs, :dir)))
host = replace(getkw!(kwargs, :host), r".*://" => "")
julia = getkw!(kwargs, :julia)
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")
authors = getkw!(kwargs, :authors)
authors isa Vector || (authors = map(strip, split(authors, ",")))
print(io, spc, "→ Plugins:")
if isempty(t.plugins)
print(io, " None")
else
for plugin in sort(collect(values(t.plugins)); by=string)
println(io)
buf = IOBuffer()
show(buf, plugin)
print(io, spc^2, "")
print(io, join(split(String(take!(buf)), "\n"), "\n$(spc^2)"))
# User-supplied plugins come first, so that deduping the list will remove the defaults.
plugins = Plugin[]
append!(plugins, getkw!(kwargs, :plugins))
disabled = getkw!(kwargs, :disable_defaults)
append!(plugins, filter(p -> !(typeof(p) in disabled), default_plugins()))
plugins = sort(unique(typeof, plugins); by=string)
if isempty(user)
foreach(plugins) do p
if needs_username(p)
T = nameof(typeof(p))
s = """$T: Git hosting service username is required, set one with keyword `user="<username>"`"""
throw(ArgumentError(s))
end
end
end
if !isempty(kwargs)
@warn "Unrecognized keywords were supplied, see the documentation for help" kwargs
end
t = Template(authors, dir, host, julia, plugins, user)
foreach(p -> validate(p, t), t.plugins)
return t
end
"""
interactive_template(; fast::Bool=false) -> Template
(::Template)(pkg::AbstractString)
Interactively create a [`Template`](@ref). If `fast` is set, defaults will be assumed for
all values except username and plugins.
Generate a package named `pkg` from a [`Template`](@ref).
"""
function interactive_template(; git::Bool=true, fast::Bool=false)
@info "Default values are shown in [brackets]"
# Getting the leaf types in a separate thread eliminates an awkward wait after
# "Select plugins" is printed.
plugin_types = @async leaves(Plugin)
kwargs = Dict{Symbol, Any}()
function (t::Template)(pkg::AbstractString)
endswith(pkg, ".jl") && (pkg = pkg[1:end-3])
pkg_dir = joinpath(t.dir, pkg)
ispath(pkg_dir) && throw(ArgumentError("$pkg_dir already exists"))
mkpath(pkg_dir)
default_user = LibGit2.getconfig("github.user", "")
print("Username [", isempty(default_user) ? "REQUIRED" : default_user, "]: ")
user = readline()
kwargs[:user] = if !isempty(user)
user
elseif !isempty(default_user)
default_user
else
throw(ArgumentError("Username is required"))
try
foreach((prehook, hook, posthook)) do h
@info "Running $(nameof(h))s"
foreach(sort(t.plugins; by=p -> priority(p, h), rev=true)) do p
h(p, t, pkg_dir)
end
end
catch
rm(pkg_dir; recursive=true, force=true)
rethrow()
end
kwargs[:host] = if fast || !git
"https://github.com" # If Git isn't enabled, this value never gets used.
else
default_host = "github.com"
print("Code hosting service [$default_host]: ")
host = readline()
isempty(host) ? default_host : host
end
kwargs[:license] = if fast
"MIT"
else
println("License:")
io = IOBuffer()
available_licenses(io)
licenses = ["" => "", collect(LICENSES)...]
menu = RadioMenu(String["None", split(String(take!(io)), "\n")...])
# If the user breaks out of the menu with Ctrl-c, the result is -1, the absolute
# value of which correponds to no license.
first(licenses[abs(request(menu))])
end
# We don't need to ask for authors if there is no license,
# because the license is the only place that they matter.
kwargs[:authors] = if fast || isempty(kwargs[:license])
LibGit2.getconfig("user.name", "")
else
default_authors = LibGit2.getconfig("user.name", "")
default_str = isempty(default_authors) ? "None" : default_authors
print("Package author(s) [$default_str]: ")
authors = readline()
isempty(authors) ? default_authors : authors
end
kwargs[:dir] = if fast
Pkg.devdir()
else
default_dir = Pkg.devdir()
print("Path to package directory [$default_dir]: ")
dir = readline()
isempty(dir) ? default_dir : dir
end
kwargs[:julia_version] = if fast
VERSION
else
default_julia_version = VERSION
print("Minimum Julia version [", version_floor(default_julia_version), "]: ")
julia_version = readline()
isempty(julia_version) ? default_julia_version : VersionNumber(julia_version)
end
kwargs[:ssh] = if fast || !git
false
else
print("Set remote to SSH? [no]: ")
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
print("Commit Manifest.toml? [no]: ")
uppercase(readline()) in ["Y", "YES", "T", "TRUE"]
end
println("Plugins:")
# Only include plugin types which have an `interactive` method.
plugin_types = filter(t -> hasmethod(interactive, (Type{t},)), fetch(plugin_types))
type_names = map(t -> split(string(t), ".")[end], plugin_types)
menu = MultiSelectMenu(String.(type_names); pagesize=length(type_names))
selected = collect(request(menu))
kwargs[:plugins] = Vector{Plugin}(map(interactive, getindex(plugin_types, selected)))
return Template(; git=git, kwargs...)
@info "New package is at $pkg_dir"
end
leaves(T::Type)::Vector{DataType} = isconcretetype(T) ? [T] : vcat(leaves.(subtypes(T))...)
# Does the template have a plugin that satisfies some predicate?
hasplugin(t::Template, f::Function) = any(f, t.plugins)
hasplugin(t::Template, ::Type{T}) where T <: Plugin = hasplugin(t, p -> p isa T)
missingopt(name) = @warn "Git config option '$name' missing, package generation will fail unless you supply a GitConfig"
# Get a plugin by type.
function getplugin(t::Template, ::Type{T}) where T <: Plugin
i = findfirst(p -> p isa T, t.plugins)
return i === nothing ? nothing : t.plugins[i]
end
# Get a keyword or a default value.
getkw!(kwargs, k) = pop!(kwargs, k, defaultkw(Template, k))
# Default Template keyword values.
defaultkw(::Type{T}, s::Symbol) where T = defaultkw(T, Val(s))
defaultkw(::Type{Template}, ::Val{:authors}) = default_authors()
defaultkw(::Type{Template}, ::Val{:dir}) = Pkg.devdir()
defaultkw(::Type{Template}, ::Val{:disable_defaults}) = DataType[]
defaultkw(::Type{Template}, ::Val{:host}) = "github.com"
defaultkw(::Type{Template}, ::Val{:julia}) = default_version()
defaultkw(::Type{Template}, ::Val{:plugins}) = Plugin[]
defaultkw(::Type{Template}, ::Val{:user}) = default_user()

8
templates/CITATION.bib Normal file
View File

@ -0,0 +1,8 @@
@misc{<<&PKG>>.jl,
author = {<<&AUTHORS>>},
title = {<<&PKG>>.jl},
url = {<<&URL>>},
version = {v0.1.0},
year = {<<&YEAR>>},
month = {<<&MONTH>>}
}

13
templates/README.md Normal file
View File

@ -0,0 +1,13 @@
# {{{PKG}}}{{#HAS_INLINE_BADGES}} {{#BADGES}}{{{.}}} {{/BADGES}}{{/HAS_INLINE_BADGES}}
{{^HAS_INLINE_BADGES}}
{{#BADGES}}
{{{.}}}
{{/BADGES}}
{{/HAS_INLINE_BADGES}}
{{#HAS_CITATION}}
## Citing
See [`CITATION.bib`](CITATION.bib) for the relevant reference(s).
{{/HAS_CITATION}}

39
templates/appveyor.yml Normal file
View File

@ -0,0 +1,39 @@
# Documentation: https://github.com/JuliaCI/Appveyor.jl
environment:
matrix:
{{#VERSIONS}}
- julia_version: {{{.}}}
{{/VERSIONS}}
platform:
{{#PLATFORMS}}
- {{{.}}}
{{/PLATFORMS}}
{{#HAS_ALLOW_FAILURES}}
matrix:
allow_failures:
{{#ALLOW_FAILURES}}
- julia_version: {{{.}}}
{{/ALLOW_FAILURES}}
{{/HAS_ALLOW_FAILURES}}
branches:
only:
- master
- /release-.*/
notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false
install:
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
build_script:
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
test_script:
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
{{#HAS_CODECOV}}
on_success:
- echo "%JL_CODECOV_SCRIPT%"
- C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
{{/HAS_CODECOV}}

18
templates/cirrus.yml Normal file
View File

@ -0,0 +1,18 @@
freebsd_instance:
image: {{{IMAGE}}}
task:
name: FreeBSD
env:
{{#VERSIONS}}
JULIA_VERSION: {{{.}}}
{{/VERSIONS}}
install_script:
- sh -c "$(fetch https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -o -)"
build_script:
- cirrusjl build
test_script:
- cirrusjl test
{{#HAS_COVERAGE}}
coverage_script:
- cirrusjl coverage{{#HAS_CODECOV}} codecov{{/HAS_CODECOV}}{{#HAS_COVERALLS}} coveralls{{/HAS_COVERALLS}}
{{/HAS_COVERAGE}}

34
templates/docs/make.jl Normal file
View File

@ -0,0 +1,34 @@
using {{{PKG}}}
using Documenter
makedocs(;
modules=[{{{PKG}}}],
authors="{{{AUTHORS}}}",
repo="https://{{{REPO}}}/blob/{commit}{path}#L{line}",
sitename="{{{PKG}}}.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
{{#CANONICAL}}
canonical="{{{CANONICAL}}}",
{{/CANONICAL}}
assets={{^HAS_ASSETS}}String{{/HAS_ASSETS}}[{{^HAS_ASSETS}}],{{/HAS_ASSETS}}
{{#ASSETS}}
"assets/{{{.}}}",
{{/ASSETS}}
{{#HAS_ASSETS}}
],
{{/HAS_ASSETS}}
),
pages=[
"Home" => "index.md",
],
{{#MAKEDOCS_KWARGS}}
{{{first}}}={{{second}}},
{{/MAKEDOCS_KWARGS}}
)
{{#HAS_DEPLOY}}
deploydocs(;
repo="{{{REPO}}}",
)
{{/HAS_DEPLOY}}

View File

@ -0,0 +1,12 @@
```@meta
CurrentModule = {{{PKG}}}
```
# {{{PKG}}}
```@index
```
```@autodocs
Modules = [{{{PKG}}}]
```

27
templates/drone.star Normal file
View File

@ -0,0 +1,27 @@
def main(ctx):
pipelines = []
for arch in [{{{ARCHES}}}]:
for julia in [{{{VERSIONS}}}]:
pipelines.append(pipeline(arch, julia))
return pipelines
def pipeline(arch, julia):
return {
"kind": "pipeline",
"type": "docker",
"name": "Julia %s - %s" % (julia, arch),
"platform": {
"os": "linux",
"arch": arch,
},
"steps": [
{
"name": "test",
"image": "julia:%s" % julia,
"commands": [
"julia -e 'using InteractiveUtils; versioninfo()'",
"julia --project=@. -e 'using Pkg; Pkg.instantiate(); Pkg.build(); Pkg.test();'",
],
},
],
}

View File

@ -0,0 +1,67 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
<<#VERSIONS>>
- '<<&.>>'
<</VERSIONS>>
os:
<<#OS>>
- <<&.>>
<</OS>>
arch:
<<#ARCH>>
- <<&.>>
<</ARCH>>
<<#HAS_EXCLUDES>>
exclude:
<</HAS_EXCLUDES>>
<<#EXCLUDES>>
- os: <<&E_OS>>
arch: <<&E_ARCH>>
<<#E_VERSION>>
version: '<<&E_VERSION>>'
<</E_VERSION>>
<</EXCLUDES>>
steps:
- uses: actions/checkout@v1
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
<<#HAS_CODECOV>>
- uses: julia-actions/julia-uploadcodecov@latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
<</HAS_CODECOV>>
<<#HAS_COVERALLS>>
- uses: julia-actions/julia-uploadcoveralls@latest
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
<</HAS_COVERALLS>>
<<#HAS_DOCUMENTER>>
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: julia-actions/setup-julia@latest
with:
version: '1.0'
- run: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(; path=pwd()));
Pkg.instantiate();'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
<</HAS_DOCUMENTER>>

45
templates/gitlab-ci.yml Normal file
View File

@ -0,0 +1,45 @@
.definitions:
script: &script
script:
- julia --project=@. -e '
using Pkg;
Pkg.build();
Pkg.test({{#HAS_COVERAGE}}; coverage=true{{/HAS_COVERAGE}});'
{{#HAS_COVERAGE}}
coverage: &coverage
coverage: /Test coverage (\d+\.\d+%)/
after_script:
- julia -e '
using Pkg;
Pkg.add("Coverage");
using Coverage;
c, t = get_summary(process_folder());
using Printf;
@printf "Test coverage %.2f%%\n" 100c / t;'
{{/HAS_COVERAGE}}
{{#VERSIONS}}
Julia {{{.}}}:
image: julia:{{{.}}}
<<: *script
{{#HAS_COVERAGE}}
<<: *coverage
{{/HAS_COVERAGE}}
{{/VERSIONS}}
{{#HAS_DOCUMENTER}}
pages:
image: julia:{{{VERSION}}}
stage: deploy
script:
- julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(; path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
- mkdir -p public
- mv docs/build public/dev
artifacts:
paths:
- public
only:
- master
{{/HAS_DOCUMENTER}}

View File

@ -1,4 +1,3 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
@ -187,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [year] [fullname]
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,15 +1,17 @@
BSD 2-Clause License
Copyright (c) {{{YEAR}}}, {{{AUTHORS}}}
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

29
templates/licenses/BSD3 Normal file
View File

@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) {{{YEAR}}}, {{{AUTHORS}}}
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,274 @@
European Union Public Licence
V. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the EUPL) applies to the Work (as
defined below) which is provided under the terms of this Licence. Any use of
the Work, other than as authorised under this Licence is prohibited (to the
extent such use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as
defined below) has placed the following notice immediately following the
copyright notice for the Work: “Licensed under the EUPL”, or has expressed by
any other means his willingness to license under the EUPL.
1. Definitions
In this Licence, the following terms have the following meaning:
The Licence: this Licence.
The Original Work: the work or software distributed or communicated by the
Licensor under this Licence, available as Source Code and also as
Executable Code as the case may be.
Derivative Works: the works or software that could be created by the
Licensee, based upon the Original Work or modifications thereof. This
Licence does not define the extent of modification or dependence on the
Original Work required in order to classify a work as a Derivative Work;
this extent is determined by copyright law applicable in the country
mentioned in Article 15.
The Work: the Original Work or its Derivative Works.
The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
The Executable Code: any code which has generally been compiled and which
is meant to be interpreted by a computer as a program.
The Licensor: the natural or legal person that distributes or communicates
the Work under the Licence.
Contributor(s): any natural or legal person who modifies the Work under
the Licence, or otherwise contributes to the creation of a Derivative Work.
The Licensee or You: any natural or legal person who makes any usage of
the Work under the terms of the Licence.
Distribution or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, online or offline, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
2. Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
sublicensable licence to do the following, for the duration of copyright
vested in the Original Work:
— use the Work in any circumstance and for all usage,
— reproduce the Work,
— modify the Work, and make Derivative Works based upon the Work,
— communicate to the public, including the right to make available or display
the Work or copies thereof to the public and perform publicly, as the case
may be, the Work,
— distribute the Work or copies thereof,
— lend and rent the Work or copies thereof,
— sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now
known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make
effective the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights
to any patents held by the Licensor, to the extent necessary to make use of
the rights granted on the Work under this Licence.
3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as
Executable Code. If the Work is provided as Executable Code, the Licensor
provides in addition a machine-readable copy of the Source Code of the Work
along with each copy of the Work that the Licensor distributes or indicates,
in a notice following the copyright notice attached to the Work, a repository
where the Source Code is easily and freely accessible for as long as the
Licensor continues to distribute or communicate the Work.
4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits
from any exception or limitation to the exclusive rights of the rights owners
in the Work, of the exhaustion of those rights or of other applicable
limitations thereto.
5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the
disclaimer of warranties. The Licensee must include a copy of such notices and
a copy of the Licence with every copy of the Work he/she distributes or
communicates. The Licensee must cause any Derivative Work to carry prominent
notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the
Original Works or Derivative Works, this Distribution or Communication will be
done under the terms of this Licence or of a later version of this Licence
unless the Original Work is expressly distributed only under this version of
the Licence — for example by communicating EUPL v. 1.2 only. The Licensee
(becoming Licensor) cannot offer or impose any additional terms or conditions
on the Work or Derivative Work that alter or restrict the terms of the
Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative
Works or copies thereof based upon both the Work and another work licensed
under a Compatible Licence, this Distribution or Communication can be done
under the terms of this Compatible Licence. For the sake of this clause,
Compatible Licence refers to the licences listed in the appendix attached to
this Licence. Should the Licensee's obligations under the Compatible Licence
conflict with his/her obligations under this Licence, the obligations of the
Compatible Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the
Work, the Licensee will provide a machine-readable copy of the Source Code or
indicate a repository where this Source will be easily and freely available
for as long as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade
names, trademarks, service marks, or names of the Licensor, except as required
for reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she
brings to the Work are owned by him/her or licensed to him/her and that he/she
has the power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent
Contributors grant You a licence to their contributions to the Work, under the
terms of this Licence.
7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
Contributors. It is not a finished work and may therefore contain defects or
bugs inherent to this type of development.
For the above reason, the Work is provided under the Licence on an as is
basis and without warranties of any kind concerning the Work, including
without limitation merchantability, fitness for a particular purpose, absence
of defects or errors, accuracy, non-infringement of intellectual property
rights other than copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a
condition for the grant of any rights to the Work.
8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the
use of the Work, including without limitation, damages for loss of goodwill,
work stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such
damage. However, the Licensor will be liable under statutory product liability
laws as far such laws apply to the Work.
9. Additional agreements
While distributing the Work, You may choose to conclude an additional
agreement, defining obligations or services consistent with this Licence.
However, if accepting obligations, You may act only on your own behalf and on
your sole responsibility, not on behalf of the original Licensor or any other
Contributor, and only if You agree to indemnify, defend, and hold each
Contributor harmless for any liability incurred by, or claims asserted against
such Contributor by the fact You have accepted any warranty or additional
liability.
10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon I
agree placed under the bottom of a window displaying the text of this Licence
or by affirming consent in any other similar way, in accordance with the rules
of applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and
conditions by exercising any rights granted to You by Article 2 of this
Licence, such as the use of the Work, the creation by You of a Derivative Work
or the Distribution or Communication by You of the Work or copies thereof.
11. Information to the public
In case of any Distribution or Communication of the Work by means of
electronic communication by You (for example, by offering to download the Work
from a remote location) the distribution channel or media (for example, a
website) must at least provide to the public the information requested by the
applicable law regarding the Licensor, the Licence and the way it may be
accessible, concluded, stored and reproduced by the Licensee.
12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon
any breach by the Licensee of the terms of the Licence. Such a termination
will not terminate the licences of any person who has received the Work from
the Licensee under the Licence, provided such persons remain in full
compliance with the Licence.
13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as a
whole. Such provision will be construed or reformed so as necessary to make it
valid and enforceable.
The European Commission may publish other linguistic versions or new versions
of this Licence or updated versions of the Appendix, so far this is required
and reasonable, without reducing the scope of the rights granted by the
Licence. New versions of the Licence will be published with a unique version
number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version of
their choice.
14. Jurisdiction
Without prejudice to specific agreement between parties,
— any litigation resulting from the interpretation of this License, arising
between the European Union institutions, bodies, offices or agencies, as a
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
of Justice of the European Union, as laid down in article 272 of the Treaty
on the Functioning of the European Union,
— any litigation arising between other parties and resulting from the
interpretation of this License, will be subject to the exclusive
jurisdiction of the competent court where the Licensor resides or conducts
its primary business.
15. Applicable Law
Without prejudice to specific agreement between parties,
— this Licence shall be governed by the law of the European Union Member State
where the Licensor has his seat, resides or has his registered office,
— this licence shall be governed by Belgian law if the Licensor has no seat,
residence or registered office inside a European Union Member State.
Appendix
Compatible Licences according to Article 5 EUPL are:
— GNU General Public License (GPL) v. 2, v. 3
— GNU Affero General Public License (AGPL) v. 3
— Open Software License (OSL) v. 2.1, v. 3.0
— Eclipse Public License (EPL) v. 1.0
— CeCILL v. 2.0, v. 2.1
— Mozilla Public Licence (MPL) v. 2
— GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
— Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
works other than software
— European Union Public Licence (EUPL) v. 1.1, v. 1.2
— Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or
Strong Reciprocity (LiLiQ-R+)
— The European Commission may update this Appendix to later versions of the
above licences without producing a new version of the EUPL, as long as they
provide the rights granted in Article 2 of this Licence and protect the
covered Source Code from exclusive appropriation.
— All other changes or additions to this Appendix require the production of a
new EUPL version.

View File

@ -1,19 +1,3 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
@ -294,3 +278,62 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -1,19 +1,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -631,3 +619,56 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -1,3 +1,6 @@
ISC License
Copyright (c) {{{YEAR}}}, {{{AUTHORS}}}
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above

View File

@ -1,19 +1,3 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
@ -472,3 +456,49 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random
Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -1,3 +1,6 @@
MIT License
Copyright (c) {{{YEAR}}} {{{AUTHORS}}}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

373
templates/licenses/MPL Normal file
View File

@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

5
templates/src/module.jl Normal file
View File

@ -0,0 +1,5 @@
module {{{PKG}}}
# Write your package code here.
end

View File

@ -0,0 +1,6 @@
using {{{PKG}}}
using Test
@testset "{{{PKG}}}.jl" begin
# Write your tests here.
end

64
templates/travis.yml Normal file
View File

@ -0,0 +1,64 @@
# Documentation: http://docs.travis-ci.com/user/languages/julia
language: julia
notifications:
email: false
julia:
{{#VERSIONS}}
- {{{.}}}
{{/VERSIONS}}
os:
{{#OS}}
- {{{.}}}
{{/OS}}
arch:
{{#ARCH}}
- {{{.}}}
{{/ARCH}}
jobs:
fast_finish: true
{{#HAS_ALLOW_FAILURES}}
allow_failures:
{{/HAS_ALLOW_FAILURES}}
{{#ALLOW_FAILURES}}
- julia: {{{.}}}
{{/ALLOW_FAILURES}}
{{#HAS_EXCLUDES}}
exclude:
{{/HAS_EXCLUDES}}
{{#EXCLUDES}}
- arch: {{{E_ARCH}}}
{{#E_OS}}
os: {{{E_OS}}}
{{/E_OS}}
{{#E_JULIA}}
julia: {{{E_JULIA}}}
{{/E_JULIA}}
{{/EXCLUDES}}
{{#HAS_DOCUMENTER}}
include:
- stage: Documentation
julia: {{{VERSION}}}
script: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(; path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
after_success: skip
{{/HAS_DOCUMENTER}}
{{#HAS_COVERAGE}}
after_success:
{{#HAS_CODECOV}}
- julia -e '
using Pkg;
Pkg.add("Coverage");
using Coverage;
Codecov.submit(process_folder());'
{{/HAS_CODECOV}}
{{#HAS_COVERALLS}}
- julia -e '
using Pkg;
Pkg.add("Coverage");
using Coverage;
Coveralls.submit(process_folder());'
{{/HAS_COVERALLS}}
{{/HAS_COVERAGE}}

View File

@ -1,10 +1,10 @@
# Documentation: https://github.com/JuliaCI/Appveyor.jl
environment:
matrix:
- julia_version: {{VERSION}}
- julia_version: nightly
- julia_version: 1.0
- julia_version: 1.2
- julia_version: nightly
platform:
- x86
- x64
matrix:
allow_failures:
@ -26,8 +26,6 @@ build_script:
test_script:
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
{{#CODECOV}}
on_success:
- echo "%JL_CODECOV_SCRIPT%"
- C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
{{/CODECOV}}

View File

@ -3,14 +3,14 @@ freebsd_instance:
task:
name: FreeBSD
env:
JULIA_VERSION: {{VERSION}}
JULIA_VERSION: 1.0
JULIA_VERSION: 1.2
JULIA_VERSION: nightly
install_script:
- sh -c "$(fetch https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -o -)"
build_script:
- cirrusjl build
test_script:
- cirrusjl test
{{#COVERAGE}}
coverage_script:
- cirrusjl coverage{{#CODECOV}} codecov{{/CODECOV}}{{#COVERALLS}} coveralls{{/COVERALLS}}
{{/COVERAGE}}
- cirrusjl coverage codecov coveralls

27
test/fixtures/AllPlugins/.drone.star vendored Normal file
View File

@ -0,0 +1,27 @@
def main(ctx):
pipelines = []
for arch in ["amd64"]:
for julia in ["1.0", "1.2"]:
pipelines.append(pipeline(arch, julia))
return pipelines
def pipeline(arch, julia):
return {
"kind": "pipeline",
"type": "docker",
"name": "Julia %s - %s" % (julia, arch),
"platform": {
"os": "linux",
"arch": arch,
},
"steps": [
{
"name": "test",
"image": "julia:%s" % julia,
"commands": [
"julia -e 'using InteractiveUtils; versioninfo()'",
"julia --project=@. -e 'using Pkg; Pkg.instantiate(); Pkg.build(); Pkg.test();'",
],
},
],
}

View File

@ -0,0 +1,33 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1.0'
- '1.2'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v1
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-uploadcodecov@latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: julia-actions/julia-uploadcoveralls@latest
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}

5
test/fixtures/AllPlugins/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
*.jl.*.cov
*.jl.cov
*.jl.mem
/docs/build/
Manifest.toml

25
test/fixtures/AllPlugins/.gitlab-ci.yml vendored Normal file
View File

@ -0,0 +1,25 @@
.definitions:
script: &script
script:
- julia --project=@. -e '
using Pkg;
Pkg.build();
Pkg.test(; coverage=true);'
coverage: &coverage
coverage: /Test coverage (\d+\.\d+%)/
after_script:
- julia -e '
using Pkg;
Pkg.add("Coverage");
using Coverage;
c, t = get_summary(process_folder());
using Printf;
@printf "Test coverage %.2f%%\n" 100c / t;'
Julia 1.0:
image: julia:1.0
<<: *script
<<: *coverage
Julia 1.2:
image: julia:1.2
<<: *script
<<: *coverage

29
test/fixtures/AllPlugins/.travis.yml vendored Normal file
View File

@ -0,0 +1,29 @@
# Documentation: http://docs.travis-ci.com/user/languages/julia
language: julia
notifications:
email: false
julia:
- 1.0
- 1.2
- nightly
os:
- linux
- osx
- windows
arch:
- x64
jobs:
fast_finish: true
allow_failures:
- julia: nightly
after_success:
- julia -e '
using Pkg;
Pkg.add("Coverage");
using Coverage;
Codecov.submit(process_folder());'
- julia -e '
using Pkg;
Pkg.add("Coverage");
using Coverage;
Coveralls.submit(process_folder());'

8
test/fixtures/AllPlugins/CITATION.bib vendored Normal file
View File

@ -0,0 +1,8 @@
@misc{AllPlugins.jl,
author = {tester},
title = {AllPlugins.jl},
url = {https://github.com/tester/AllPlugins.jl},
version = {v0.1.0},
year = {2019},
month = {8}
}

21
test/fixtures/AllPlugins/LICENSE vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 tester
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,2 @@
# This file is machine-generated - editing it directly is not advised

13
test/fixtures/AllPlugins/Project.toml vendored Normal file
View File

@ -0,0 +1,13 @@
name = "AllPlugins"
uuid = "5b7e9947-ddc0-4b3f-9b55-0d8042f74170"
authors = ["tester"]
version = "0.1.0"
[compat]
julia = "1"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]

11
test/fixtures/AllPlugins/README.md vendored Normal file
View File

@ -0,0 +1,11 @@
# AllPlugins
[![Build Status](https://github.com/tester/AllPlugins.jl/actions)](https://github.com/tester/AllPlugins.jl/workflows/CI/badge.svg)
[![Build Status](https://gitlab.com/tester/AllPlugins.jl/badges/master/build.svg)](https://gitlab.com/tester/AllPlugins.jl/pipelines)
[![Coverage](https://gitlab.com/tester/AllPlugins.jl/badges/master/coverage.svg)](https://gitlab.com/tester/AllPlugins.jl/commits/master)
[![Build Status](https://travis-ci.com/tester/AllPlugins.jl.svg?branch=master)](https://travis-ci.com/tester/AllPlugins.jl)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/tester/AllPlugins.jl?svg=true)](https://ci.appveyor.com/project/tester/AllPlugins-jl)
[![Build Status](https://cloud.drone.io/api/badges/tester/AllPlugins.jl/status.svg)](https://cloud.drone.io/tester/AllPlugins.jl)
[![Build Status](https://api.cirrus-ci.com/github/tester/AllPlugins.jl.svg)](https://cirrus-ci.com/github/tester/AllPlugins.jl)
[![Coverage](https://codecov.io/gh//.jl/branch/master/graph/badge.svg)](https://codecov.io/gh//.jl)
[![Coverage](https://coveralls.io/repos/github//.jl/badge.svg?branch=master)](https://coveralls.io/github//.jl?branch=master)

View File

@ -0,0 +1,89 @@
# This file is machine-generated - editing it directly is not advised
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
git-tree-sha1 = "0513f1a8991e9d83255e0140aace0d0fc4486600"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.0"
[[Documenter]]
deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "1b6ae3796f60311e39cd1770566140d2c056e87f"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.23.3"
[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.0"
[[LibGit2]]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "ef0af6c8601db18c282d092ccbd2f01f3f0cd70b"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "0.3.7"
[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

View File

@ -0,0 +1,2 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

16
test/fixtures/AllPlugins/docs/make.jl vendored Normal file
View File

@ -0,0 +1,16 @@
using AllPlugins
using Documenter
makedocs(;
modules=[AllPlugins],
authors="tester",
repo="https://github.com/tester/AllPlugins.jl/blob/{commit}{path}#L{line}",
sitename="AllPlugins.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
assets=String[],
),
pages=[
"Home" => "index.md",
],
)

View File

@ -0,0 +1,12 @@
```@meta
CurrentModule = AllPlugins
```
# AllPlugins
```@index
```
```@autodocs
Modules = [AllPlugins]
```

View File

@ -0,0 +1,5 @@
module AllPlugins
# Write your package code here.
end

View File

@ -0,0 +1,6 @@
using AllPlugins
using Test
@testset "AllPlugins.jl" begin
# Write your tests here.
end

1
test/fixtures/Basic/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
Manifest.toml

21
test/fixtures/Basic/LICENSE vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 tester
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2
test/fixtures/Basic/Manifest.toml vendored Normal file
View File

@ -0,0 +1,2 @@
# This file is machine-generated - editing it directly is not advised

13
test/fixtures/Basic/Project.toml vendored Normal file
View File

@ -0,0 +1,13 @@
name = "Basic"
uuid = "5b7e9947-ddc0-4b3f-9b55-0d8042f74170"
authors = ["tester"]
version = "0.1.0"
[compat]
julia = "1"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]

1
test/fixtures/Basic/README.md vendored Normal file
View File

@ -0,0 +1 @@
# Basic

5
test/fixtures/Basic/src/Basic.jl vendored Normal file
View File

@ -0,0 +1,5 @@
module Basic
# Write your package code here.
end

Some files were not shown because too many files have changed in this diff Show More