-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitial-setup.sh
125 lines (92 loc) · 2.73 KB
/
initial-setup.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
#!/usr/bin/env bash
ROOT=$(pwd)
DIR=${1:-"."}
FRONT_END=${2:-"react"}
echo ">> Creating directory $DIR"
mkdir -p $DIR
cd $DIR
if [ -z "$(asdf --version 2> /dev/null)" ]; then
echo ">> This script requires ASDF"
exit 1
fi
echo "nodejs 16.15.0
firebase 11.1.0
jq 1.6
gcloud 386.0.0" > .tool-versions
echo ">> Adding asdf plugins"
asdf plugin add nodejs
asdf plugin add firebase
asdf plugin add gcloud
asdf plugin add jq
asdf install
echo ">> Creating turbo-repo"
npx create-turbo@latest --use-npm --no-install .
echo ">> Cleaning lint rules and readme"
rm -rf .eslintrc.js README.md package-lock.json
echo ">> Cleaning up apps/*"
rm -rf ./apps/*
echo ">> Creating a $FRONT_END project with vite"
if [ "$FRONT_END" = 'solidjs' ]; then
npx degit solidjs/templates/ts apps/web
else
npm create vite@latest -- --template react-ts web
mv web apps/web
fi
echo ">> Cleaning up $FRONT_END files"
rm -rf apps/web/README.md apps/web/*-lock.*
echo ">> Cleaning up packages/*"
rm -rf packages/*
echo ">> Creating common and libs"
mkdir -p packages/libs && echo '{
"name": "libs",
"main": "index.ts",
"types": "index.ts"
}' > packages/libs/package.json
echo "export const libs = \"libs\";" > packages/libs/index.ts
echo ">> Creating common config"
mkdir -p packages/config && echo '{
"name": "config",
"main": "index.ts",
"types": "index.ts"
}' > packages/config/package.json
echo "export const config = \"config\";" > packages/config/index.ts
echo ">> Setup functions
Manually run:
$ cd $DIR; firebase init functions
Selecting:
- [yes] typescript
- [yes] eslint
- [no] install dependencies
"
read -p ">> Waiting for functions install. Press enter here when complete." < /dev/tty
mv functions apps/functions
echo ">> Correcting functions dev command"
jq '(.scripts |= (. + {"dev":.serve}|del(.serve)))' apps/functions/package.json > /tmp/package.json
mv /tmp/package.json apps/functions/package.json
echo ">> Correcting functions source"
jq '.functions += {"source": "apps/functions"}' firebase.json > /tmp/firebase.json
mv /tmp/firebase.json firebase.json
echo ">> Setup firestore
Manually run:
$ cd $DIR; firebase init firestore
Selecting:
- [yes] defaults
"
read -p ">> Waiting for firestore install. Press enter here when complete." < /dev/tty
echo ">> Setup storage
Manually run:
$ cd $DIR; firebase init storage
Selecting:
- [yes] defaults
"
read -p ">> Waiting for storage install. Press enter here when complete." < /dev/tty
echo ">> Setup hosting
Manually run:
$ cd $DIR; firebase init hosting
Selecting:
- [Public directory] apps/web/dist
- [yes] Configure as a single-page app
- [no] Set up automatic builds and deploys with GitHub
"
read -p ">> Waiting for hosting install. Press enter here when complete." < /dev/tty
npm install