forked from btcpayserver/btcpayserver-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-deps.sh
executable file
·375 lines (286 loc) · 11.9 KB
/
setup-deps.sh
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
#!/bin/bash
set -e
BASE_DIR=$(cd `dirname $0` && pwd)
DOCS_DIR="$BASE_DIR/docs"
PUBLIC_DIR="$DOCS_DIR/.vuepress/public"
BTCPAYSERVER_DIR="$BASE_DIR/deps/btcpayserver"
NBXPLORER_DIR="$BASE_DIR/deps/nbxplorer"
CONFIGURATOR_DIR="$BASE_DIR/deps/configurator"
DOCKER_DIR="$BASE_DIR/deps/docker"
VAULT_DIR="$BASE_DIR/deps/vault"
TRANSMUTER_DIR="$BASE_DIR/deps/transmuter"
ZAPIER_DIR="$BASE_DIR/deps/zapier"
LNBANK_DIR="$BASE_DIR/deps/lnbank"
PODSERVER_DIR="$BASE_DIR/deps/podserver"
TROCADOR_DIR="$BASE_DIR/deps/trocador"
LNDHUBAPI_DIR="$BASE_DIR/deps/lndhub-api"
KUKKS_DIR="$BASE_DIR/deps/kukks"
SMARTSTORE_DIR="$BASE_DIR/deps/smartstore"
update_external() {
file="$1"
repo="$2"
base="$3"
path="${file#${base}}"
[[ $path = "Security.md" ]] && path="SECURITY.md"
[[ $path = "README.md" || $path = "SECURITY.md" ]] && folder="" || folder="docs/"
content=$(cat "$file")
# add frontmatter to omit edit links for external docs
echo $'---\neditLink: '"$repo/edit/master/$folder$path"$'\nexternalRepo: '"$repo"$'\n---\n'"$content" > "$file"
}
# BTCPay Server
echo "Setup dependency: BTCPayServer"
rm -rf "$DOCS_DIR/BTCPayServer"
mkdir -p "$DOCS_DIR/BTCPayServer"
if [ ! -d "$BTCPAYSERVER_DIR" ]; then
git clone https://github.com/btcpayserver/btcpayserver.git "$BTCPAYSERVER_DIR"
else
cd "$BTCPAYSERVER_DIR" && git checkout master && git pull
fi
cd "$BTCPAYSERVER_DIR"
cp SECURITY.md "$DOCS_DIR/BTCPayServer/Security.md"
cp BTCPayServer.Tests/README.md "$DOCS_DIR/BTCPayServer/LocalDevSetup.md"
cp -r docs/* "$DOCS_DIR/BTCPayServer"
line=$(grep -n '## How to manually test payments' $DOCS_DIR/BTCPayServer/LocalDevSetup.md | cut -d ":" -f 1)
{ echo $'---\neditLink: https://github.com/btcpayserver/btcpayserver-doc/edit/master/docs/Development/LocalDev.md\n---\n'; cat "$DOCS_DIR/Development/LocalDev.md"; echo; tail -n +$line "$DOCS_DIR/BTCPayServer/LocalDevSetup.md"; } > "$DOCS_DIR/Development/LocalDevelopment.md"
for file in "$DOCS_DIR"/BTCPayServer/*.md; do
update_external "$file" https://github.com/btcpayserver/btcpayserver "$DOCS_DIR"/BTCPayServer/
done
# NBXplorer
echo "Setup dependency: NBXplorer"
rm -rf "$DOCS_DIR/NBXplorer"
mkdir -p "$DOCS_DIR/NBXplorer"
if [ ! -d "$NBXPLORER_DIR" ]; then
git clone https://github.com/dgarage/NBXplorer.git "$NBXPLORER_DIR"
else
cd "$NBXPLORER_DIR" && git checkout master && git pull
fi
cd "$NBXPLORER_DIR"
cp -r README.md docs/* "$DOCS_DIR/NBXplorer"
sed -ie 's$(./docs/$(./$g' "$DOCS_DIR/NBXplorer/README.md"
for file in "$DOCS_DIR"/NBXplorer/*.md; do
update_external "$file" https://github.com/dgarage/NBXplorer "$DOCS_DIR"/NBXplorer/
done
# Vault
echo "Setup dependency: Vault"
rm -rf "$DOCS_DIR/Vault"
mkdir -p "$DOCS_DIR/Vault"
if [ ! -d "$VAULT_DIR" ]; then
git clone https://github.com/btcpayserver/BTCPayServer.Vault.git "$VAULT_DIR"
else
cd "$VAULT_DIR" && git checkout master && git pull
fi
cd "$VAULT_DIR"
cp -r README.md docs/* "$DOCS_DIR/Vault"
sed -ie 's$(docs/$(./$g' "$DOCS_DIR/Vault/README.md"
for file in "$DOCS_DIR"/Vault/*.md; do
update_external "$file" https://github.com/btcpayserver/BTCPayServer.Vault "$DOCS_DIR"/Vault/
done
# Configurator
echo "Setup dependency: Configurator"
rm -rf "$DOCS_DIR/Configurator"
mkdir -p "$DOCS_DIR/Configurator"
if [ ! -d "$CONFIGURATOR_DIR" ]; then
git clone https://github.com/btcpayserver/btcpayserver-configurator.git "$CONFIGURATOR_DIR"
else
cd "$CONFIGURATOR_DIR" && git checkout master && git pull
fi
cd "$CONFIGURATOR_DIR"
cp -r README.md docs/* "$DOCS_DIR/Configurator"
sed -ie 's$(./docs/$(./$g' "$DOCS_DIR/Configurator/README.md"
for file in "$DOCS_DIR"/Configurator/*.md; do
update_external "$file" https://github.com/btcpayserver/btcpayserver-configurator "$DOCS_DIR"/Configurator/
done
# Docker
echo "Setup dependency: Docker"
rm -rf "$DOCS_DIR/Docker"
mkdir -p "$DOCS_DIR/Docker"
if [ ! -d "$DOCKER_DIR" ]; then
git clone https://github.com/btcpayserver/btcpayserver-docker.git "$DOCKER_DIR"
else
cd "$DOCKER_DIR" && git checkout master && git pull
fi
cd "$DOCKER_DIR"
cp -r docs/* "$DOCS_DIR/Docker"
cp -r docs/img/* "$DOCS_DIR/img"
line=$(grep -n '# Introduction' README.md | cut -d ":" -f 1)
tail -n +$line "README.md" > "$DOCS_DIR/Docker/README.md"
sed -ie 's$(docs/$(./$g' "$DOCS_DIR/Docker/README.md"
for file in "$DOCS_DIR"/Docker/*.md; do
update_external "$file" https://github.com/btcpayserver/btcpayserver-docker "$DOCS_DIR"/Docker/
done
cp contrib/FastSync/README.md "$DOCS_DIR/Docker/fastsync.md"
sed -ie 's$(utxo-sets)$(https://github.com/btcpayserver/btcpayserver-docker/blob/master/contrib/FastSync/utxo-sets)$g' "$DOCS_DIR/Docker/fastsync.md"
sed -ie 's$(load-utxo-set.sh)$(https://github.com/btcpayserver/btcpayserver-docker/blob/master/contrib/FastSync/load-utxo-set.sh)$g' "$DOCS_DIR/Docker/fastsync.md"
sed -ie 's$(save-utxo-set.sh)$(https://github.com/btcpayserver/btcpayserver-docker/blob/master/contrib/FastSync/save-utxo-set.sh)$g' "$DOCS_DIR/Docker/fastsync.md"
sed -ie 's$(sigs/NicolasDorier.utxo-sets.asc)$(https://github.com/btcpayserver/btcpayserver-docker/blob/master/contrib/FastSync/sigs/NicolasDorier.utxo-sets.asc)$g' "$DOCS_DIR/Docker/fastsync.md"
# Transmuter
echo "Setup dependency: Transmuter"
rm -rf "$DOCS_DIR/Transmuter"
mkdir -p "$DOCS_DIR/Transmuter"
if [ ! -d "$TRANSMUTER_DIR" ]; then
git clone https://github.com/btcpayserver/btcTransmuter.git "$TRANSMUTER_DIR"
else
cd "$TRANSMUTER_DIR" && git checkout master && git pull
fi
cd "$TRANSMUTER_DIR"
cp -r README.md docs/* "$DOCS_DIR/Transmuter"
sed -ie 's$(docs/$(./$g' "$DOCS_DIR/Transmuter/README.md"
for file in "$DOCS_DIR"/Transmuter/*.md; do
update_external "$file" https://github.com/btcpayserver/btcTransmuter "$DOCS_DIR"/Transmuter/
done
# Zapier
echo "Setup dependency: Zapier"
rm -rf "$ZAPIER_DIR"
rm -rf "$DOCS_DIR/Zapier"
mkdir -p "$DOCS_DIR/Zapier"
if [ ! -d "$ZAPIER_DIR" ]; then
git clone --depth 1 https://github.com/btcpayserver/zapier.git "$ZAPIER_DIR"
else
cd "$ZAPIER_DIR"
fi
cd "$ZAPIER_DIR"
cp -r README.md doc/* "$DOCS_DIR/Zapier"
sed -ie 's$(./doc/$(./$g' "$DOCS_DIR/Zapier/README.md"
for file in "$DOCS_DIR"/Zapier/*.md; do
update_external "$file" https://github.com/btcpayserver/zapier "$DOCS_DIR"/Zapier/
done
# LNbank
echo "Setup dependency: LNbank"
rm -rf "$LNBANK_DIR"
rm -rf "$DOCS_DIR/LNbank"
mkdir -p "$DOCS_DIR/LNbank"
if [ ! -d "$LNBANK_DIR" ]; then
git clone --depth 1 https://github.com/dennisreimann/btcpayserver-plugin-lnbank.git "$LNBANK_DIR"
fi
cd "$LNBANK_DIR"
cp -r README.md docs/* "$DOCS_DIR/LNbank"
sed -ie 's$(./docs/$(./$g' "$DOCS_DIR/LNbank/README.md"
for file in "$DOCS_DIR"/LNbank/*.md; do
update_external "$file" https://github.com/dennisreimann/btcpayserver-plugin-lnbank "$DOCS_DIR"/LNbank/
done
cp -r BTCPayServer.Plugins.LNbank/Resources/swagger/* "$BASE_DIR/swagger/plugins"
# PodServer
echo "Setup dependency: PodServer"
rm -rf "$PODSERVER_DIR"
rm -rf "$DOCS_DIR/PodServer"
mkdir -p "$DOCS_DIR/PodServer"
if [ ! -d "$PODSERVER_DIR" ]; then
git clone --depth 1 https://github.com/dennisreimann/btcpayserver-plugin-podserver.git "$PODSERVER_DIR"
fi
cd "$PODSERVER_DIR"
cp -r README.md docs/* "$DOCS_DIR/PodServer"
sed -ie 's$(./docs/$(./$g' "$DOCS_DIR/PodServer/README.md"
for file in "$DOCS_DIR"/PodServer/*.md; do
update_external "$file" https://github.com/dennisreimann/btcpayserver-plugin-podserver "$DOCS_DIR"/PodServer/
done
# LNDhub API
echo "Setup dependency: LNDhub API"
rm -rf "$LNDHUBAPI_DIR"
rm -rf "$DOCS_DIR/LNDhubAPI"
mkdir -p "$DOCS_DIR/LNDhubAPI"
if [ ! -d "$LNDHUBAPI_DIR" ]; then
git clone --depth 1 https://github.com/dennisreimann/btcpayserver-plugin-lndhub-api.git "$LNDHUBAPI_DIR"
fi
cd "$LNDHUBAPI_DIR"
cp -r README.md docs/* "$DOCS_DIR/LNDhubAPI"
sed -ie 's$(./docs/$(./$g' "$DOCS_DIR/LNDhubAPI/README.md"
for file in "$DOCS_DIR"/LNDhubAPI/*.md; do
update_external "$file" https://github.com/dennisreimann/btcpayserver-plugin-lndhub-api "$DOCS_DIR"/LNDhubAPI/
done
# Trocador
echo "Setup dependency: Trocador"
rm -rf "$TROCADOR_DIR"
rm -rf "$DOCS_DIR/Trocador"
mkdir -p "$DOCS_DIR/Trocador"
if [ ! -d "$TROCADOR_DIR" ]; then
git clone --depth 1 https://github.com/saltrafael/trocador-plugin.git "$TROCADOR_DIR"
fi
cd "$TROCADOR_DIR"
cp -r README.md "$DOCS_DIR/Trocador"
for file in "$DOCS_DIR"/Trocador/*.md; do
update_external "$file" https://github.com/saltrafael/trocador-plugin "$DOCS_DIR"/Trocador/
done
# Smartstore
echo "Setup dependency: Smartstore"
rm -rf "$SMARTSTORE_DIR"
rm -rf "$DOCS_DIR/Smartstore"
mkdir -p "$DOCS_DIR/Smartstore"
if [ ! -d "$SMARTSTORE_DIR" ]; then
git clone --depth 1 https://github.com/btcpayserver/Smartstore.BTCPayServer.git "$SMARTSTORE_DIR"
fi
cd "$SMARTSTORE_DIR"
cp -r src/Smartstore.Modules/Smartstore.BTCPayServer/README.md "$DOCS_DIR/Smartstore"
for file in "$DOCS_DIR"/Smartstore/*.md; do
update_external "$file" https://github.com/btcpayserver/Smartstore.BTCPayServer.git "$DOCS_DIR"/Smartstore/
done
# Kukks' plugins
echo "Setup dependency: Kukks' plugins"
rm -rf "$KUKKS_DIR"
rm -rf "$DOCS_DIR/TicketTailor" "$DOCS_DIR/Nostr" "$DOCS_DIR/Wabisabi"
mkdir -p "$DOCS_DIR/TicketTailor" "$DOCS_DIR/Nostr" "$DOCS_DIR/Wabisabi"
if [ ! -d "$KUKKS_DIR" ]; then
git clone --depth 1 https://github.com/Kukks/BTCPayServerPlugins.git "$KUKKS_DIR"
fi
cd "$KUKKS_DIR/Plugins/BTCPayServer.Plugins.Wabisabi"
cp -r readme.md docs/* "$DOCS_DIR/Wabisabi"
sed -ie 's$docs/$./$g' "$DOCS_DIR/Wabisabi/readme.md"
for file in "$DOCS_DIR"/Wabisabi/*.md; do
update_external "$file" https://github.com/Kukks/BTCPayServerPlugins/tree/master/Plugins/BTCPayServer.Plugins.Wabisabi "$DOCS_DIR"/Wabisabi/
done
cd "$KUKKS_DIR/Plugins/BTCPayServer.Plugins.TicketTailor"
cp -r README.md "$DOCS_DIR/TicketTailor"
for file in "$DOCS_DIR"/TicketTailor/*.md; do
update_external "$file" https://github.com/Kukks/BTCPayServerPlugins/tree/master/Plugins/BTCPayServer.Plugins.TicketTailor "$DOCS_DIR"/TicketTailor/
done
cd "$KUKKS_DIR/Plugins/BTCPayServer.Plugins.NIP05"
cp -r readme.md "$DOCS_DIR/Nostr"
for file in "$DOCS_DIR"/Nostr/*.md; do
update_external "$file" https://github.com/Kukks/BTCPayServerPlugins/tree/master/Plugins/BTCPayServer.Plugins.NIP05 "$DOCS_DIR"/Nostr/
done
# Swagger
# BTCPay Swagger: Checkout latest release tag, so that we do not publish docs for unreleased APIs yet
cd "$BTCPAYSERVER_DIR"
git checkout $(git tag --sort -version:refname | awk 'match($0, /^v[0-9]+\.[0-9]+\.[0-9]+$/)' | head -n 1)
# Swagger
if command -v jq >/dev/null 2>&1; then
swagger_file="$PUBLIC_DIR/API/Greenfield/v1/swagger.json"
jq -rs 'def deepmerge(a;b):
reduce b[] as $item (a;
reduce ($item | keys_unsorted[]) as $key (.;
$item[$key] as $val | ($val | type) as $type | .[$key] = if ($type == "object") then
deepmerge({}; [if .[$key] == null then {} else .[$key] end, $val])
elif ($type == "array") then
(.[$key] + $val | unique)
else
$val
end)
);
deepmerge({}; .)' BTCPayServer/wwwroot/swagger/v1/*.json $BASE_DIR/swagger/btcpay.json > $swagger_file
# report but don't stop on error
set +e
REDOCLY_TELEMETRY=off npx @redocly/cli lint $swagger_file
set -e
fi
# We need the base file to be able to generate the swagger for the plugins
cp BTCPayServer/wwwroot/swagger/v1/swagger.template.json $BASE_DIR/swagger/plugins/btcpay.json
# Plugin Swagger
cd $BASE_DIR
if command -v jq >/dev/null 2>&1; then
swagger_file="$PUBLIC_DIR/API/Greenfield/Plugins/swagger.json"
jq -rs 'def deepmerge(a;b):
reduce b[] as $item (a;
reduce ($item | keys_unsorted[]) as $key (.;
$item[$key] as $val | ($val | type) as $type | .[$key] = if ($type == "object") then
deepmerge({}; [if .[$key] == null then {} else .[$key] end, $val])
elif ($type == "array") then
(.[$key] + $val | unique)
else
$val
end)
);
deepmerge({}; .)' swagger/plugins/btcpay.json swagger/plugins.json swagger/plugins/**/*.json > $swagger_file
# report but don't stop on error
set +e
REDOCLY_TELEMETRY=off npx @redocly/cli lint $swagger_file --skip-rule=no-unused-components
set -e
fi