-
Notifications
You must be signed in to change notification settings - Fork 5
/
site-cli.edn
223 lines (180 loc) · 6.45 KB
/
site-cli.edn
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
; See https://book.babashka.org/#tasks
{:min-bb-version "0.6.2"
:paths ["src"]
:deps {io.github.lispyclouds/bblgum {:git/sha "7ebae0e2231899fe2a6ad44bc9ef5fca64099fcd"}
org.babashka/cli {:mvn/version "0.4.39"}
juxt.site/installer-graph {:local/root "installer-graph"}
juxt.site/cli-util {:local/root "cli-util"}
io.aviso/pretty {:mvn/version "1.1"}}
:tasks
{:requires
(juxt.site.site-cli.tasks
[clojure.core.async :as async]
[clojure.edn :as edn]
[clojure.java.io :as io]
[juxt.site.cli-util.tasks :as common-tasks])
;; Common tasks
ping
{:doc "Check server health"
:task (common-tasks/ping-task)}
config-file
{:doc "Show configuration-file"
:task (common-tasks/config-file-task)}
config
{:doc "Show configuration"
:opts {:require [:format]
:exec-args {:format "edn"}
:alias {:f :format}}
:task (common-tasks/config-task)}
profile
{:doc "Show profile"
:opts {}
:task (common-tasks/profile-task)}
request-token
{:doc "Acquire an access token"
:opts {:require [:client-id]
:exec-args {:client-id "site-cli"}}
:task (common-tasks/request-token-task)}
check-token
{:doc "Show current token. Use with --token or defaults to currently saved token."
:task (common-tasks/check-token-task)}
;; site-cli tasks (requires admin-server)
;; Override bb's help
help
{:doc "Show help"
:task (juxt.site.site-cli.tasks/help-task)
:override-builtin true}
configure
{:doc "Generate a site-cli.edn configuration file"
:opts {:require [:auth-base-uri :data-base-uri]
:coerce {:auth-base-uri :string
:data-base-uri :string}}
:task (juxt.site.site-cli.tasks/configure-task)}
;; TODO: In the config, there must be a value that allows a
;; reset. By default, don't allow a reset on remote hosts, it's too
;; easy to mistakenly delete all the resources.
reset
{:doc "Delete all resources. Only available via localhost."
:opts {:coerce {:no-confirm :boolean
:no-countdown :boolean}}
:task (juxt.site.site-cli.tasks/reset)}
init
{:doc "Initialise a server with minimal resources. Only available via localhost."
:opts {:coerce {:no-clients :boolean}}
:task (juxt.site.site-cli.tasks/init-task)}
register-system-clients
{:doc "Initialise a server with minimal resources. Only available via localhost."
:opts {}
:task (juxt.site.site-cli.tasks/register-system-clients-task)}
post-init
{:doc "Show post-init options. Requires the server."
:task (juxt.site.site-cli.tasks/post-init-task)}
bootstrap
{:doc "Bootstrap an instance with a default user & a demo API."
:task (juxt.site.site-cli.tasks/bootstrap-task)}
list
{:doc "List resources. Only available via localhost."
:opts {:args->opts [:pattern]}
:task (juxt.site.site-cli.tasks/list-task)}
find
{:doc "Find resources by pattern. Only available via localhost."
:opts {:args->opts [:pattern]
:coerce {:pattern :string}}
:task (juxt.site.site-cli.tasks/find)}
source
{:doc "Find what bundle installs this resource"
:opts {:args->opts [:pattern]
:coerce {:pattern :string}}
:task (juxt.site.site-cli.tasks/source)}
bundle-deps
{:doc "Find the immediate dependencies of this bundle"
:opts {:args->opts [:bundle]
:coerce {:bundle :string}}
:task (juxt.site.site-cli.tasks/bundle-deps)}
client-secret
{:doc "Retrieve a client_secret. Only available via localhost."
:opts {:args->opts [:client-id]
:require [:client-id]
:coerce {:save :boolean}
:exec-args {:client-id "site-cli"}}
:task (juxt.site.site-cli.tasks/print-or-save-client-secret-task)}
;; site-cli remote-only tasks
whoami
{:doc "Introspect current user/application"
:opts {:coerce {:verbose :boolean}
:alias {:v :verbose}}
:task (juxt.site.site-cli.tasks/whoami-task)}
register-user
{:doc "Register a user"
:opts {:require [:username]}
:task (juxt.site.site-cli.tasks/register-user-task)}
assign-user-role
{:doc "Assign a user a role"
:opts {:require [:username :role]}
:task (juxt.site.site-cli.tasks/assign-user-role-task)}
register-application
{:doc "Register an application"
:opts {:coerce {:client-id :string
:client-type :string
:redirect-uris [:string]
:scope [:string]}}
:task (juxt.site.site-cli.tasks/register-application)}
users
{:doc "Show current users"
:opts {:args->opts [:pattern]}
:task (juxt.site.site-cli.tasks/users)}
applications
{:doc "Show registered applications"
:opts {:coerce {:verbose :boolean}
:alias {:v :verbose}}
:task (juxt.site.site-cli.tasks/applications)}
openapis
{:doc "Show OpenAPI APIs"
:opts {:args->opts [:pattern]}
:task (juxt.site.site-cli.tasks/openapis)}
logs
{:doc "Get logs"
:task (juxt.site.site-cli.tasks/logs)}
events
{:doc "Introspect events"
:task (juxt.site.site-cli.tasks/events)}
new-keypair
{:doc "Create a new keypair"
:task (juxt.site.site-cli.tasks/new-keypair)}
bundle
{:doc "Stream a bundle to stdout"
:opts {:args->opts [:bundle]
:alias {:o :outfile}}
:task (juxt.site.site-cli.tasks/bundle-task)}
bundles
{:doc "List bundles"
:task (juxt.site.site-cli.tasks/bundles-task)}
install
{:doc "Install bundle"
:opts {:args->opts [:bundle]
:alias {:n :debug}
:coerce {:bundle []
:debug :boolean}}
:task (juxt.site.site-cli.tasks/install-bundle-task)}
install-openapi
{:doc "Install an API by uploading an OpenAPI document"
:opts {:require [:openapi]
:args->opts [:openapi]}
:task (juxt.site.site-cli.tasks/install-openapi-task)}
;; Dynamic builders
new-resource
{:doc "Create a new web resource"
:task (juxt.site.site-cli.tasks/new-resource)}
attach-method
{:doc "Attach a method to a resource"
:task (juxt.site.site-cli.tasks/attach-method)}
new-openapi {:doc "(Coming soon...)"} ; e.g. /folk
add-resource-to-openapi {:doc "(Coming soon...)"} ; e.g. add-resource-to-openapi --openapi /folk --resource /folk/contacts (must be relative to /folk)
annotate-resource {:doc "(Coming soon...)"} ; Add OpenAPI metadata to resource
;; Temporary convenience functions
install-openapi-support
{:doc "Auto configure"
:task (juxt.site.site-cli.tasks/install-openapi-support)}
install-petstore
{:doc "Reload petstore"
:task (juxt.site.site-cli.tasks/install-petstore)}}}