-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-project.sh
More file actions
executable file
·81 lines (62 loc) · 2.12 KB
/
create-project.sh
File metadata and controls
executable file
·81 lines (62 loc) · 2.12 KB
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
#!/usr/bin/env bash
cat << EndLicense
bootstrap-react-redis Copyright (C) 2019 Daniel Lambert
This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
This is free software, and you are welcome to redistribute it
under certain conditions; for details see COPYING.
EndLicense
set -e
# provide Visual Cues to contrast with the output of "npm init/install"
bold=$(tput bold)
normal=$(tput sgr0)
section_title() {
echo -e "\n\n==========================================================\n"
echo "==>${bold} $* ${normal}"
echo ""
}
exec_cmd() {
section_title $*
$*
}
echo -n "Enter project name (no capitals, no spaces): "
read APP_NAME
cat > bootstrap_docker-compose.yaml << EndSnippet
version: '2'
services:
node-base:
image: node:12
user: 'node'
working_dir: /home/node/app
volumes:
- ./:/home/node/app
EndSnippet
# DOCKER-RUN: npm init react-app ${APP_NAME}
exec_cmd sudo docker-compose \
-f bootstrap_docker-compose.yaml \
run --rm \
node-base npm init react-app ${APP_NAME}
# DOCKER-RUN: npm install --save-dev ..."
# inspired by: https://www.twilio.com/blog/react-app-with-node-js-server-proxy
exec_cmd sudo docker-compose \
-f bootstrap_docker-compose.yaml \
run --rm \
--workdir="/home/node/app/${APP_NAME}" \
node-base npm install --save-dev \
express body-parser node-env-run nodemon npm-run-all express-pino-logger pino-colada \
redis \
chai chai-http mocha
section_title Patch package.json
mv ${APP_NAME}/package.json package.json.orig
cat package.json.orig \
| sed 's#"start": "react-scripts start"#"start": "react-scripts start",\n "server": "node-env-run server --exec nodemon \| pino-colada",\n "server-test": "mocha --watch",\n "dev": "run-p server start"#g' \
| sed 's#"scripts": {#"proxy": "http://localhost:3001",\n "scripts": {#g' \
| tee ${APP_NAME}/package.json
section_title Patch GIT-ignore
echo -e "\nredis_persistence/" >> ${APP_NAME}/.gitignore
# COPY Docker files
exec_cmd cp -r skel/* ${APP_NAME}/
exec_cmd touch ${APP_NAME}/.env
section_title "Cleaning up..."
# Cleanup
exec_cmd rm bootstrap_docker-compose.yaml package.json.orig
section_title "Done"