-
Notifications
You must be signed in to change notification settings - Fork 6
/
demo1-deploy.sh
executable file
·185 lines (137 loc) · 5.78 KB
/
demo1-deploy.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
#!/bin/bash
# runs demo1 locally for MacOS
set -ex
function assert_env_nonempty() {
if [ ".$1" = "." ]; then
echo "shell env is empty"; echo $2
return 1
fi
}
# args:
# source:
assert_env_nonempty $IMPLISOLID_REPO "env-argument IMPLISOLID_REPO= not specified"
#assert_env_nonempty $SCRIPTS_DIR "env-argument SCRIPTS_DIR= not specified"
# target/destination: to-deploy:
assert_env_nonempty $DEPLOY_LOCATION "env-argument DEPLOY_LOCATION= not specified"
assert_env_nonempty $BUILD_LOCATION "env-argument BUILD_LOCATION= not specified"
#echo SCRIPTS_DIR is not really used
# deploy: to put it "there"
# run: BASELOC1=$(pwd) bash deploy-demo-1.sh
# todo: put there in any given (parametrised) location
# Prerequisite:
# * compiles files to be ready here: $IMPLISOLID_REPO/build. Use scripts/demo1-build.sh
# * three repos are cloned
set -e
# Altenative names: BASE_IMPLISOLID, REPOBASE_IMPLISOLID, IMPLISOLID, REPO_IMPLISOLID, IMPLISOLID_REPO
# repo bases
#export IMPLISOLID_REPO=$BASELOC1/implisolid
# same as $REPO_ROOT
#export SOHALE_IO_REPO=$BASELOC3/sohale.github.io/
# export BASE_MP5_PRIVATE=$BASELOC2/mp5/mp5-private
# relative location of repos
#export IMPLISOLID_BUILD_REPO=$IMPLISOLID_REPO/docs/implisolid-build
# todo: specify a separate independent folder => you wil know the structure BEFORE this.
# qt the tie oof e2e sscript
# based on configuration
# Wait, what?
#export LOCAL_DEPLOY_LOCATION=$IMPLISOLID_REPO/demos/demo1
#export REMOTE_DEPLOY_LOCATION=$IMPLISOLID_BUILD_REPO/demo1
# Two alternatives:
# why two options?
#export DEPLOY_LOCATION=$LOCAL_DEPLOY_LOCATION
#export DEPLOY_LOCATION=$REMOTE_DEPLOY_LOCATION
# simplified:
#export DEPLOY_LOCATION=$IMPLISOLID_BUILD_REPO/demo1
#sources deployed files:
export DEMO0=$IMPLISOLID_REPO/examples/mp5interactive
export JSI2=$IMPLISOLID_REPO/js_iteration_2
export EX_JSLIB=$IMPLISOLID_REPO/examples/js-lib
ls $IMPLISOLID_REPO/examples/js-lib/OrbitControls_r79-copy.js
ls $EX_JSLIB/OrbitControls_r79-copy.js
# see notes-on-folders.md
# hard-built: as built on github
#export BUILT=$IMPLISOLID_BUILD_REPO
# soft-built: locally just built
#export BUILD_LOCATION=$IMPLISOLID_REPO/demos/build
export compiled_file=$BUILD_LOCATION/mcc2.compiled.js
# Pre-built from submodule on github:
#export compiled_file=$BUILT/opt/mcc2.compiled.js
#export START_DEMOS=$IMPLISOLID_REPO/demos
#cd $START_DEMOS
#mkdir -p $START_DEMOS/demo1
#rm -rfv $START_DEMOS/demo1; mkdir $START_DEMOS/demo1; cd $START_DEMOS/demo1
# removed references to $IMPLISOLID_REPO/demos/demo1
mkdir -p $IMPLISOLID_REPO/build/unrelated
cd $IMPLISOLID_REPO/build/unrelated
function gather_files_for_deploy() {
# Gathers various files and prepares them for deploying.
# Why not move them permanently on the (git) repo?
# Copies file from 4 sources:
# EX_JSLIB,JSI2,DEMO0, compiled_file
# To: destination: DEPLOY_LOCATION
#compiled_file should be ready ( in $BUILD_LOCATION )
mkdir -p $DEPLOY_LOCATION/js-copy
# local run:
CP_not() {
ln -s $1 $2
}
# server deploy (then push to the "implicit_build" repo)
CP() {
cp $1 $2
}
# OrbitControls_r79.js was also in `mp5-private/implisolid/js_iteration_1/controls/OrbitControls_r79.js`
CP $EX_JSLIB/OrbitControls_r79-copy.js $DEPLOY_LOCATION/js-copy/OrbitControls_r79.js
mkdir -p $DEPLOY_LOCATION/js-copy
CP $DEMO0/mp5_json_code.html $DEPLOY_LOCATION/
CP $JSI2/geometry79.js $DEPLOY_LOCATION/js-copy/
CP $JSI2/implisolid_main.js $DEPLOY_LOCATION/js-copy/
CP $JSI2/js/js_utils.js $DEPLOY_LOCATION/js-copy/
CP $JSI2/js/pointset_utils.js $DEPLOY_LOCATION/js-copy/
CP $JSI2/js/arrow_utils.js $DEPLOY_LOCATION/js-copy/
CP $EX_JSLIB/example_objects.js $DEPLOY_LOCATION/js-copy/
CP $EX_JSLIB/example_materials.js $DEPLOY_LOCATION/js-copy/
CP $EX_JSLIB/performance_graphs.js $DEPLOY_LOCATION/js-copy/
CP $EX_JSLIB/misc_props.js $DEPLOY_LOCATION/js-copy/
CP $EX_JSLIB/boundingbox_utils.js $DEPLOY_LOCATION/js-copy/
CP $EX_JSLIB/simple_assert.js $DEPLOY_LOCATION/js-copy/
# CP $EX_JSLIB/my_assert.js $DEPLOY_LOCATION/js-copy/
CP $EX_JSLIB/js_utils.js $DEPLOY_LOCATION/js-copy/
# todo: move to a folder specific to this demo?
CP $EX_JSLIB/asmjscb.js $DEPLOY_LOCATION/js-copy/
echo "compiled_file $compiled_file"
CP $compiled_file $DEPLOY_LOCATION/js-copy/
# CP $BUILT/opt/mcc2.compiled.js.mem $DEPLOY_LOCATION/js-copy/
# self-refelection of deploy (version inspect endpoint!)
}
################
#bash copy_files_for_deploy.sh
gather_files_for_deploy
################
function find_noprefix() {
FOLDER=$1
find $FOLDER |awk -v prefix="$FOLDER/" '{ match($0, prefix); printf substr($0, RSTART+RLENGTH); printf "\n"}'
}
find_noprefix $DEPLOY_LOCATION
# Info about latest commit to be available on browser
git rev-parse HEAD >$DEPLOY_LOCATION/latest-commit.txt
git log -n 1 >$DEPLOY_LOCATION/latest-commit-log.txt
echo "\n\ngit diff\n" >>$DEPLOY_LOCATION/latest-commit-log.txt
git diff >>$DEPLOY_LOCATION/latest-commit-log.txt
date >>$DEPLOY_LOCATION/latest-commit-log.txt
echo "for latest commit info click: try http://localhost:8000/latest-commit-log.txt"
# examine and produce all errors (the "ln -s" file links that the file is non-existant )
#ls -1 $DEPLOY_LOCATION | xargs cat 1>/dev/null
echo "Checking missing symbolic links *******"
# pushd $DEPLOY_LOCATION/js-copy
cd $DEPLOY_LOCATION/js-copy
ls -1 . | xargs cat 1>/dev/null
cd ..
cd $DEPLOY_LOCATION
cat >$DEPLOY_LOCATION/launch-local-autogenerated.bash << LAUNCH_SCRIPT
echo visit http://localhost:8000/mp5_json_code.html
python3 -m http.server 8000
LAUNCH_SCRIPT
cat $DEPLOY_LOCATION/launch-local-autogenerated.bash
# But this file is not actually executed.
# Instead this will be executed: $SCRIPTS_DIR/demos/demo1/launch-demo1-local.bash
echo "DEPLOY_LOCATION is $DEPLOY_LOCATION"