forked from zwave-js/zwave-js-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.sh
executable file
·133 lines (115 loc) · 3 KB
/
package.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
#!/usr/bin/env bash
set -e
ask() {
# http://djm.me/ask
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
# Ask the question
read -p "$1 [$prompt] " REPLY
# Default?
if [ -z "$REPLY" ]; then
REPLY=$default
fi
# Check if the reply is valid
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
APP=$(node -p "require('./package.json').name")
PKG_FOLDER="pkg"
echo "Destination folder: $PKG_FOLDER"
echo "App-name: $APP"
VERSION=$(node -p "require('./package.json').version")
echo "Version: $VERSION"
NODE_MAJOR=$(node -v | egrep -o '[0-9].' | head -n 1)
echo "## Clear $PKG_FOLDER folder"
rm -rf $PKG_FOLDER/*
if [ ! -z "$1" ]; then
echo "## Building application..."
echo ''
yarn run build
echo "Executing command: pkg package.json -t node$NODE_MAJOR-linux-x64,node$NODE_MAJOR-win-x64 --out-path $PKG_FOLDER"
pkg package.json -t node$NODE_MAJOR-linux-x64,node$NODE_MAJOR-win-x64 --out-path $PKG_FOLDER
else
if ask "Re-build $APP?"; then
echo "## Building application"
yarn run build
fi
echo '###################################################'
echo '## Choose architecture to build'
echo '###################################################'
echo ' '
echo 'Your architecture is' $(arch)
PS3="Architecture: >"
options=(
"x64"
"armv7"
"armv6"
"x86"
"alpine"
"arm64"
)
echo ''
select option in "${options[@]}"; do
case "$REPLY" in
1)
echo "## Creating application package in $PKG_FOLDER folder"
pkg package.json -t node$NODE_MAJOR-linux-x64 --out-path $PKG_FOLDER
break
;;
2)
echo "## Creating application package in $PKG_FOLDER folder"
pkg package.json -t node$NODE_MAJOR-linux-armv7 --out-path $PKG_FOLDER --public-packages=*
break
;;
3)
echo "## Creating application package in $PKG_FOLDER folder"
pkg package.json -t node$NODE_MAJOR-linux-armv6 --out-path $PKG_FOLDER --public-packages=*
break
;;
4)
echo "## Creating application package in $PKG_FOLDER folder"
pkg package.json -t node$NODE_MAJOR-linux-x86 --out-path $PKG_FOLDER
break
;;
5)
echo "## Creating application package in $PKG_FOLDER folder"
pkg package.json -t node$NODE_MAJOR-alpine-x64 --out-path $PKG_FOLDER
break
;;
6)
echo "## Creating application package in $PKG_FOLDER folder"
pkg package.json -t node$NODE_MAJOR-linux-arm64 --out-path $PKG_FOLDER --public-packages=*
break
;;
*)
echo '####################'
echo '## Invalid option ##'
echo '####################'
exit
esac
done
fi
echo "## Create folders needed"
cd $PKG_FOLDER
mkdir store -p
if [ ! -z "$1" ]; then
echo "## Create zip file $APP-v$VERSION-win"
zip -r $APP-v$VERSION-win.zip store $APP-win.exe
echo "## Create zip file $APP-v$VERSION-linux"
zip -r $APP-v$VERSION-linux.zip store $APP-linux
else
echo "## Create zip file $APP-v$VERSION"
zip -r $APP-v$VERSION.zip store $APP
fi