-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathprebuild.sh
72 lines (58 loc) · 1.48 KB
/
prebuild.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
#!/bin/bash
set -e
REPO_NAME="cinny"
REPO_URL="https://github.com/cinnyapp/cinny"
REPO_BRANCH="dev"
APP_TARGET="dist"
REPO_VERSION="2.1.3"
CLICK_VERSION_PREFIX=""
NODE_VERSION="v16.15.0"
walk () {
echo "Entering $1"
cd $1
}
cleanup () {
if [ -d "${ROOT}/${REPO_NAME}" ]; then
echo "Cleaning up"
rm -rf "${ROOT}/${REPO_NAME}" "${ROOT}/target"
fi
}
clone () {
echo "Cloning source repo"
git clone "${REPO_URL}" "${ROOT}/${REPO_NAME}" --depth=1 --branch="v${REPO_VERSION}"
}
apply_patches () {
echo "Patching cinny source code"
if [ -d "${ROOT}/patches" ]; then
for patch in ${ROOT}/patches/*.patch; do
echo "Applying $patch"
git apply ${patch}
done
fi
cp "${ROOT}/svg/cinny_512.svg" "${ROOT}/assets/logo.svg"
cp "${ROOT}/svg/cinny_18.svg" "${ROOT}/cinny/public/res/svg/cinny.svg"
}
setup_node () {
echo "Setting up node $NODE_VERSION"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install $NODE_VERSION
}
build () {
echo "Building cinny"
npm install
npm run build
}
package () {
echo "Packaging cinny"
cp -r "${APP_TARGET}" "${ROOT}/target"
sed -i "s/@CLICK_VERSION@/$REPO_VERSION$CLICK_VERSION_PREFIX/g" "${ROOT}/manifest.json.in"
}
cleanup
clone
walk "${ROOT}/${REPO_NAME}"
apply_patches
setup_node
build
package