-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathre_frame.clj
130 lines (95 loc) · 3.15 KB
/
re_frame.clj
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
129
130
(ns leiningen.new.re-frame
(:require
[leiningen.core.main :as main]
[leiningen.new.options.base :as base]
[leiningen.new.options.garden :as garden]
[leiningen.new.options.kondo :as kondo]
[leiningen.new.options.re-com :as re-com]
[leiningen.new.options.routes :as routes]
[leiningen.new.options.test :as test]
[leiningen.new.options.views :as views]
[leiningen.new.options.helpers :as helpers]
[leiningen.new.options.cider :as cider]
[leiningen.new.options.github-actions :as github-actions]
[clojure.set :as set])
(:use [leiningen.new.templates :only [name-to-path sanitize-ns ->files]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Files & Data for Template
(defn app-files [data options]
(concat
(base/files data)
(views/view-cljs options data)
;; css
(when (helpers/option? garden/option options) (garden/files data))
;; debug
;;
;; development
(when (helpers/option? kondo/option options) (kondo/files data))
(when (helpers/option? test/option options) (test/files data))
;; full-stack
(when (helpers/option? cider/option options) (cider/files data))
;; misc.
(when (helpers/option? re-com/option options) (re-com/assets data))
(when (helpers/option? github-actions/option options) (github-actions/files data))
;; routing
(when (helpers/option? routes/option options) (routes/routes-cljs data))))
(defn template-data [name options]
{:name name
:ns-name (sanitize-ns name)
:sanitized (name-to-path name)
;; css
:garden? (helpers/option? garden/option options)
;; debug
:re-frisk? (helpers/option? "+re-frisk" options)
:10x? (helpers/option? "+10x" options)
;; development
:cider? (helpers/option? cider/option options)
:kondo? (helpers/option? kondo/option options)
:test? (helpers/option? test/option options)
:git-inject? (helpers/option? "+git-inject" options)
;; misc.
:re-com? (helpers/option? re-com/option options)
:re-pressed? (helpers/option? "+re-pressed" options)
:breaking-point? (helpers/option? "+breaking-point" options)
:github-actions? (helpers/option? github-actions/option options)
;; routing
:routes? (helpers/option? routes/option options)})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check Options
(def available-set
#{;; css
garden/option
;; debug
"+re-frisk"
"+10x"
;; development
cider/option
kondo/option
test/option
"+git-inject"
;; misc.
re-com/option
"+re-pressed"
"+breaking-point"
github-actions/option
;; routing
routes/option})
(defn check-available [options]
(let [options-set (into #{} options)
abort? (not (set/superset? available-set
options-set))]
(when abort?
(main/abort "\nError: invalid profile(s)\n"))))
(defn check-options
"Check the user-provided options"
[options]
(doto options
check-available))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main
(defn re-frame [name & options]
(let [data (template-data name options)]
(check-options options)
(main/info "Generating re-frame project.")
(apply ->files data
(app-files data options))))