-
Notifications
You must be signed in to change notification settings - Fork 3
/
repository-cleanup.sh
executable file
·76 lines (66 loc) · 3.74 KB
/
repository-cleanup.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
#!/bin/bash
branch=$1
if [ -z "$branch" ] ; then
branch=$(git rev-parse --abbrev-ref HEAD)
fi
if [ "$branch" = "dev" ] ; then
echo "Using pre-release Systemathics.Apis (and dev.systemathics.eu)"
elif [ "$branch" = "prod" ] ; then
echo "Using production Systemathics.Apis (and ganymede.cloud)"
else
echo "Don't know how to handle branch $branch"
exit 1
fi
ROOT_DIR="$(dirname "$(readlink -f "$0")")"
DOS2UNIX=$(which dos2unix)
if [ ! -z "$DOS2UNIX" ] ; then
find $ROOT_DIR -name "*.ipynb" -print0 | xargs -0 dos2unix \{} >& /dev/null;
fi
export PATH=$HOME/.local/bin:$PATH
NBSTRIPOUT=$(which nbstripout)
if [ -z "$NBSTRIPOUT" ] ; then
pip install nbstripout
fi
NBSTRIPOUT=$(which nbstripout)
find $ROOT_DIR -name "*.ipynb" -print0 | xargs -0 $NBSTRIPOUT --drop-empty-cells --strip-init-cells \{};
# cleanup any pre-release mention (python)
find $ROOT_DIR/python -name "*.ipynb" -print0 | xargs -0 sed -i 's/"\(pip install systemathics.apis\).*"/"\1"/'
find $ROOT_DIR/csharp -name "*.ipynb" -print0 | xargs -0 sed -i 's/#r\s*.*\(\\"nuget:\s*Systemathics.Apis\).*\(\\"\)/#r \1\2/'
find $ROOT_DIR/fsharp -name "*.ipynb" -print0 | xargs -0 sed -i 's/#r\s*.*\(\\"nuget:\s*Systemathics.Apis\).*\(\\"\)/#r \1\2/'
# rewrite URLs
find $ROOT_DIR -name "*.ipynb" -print0 | xargs -0 sed -i 's|https://dev.systemathics.eu|https://ganymede.cloud|g'
find $ROOT_DIR -name "*.md" -print0 | xargs -0 sed -i 's|https://dev.systemathics.eu|https://ganymede.cloud|g'
sed -i 's|ganymede-dev|ganymede-prod|g' remoteaccess/env.sh
sed -i 's|ganymede-dev|ganymede-prod|g' remoteaccess/env.ps1
sed -i 's|ganymede-dev|ganymede-prod|g' remoteaccess/jupyter-lab-windows.cmd
sed -i 's|ganymede-dev|ganymede-prod|g' get-auth0-token.py
sed -i 's|dev.systemathics.eu|ganymede.cloud|g' remoteaccess/env.sh
sed -i 's|dev.systemathics.eu|ganymede.cloud|g' remoteaccess/env.ps1
sed -i 's|dev.systemathics.eu|ganymede.cloud|g' remoteaccess/jupyter-lab-windows.cmd
sed -i 's|dev.systemathics.eu|ganymede.cloud|g' get-auth0-token.py
if [ "$branch" = "dev" ] ; then
# apply pre-release version
find $ROOT_DIR/csharp -name "*.ipynb" -print0 | xargs -0 sed -i 's/nuget: Systemathics.Apis/nuget: Systemathics.Apis, 2.33.\*-pre\*/'
find $ROOT_DIR/fsharp -name "*.ipynb" -print0 | xargs -0 sed -i 's/nuget: Systemathics.Apis/nuget: Systemathics.Apis, 2.33.\*-pre\*/'
find $ROOT_DIR/python -name "*.ipynb" -print0 | xargs -0 sed -i 's/pip install systemathics.apis/pip install systemathics.apis==2.33.\* --pre/'
# rewrite URLs
find $ROOT_DIR -name "*.ipynb" -print0 | xargs -0 sed -i 's|https://ganymede.cloud|https://dev.systemathics.eu|g'
find $ROOT_DIR -name "*.md" -print0 | xargs -0 sed -i 's|https://ganymede.cloud|https://dev.systemathics.eu|g'
sed -i 's|ganymede-prod|ganymede-dev|g' remoteaccess/env.sh
sed -i 's|ganymede-prod|ganymede-dev|g' remoteaccess/env.ps1
sed -i 's|ganymede-prod|ganymede-dev|g' remoteaccess/jupyter-lab-windows.cmd
sed -i 's|ganymede-prod|ganymede-dev|g' get-auth0-token.py
sed -i 's|ganymede.cloud|dev.systemathics.software|g' remoteaccess/env.sh
sed -i 's|ganymede.cloud|dev.systemathics.software|g' remoteaccess/env.ps1
sed -i 's|ganymede.cloud|dev.systemathics.software|g' remoteaccess/jupyter-lab-windows.cmd
sed -i 's|ganymede.cloud|dev.systemathics.software|g' get-auth0-token.py
fi
if [ "$branch" = "prod" ] ; then
# apply version
find $ROOT_DIR/csharp -name "*.ipynb" -print0 | xargs -0 sed -i 's/nuget: Systemathics.Apis/nuget: Systemathics.Apis, 2.39.\*/'
find $ROOT_DIR/fsharp -name "*.ipynb" -print0 | xargs -0 sed -i 's/nuget: Systemathics.Apis/nuget: Systemathics.Apis, 2.39.\*/'
find $ROOT_DIR/python -name "*.ipynb" -print0 | xargs -0 sed -i 's/pip install systemathics.apis/pip install systemathics.apis==2.39.\*/'
fi
du -sh csharp/
du -sh fsharp/
du -sh csharp/