forked from pytchlang/pytch-releases
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevelop.sh
executable file
·142 lines (109 loc) · 3.5 KB
/
develop.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
#!/bin/bash
########################################################################
#
# Check required (versions of) tools are available
for tool in node git virtualenv python3 realpath; do
if ! hash "$tool" 2> /dev/null; then
echo Could not find "$tool"
exit 1
fi
done
node_version=$(node --version)
if [ "$(echo "$node_version" | grep -c -E '^v14[.]')" -ne 1 ]; then
echo Need node v14 but have "$node_version"
exit 1
fi
########################################################################
cd_or_fail() { cd "$1" || exit 1; }
REPO_ROOT="$(dirname "$(realpath "$0")")"
cd_or_fail "$REPO_ROOT"
# Bail if it looks like we've already run.
if [ -e pytch-vm/src ] || [ -e pytch-webapp/src ]; then
echo
echo "It looks like development set-up has already been done"
echo "Not making any changes"
echo
exit 1
fi
echo "Initialising submodules ..."
git submodule --quiet init
git submodule --quiet update
if [ ! -e pytch-vm/src ] || [ ! -e pytch-webapp/src ]; then
echo
echo "Failed to initialise submodules"
echo
exit 1
fi
(
echo " Preparing tutorials repo ..."
cd_or_fail pytch-tutorials
# Ensure we have a local branch for every remote branch.
for branchname in $(git for-each-ref --format='%(refname)' refs/remotes/origin/ \
| sed 's|^refs/remotes/origin/||'); do
if [ "$branchname" != HEAD ]; then
# Create branch if it doesn't already exist.
git show-ref --quiet "refs/heads/$branchname" \
|| git branch --quiet "$branchname" "origin/$branchname"
fi
done
echo " Prepared tutorials repo"
)
# Where possible, check each submodule out at the first named branch
# referring to its HEAD.
#
# I do mean 'echo $name' in single quotes:
# shellcheck disable=SC2016
for m in $(git submodule foreach --quiet 'echo $name'); do
(
cd_or_fail "$m"
branch=$(git branch --no-column --format="%(refname:short)" --points-at "$(git rev-parse HEAD)" \
| grep -v "HEAD detached" \
| head -1)
if [ -n "$branch" ] && [ -z "$(git symbolic-ref --short -q HEAD)" ]; then
git checkout --quiet "$branch"
fi
)
done
echo "Initialised submodules"
./pytch-build/makesite/pytch-git-status.sh
(
echo "Preparing VM ..."
cd_or_fail pytch-vm
(
npm install
npm run devbuild
( cd_or_fail dist; ln -s skulpt.js skulpt.min.js )
) > "$REPO_ROOT"/pytch-vm-preparation.out 2> "$REPO_ROOT"/pytch-vm-preparation.err
echo "Prepared VM"
) &
(
echo "Preparing build tools ..."
cd_or_fail pytch-build
(
# Don't shellcheck venv/bin/activate:
# shellcheck disable=SC1091
virtualenv -p python3 venv \
&& source venv/bin/activate \
&& pip install --upgrade pip \
&& pip install -r requirements_dev.txt \
&& python setup.py install
) > "$REPO_ROOT"/pytch-build-preparation.out 2> "$REPO_ROOT"/pytch-build-preparation.err
echo "Prepared build tools"
) &
(
echo "Preparing webapp ..."
cd_or_fail pytch-webapp
(
npm install
) > "$REPO_ROOT"/pytch-webapp-preparation.out 2> "$REPO_ROOT"/pytch-webapp-preparation.err
echo "Prepared webapp"
) &
wait
echo
echo "Built all"
echo "See *-preparation.{out,err} for details"
echo
echo "You should now be able to run"
echo " ./pytch-build/makesite/local-server/dev-server.sh"
echo "to launch a local development server"
echo