-
Notifications
You must be signed in to change notification settings - Fork 4
/
tgdev.sh
executable file
·93 lines (73 loc) · 2.75 KB
/
tgdev.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
#!/bin/bash
BUILD_INSTALLER=true
DEBUG_BUILD=true
DEV=true
# Check dependencies
check_dependency() {
command -v "$1" >/dev/null 2>&1 || { echo >&2 "$1 is required but it's not installed. Aborting."; exit 1; }
}
check_dependency unzip
check_dependency zip
check_dependency npm
check_dependency npx
#########
set_config(){
echo "{ \"BUILD_INSTALLER\": $BUILD_INSTALLER, \"DEBUG_BUILD\": $DEBUG_BUILD, \"DEV\": $DEV }" > config.json
}
if [ "$1" == "run" ]; then
echo "running development build"
BUILD_INSTALLER=false
set_config
npx cross-env OSTARGETS="--linux=deb rpm" npm run dev
exit 0
elif [ "$1" == "pack" ]; then
DEBUG_BUILD=false
DEV=false
echo "cleaning dependencies"
npm run rebuild
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "building linux installers"
set_config
npx cross-env OSTARGETS="--linux=deb rpm" npm run build
echo "building linux zip"
BUILD_INSTALLER=false
set_config
npx cross-env OSTARGETS="--linux=zip" npm run build
# Unzip the build and zip again after the unpacked directory holding the LinuxRunOnExternalMedia for the USB remount script, is moved to the app root directory for the user to access easily
# for zip_file in dist/tagasaurus-*.zip; do
# # Extract the version or unique identifier from the filename
# identifier=$(basename "$zip_file" .zip | cut -d'-' -f2)
# # Extract the ZIP file
# unzip "$zip_file" -d dist/tempDir || { echo "Failed to unzip $zip_file."; exit 1; }
# # Copy the directory within the extracted contents
# cp -r dist/tempDir/resources/app.asar.unpacked/LinuxRunOnExternalMedia dist/tempDir/LinuxRunOnExternalMedia
# # Recreate the ZIP file with the modified contents
# (
# cd dist/tempDir || exit
# zip -r "../tagasaurus-$identifier-Linux.zip" .
# )
# # Clean up: remove the extracted contents and the original ZIP
# rm -rf dist/tempDir
# rm "$zip_file"
# done
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
echo "building windows zip"
BUILD_INSTALLER=false
set_config
npm run build-win-zip
BUILD_INSTALLER=true
echo "building windows nsis"
set_config
npm run build-win-nsis
else
echo "unsupported OS" # Unknown.
fi
elif [ "$1" == "clean" ]; then
echo "cleaning dependencies"
npm run clean
elif [ "$1" == "rebuild" ]; then
echo "cleaning dependencies and rebuilding dependencies"
npm run rebuild
else
echo "expected argument 'run' | 'pack' | 'clean' | 'rebuild' "
fi