Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive mode #145

Merged
merged 38 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6770f88
Add the interactive constructors
christopher-dG Mar 7, 2020
ce7d1fc
Add more cool prompts
christopher-dG Mar 9, 2020
c127b50
Fix some general interactive bugs, specialize for License
christopher-dG Mar 19, 2020
30fe9bb
Misc updates (mostly documentation)
christopher-dG Apr 14, 2020
2aca99c
Document interactive stuff, add a few tests
christopher-dG Apr 14, 2020
999f70a
Bump manifests
christopher-dG Apr 14, 2020
2d66db1
Fix interactive extra_versions for CI plugins
christopher-dG Apr 14, 2020
37c66ba
Fixes for 1.0
christopher-dG Apr 14, 2020
d54b644
Fix a bug or two, add some input tests
christopher-dG Apr 14, 2020
4ecd018
Add some logging to the tests
christopher-dG Apr 14, 2020
1fa1305
Add `generate` interactive shortcut (#128) and a missing deprecation
christopher-dG Apr 14, 2020
3a8db74
Try default Travis command to hopefully make interactive tests work
christopher-dG Apr 15, 2020
2202161
Include 1.5 in Julia version choices
christopher-dG Apr 15, 2020
1e686df
Simplify customizable field extension
christopher-dG Apr 15, 2020
c048030
Delete useless old test helper, add reference to unique!(f, xs)
christopher-dG Apr 20, 2020
2f664d2
Fix a Documenter bug, add some interactive plugin tests
christopher-dG Apr 21, 2020
7e26f43
Bump Documenter
christopher-dG Apr 21, 2020
059b87b
Fix conversion error (maybe)
christopher-dG Apr 23, 2020
e6c4b5c
Add at-plugin macro to save default values
christopher-dG Apr 23, 2020
e157265
Add default values to interactive prompts
christopher-dG Apr 24, 2020
24dec21
Replace Documenter{Nothing} with Documenter{NoDeploy}, fix some bugs
christopher-dG Apr 24, 2020
500649c
Add custom interactive method for Template
christopher-dG Apr 24, 2020
8fc35a8
Relax type parameters
christopher-dG Apr 24, 2020
7766420
Update/fix some tests
christopher-dG May 2, 2020
ad7a886
Test disabling default plugins
christopher-dG May 3, 2020
b140412
Add default keywords to License plugin
christopher-dG May 4, 2020
2fa622a
Fix tests for 1.0
christopher-dG May 5, 2020
2029efd
Make sure to show all menu options
christopher-dG May 5, 2020
9ede8dc
Update docs env, remove root Manifest
christopher-dG May 5, 2020
05caefd
Document `at-plugin`
christopher-dG May 6, 2020
632d1fd
Apply most of Curtis' suggestions
christopher-dG May 21, 2020
1f439cf
Apply more of Curtis' suggestions
christopher-dG May 25, 2020
8bcd6a3
Fix a MethodError
christopher-dG May 25, 2020
ba15a67
Revert a not-1.0-compatible change
christopher-dG May 25, 2020
d8d1886
Simplify plugin collection for new API
christopher-dG May 25, 2020
0741748
Catch interrupt exceptions and cancel gracefully
christopher-dG May 25, 2020
bab37a2
Offer version options that better match the current version
christopher-dG May 25, 2020
8f13009
Update version range
christopher-dG May 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.jl.*.cov
*.jl.cov
*.jl.mem
/Manifest.toml
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ julia:
before_script:
- git config --global user.name Tester
- git config --global user.email [email protected]
script: travis_wait julia --project -e 'using Pkg; Pkg.test(coverage=true)'
matrix:
fast_finish: true
allow_failures:
Expand Down
115 changes: 0 additions & 115 deletions Manifest.toml

This file was deleted.

2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ version = "0.7.0-DEV"

[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"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Expand Down
27 changes: 13 additions & 14 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[DataAPI]]
git-tree-sha1 = "674b67f344687a88310213ddfa8a2b3c76cc4252"
git-tree-sha1 = "176e23402d80e7743fc26c19c681bfb11246af32"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.1.0"
version = "1.3.0"

[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
Expand All @@ -29,9 +29,9 @@ version = "0.8.1"

[[Documenter]]
deps = ["Base64", "Dates", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "646ebc3db49889ffeb4c36f89e5d82c6a26295ff"
git-tree-sha1 = "395fa1554c69735802bba37d9e7d9586fd44326c"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.24.7"
version = "0.24.11"

[[InteractiveUtils]]
deps = ["Markdown"]
Expand Down Expand Up @@ -71,15 +71,14 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[Mustache]]
deps = ["Printf", "Tables"]
git-tree-sha1 = "e06eef2abee113c49695f5347668e15d4c02978a"
git-tree-sha1 = "2e11fc5de3a01d23482a257e22009ddaab058d9a"
uuid = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70"
version = "1.0.0"
version = "1.0.2"

[[OrderedCollections]]
deps = ["Random", "Serialization", "Test"]
git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1"
git-tree-sha1 = "12ce190210d278e12644bcadf5b21cbdcf225cd3"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.1.0"
version = "1.2.0"

[[Parameters]]
deps = ["OrderedCollections"]
Expand All @@ -89,16 +88,16 @@ version = "0.12.0"

[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "0c16b3179190d3046c073440d94172cfc3bb0553"
git-tree-sha1 = "f8f5d2d4b4b07342e5811d2b6428e45524e241df"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "0.3.12"
version = "1.0.2"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[PkgTemplates]]
deps = ["Dates", "LibGit2", "Mustache", "Parameters", "Pkg", "UUIDs"]
deps = ["Dates", "InteractiveUtils", "LibGit2", "Mustache", "Parameters", "Pkg", "REPL", "UUIDs"]
path = ".."
uuid = "14b8a8f1-9102-5b29-a752-f990bacb7fe1"
version = "0.7.0-DEV"
Expand Down Expand Up @@ -132,9 +131,9 @@ version = "1.0.0"

[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "aaed7b3b00248ff6a794375ad6adf30f30ca5591"
git-tree-sha1 = "c45dcc27331febabc20d86cb3974ef095257dcf3"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "0.2.11"
version = "1.0.4"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
Expand Down
30 changes: 25 additions & 5 deletions docs/src/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ To understand how they're implemented, let's look at simplified versions of two
### Example: `Documenter`

```julia
@with_kw_noshow struct Documenter <: Plugin
@plugin struct Documenter <: Plugin
make_jl::String = default_file("docs", "make.jl")
index_md::String = default_file("docs", "src", "index.md")
end
Expand Down Expand Up @@ -117,10 +117,11 @@ function hook(p::Documenter, t::Template, pkg_dir::AbstractString)
end
```

The `@with_kw_noshow` macro defines keyword constructors for us.
The `@plugin` macro defines some helpful methods for us.
Inside of our struct definition, we're using [`default_file`](@ref) to refer to files in this repository.

```@docs
@plugin
default_file
```

Expand All @@ -138,7 +139,11 @@ 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.
In other cases, you can still access the [`Template`](@ref)'s plugins to depend on the presence/properties of other plugins via [`getplugin`](@ref), although that's less powerful.

```@docs
getplugin
```

Third, we implement [`view`](@ref), which is used to fill placeholders in badges and rendered files.

Expand Down Expand Up @@ -197,6 +202,7 @@ function posthook(::Git, ::Template, pkg_dir::AbstractString)
end
```

We didn't use `@plugin` for this one, because there are no fields.
Validation and all three hooks are implemented:

- [`validate`](@ref) makes sure that all required Git configuration is present.
Expand All @@ -217,7 +223,7 @@ 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 <: FilePlugin
@plugin struct Citation <: FilePlugin
file::String = default_file("CITATION.bib")
end

Expand Down Expand Up @@ -294,7 +300,7 @@ Of course, we could use a normal [`Plugin`](@ref), but it turns out there's a wa
The plugin implements its own `hook`, but uses `invoke` to avoid duplicating the file creation code:

```julia
@with_kw_noshow struct Tests <: FilePlugin
@plugin struct Tests <: FilePlugin
file::String = default_file("runtests.jl")
end

Expand All @@ -315,6 +321,20 @@ If you want to extend the validation but keep the file existence check, use the

For more examples, see the plugins in the [Continuous Integration (CI)](@ref) and [Code Coverage](@ref) sections.

## Supporting Interactive Mode

When it comes to supporting interactive mode for your custom plugins, you have two options: write your own [`interactive`](@ref) method, or use the default one.
If you choose the first option, then you are free to implement the method however you want.
If you want to use the default implementation, then there are a few functions that you should be aware of, although in many cases you will not need to add any new methods.

```@docs
interactive
prompt
customizable
input_tips
convert_input
```

## Miscellaneous Tips

### Writing Template Files
Expand Down
7 changes: 5 additions & 2 deletions docs/src/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ One less name to remember!
| :-----------------------------------------: | :---------------------------------: |
| `generate(::Template, pkg::AbstractString)` | `(::Template)(pkg::AbstractString)` |

## Interactive Templates
## Interactive Mode

Currently not implemented, but will be in the future.
| Old | New |
| :-----------------------------------------: | :---------------------------------: |
| `interactive_template()` | `Template(; interactive=true)` |
| `generate_interactive(pkg::AbstractString)` | `Template(; interactive=true)(pkg)` |

## Other Functions

Expand Down
3 changes: 2 additions & 1 deletion docs/src/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ t("MyPkg")

```@docs
Template
generate
```

## Plugins
Expand All @@ -40,6 +41,7 @@ Tests
Readme
License
Git
CompatHelper
TagBot
Secret
```
Expand Down Expand Up @@ -76,7 +78,6 @@ Documenter

```@docs
Develop
CompatHelper
Citation
```

Expand Down
4 changes: 4 additions & 0 deletions src/PkgTemplates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ module PkgTemplates
using Base: active_project, contractuser

using Dates: month, today, year
using InteractiveUtils: subtypes
using LibGit2: LibGit2, GitConfig, GitRemote, GitRepo
using Pkg: Pkg, TOML, PackageSpec
using REPL.TerminalMenus: MultiSelectMenu, RadioMenu, request
using UUIDs: uuid4

using Mustache: render
Expand All @@ -25,6 +27,7 @@ export
GitHubActions,
GitLabCI,
License,
NoDeploy,
ProjectFile,
Readme,
Secret,
Expand All @@ -44,6 +47,7 @@ abstract type Plugin end
include("template.jl")
include("plugin.jl")
include("show.jl")
include("interactive.jl")
include("deprecated.jl")

# Run some function with a project activated at the given path.
Expand Down
1 change: 1 addition & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
@deprecate interactive_template() Template(; interactive=true)
@deprecate generate_interactive(pkg::AbstractString) Template(; interactive=true)(pkg)
@deprecate GitHubPages(; kwargs...) Documenter{TravisCI}(; kwargs...)
@deprecate GitLabPages(; kwargs...) Documenter{GitLabCI}(; kwargs...)
Loading