-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myplugins.jl
128 lines (101 loc) · 3.37 KB
/
myplugins.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using PkgTemplates
using PkgTemplates: FilePlugin, Template
import PkgTemplates: source, destination, view
struct Dockerfile <: FilePlugin
tag::String
file::String
destination::String
function Dockerfile(; tag = string(VERSION), with_jupyter = false)
if with_jupyter
new(tag, joinpath("templates", "with_jupyter", "Dockerfile"), "Dockerfile")
else
new(tag, joinpath("templates", "Dockerfile"), "Dockerfile")
end
end
end
source(p::Dockerfile) = p.file
destination(p::Dockerfile) = p.destination
view(f::Dockerfile, ::Template, pkg::AbstractString) = Dict("PKG" => pkg, "tag" => f.tag)
# ---
Base.@kwdef struct PlaygroundPluto <: FilePlugin
file::String = "templates/playground/pluto/.gitkeep"
destination::String = "playground/pluto/.gitkeep"
end
source(p::PlaygroundPluto) = p.file
destination(p::PlaygroundPluto) = p.destination
# ---
Base.@kwdef struct JuliaFormatter <: FilePlugin
file::String = "templates/dot_JuliaFormatter.toml"
destination::String = ".JuliaFormatter.toml"
end
source(p::JuliaFormatter) = p.file
destination(p::JuliaFormatter) = p.destination
# ---
Base.@kwdef struct Jupytext{T} <: FilePlugin
file::String
destination::String
end
U = Union{Val{:julia},Val{:python},Val{:r}}
function Jupytext(x::T) where {T}
throw(TypeError(:Jupytext, "$(@__FILE__)", U, x))
end
for lang in ("julia", "python", "r")
@eval function Jupytext(::Val{Symbol($lang)})
file = joinpath(
"templates",
"with_jupyter",
"playground",
"notebook",
$lang,
"jupytext.toml",
)
destination = joinpath("playground", "notebook", $lang, "jupytext.toml")
Jupytext{Symbol($lang)}(; file, destination)
end
end
Jupytext(lang::Symbol) = Jupytext(Val(lang))
Jupytext(lang::AbstractString) = Jupytext(Symbol(lowercase(lang)))
source(p::Jupytext) = p.file
destination(p::Jupytext) = p.destination
# ---
Base.@kwdef struct DevContainer <: FilePlugin
file::String = "templates/dot_devcontainer/devcontainer.json"
destination::String = ".devcontainer/devcontainer.json"
end
source(p::DevContainer) = p.file
destination(p::DevContainer) = p.destination
# ---
struct DockerCompose <: FilePlugin
file::String
destination::String
function DockerCompose(; with_jupyter = false)
if with_jupyter
new(
joinpath("templates", "with_jupyter", "docker-compose.yml"),
"docker-compose.yml",
)
else
new(joinpath("templates", "docker-compose.yml"), "docker-compose.yml")
end
end
end
source(p::DockerCompose) = p.file
destination(p::DockerCompose) = p.destination
view(::DockerCompose, ::Template, pkg::AbstractString) =
Dict("DOCKER_IMAGE" => lowercase(pkg) * "jl", "PKG" => pkg)
# ---
Base.@kwdef struct Makefile <: FilePlugin
file::String = "templates/Makefile"
destination::String = "Makefile"
end
source(p::Makefile) = p.file
destination(p::Makefile) = p.destination
view(::Makefile, ::Template, pkg::AbstractString) =
Dict("DOCKER_IMAGE" => lowercase(pkg) * "jl")
# ---
Base.@kwdef struct VSCodeExtensions <: FilePlugin
file::String = "templates/dot_vscode/extensions.json"
destination::String = ".vscode/extensions.json"
end
source(p::VSCodeExtensions) = p.file
destination(p::VSCodeExtensions) = p.destination