Skip to content

Commit ed3fe57

Browse files
authored
Merge pull request #10 from Heshdude/minify
Adding Minify
2 parents 5a1226d + 0199e4d commit ed3fe57

File tree

11 files changed

+360
-110
lines changed

11 files changed

+360
-110
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
uses: technote-space/get-diff-action@v1
1616
- name: Generate installers
1717
run: pip install toml && python generate.py ${{ env.GIT_DIFF }}
18+
- name: Minify generated installers
19+
run: ./minify.sh ${{ env.GIT_DIFF }}
1820
- name: Archive Production Artifact
1921
uses: actions/upload-artifact@master
2022
with:
@@ -46,5 +48,5 @@ jobs:
4648
PROJECT_ID: installer-to
4749
APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
4850
with:
49-
args: rsync -r installers gs://installer-to.appspot.com/installers
51+
args: rsync -r installers gs://installer-to.appspot.com/
5052
cli: gsutil

generate.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import os
44
import logging
55
import errno
6+
import constants
7+
8+
print (constants.CURL_CHECK)
69

710
methods = {
811
"curl": "$CURL",
@@ -22,7 +25,12 @@ def get_method_case(method):
2225
exit(1)
2326

2427
def parse_line(line):
25-
line = line.replace('@sudo', '$SUDO')
28+
line = line\
29+
.replace('@sudo', '$SUDO')\
30+
.replace('@log', 'info')\
31+
.replace('@info', 'info')\
32+
.replace('@warn', 'warn')\
33+
.replace('@error', 'error')
2634
return line
2735

2836
def generate(path):
@@ -37,14 +45,14 @@ def generate(path):
3745

3846
installer_sh.write("""#!/bin/sh
3947
40-
CURL_CMD=$(which curl) # curl tool
41-
YUM_CMD=$(which yum) # yum package manager for RHEL & CentOS
42-
DNF_CMD=$(which dnf) # dnf package manager for new RHEL & CentOS
43-
APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian based distributions
44-
PACMAN_CMD=$(which pacman) # pacman package manager for ArchLinux
45-
APK_CMD=$(which apk) # apk package manager for Alpine
46-
GIT_CMD=$(which git) # to build from source pulling from git
47-
SUDO_CMD=$(which sudo) # check if sudo command is there
48+
CURL_CMD=$(which curl)
49+
YUM_CMD=$(which yum)
50+
DNF_CMD=$(which dnf)
51+
APT_GET_CMD=$(which apt-get)
52+
PACMAN_CMD=$(which pacman)
53+
APK_CMD=$(which apk)
54+
GIT_CMD=$(which git)
55+
SUDO_CMD=$(which sudo)
4856
4957
USER="$(id -un 2>/dev/null || true)"
5058
SUDO=''
@@ -60,6 +68,23 @@ def generate(path):
6068
fi
6169
fi
6270
71+
RESET='\033[0m'
72+
RED='\033[0;31m'
73+
GREEN='\033[0;32m'
74+
YELLOW='\033[0;33m'
75+
log () {
76+
echo "[`date "+%Y.%m.%d-%H:%M:%S%Z"`]$1 $2"
77+
}
78+
info () {
79+
log "$GREEN INFO$RESET $1"
80+
}
81+
warn () {
82+
log "$YELLOW WARN$RESET $1"
83+
}
84+
error () {
85+
log "$RED ERROR$RESET $1"
86+
}
87+
6388
""")
6489

6590
seperator = "if"

installers/dunner/installer.toml

Lines changed: 0 additions & 26 deletions
This file was deleted.

installers/git/installer.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/sh
2-
3-
CURL_CMD=$(which curl) # curl tool
4-
YUM_CMD=$(which yum) # yum package manager for RHEL & CentOS
5-
DNF_CMD=$(which dnf) # dnf package manager for new RHEL & CentOS
6-
APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian based distributions
7-
PACMAN_CMD=$(which pacman) # pacman package manager for ArchLinux
8-
APK_CMD=$(which apk) # apk package manager for Alpine
9-
GIT_CMD=$(which git) # to build from source pulling from git
10-
SUDO_CMD=$(which sudo) # check if sudo command is there
2+
3+
CURL_CMD=$(which curl)
4+
YUM_CMD=$(which yum)
5+
DNF_CMD=$(which dnf)
6+
APT_GET_CMD=$(which apt-get)
7+
PACMAN_CMD=$(which pacman)
8+
APK_CMD=$(which apk)
9+
GIT_CMD=$(which git)
10+
SUDO_CMD=$(which sudo)
1111

1212
USER="$(id -un 2>/dev/null || true)"
1313
SUDO=''
@@ -26,20 +26,20 @@ fi
2626
if [ ! -z $APT_GET_CMD ]; then
2727
$SUDO apt-get update
2828
$SUDO apt-get install git
29-
29+
3030
elif [ ! -z $YUM_CMD ]; then
3131
$SUDO yum install git
32-
32+
3333
elif [ ! -z $PACMAN_CMD ]; then
3434
pacman -Sy git
35-
35+
3636
elif [ ! -z $DNF_CMD ]; then
3737
$SUDO dnf install git
38-
38+
3939
elif [ ! -z $APK_CMD ]; then
4040
$SUDO apk add git
41-
41+
4242
else
4343
echo "Couldn't install package"
4444
exit 1;
45-
fi
45+
fi

installers/hello/installer.sh

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/sh
22

3-
CURL_CMD=$(which curl) # curl tool
4-
YUM_CMD=$(which yum) # yum package manager for RHEL & CentOS
5-
DNF_CMD=$(which dnf) # dnf package manager for new RHEL & CentOS
6-
APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian based distributions
7-
PACMAN_CMD=$(which pacman) # pacman package manager for ArchLinux
8-
APK_CMD=$(which apk) # apk package manager for Alpine
9-
GIT_CMD=$(which git) # to build from source pulling from git
10-
SUDO_CMD=$(which sudo) # check if sudo command is there
3+
CURL_CMD=$(which curl)
4+
YUM_CMD=$(which yum)
5+
DNF_CMD=$(which dnf)
6+
APT_GET_CMD=$(which apt-get)
7+
PACMAN_CMD=$(which pacman)
8+
APK_CMD=$(which apk)
9+
GIT_CMD=$(which git)
10+
SUDO_CMD=$(which sudo)
1111

1212
USER="$(id -un 2>/dev/null || true)"
1313
SUDO=''
@@ -23,29 +23,52 @@ if [ "$USER" != 'root' ]; then
2323
fi
2424
fi
2525

26+
RESET=''
27+
RED=''
28+
GREEN=''
29+
YELLOW=''
30+
log () {
31+
echo "[`date "+%Y.%m.%d-%H:%M:%S%Z"`]$1 $2"
32+
}
33+
info () {
34+
log "$GREEN INFO$RESET $1"
35+
}
36+
warn () {
37+
log "$YELLOW WARN$RESET $1"
38+
}
39+
error () {
40+
log "$RED ERROR$RESET $1"
41+
}
42+
2643
if [ ! -z $APT_GET_CMD ]; then
27-
echo "Installing hello"
28-
echo "Installed hello"
44+
info "Installing hello"
45+
warn "This is only a demo installation"
46+
info "Installed hello"
2947

3048
elif [ ! -z $YUM_CMD ]; then
31-
echo "Installing hello"
32-
echo "Installed hello"
49+
info "Installing hello"
50+
warn "This is only a demo installation"
51+
info "Installed hello"
3352

3453
elif [ ! -z $PACMAN_CMD ]; then
35-
echo "Installing hello"
36-
echo "Installed hello"
54+
info "Installing hello"
55+
warn "This is only a demo installation"
56+
info "Installed hello"
3757

3858
elif [ ! -z $APK_CMD ]; then
39-
echo "Installing hello"
40-
echo "Installed hello"
59+
info "Installing hello"
60+
warn "This is only a demo installation"
61+
info "Installed hello"
4162

4263
elif [ ! -z $DNF_CMD ]; then
43-
echo "Installing hello"
44-
echo "Installed hello"
64+
info "Installing hello"
65+
warn "This is only a demo installation"
66+
info "Installed hello"
4567

4668
elif [ ! -z $CURL_CMD ]; then
47-
echo "Installing hello"
48-
echo "Installed hello"
69+
info "Installing hello"
70+
warn "This is only a demo installation"
71+
info "Installed hello"
4972

5073
else
5174
echo "Couldn't install package"

installers/hello/installer.toml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
1+
# Use `sudo` as `@sudo`. This will check for `sudo` command and user type for you.
2+
# You can add logs like below
3+
# @log "This is an info log"
4+
# @info "This is an info log"
5+
# @warn "This is an warn log"
6+
# @error "This is an error log"
7+
18
[apt]
29
sh = """
3-
echo "Installing hello"
4-
echo "Installed hello"
10+
@info "Installing hello"
11+
@warn "This is only a demo installation"
12+
@info "Installed hello"
513
"""
614

715
[yum]
816
sh = """
9-
echo "Installing hello"
10-
echo "Installed hello"
17+
@info "Installing hello"
18+
@warn "This is only a demo installation"
19+
@info "Installed hello"
1120
"""
1221

1322
[pacman]
1423
sh = """
15-
echo "Installing hello"
16-
echo "Installed hello"
24+
@info "Installing hello"
25+
@warn "This is only a demo installation"
26+
@info "Installed hello"
1727
"""
1828

1929
[apk]
2030
sh = """
21-
echo "Installing hello"
22-
echo "Installed hello"
31+
@info "Installing hello"
32+
@warn "This is only a demo installation"
33+
@info "Installed hello"
2334
"""
2435

2536
[dnf]
2637
sh = """
27-
echo "Installing hello"
28-
echo "Installed hello"
38+
@info "Installing hello"
39+
@warn "This is only a demo installation"
40+
@info "Installed hello"
2941
"""
3042

3143
[curl]
3244
sh = """
33-
echo "Installing hello"
34-
echo "Installed hello"
45+
@info "Installing hello"
46+
@warn "This is only a demo installation"
47+
@info "Installed hello"
3548
"""

installers/node/installer.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
[apt]
22
sh = """
33
if [ -n "$(uname -a | grep Ubuntu)" ]; then
4-
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
5-
sudo apt-get install -y nodejs
4+
curl -sL https://deb.nodesource.com/setup_12.x | @sudo -E bash -
5+
@sudo apt-get install -y nodejs
66
else
77
curl -sL https://deb.nodesource.com/setup_12.x | bash -
8-
sudo apt-get install -y nodejs
8+
@sudo apt-get install -y nodejs
99
fi
1010
"""
1111

1212
[yum]
1313
sh = """
14-
sudo yum install nodejs12
14+
@sudo yum install nodejs12
1515
"""
1616

1717
[dnf]
1818
sh = """
19-
sudo dnf install -y gcc-c++ make
20-
curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash -
21-
sudo dnf install nodejs
19+
@sudo dnf install -y gcc-c++ make
20+
curl -sL https://rpm.nodesource.com/setup_12.x | @sudo -E bash -
21+
@sudo dnf install nodejs
2222
"""
2323

2424
[apk]
2525
sh = """
26-
sudo apk update
27-
sudo apk add nodejs
26+
@sudo apk update
27+
@sudo apk add nodejs
2828
"""

0 commit comments

Comments
 (0)