-
Notifications
You must be signed in to change notification settings - Fork 1
/
initialize.sh
71 lines (61 loc) · 1.9 KB
/
initialize.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
#!/bin/bash
# If you feel the need to criticize this script, please note that it
# is an ad-hoc solution for an ad-hoc problem with little to no
# scalability.
if [ -z "$BASH_VERSION" -a -z "$ZSH_VERSION" ]; then
echo "Please use a BASH-like shell to run this script."
exit 1
fi
if [ ! -e .rootholder ]; then
echo "Please run this inside the root folder of an uninitialized project."
exit 1
fi
function _which {
if [[ -n "$ZSH_VERSION" ]]; then
builtin whence -p "$1"
else
builtin type -P "$1"
fi
}
readonly NPM=$(_which npm)
if [ -z "$NPM" ]; then
echo "Node.js is not installed or not available in the PATH."
exit 2
fi
"$NPM" install # This will install all the Node.js dependencies
if [ $? -eq 0 ]; then
echo "All dependencies installed successfully."
else
echo "Failed to install all dependencies."
exit 3
fi
"$NPM" update
"$NPM" audit fix
readonly GIT=$(_which git)
if [ -z "$GIT" ]; then
echo "Git is not installed or not available in the PATH."
echo "You really, really want GIT in your PATH."
exit 4
fi
readonly CURL=$(_which curl)
if [ -z "$CURL" ]; then
echo "cURL is not installed or not available in the PATH."
echo "You really, really want cURL in your PATH."
exit 5
fi
# Grab the configuration files
readonly LC='https://raw.githubusercontent.com/microverseinc/linters-config/master/html-css'
readonly RT='https://raw.githubusercontent.com/microverseinc/readme-template/master'
"$CURL" $LC/.hintrc -o .hintrc -s
"$CURL" $LC/.stylelintrc.json -o .stylelintrc.json -s
"$CURL" $LC/.github/workflows/linters.yml -o .github/workflows/linters.yml -s
mv -f README.md README.md.old
"$CURL" $RT/README.md -o README.md -s
"$CURL" https://unpkg.com/reset-css/less/reset.less -o src/less/reset.less -s -L
find . \( -name '.placeholder' -o -name '.rootholder' \) -a -type f -delete
$SHELL tasks.sh
"$GIT" init
"$GIT" add .
"$GIT" commit -m "project: initialize the project"
echo "Done!"
exit 0