forked from SiloCityLabs/Cuttlephone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
51 lines (40 loc) · 1.36 KB
/
publish.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
#!/bin/bash
if [ ! -d "build/" ]
then
echo "Error: Directory build/ doesn't exist"
fi
#get all phone models and case configs
#change split char to help jq parse the JSON
IFS=""
#fetch phone models from JSON. Strip \r from Windows JSON
presets_jq=($(jq -r '.[] | select(type == "object") | .[] | .phone_model' phone_case.json | tr -d '\r'))
echo "Available phone models:"
echo $presets_jq
echo
#turn presets into an array, splitting on the newline
IFS=$'\n'
presets=($presets_jq)
unset IFS
#put models and variables on websites
jekyll_data_dir='./docs/_data/'
echo "Copying configs to website"
cp phone_case.json $jekyll_data_dir
premade_models_path='./docs/premade-models/'
#TODO: pull these from the JSON
#TODO: enable "gamepad" when it works
declare -a case_types=( "phone case" "junglecat" "joycon" )
declare -a case_materials=( "hard" "soft" )
filetype='3mf'
echo "Copying all models"
#loop through all case configs and build models
#TODO: use the build tags in build_vars. Only copy files we made already
for model in "${presets[@]}"; do
for case_type in "${case_types[@]}"; do
for case_material in "${case_materials[@]}"; do
filename="${model} ${case_type} ${case_material}.${filetype}"
echo "Copying - ${filename}"
cp "build/${filename}" $premade_models_path
done
done
done
exit;