Skip to content

Commit 4974dbe

Browse files
authored
Adds ability to ask for installation directory (#2746)
1 parent d459393 commit 4974dbe

File tree

1 file changed

+59
-13
lines changed

1 file changed

+59
-13
lines changed

bootstrap.sh

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,60 @@ check_npm() {
5353

5454

5555
echo ''
56-
echo 'This will setup parse-server in the current directory'
56+
echo '
57+
`.-://////:-..`
58+
`:/oooooooooooooooo+:.`
59+
`:+oooooooooooooooooooooo+/`
60+
:+ooooooooooooooooooooooooooo/.
61+
.+oooooooooooooo/:.....-:+ooooooo-
62+
.+ooooooooooooo/` .:///:-` -+oooooo:
63+
`+ooooooooooooo: `/ooooooo+- `ooooooo-
64+
:oooooooooooooo :ooooooooo+` /oooooo+
65+
+ooooooooooooo/ +ooooooooo+ /ooooooo.
66+
oooooooooooooo+ ooooooooo` .oooooooo.
67+
+ooooooooooo+/: `ooooooo` .:ooooooooo.
68+
:ooooooo+.````````````` /+oooooooooo+
69+
`+oooooo- `ooo+ /oooooooooooooooooooo-
70+
.+ooooo/ :/:` -ooooooooooooooooooo:
71+
.+ooooo+:-..-/ooooooooooooooooooo-
72+
:+ooooooooooooooooooooooooooo/.
73+
`:+oooooooooooooooooooooo+/`
74+
`:/oooooooooooooooo+:.`
75+
`.-://////:-..`
76+
77+
parse-server
78+
79+
'
80+
81+
82+
INSTALL_DIR=""
83+
printf "Enter an installation directory\n"
84+
printf "(%s): " "${PWD}"
85+
read -r INSTALL_DIR
86+
87+
if [ "$INSTALL_DIR" = "" ]; then
88+
INSTALL_DIR="${PWD}"
89+
fi
90+
91+
echo ''
92+
printf "This will setup parse-server in %s\n" "${INSTALL_DIR}"
5793
confirm 'Y' 'Do you want to continue? (Y/n): '
5894

5995
check_node
6096
check_npm
6197

62-
echo "Setting up parse-server in $PWD"
98+
printf "Setting up parse-server in %s" "${INSTALL_DIR}\n"
99+
100+
if [ -d "${INSTALL_DIR}" ]; then
101+
echo "{CHECK} ${INSTALL_DIR} exists"
102+
else
103+
mkdir -p "${INSTALL_DIR}"
104+
echo "${CHECK} Created ${INSTALL_DIR}"
105+
fi
106+
107+
cd "${INSTALL_DIR}"
63108

64-
if [ -f './package.json' ]; then
109+
if [ -f "package.json" ]; then
65110
echo "\n${RED}package.json exists${NC}"
66111
confirm 'N' "Do you want to continue? \n${RED}this will erase your configuration${NC} (y/N): "
67112
fi
@@ -77,33 +122,33 @@ i=0
77122
while [ "$APP_NAME" = "" ]
78123
do
79124
[[ $i != 0 ]] && printf "${RED}An application name is required!${NC}\n"
80-
printf 'Enter your Application Name: '
125+
printf "Enter your ${BOLD}Application Name${NC}: "
81126
read -r APP_NAME
82127
i=$(($i+1))
83128
done
84129

85-
printf 'Enter your appId (leave empty to generate): '
130+
printf "Enter your ${BOLD}Application Id${NC} (leave empty to generate): "
86131
read -r APP_ID
87132

88133
[[ $APP_ID = '' ]] && APP_ID=$(genstring) && printf "\n$APP_ID\n\n"
89134

90-
printf 'Enter your masterKey (leave empty to generate): '
135+
printf "Enter your ${BOLD}Master Key${NC} (leave empty to generate): "
91136
read -r MASTER_KEY
92137

93138
[[ $MASTER_KEY = '' ]] && MASTER_KEY=$(genstring) && printf "\n$MASTER_KEY\n\n"
94139

95-
printf "Enter your mongodbURI (%s): " $DEFAULT_MONGODB_URI
140+
printf "Enter your ${BOLD}mongodbURI${NC} (%s): " $DEFAULT_MONGODB_URI
96141
read -r MONGODB_URI
97142

98143
[[ $MONGODB_URI = '' ]] && MONGODB_URI="$DEFAULT_MONGODB_URI"
99144

100145
cat > ./config.json << EOF
101146
{
102-
"appId": "$APP_ID",
103-
"masterKey": "$MASTER_KEY",
104-
"appName": "$APP_NAME",
147+
"applicationId": "${APP_ID}",
148+
"masterKey": "${MASTER_KEY}",
149+
"appName": "${APP_NAME}",
105150
"cloud": "./cloud/main",
106-
"databaseURI": "$MONGODB_URI"
151+
"databaseURI": "${MONGODB_URI}"
107152
}
108153
EOF
109154
echo "${CHECK} Created config.json"
@@ -113,8 +158,9 @@ NPM_APP_NAME=$(echo "$APP_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
113158
cat > ./package.json << EOF
114159
{
115160
"name": "$NPM_APP_NAME",
161+
"description": "parse-server for $APP_NAME",
116162
"scripts": {
117-
"start": "parse-server ./config.json"
163+
"start": "parse-server config.json"
118164
},
119165
"dependencies": {
120166
"parse-server": "^2.0.0"
@@ -149,7 +195,7 @@ fi
149195

150196
echo "\n${CHECK} running npm install\n"
151197

152-
npm install
198+
npm install -s
153199

154200
CURL_CMD=$(cat << EOF
155201
curl -X POST -H 'X-Parse-Application-Id: ${APP_ID}' \\

0 commit comments

Comments
 (0)