-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdevelop.sh
More file actions
executable file
·167 lines (131 loc) · 4.16 KB
/
develop.sh
File metadata and controls
executable file
·167 lines (131 loc) · 4.16 KB
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
#!/bin/bash -e
########################################################################
#
# Check required (versions of) tools are available
have_all_tools=yes
for tool in node git python python3 realpath poetry zip pandoc; do
if ! hash "$tool" 2> /dev/null; then
echo Could not find "$tool"
have_all_tools=no
fi
done
if [ "$have_all_tools" = "no" ]; then
echo
echo "Required tool/s missing. Please install it/them and try again."
exit 1
fi
node_version=$(node --version)
if [ "$(echo "$node_version" | grep -c -E '^v24[.]')" -ne 1 ]; then
echo Need node v24 but have "$node_version"
exit 1
fi
poetry_version=$(poetry --version)
if [ "$(echo "$poetry_version" | grep -c -E 'version 2[.]')" -ne 1 ]; then
echo Need Poetry v2 but have "$poetry_version"
exit 1
fi
########################################################################
REPO_ROOT="$(dirname "$(realpath "$0")")"
cd "$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 ..."
(
echo
echo "# Following line added by develop.sh script of pytch-releases:"
echo /site-layer/
) >> .git/modules/pytch-tutorials/info/exclude
cd 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 "$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 pytch-vm
(
npm install
npm run devbuild
( cd 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 pytch-build
(
# Poetry seems to want a keyring even if doing an operation which
# doesn't need one. Tell it to use a null one.
PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
export PYTHON_KEYRING_BACKEND
poetry env use -q python3
poetry install
) > "$REPO_ROOT"/pytch-build-preparation.out 2> "$REPO_ROOT"/pytch-build-preparation.err
echo "Prepared build tools"
) &
(
echo "Preparing webapp ..."
cd pytch-webapp
(
npm install
if [ -e src/.env ]; then
echo "File src/.env exists; leaving it alone"
else
echo "Creating src/.env appropriate to local development"
cp src/dot-env-local-development src/.env
fi
) > "$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
echo " ./pytch-build/makesite/local-server/dev-server.sh"
echo
echo "to launch a local development server"
echo