forked from btcpayserver/btcpayserver-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-deps.sh
executable file
·253 lines (194 loc) · 7.93 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
#!/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"
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
# Checkout latest release tag, so that we do not publish docs for unreleased APIs yet.
git checkout $(git tag --sort -version:refname | awk 'match($0, /^v[0-9]+\./)' | head -n 1)
# 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/* "$BTCPAYSERVER_DIR/BTCPayServer/wwwroot/swagger/"
# 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_DIR/PodServer"
for file in "$DOCS_DIR"/PodServer/*.md; do
update_external "$file" https://github.com/dennisreimann/btcpayserver-plugin-podserver "$DOCS_DIR"/PodServer/
done
# Swagger
cd "$BTCPAYSERVER_DIR"
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 > $swagger_file
# report but don't stop on error
set +e
npx swagger-cli validate $swagger_file
npx @redocly/cli lint $swagger_file
set -e
fi